forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrulesProvider.ts
More file actions
38 lines (31 loc) · 1.19 KB
/
rulesProvider.ts
File metadata and controls
38 lines (31 loc) · 1.19 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
38
/// <reference path="references.ts"/>
/* @internal */
namespace ts.formatting {
export class RulesProvider {
private globalRules: Rules;
private options: ts.FormatCodeSettings;
private rulesMap: RulesMap;
constructor() {
this.globalRules = new Rules();
const activeRules = this.globalRules.HighPriorityCommonRules.slice(0).concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules);
this.rulesMap = RulesMap.create(activeRules);
}
public getRuleName(rule: Rule): string {
return this.globalRules.getRuleName(rule);
}
public getRuleByName(name: string): Rule {
return this.globalRules[name];
}
public getRulesMap() {
return this.rulesMap;
}
public getFormatOptions(): Readonly<ts.FormatCodeSettings> {
return this.options;
}
public ensureUpToDate(options: ts.FormatCodeSettings) {
if (!this.options || !ts.compareDataObjects(this.options, options)) {
this.options = ts.clone(options);
}
}
}
}