This commit is contained in:
Mohamed Hegazy 2016-05-25 12:27:39 -07:00
commit e5ed3755dc
3 changed files with 5 additions and 18 deletions

View file

@ -1,16 +1,9 @@
///<reference path='references.ts' />
/* tslint:disable:no-null-keyword */
/* @internal */
namespace ts.formatting {
export class RuleOperation {
public Context: RuleOperationContext;
public Action: RuleAction;
constructor() {
this.Context = null;
this.Action = null;
}
constructor(public Context: RuleOperationContext, public Action: RuleAction) {}
public toString(): string {
return "[context=" + this.Context + "," +
@ -22,10 +15,7 @@ namespace ts.formatting {
}
static create2(context: RuleOperationContext, action: RuleAction) {
const result = new RuleOperation();
result.Context = context;
result.Action = action;
return result;
return new RuleOperation(context, action);
}
}
}

View file

@ -1,5 +1,4 @@
///<reference path='references.ts' />
/* tslint:disable:no-null-keyword */
/* @internal */
namespace ts.formatting {
@ -62,14 +61,14 @@ namespace ts.formatting {
public GetRule(context: FormattingContext): Rule {
const bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind);
const bucket = this.map[bucketIndex];
if (bucket != null) {
if (bucket) {
for (const rule of bucket.Rules()) {
if (rule.Operation.Context.InContext(context)) {
return rule;
}
}
}
return null;
return undefined;
}
}

View file

@ -1,5 +1,4 @@
/// <reference path="references.ts"/>
/* tslint:disable:no-null-keyword */
/* @internal */
namespace ts.formatting {
@ -26,8 +25,7 @@ namespace ts.formatting {
}
public ensureUpToDate(options: ts.FormatCodeOptions) {
// TODO: Should this be '==='?
if (this.options == null || !ts.compareDataObjects(this.options, options)) {
if (!this.options || !ts.compareDataObjects(this.options, options)) {
const activeRules = this.createActiveRules(options);
const rulesMap = RulesMap.create(activeRules);