Use 'let' in the services layer.
This commit is contained in:
parent
eb8150cbe2
commit
fd98f19363
|
@ -18,8 +18,8 @@
|
|||
module ts.formatting {
|
||||
export class Rules {
|
||||
public getRuleName(rule: Rule) {
|
||||
var o: ts.Map<any> = <any>this;
|
||||
for (var name in o) {
|
||||
let o: ts.Map<any> = <any>this;
|
||||
for (let name in o) {
|
||||
if (o[name] === rule) {
|
||||
return name;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ module ts.formatting {
|
|||
// Lambda expressions
|
||||
public SpaceAfterArrow: Rule;
|
||||
|
||||
// Optional parameters and var args
|
||||
// Optional parameters and let args
|
||||
public NoSpaceAfterEllipsis: Rule;
|
||||
public NoSpaceAfterOptionalParameters: Rule;
|
||||
|
||||
|
@ -330,7 +330,7 @@ module ts.formatting {
|
|||
// Lambda expressions
|
||||
this.SpaceAfterArrow = new Rule(RuleDescriptor.create3(SyntaxKind.EqualsGreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
|
||||
|
||||
// Optional parameters and var args
|
||||
// Optional parameters and let args
|
||||
this.NoSpaceAfterEllipsis = new Rule(RuleDescriptor.create1(SyntaxKind.DotDotDotToken, SyntaxKind.Identifier), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
|
||||
this.NoSpaceAfterOptionalParameters = new Rule(RuleDescriptor.create3(SyntaxKind.QuestionToken, Shared.TokenRange.FromTokens([SyntaxKind.CloseParenToken, SyntaxKind.CommaToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), RuleAction.Delete));
|
||||
|
||||
|
@ -462,7 +462,7 @@ module ts.formatting {
|
|||
|
||||
// equal in import a = module('a');
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
// equal in var a = 0;
|
||||
// equal in let a = 0;
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
// equal in p = 0;
|
||||
case SyntaxKind.Parameter:
|
||||
|
@ -470,7 +470,7 @@ module ts.formatting {
|
|||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.PropertySignature:
|
||||
return context.currentTokenSpan.kind === SyntaxKind.EqualsToken || context.nextTokenSpan.kind === SyntaxKind.EqualsToken;
|
||||
// "in" keyword in for (var x in []) { }
|
||||
// "in" keyword in for (let x in []) { }
|
||||
case SyntaxKind.ForInStatement:
|
||||
return context.currentTokenSpan.kind === SyntaxKind.InKeyword || context.nextTokenSpan.kind === SyntaxKind.InKeyword;
|
||||
// Technically, "of" is not a binary operator, but format it the same way as "in"
|
||||
|
|
|
@ -26,7 +26,7 @@ module ts.formatting {
|
|||
}
|
||||
|
||||
static create(rules: Rule[]): RulesMap {
|
||||
var result = new RulesMap();
|
||||
let result = new RulesMap();
|
||||
result.Initialize(rules);
|
||||
return result;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ module ts.formatting {
|
|||
this.map = <any> new Array(this.mapRowLength * this.mapRowLength);//new Array<RulesBucket>(this.mapRowLength * this.mapRowLength);
|
||||
|
||||
// This array is used only during construction of the rulesbucket in the map
|
||||
var rulesBucketConstructionStateList: RulesBucketConstructionState[] = <any> new Array(this.map.length);//new Array<RulesBucketConstructionState>(this.map.length);
|
||||
let rulesBucketConstructionStateList: RulesBucketConstructionState[] = <any> new Array(this.map.length);//new Array<RulesBucketConstructionState>(this.map.length);
|
||||
|
||||
this.FillRules(rules, rulesBucketConstructionStateList);
|
||||
return this.map;
|
||||
|
@ -49,20 +49,20 @@ module ts.formatting {
|
|||
}
|
||||
|
||||
private GetRuleBucketIndex(row: number, column: number): number {
|
||||
var rulesBucketIndex = (row * this.mapRowLength) + column;
|
||||
let rulesBucketIndex = (row * this.mapRowLength) + column;
|
||||
//Debug.Assert(rulesBucketIndex < this.map.Length, "Trying to access an index outside the array.");
|
||||
return rulesBucketIndex;
|
||||
}
|
||||
|
||||
private FillRule(rule: Rule, rulesBucketConstructionStateList: RulesBucketConstructionState[]): void {
|
||||
var specificRule = rule.Descriptor.LeftTokenRange != Shared.TokenRange.Any &&
|
||||
let specificRule = rule.Descriptor.LeftTokenRange != Shared.TokenRange.Any &&
|
||||
rule.Descriptor.RightTokenRange != Shared.TokenRange.Any;
|
||||
|
||||
rule.Descriptor.LeftTokenRange.GetTokens().forEach((left) => {
|
||||
rule.Descriptor.RightTokenRange.GetTokens().forEach((right) => {
|
||||
var rulesBucketIndex = this.GetRuleBucketIndex(left, right);
|
||||
let rulesBucketIndex = this.GetRuleBucketIndex(left, right);
|
||||
|
||||
var rulesBucket = this.map[rulesBucketIndex];
|
||||
let rulesBucket = this.map[rulesBucketIndex];
|
||||
if (rulesBucket == undefined) {
|
||||
rulesBucket = this.map[rulesBucketIndex] = new RulesBucket();
|
||||
}
|
||||
|
@ -73,8 +73,8 @@ module ts.formatting {
|
|||
}
|
||||
|
||||
public GetRule(context: FormattingContext): Rule {
|
||||
var bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind);
|
||||
var bucket = this.map[bucketIndex];
|
||||
let bucketIndex = this.GetRuleBucketIndex(context.currentTokenSpan.kind, context.nextTokenSpan.kind);
|
||||
let bucket = this.map[bucketIndex];
|
||||
if (bucket != null) {
|
||||
for (let rule of bucket.Rules()) {
|
||||
if (rule.Operation.Context.InContext(context)) {
|
||||
|
@ -86,8 +86,8 @@ module ts.formatting {
|
|||
}
|
||||
}
|
||||
|
||||
var MaskBitSize = 5;
|
||||
var Mask = 0x1f;
|
||||
let MaskBitSize = 5;
|
||||
let Mask = 0x1f;
|
||||
|
||||
export enum RulesPosition {
|
||||
IgnoreRulesSpecific = 0,
|
||||
|
@ -121,10 +121,10 @@ module ts.formatting {
|
|||
}
|
||||
|
||||
public GetInsertionIndex(maskPosition: RulesPosition): number {
|
||||
var index = 0;
|
||||
let index = 0;
|
||||
|
||||
var pos = 0;
|
||||
var indexBitmap = this.rulesInsertionIndexBitmap;
|
||||
let pos = 0;
|
||||
let indexBitmap = this.rulesInsertionIndexBitmap;
|
||||
|
||||
while (pos <= maskPosition) {
|
||||
index += (indexBitmap & Mask);
|
||||
|
@ -136,11 +136,11 @@ module ts.formatting {
|
|||
}
|
||||
|
||||
public IncreaseInsertionIndex(maskPosition: RulesPosition): void {
|
||||
var value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask;
|
||||
let value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask;
|
||||
value++;
|
||||
Debug.assert((value & Mask) == value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules.");
|
||||
|
||||
var temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition);
|
||||
let temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition);
|
||||
temp |= value << maskPosition;
|
||||
|
||||
this.rulesInsertionIndexBitmap = temp;
|
||||
|
@ -159,7 +159,7 @@ module ts.formatting {
|
|||
}
|
||||
|
||||
public AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void {
|
||||
var position: RulesPosition;
|
||||
let position: RulesPosition;
|
||||
|
||||
if (rule.Operation.Action == RuleAction.Ignore) {
|
||||
position = specificTokens ?
|
||||
|
@ -177,11 +177,11 @@ module ts.formatting {
|
|||
RulesPosition.NoContextRulesAny;
|
||||
}
|
||||
|
||||
var state = constructionState[rulesBucketIndex];
|
||||
let state = constructionState[rulesBucketIndex];
|
||||
if (state === undefined) {
|
||||
state = constructionState[rulesBucketIndex] = new RulesBucketConstructionState();
|
||||
}
|
||||
var index = state.GetInsertionIndex(position);
|
||||
let index = state.GetInsertionIndex(position);
|
||||
this.rules.splice(index, 0, rule);
|
||||
state.IncreaseInsertionIndex(position);
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ module ts.formatting {
|
|||
|
||||
public ensureUpToDate(options: ts.FormatCodeOptions) {
|
||||
if (this.options == null || !ts.compareDataObjects(this.options, options)) {
|
||||
var activeRules = this.createActiveRules(options);
|
||||
var rulesMap = RulesMap.create(activeRules);
|
||||
let activeRules = this.createActiveRules(options);
|
||||
let rulesMap = RulesMap.create(activeRules);
|
||||
|
||||
this.activeRules = activeRules;
|
||||
this.rulesMap = rulesMap;
|
||||
|
@ -50,7 +50,7 @@ module ts.formatting {
|
|||
}
|
||||
|
||||
private createActiveRules(options: ts.FormatCodeOptions): Rule[] {
|
||||
var rules = this.globalRules.HighPriorityCommonRules.slice(0);
|
||||
let rules = this.globalRules.HighPriorityCommonRules.slice(0);
|
||||
|
||||
if (options.InsertSpaceAfterCommaDelimiter) {
|
||||
rules.push(this.globalRules.SpaceAfterComma);
|
||||
|
|
Loading…
Reference in a new issue