• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* @internal */
2namespace ts.formatting {
3    export interface Rule {
4        // Used for debugging to identify each rule based on the property name it's assigned to.
5        readonly debugName: string;
6        readonly context: readonly ContextPredicate[];
7        readonly action: RuleAction;
8        readonly flags: RuleFlags;
9    }
10
11    export type ContextPredicate = (context: FormattingContext) => boolean;
12    export const anyContext: readonly ContextPredicate[] = emptyArray;
13
14    export const enum RuleAction {
15        StopProcessingSpaceActions = 1 << 0,
16        StopProcessingTokenActions = 1 << 1,
17        InsertSpace                = 1 << 2,
18        InsertNewLine              = 1 << 3,
19        DeleteSpace                = 1 << 4,
20        DeleteToken                = 1 << 5,
21        InsertTrailingSemicolon    = 1 << 6,
22
23        StopAction = StopProcessingSpaceActions | StopProcessingTokenActions,
24        ModifySpaceAction = InsertSpace | InsertNewLine | DeleteSpace,
25        ModifyTokenAction = DeleteToken | InsertTrailingSemicolon,
26    }
27
28    export const enum RuleFlags {
29        None,
30        CanDeleteNewLines,
31    }
32
33    export interface TokenRange {
34        readonly tokens: readonly SyntaxKind[];
35        readonly isSpecific: boolean;
36    }
37}
38