forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrule.ts
More file actions
37 lines (32 loc) · 1.28 KB
/
rule.ts
File metadata and controls
37 lines (32 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* @internal */
namespace ts.formatting {
export interface Rule {
// Used for debugging to identify each rule based on the property name it's assigned to.
readonly debugName: string;
readonly context: readonly ContextPredicate[];
readonly action: RuleAction;
readonly flags: RuleFlags;
}
export type ContextPredicate = (context: FormattingContext) => boolean;
export const anyContext: readonly ContextPredicate[] = emptyArray;
export const enum RuleAction {
StopProcessingSpaceActions = 1 << 0,
StopProcessingTokenActions = 1 << 1,
InsertSpace = 1 << 2,
InsertNewLine = 1 << 3,
DeleteSpace = 1 << 4,
DeleteToken = 1 << 5,
InsertTrailingSemicolon = 1 << 6,
StopAction = StopProcessingSpaceActions | StopProcessingTokenActions,
ModifySpaceAction = InsertSpace | InsertNewLine | DeleteSpace,
ModifyTokenAction = DeleteToken | InsertTrailingSemicolon,
}
export const enum RuleFlags {
None,
CanDeleteNewLines,
}
export interface TokenRange {
readonly tokens: readonly SyntaxKind[];
readonly isSpecific: boolean;
}
}