Skip to content

Commit

Permalink
Changes from CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jramsay committed May 23, 2017
1 parent dcab328 commit 3b9ef4e
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 146 deletions.
18 changes: 5 additions & 13 deletions src/services/formatting/ruleOperationContext.ts
Expand Up @@ -4,27 +4,19 @@
namespace ts.formatting {

export class RuleOperationContext {
constructor(private optionName: string, private checkApplyRuleOperation: { (optionName: string, options: FormatCodeSettings): boolean }, private customContextChecks: { (context: FormattingContext): boolean; }[]) {
}

static Any: RuleOperationContext = new RuleOperationContext(undefined, undefined, []);
private customContextChecks: { (context: FormattingContext): boolean; }[];

static Create1(...funcs: { (context: FormattingContext): boolean; }[]) {
return new RuleOperationContext(undefined, undefined, funcs);
}
static Create2(optionName: string, checkApplyRuleOperation: { (optionName: string, options: FormatCodeSettings): boolean }, ...funcs: { (context: FormattingContext): boolean; }[]) {
return new RuleOperationContext(optionName, checkApplyRuleOperation, funcs);
constructor(...funcs: { (context: FormattingContext): boolean; }[]) {
this.customContextChecks = funcs;
}

static Any: RuleOperationContext = new RuleOperationContext();

public IsAny(): boolean {
return this === RuleOperationContext.Any;
}

public InContext(context: FormattingContext): boolean {
if (this.checkApplyRuleOperation && !this.checkApplyRuleOperation(this.optionName, context.options)) {
return false;
}

if (this.IsAny()) {
return true;
}
Expand Down

0 comments on commit 3b9ef4e

Please sign in to comment.