From 3b0fc5c4097345784900bfc3e1edbc59eb0d28ba Mon Sep 17 00:00:00 2001 From: Stephen Weatherford Date: Thu, 19 Apr 2018 07:52:54 -0700 Subject: [PATCH] lint: no-reserved-keywords, part of #54 --- src/AzureRMTools.ts | 22 +++++------ src/Completion.ts | 26 ++++++------ src/DeploymentTemplate.ts | 12 +++--- src/Histogram.ts | 6 +-- src/HttpClient.ts | 10 ++--- src/JSON.ts | 5 ++- src/PositionContext.ts | 20 +++++----- src/Reference.ts | 10 ++--- src/SurveyMetadata.ts | 4 +- src/TLE.ts | 34 ++++++++-------- src/Treeview.ts | 4 ++ test/Completion.test.ts | 4 +- test/DeploymentTemplate.test.ts | 28 ++++++------- test/Histogram.test.ts | 30 +++++++------- test/HttpClient.test.ts | 8 ++-- test/PositionContext.test.ts | 70 ++++++++++++++++----------------- test/Reference.test.ts | 44 ++++++++++----------- test/TLE.test.ts | 12 +++--- test/Tokenizer.test.ts | 6 +-- tslint.json | 2 +- 20 files changed, 181 insertions(+), 176 deletions(-) diff --git a/src/AzureRMTools.ts b/src/AzureRMTools.ts index 0eba3c91f..c340e763b 100644 --- a/src/AzureRMTools.ts +++ b/src/AzureRMTools.ts @@ -282,7 +282,7 @@ export class AzureRMTools { }; const functionCounts: Histogram = deploymentTemplate.functionCounts; for (const functionName of functionCounts.keys) { - functionCountEvent[functionName] = functionCounts.get(functionName); + functionCountEvent[functionName] = functionCounts.getCount(functionName); } this.log(functionCountEvent); } @@ -413,22 +413,22 @@ export class AzureRMTools { completionToAdd.detail = completion.detail; completionToAdd.documentation = completion.description; - switch (completion.type) { - case Completion.Type.Function: + switch (completion.kind) { + case Completion.CompletionKind.Function: completionToAdd.kind = vscode.CompletionItemKind.Function; break; - case Completion.Type.Parameter: - case Completion.Type.Variable: + case Completion.CompletionKind.Parameter: + case Completion.CompletionKind.Variable: completionToAdd.kind = vscode.CompletionItemKind.Variable; break; - case Completion.Type.Property: + case Completion.CompletionKind.Property: completionToAdd.kind = vscode.CompletionItemKind.Field; break; default: - assert.fail(`Unrecognized Completion.Type: ${completion.type}`); + assert.fail(`Unrecognized Completion.Type: ${completion.kind}`); break; } @@ -491,17 +491,17 @@ export class AzureRMTools { const references: Reference.List = context.references; if (references && references.length > 0) { let referenceType: string; - switch (references.type) { - case Reference.Type.Parameter: + switch (references.kind) { + case Reference.ReferenceKind.Parameter: referenceType = "parameter"; break; - case Reference.Type.Variable: + case Reference.ReferenceKind.Variable: referenceType = "variable"; break; default: - assert.fail(`Unrecognized Reference.Type: ${references.type}`); + assert.fail(`Unrecognized Reference.Kind: ${references.kind}`); referenceType = "no reference type"; break; } diff --git a/src/Completion.ts b/src/Completion.ts index ce2ee1e71..2cfebaa50 100644 --- a/src/Completion.ts +++ b/src/Completion.ts @@ -9,40 +9,40 @@ import * as tle from "./TLE"; * A completion item in the list of completion suggestions that appear when a user invokes auto-completion (Ctrl + Space). */ export class Item { - constructor(private _name: string, private _insertText: string, private _insertSpan: language.Span, private _detail: string, private _description: string, private _type: Type) { + constructor(private _name: string, private _insertText: string, private _insertSpan: language.Span, private _detail: string, private _description: string, private _type: CompletionKind) { } - + public get name(): string { return this._name; } - + public get insertText(): string { return this._insertText; } - + public get insertSpan(): language.Span { return this._insertSpan; } - + public get detail(): string { return this._detail; } - + public get description(): string { return this._description; } - - public get type(): Type { + + public get kind(): CompletionKind { return this._type; } } -export enum Type { +export enum CompletionKind { Function, - + Parameter, - + Variable, - + Property -} \ No newline at end of file +} diff --git a/src/DeploymentTemplate.ts b/src/DeploymentTemplate.ts index 3978839ce..0c4f2d9d4 100644 --- a/src/DeploymentTemplate.ts +++ b/src/DeploymentTemplate.ts @@ -175,14 +175,14 @@ export class DeploymentTemplate { this._warnings = []; for (const parameterDefinition of this.parameterDefinitions) { - const parameterReferences: Reference.List = this.findReferences(Reference.Type.Parameter, parameterDefinition.name.toString()); + const parameterReferences: Reference.List = this.findReferences(Reference.ReferenceKind.Parameter, parameterDefinition.name.toString()); if (parameterReferences.length === 1) { this._warnings.push(new language.Issue(parameterDefinition.name.span, `The parameter '${parameterDefinition.name.toString()}' is never used.`)); } } for (const variableDefinition of this.variableDefinitions) { - const variableReferences: Reference.List = this.findReferences(Reference.Type.Variable, variableDefinition.name.toString()); + const variableReferences: Reference.List = this.findReferences(Reference.ReferenceKind.Variable, variableDefinition.name.toString()); if (variableReferences.length === 1) { this._warnings.push(new language.Issue(variableDefinition.name.span, `The variable '${variableDefinition.name.toString()}' is never used.`)); } @@ -415,19 +415,19 @@ export class DeploymentTemplate { return result; } - public findReferences(referenceType: Reference.Type, referenceName: string): Reference.List { + public findReferences(referenceType: Reference.ReferenceKind, referenceName: string): Reference.List { const result: Reference.List = new Reference.List(referenceType); if (referenceName) { switch (referenceType) { - case Reference.Type.Parameter: + case Reference.ReferenceKind.Parameter: const parameterDefinition: ParameterDefinition = this.getParameterDefinition(referenceName); if (parameterDefinition) { result.add(parameterDefinition.name.unquotedSpan); } break; - case Reference.Type.Variable: + case Reference.ReferenceKind.Variable: const variableDefinition: Json.Property = this.getVariableDefinition(referenceName); if (variableDefinition) { result.add(variableDefinition.name.unquotedSpan); @@ -435,7 +435,7 @@ export class DeploymentTemplate { break; default: - assert.fail(`Unrecognized Reference.Type: ${referenceType}`); + assert.fail(`Unrecognized Reference.Kind: ${referenceType}`); break; } diff --git a/src/Histogram.ts b/src/Histogram.ts index 3d9e1fac7..cdb6ca0d0 100644 --- a/src/Histogram.ts +++ b/src/Histogram.ts @@ -35,12 +35,12 @@ export class Histogram { } else { for (let rhsKey of key.keys) { - this.add(rhsKey, key.get(rhsKey)); + this.add(rhsKey, key.getCount(rhsKey)); } } } - public get(key: string): number { + public getCount(key: string): number { let result: number; if (key === null) { result = this._nullCounts; @@ -56,4 +56,4 @@ export class Histogram { } return result; } -} \ No newline at end of file +} diff --git a/src/HttpClient.ts b/src/HttpClient.ts index ca815afa6..dfc776a8b 100644 --- a/src/HttpClient.ts +++ b/src/HttpClient.ts @@ -7,7 +7,7 @@ import * as http from "http"; import * as https from "https"; export class HttpClient { - public static get(url: string): Promise { + public static request(url: string): Promise { assert(url, "Cannot make a HTTP request for a null, undefined, or empty url."); if (!url.startsWith("http")) { @@ -19,14 +19,14 @@ export class HttpClient { function callback(response: http.IncomingMessage): void { if (300 <= response.statusCode && response.statusCode < 400 && response.headers["location"]) { - resolve(HttpClient.get(response.headers["location"].toString())); + resolve(HttpClient.request(response.headers["location"].toString())); } else if (200 <= response.statusCode && response.statusCode < 400) { let responseContent: string = ""; let encoding: string; - response.on("data", (dataChunk: string|Buffer) => { - const buffer: Buffer = dataChunk instanceof Buffer? dataChunk: new Buffer(dataChunk); + response.on("data", (dataChunk: string | Buffer) => { + const buffer: Buffer = dataChunk instanceof Buffer ? dataChunk : new Buffer(dataChunk); let byteOrderMarkLength: number = 0; if (!encoding) { if (dataChunk[0] == 0xFF && @@ -73,4 +73,4 @@ export class HttpClient { }); }); } -} \ No newline at end of file +} diff --git a/src/JSON.ts b/src/JSON.ts index c7a7ce4ae..fc9be62d9 100644 --- a/src/JSON.ts +++ b/src/JSON.ts @@ -62,6 +62,7 @@ export class Token extends Segment { super(_startIndex); } + // tslint:disable-next-line:no-reserved-keywords // Not worth risk to change public get type(): TokenType { return this._type; } @@ -555,7 +556,7 @@ export class ObjectValue extends Value { } /** - * Get the property names + * Get the property names */ public get propertyNames(): string[] { return Object.keys(this.propertyMap); @@ -1096,4 +1097,4 @@ export abstract class Visitor { public visitNullValue(nullValue: NullValue): void { } -} \ No newline at end of file +} diff --git a/src/PositionContext.ts b/src/PositionContext.ts index 13fa041fa..675c94572 100644 --- a/src/PositionContext.ts +++ b/src/PositionContext.ts @@ -307,7 +307,7 @@ export class PositionContext { } private static createPropertyCompletionItem(propertyName: string, replaceSpan: language.Span): Completion.Item { - return new Completion.Item(propertyName, `${propertyName}$0`, replaceSpan, "(property)", "", Completion.Type.Property); + return new Completion.Item(propertyName, `${propertyName}$0`, replaceSpan, "(property)", "", Completion.CompletionKind.Property); } public get references(): Reference.List { @@ -315,17 +315,17 @@ export class PositionContext { this._references = null; let referenceName: string = null; - let referenceType: Reference.Type = null; + let referenceType: Reference.ReferenceKind = null; const tleStringValue: TLE.StringValue = TLE.asStringValue(this.tleValue); if (tleStringValue) { referenceName = tleStringValue.toString(); if (tleStringValue.isParametersArgument()) { - referenceType = Reference.Type.Parameter; + referenceType = Reference.ReferenceKind.Parameter; } else if (tleStringValue.isVariablesArgument()) { - referenceType = Reference.Type.Variable; + referenceType = Reference.ReferenceKind.Variable; } } @@ -336,12 +336,12 @@ export class PositionContext { const parameterDefinition: ParameterDefinition = this._deploymentTemplate.getParameterDefinition(referenceName); if (parameterDefinition && parameterDefinition.name === jsonStringValue) { - referenceType = Reference.Type.Parameter; + referenceType = Reference.ReferenceKind.Parameter; } else { const variableDefinition: Json.Property = this._deploymentTemplate.getVariableDefinition(referenceName); if (variableDefinition && variableDefinition.name === jsonStringValue) { - referenceType = Reference.Type.Variable; + referenceType = Reference.ReferenceKind.Variable; } } } @@ -461,7 +461,7 @@ export class PositionContext { insertText += "($0)"; } - completionItems.push(new Completion.Item(name, insertText, replaceSpan, `(function) ${functionMetadata.usage}`, functionMetadata.description, Completion.Type.Function)); + completionItems.push(new Completion.Item(name, insertText, replaceSpan, `(function) ${functionMetadata.usage}`, functionMetadata.description, Completion.CompletionKind.Function)); } return completionItems; }); @@ -474,7 +474,7 @@ export class PositionContext { const parameterDefinitionMatches: ParameterDefinition[] = this._deploymentTemplate.findParameterDefinitionsWithPrefix(prefix); for (const parameterDefinition of parameterDefinitionMatches) { const name: string = `'${parameterDefinition.name}'`; - parameterCompletions.push(new Completion.Item(name, `${name}${replaceSpanInfo.includeRightParenthesisInCompletion ? ")" : ""}$0`, replaceSpanInfo.replaceSpan, `(parameter)`, parameterDefinition.description, Completion.Type.Parameter)); + parameterCompletions.push(new Completion.Item(name, `${name}${replaceSpanInfo.includeRightParenthesisInCompletion ? ")" : ""}$0`, replaceSpanInfo.replaceSpan, `(parameter)`, parameterDefinition.description, Completion.CompletionKind.Parameter)); } return parameterCompletions; } @@ -486,7 +486,7 @@ export class PositionContext { const variableDefinitionMatches: Json.Property[] = this._deploymentTemplate.findVariableDefinitionsWithPrefix(prefix); for (const variableDefinition of variableDefinitionMatches) { const variableName: string = `'${variableDefinition.name.toString()}'`; - variableCompletions.push(new Completion.Item(variableName, `${variableName}${replaceSpanInfo.includeRightParenthesisInCompletion ? ")" : ""}$0`, replaceSpanInfo.replaceSpan, `(variable)`, "", Completion.Type.Variable)); + variableCompletions.push(new Completion.Item(variableName, `${variableName}${replaceSpanInfo.includeRightParenthesisInCompletion ? ")" : ""}$0`, replaceSpanInfo.replaceSpan, `(variable)`, "", Completion.CompletionKind.Variable)); } return variableCompletions; } @@ -536,4 +536,4 @@ export class PositionContext { interface ReplaceSpanInfo { includeRightParenthesisInCompletion: boolean; replaceSpan: language.Span; -} \ No newline at end of file +} diff --git a/src/Reference.ts b/src/Reference.ts index 81d985a24..3c27ec7e6 100644 --- a/src/Reference.ts +++ b/src/Reference.ts @@ -10,7 +10,7 @@ import * as language from "./Language"; * A list of references that have been found. */ export class List { - constructor(private _type: Type, private _spans: language.Span[] = []) { + constructor(private _type: ReferenceKind, private _spans: language.Span[] = []) { assert(_type !== null, "Cannot create a reference list a null type."); assert(_type !== undefined, "Cannot create a reference list an undefined type."); assert(_spans, "Cannot create a reference list with a null spans array."); @@ -24,7 +24,7 @@ export class List { return this._spans; } - public get type(): Type { + public get kind(): ReferenceKind { return this._type; } @@ -36,7 +36,7 @@ export class List { public addAll(list: List): void { assert(list, "Cannot add all of the references from a null or undefined list."); - assert.deepStrictEqual(this._type, list.type, "Cannot add references from a list of a different reference type."); + assert.deepStrictEqual(this._type, list.kind, "Cannot add references from a list of a different reference type."); for (const span of list.spans) { this.add(span); @@ -57,8 +57,8 @@ export class List { } } -export enum Type { +export enum ReferenceKind { Parameter, Variable -} \ No newline at end of file +} diff --git a/src/SurveyMetadata.ts b/src/SurveyMetadata.ts index da72f1db7..4c4391ad1 100644 --- a/src/SurveyMetadata.ts +++ b/src/SurveyMetadata.ts @@ -54,7 +54,7 @@ export class SurveyMetadata { } public static fromUrl(metadataUrl: string): Promise { - return HttpClient.get(metadataUrl).then((content: string) => { + return HttpClient.request(metadataUrl).then((content: string) => { return SurveyMetadata.fromString(content); }); } @@ -101,4 +101,4 @@ interface SurveyMetadataContract { daysBetweenSurveys?: number; surveyLink?: string; } -} \ No newline at end of file +} diff --git a/src/TLE.ts b/src/TLE.ts index eb92c2d27..c1ac5ff40 100644 --- a/src/TLE.ts +++ b/src/TLE.ts @@ -794,10 +794,10 @@ export class FindReferencesVisitor extends Visitor { private _references: Reference.List; private _lowerCasedName: string; - constructor(private _type: Reference.Type, private _name: string) { + constructor(private _kind: Reference.ReferenceKind, private _name: string) { super(); - this._references = new Reference.List(_type); + this._references = new Reference.List(_kind); this._lowerCasedName = Utilities.unquote(_name).toLowerCase(); } @@ -807,27 +807,27 @@ export class FindReferencesVisitor extends Visitor { public visitString(tleString: StringValue): void { if (tleString && Utilities.unquote(tleString.toString()).toLowerCase() === this._lowerCasedName) { - switch (this._type) { - case Reference.Type.Parameter: + switch (this._kind) { + case Reference.ReferenceKind.Parameter: if (tleString.isParametersArgument()) { this._references.add(tleString.unquotedSpan); } break; - case Reference.Type.Variable: + case Reference.ReferenceKind.Variable: if (tleString.isVariablesArgument()) { this._references.add(tleString.unquotedSpan); } break; default: - assert.fail(`Unrecognized ReferenceType: ${this._type}`); + assert.fail(`Unrecognized ReferenceKind: ${this._kind}`); break; } } } - public static visit(tleValue: Value, referenceType: Reference.Type, referenceName: string): FindReferencesVisitor { + public static visit(tleValue: Value, referenceType: Reference.ReferenceKind, referenceName: string): FindReferencesVisitor { const visitor = new FindReferencesVisitor(referenceType, referenceName); if (tleValue) { tleValue.accept(visitor); @@ -924,22 +924,22 @@ export class Parser { if (tokenizer.hasCurrent()) { let token = tokenizer.current; - let type = token.getType(); - if (type === TokenType.Literal) { + let tokenType = token.getType(); + if (tokenType === TokenType.Literal) { expression = Parser.parseFunction(tokenizer, errors); } - else if (type === TokenType.QuotedString) { + else if (tokenType === TokenType.QuotedString) { if (!token.stringValue.endsWith(token.stringValue[0])) { errors.push(new language.Issue(token.span, "A constant string is missing an end quote.")); } expression = new StringValue(token); tokenizer.next(); } - else if (type === TokenType.Number) { + else if (tokenType === TokenType.Number) { expression = new NumberValue(token); tokenizer.next(); } - else if (type !== TokenType.RightSquareBracket && type !== TokenType.Comma) { + else if (tokenType !== TokenType.RightSquareBracket && tokenType !== TokenType.Comma) { errors.push(new language.Issue(token.span, "Template language expressions must start with a function.")); tokenizer.next(); } @@ -962,8 +962,8 @@ export class Parser { else { errorSpan = tokenizer.current.span; - let type = tokenizer.current.getType(); - if (type !== TokenType.RightParenthesis && type !== TokenType.RightSquareBracket && type !== TokenType.Comma) { + let tokenType = tokenizer.current.getType(); + if (tokenType !== TokenType.RightParenthesis && tokenType !== TokenType.RightSquareBracket && tokenType !== TokenType.Comma) { tokenizer.next(); } } @@ -1336,12 +1336,12 @@ export class Token { private _span: language.Span; private _stringValue: string; - private static create(type: TokenType, startIndex: number, stringValue: string): Token { - assert.notEqual(null, type); + private static create(tokenType: TokenType, startIndex: number, stringValue: string): Token { + assert.notEqual(null, tokenType); assert.notEqual(null, stringValue); let t = new Token(); - t._type = type; + t._type = tokenType; t._span = new language.Span(startIndex, stringValue.length); t._stringValue = stringValue; return t; diff --git a/src/Treeview.ts b/src/Treeview.ts index a6716ca28..0c4970d95 100644 --- a/src/Treeview.ts +++ b/src/Treeview.ts @@ -334,11 +334,13 @@ export interface IElementInfo { key: { start: number; end: number; + // tslint:disable-next-line:no-reserved-keywords // Not worth the risk to change type: string; }, value: { start: number; end: number; + // tslint:disable-next-line:no-reserved-keywords // Not worth the risk to change type: string; }, level: number; @@ -348,11 +350,13 @@ export interface IElementInfo { key: { start: number; end: number; + // tslint:disable-next-line:no-reserved-keywords // Not worth the risk to change type: string; }, value: { start: number; end: number; + // tslint:disable-next-line:no-reserved-keywords // Not worth the risk to change type: string; } }, diff --git a/test/Completion.test.ts b/test/Completion.test.ts index 9118b8f5f..4b7cd92f4 100644 --- a/test/Completion.test.ts +++ b/test/Completion.test.ts @@ -10,13 +10,13 @@ import * as language from "../src/Language"; suite("Completion", () => { suite("Item", () => { test("constructor(string, Span, string, string, Type)", () => { - const item: Completion.Item = new Completion.Item("a", "b", new language.Span(1, 2), "c", "d", Completion.Type.Function); + const item: Completion.Item = new Completion.Item("a", "b", new language.Span(1, 2), "c", "d", Completion.CompletionKind.Function); assert.deepStrictEqual(item.description, "d"); assert.deepStrictEqual(item.detail, "c"); assert.deepStrictEqual(item.insertSpan, new language.Span(1, 2)); assert.deepStrictEqual(item.insertText, "b"); assert.deepStrictEqual(item.name, "a"); - assert.deepStrictEqual(item.type, Completion.Type.Function); + assert.deepStrictEqual(item.kind, Completion.CompletionKind.Function); }); }); }); diff --git a/test/DeploymentTemplate.test.ts b/test/DeploymentTemplate.test.ts index b88ff58a2..7f1431771 100644 --- a/test/DeploymentTemplate.test.ts +++ b/test/DeploymentTemplate.test.ts @@ -831,57 +831,57 @@ suite("DeploymentTemplate", () => { test("with null name", () => { const dt = new DeploymentTemplate("", "id"); - const list: Reference.List = dt.findReferences(Reference.Type.Parameter, null); + const list: Reference.List = dt.findReferences(Reference.ReferenceKind.Parameter, null); assert(list); - assert.deepStrictEqual(list.type, Reference.Type.Parameter); + assert.deepStrictEqual(list.kind, Reference.ReferenceKind.Parameter); assert.deepStrictEqual(list.spans, []); }); test("with undefined name", () => { const dt = new DeploymentTemplate("", "id"); - const list: Reference.List = dt.findReferences(Reference.Type.Parameter, undefined); + const list: Reference.List = dt.findReferences(Reference.ReferenceKind.Parameter, undefined); assert(list); - assert.deepStrictEqual(list.type, Reference.Type.Parameter); + assert.deepStrictEqual(list.kind, Reference.ReferenceKind.Parameter); assert.deepStrictEqual(list.spans, []); }); test("with empty name", () => { const dt = new DeploymentTemplate("", "id"); - const list: Reference.List = dt.findReferences(Reference.Type.Parameter, ""); + const list: Reference.List = dt.findReferences(Reference.ReferenceKind.Parameter, ""); assert(list); - assert.deepStrictEqual(list.type, Reference.Type.Parameter); + assert.deepStrictEqual(list.kind, Reference.ReferenceKind.Parameter); assert.deepStrictEqual(list.spans, []); }); test("with parameter type and no matching parameter definition", () => { const dt = new DeploymentTemplate(`{ "parameters": { "pName": {} } }`, "id"); - const list: Reference.List = dt.findReferences(Reference.Type.Parameter, "dontMatchMe"); + const list: Reference.List = dt.findReferences(Reference.ReferenceKind.Parameter, "dontMatchMe"); assert(list); - assert.deepStrictEqual(list.type, Reference.Type.Parameter); + assert.deepStrictEqual(list.kind, Reference.ReferenceKind.Parameter); assert.deepStrictEqual(list.spans, []); }); test("with parameter type and matching parameter definition", () => { const dt = new DeploymentTemplate(`{ "parameters": { "pName": {} } }`, "id"); - const list: Reference.List = dt.findReferences(Reference.Type.Parameter, "pName"); + const list: Reference.List = dt.findReferences(Reference.ReferenceKind.Parameter, "pName"); assert(list); - assert.deepStrictEqual(list.type, Reference.Type.Parameter); + assert.deepStrictEqual(list.kind, Reference.ReferenceKind.Parameter); assert.deepStrictEqual(list.spans, [new language.Span(19, 5)]); }); test("with variable type and no matching variable definition", () => { const dt = new DeploymentTemplate(`{ "variables": { "vName": {} } }`, "id"); - const list: Reference.List = dt.findReferences(Reference.Type.Variable, "dontMatchMe"); + const list: Reference.List = dt.findReferences(Reference.ReferenceKind.Variable, "dontMatchMe"); assert(list); - assert.deepStrictEqual(list.type, Reference.Type.Variable); + assert.deepStrictEqual(list.kind, Reference.ReferenceKind.Variable); assert.deepStrictEqual(list.spans, []); }); test("with variable type and matching variable definition", () => { const dt = new DeploymentTemplate(`{ "variables": { "vName": {} } }`, "id"); - const list: Reference.List = dt.findReferences(Reference.Type.Variable, "vName"); + const list: Reference.List = dt.findReferences(Reference.ReferenceKind.Variable, "vName"); assert(list); - assert.deepStrictEqual(list.type, Reference.Type.Variable); + assert.deepStrictEqual(list.kind, Reference.ReferenceKind.Variable); assert.deepStrictEqual(list.spans, [new language.Span(18, 5)]); }); }); diff --git a/test/Histogram.test.ts b/test/Histogram.test.ts index 2425f7396..6ef515da5 100644 --- a/test/Histogram.test.ts +++ b/test/Histogram.test.ts @@ -39,41 +39,41 @@ suite("Histogram", () => { test("With null key", () => { let h = new Histogram(); h.add(null); - assert.deepEqual(1, h.get(null)); + assert.deepEqual(1, h.getCount(null)); assert.deepEqual([null], h.keys); }); test("With undefined key", () => { let h = new Histogram(); h.add(undefined); - assert.deepEqual(1, h.get(undefined)); + assert.deepEqual(1, h.getCount(undefined)); assert.deepEqual([undefined], h.keys); }); test("With string key", () => { let h = new Histogram(); h.add("a"); - assert.deepEqual(1, h.get("a")); + assert.deepEqual(1, h.getCount("a")); assert.deepEqual(["a"], h.keys); }); test("With string key and count", () => { let h = new Histogram(); h.add("a", 20); - assert.deepEqual(20, h.get("a")); + assert.deepEqual(20, h.getCount("a")); assert.deepEqual(["a"], h.keys); }); test("With Histogram key", () => { let h = new Histogram(); h.add("a", 20); - assert.deepEqual(20, h.get("a")); + assert.deepEqual(20, h.getCount("a")); assert.deepEqual(["a"], h.keys); h.add(h); - assert.deepEqual(40, h.get("a")); + assert.deepEqual(40, h.getCount("a")); assert.deepEqual(["a"], h.keys); h.add(h); - assert.deepEqual(80, h.get("a")); + assert.deepEqual(80, h.getCount("a")); assert.deepEqual(["a"], h.keys); }); }); @@ -81,34 +81,34 @@ suite("Histogram", () => { suite("get(string)", () => { test("with null", () => { let h = new Histogram(); - assert.equal(0, h.get(null)); + assert.equal(0, h.getCount(null)); h.add(null); - assert.equal(1, h.get(null)); + assert.equal(1, h.getCount(null)); }); test("with undefined", () => { let h = new Histogram(); - assert.equal(0, h.get(undefined)); + assert.equal(0, h.getCount(undefined)); h.add(undefined); - assert.equal(1, h.get(undefined)); + assert.equal(1, h.getCount(undefined)); }); test("with empty", () => { let h = new Histogram(); - assert.equal(0, h.get("")); + assert.equal(0, h.getCount("")); h.add(""); - assert.equal(1, h.get("")); + assert.equal(1, h.getCount("")); }); test("with non-empty", () => { let h = new Histogram(); - assert.equal(0, h.get("a")); + assert.equal(0, h.getCount("a")); h.add("a"); - assert.equal(1, h.get("a")); + assert.equal(1, h.getCount("a")); }); }); }); diff --git a/test/HttpClient.test.ts b/test/HttpClient.test.ts index 5f039c780..154816534 100644 --- a/test/HttpClient.test.ts +++ b/test/HttpClient.test.ts @@ -11,7 +11,7 @@ import { networkTest } from "./Network"; suite("HttpClient", () => { suite("get(string)", () => { networkTest("with existing site ('http://www.bing.com')", () => { - return HttpClient.get("http://www.bing.com") + return HttpClient.request("http://www.bing.com") .then((content: string) => { assert(content, "Content was undefined, null, or empty"); assert(content.includes("Word Online"), "Content did not include the phrase 'Word Online'"); @@ -19,7 +19,7 @@ suite("HttpClient", () => { }); networkTest("with existing site without 'http' ('www.bing.com')", () => { - return HttpClient.get("www.bing.com") + return HttpClient.request("www.bing.com") .then((content: string) => { assert(content, "Content was undefined, null, or empty"); assert(content.includes("Word Online"), "Content did not include the phrase 'Word Online'"); @@ -27,7 +27,7 @@ suite("HttpClient", () => { }); networkTest("with redirection ('https://storageexplorer.com') (redirection)", () => { - return HttpClient.get("https://storageexplorer.com") + return HttpClient.request("https://storageexplorer.com") .then((content: string) => { assert(content, "No content"); assert(content.includes("Azure Storage Explorer"), "Doesn't include"); @@ -35,7 +35,7 @@ suite("HttpClient", () => { }); networkTest("with non-existing site ('http://i.dont.exist.com')", () => { - return HttpClient.get("http://i.dont.exist.com") + return HttpClient.request("http://i.dont.exist.com") .then((content: string) => { assert(false, "Expected the catch function to be called."); }) diff --git a/test/PositionContext.test.ts b/test/PositionContext.test.ts index f22eee3d3..9f99bea36 100644 --- a/test/PositionContext.test.ts +++ b/test/PositionContext.test.ts @@ -537,143 +537,143 @@ suite("PositionContext", () => { } function addCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("add", "add($0)", new language.Span(startIndex, length), "(function) add(operand1, operand2)", "Returns the sum of the two provided integers.", Completion.Type.Function); + return new Completion.Item("add", "add($0)", new language.Span(startIndex, length), "(function) add(operand1, operand2)", "Returns the sum of the two provided integers.", Completion.CompletionKind.Function); } function base64Completion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("base64", "base64($0)", new language.Span(startIndex, length), "(function) base64(inputString)", "Returns the base64 representation of the input string.", Completion.Type.Function); + return new Completion.Item("base64", "base64($0)", new language.Span(startIndex, length), "(function) base64(inputString)", "Returns the base64 representation of the input string.", Completion.CompletionKind.Function); } function concatCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("concat", "concat($0)", new language.Span(startIndex, length), "(function) concat(arg1, arg2, arg3, ...)", "Combines multiple values and returns the concatenated result. This function can take any number of arguments, and can accept either strings or arrays for the parameters.", Completion.Type.Function); + return new Completion.Item("concat", "concat($0)", new language.Span(startIndex, length), "(function) concat(arg1, arg2, arg3, ...)", "Combines multiple values and returns the concatenated result. This function can take any number of arguments, and can accept either strings or arrays for the parameters.", Completion.CompletionKind.Function); } function copyIndexCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("copyIndex", "copyIndex($0)", new language.Span(startIndex, length), "(function) copyIndex([offset]) or copyIndex(loopName, [offset])", "Returns the current index of an iteration loop.\nThis function is always used with a copy object.", Completion.Type.Function); + return new Completion.Item("copyIndex", "copyIndex($0)", new language.Span(startIndex, length), "(function) copyIndex([offset]) or copyIndex(loopName, [offset])", "Returns the current index of an iteration loop.\nThis function is always used with a copy object.", Completion.CompletionKind.Function); } function deploymentCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("deployment", "deployment()$0", new language.Span(startIndex, length), "(function) deployment()", "Returns information about the current deployment operation. This function returns the object that is passed during deployment. The properties in the returned object will differ based on whether the deployment object is passed as a link or as an in-line object.", Completion.Type.Function); + return new Completion.Item("deployment", "deployment()$0", new language.Span(startIndex, length), "(function) deployment()", "Returns information about the current deployment operation. This function returns the object that is passed during deployment. The properties in the returned object will differ based on whether the deployment object is passed as a link or as an in-line object.", Completion.CompletionKind.Function); } function divCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("div", "div($0)", new language.Span(startIndex, length), "(function) div(operand1, operand2)", "Returns the integer division of the two provided integers.", Completion.Type.Function) + return new Completion.Item("div", "div($0)", new language.Span(startIndex, length), "(function) div(operand1, operand2)", "Returns the integer division of the two provided integers.", Completion.CompletionKind.Function) } function intCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("int", "int($0)", new language.Span(startIndex, length), "(function) int(valueToConvert)", "Converts the specified value to Integer.", Completion.Type.Function); + return new Completion.Item("int", "int($0)", new language.Span(startIndex, length), "(function) int(valueToConvert)", "Converts the specified value to Integer.", Completion.CompletionKind.Function); } function lengthCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("length", "length($0)", new language.Span(startIndex, length), "(function) length(array/string)", "Returns the number of elements in an array or the number of characters in a string. You can use this function with an array to specify the number of iterations when creating resources.", Completion.Type.Function); + return new Completion.Item("length", "length($0)", new language.Span(startIndex, length), "(function) length(array/string)", "Returns the number of elements in an array or the number of characters in a string. You can use this function with an array to specify the number of iterations when creating resources.", Completion.CompletionKind.Function); } function listKeysCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("listKeys", "listKeys($0)", new language.Span(startIndex, length), "(function) listKeys(resourceName/resourceIdentifier, apiVersion)", "Returns the keys of a storage account. The resourceId can be specified by using the resourceId function or by using the format providerNamespace/resourceType/resourceName. You can use the function to get the primaryKey and secondaryKey.", Completion.Type.Function); + return new Completion.Item("listKeys", "listKeys($0)", new language.Span(startIndex, length), "(function) listKeys(resourceName/resourceIdentifier, apiVersion)", "Returns the keys of a storage account. The resourceId can be specified by using the resourceId function or by using the format providerNamespace/resourceType/resourceName. You can use the function to get the primaryKey and secondaryKey.", Completion.CompletionKind.Function); } function listPackageCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("listPackage", "listPackage($0)", new language.Span(startIndex, length), "(function) listPackage(resourceId, apiVersion)", undefined, Completion.Type.Function); + return new Completion.Item("listPackage", "listPackage($0)", new language.Span(startIndex, length), "(function) listPackage(resourceId, apiVersion)", undefined, Completion.CompletionKind.Function); } function modCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("mod", "mod($0)", new language.Span(startIndex, length), "(function) mod(operand1, operand2)", "Returns the remainder of the integer division using the two provided integers.", Completion.Type.Function); + return new Completion.Item("mod", "mod($0)", new language.Span(startIndex, length), "(function) mod(operand1, operand2)", "Returns the remainder of the integer division using the two provided integers.", Completion.CompletionKind.Function); } function mulCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("mul", "mul($0)", new language.Span(startIndex, length), "(function) mul(operand1, operand2)", "Returns the multiplication of the two provided integers.", Completion.Type.Function); + return new Completion.Item("mul", "mul($0)", new language.Span(startIndex, length), "(function) mul(operand1, operand2)", "Returns the multiplication of the two provided integers.", Completion.CompletionKind.Function); } function padLeftCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("padLeft", "padLeft($0)", new language.Span(startIndex, length), "(function) padLeft(stringToPad, totalLength, paddingCharacter)", "Returns a right-aligned string by adding characters to the left until reaching the total specified length.", Completion.Type.Function); + return new Completion.Item("padLeft", "padLeft($0)", new language.Span(startIndex, length), "(function) padLeft(stringToPad, totalLength, paddingCharacter)", "Returns a right-aligned string by adding characters to the left until reaching the total specified length.", Completion.CompletionKind.Function); } function parametersCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("parameters", "parameters($0)", new language.Span(startIndex, length), "(function) parameters(parameterName)", "Returns a parameter value. The specified parameter name must be defined in the parameters section of the template.", Completion.Type.Function); + return new Completion.Item("parameters", "parameters($0)", new language.Span(startIndex, length), "(function) parameters(parameterName)", "Returns a parameter value. The specified parameter name must be defined in the parameters section of the template.", Completion.CompletionKind.Function); } function providersCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("providers", "providers($0)", new language.Span(startIndex, length), "(function) providers(providerNamespace, [resourceType])", "Return information about a resource provider and its supported resource types. If not type is provided, all of the supported types are returned.", Completion.Type.Function); + return new Completion.Item("providers", "providers($0)", new language.Span(startIndex, length), "(function) providers(providerNamespace, [resourceType])", "Return information about a resource provider and its supported resource types. If not type is provided, all of the supported types are returned.", Completion.CompletionKind.Function); } function referenceCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("reference", "reference($0)", new language.Span(startIndex, length), "(function) reference(resourceName/resourceIdentifier, [apiVersion], ['Full'])", "Enables an expression to derive its value from another resource's runtime state.", Completion.Type.Function); + return new Completion.Item("reference", "reference($0)", new language.Span(startIndex, length), "(function) reference(resourceName/resourceIdentifier, [apiVersion], ['Full'])", "Enables an expression to derive its value from another resource's runtime state.", Completion.CompletionKind.Function); } function replaceCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("replace", "replace($0)", new language.Span(startIndex, length), "(function) replace(originalString, oldCharacter, newCharacter)", "Returns a new string with all instances of one character in the specified string replaced by another character.", Completion.Type.Function); + return new Completion.Item("replace", "replace($0)", new language.Span(startIndex, length), "(function) replace(originalString, oldCharacter, newCharacter)", "Returns a new string with all instances of one character in the specified string replaced by another character.", Completion.CompletionKind.Function); } function resourceGroupCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("resourceGroup", "resourceGroup()$0", new language.Span(startIndex, length), "(function) resourceGroup()", "Returns a structured object that represents the current resource group.", Completion.Type.Function); + return new Completion.Item("resourceGroup", "resourceGroup()$0", new language.Span(startIndex, length), "(function) resourceGroup()", "Returns a structured object that represents the current resource group.", Completion.CompletionKind.Function); } function resourceIdCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("resourceId", "resourceId($0)", new language.Span(startIndex, length), "(function) resourceId([subscriptionId], [resourceGroupName], resourceType, resourceName1, [resourceName2]...)", "Returns the unique identifier of a resource. You use this function when the resource name is ambiguous or not provisioned within the same template.", Completion.Type.Function); + return new Completion.Item("resourceId", "resourceId($0)", new language.Span(startIndex, length), "(function) resourceId([subscriptionId], [resourceGroupName], resourceType, resourceName1, [resourceName2]...)", "Returns the unique identifier of a resource. You use this function when the resource name is ambiguous or not provisioned within the same template.", Completion.CompletionKind.Function); } function skipCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("skip", "skip($0)", new language.Span(startIndex, length), "(function) skip(originalValue, numberToSkip)", "Returns an array or string with all of the elements or characters after the specified number in the array or string.", Completion.Type.Function); + return new Completion.Item("skip", "skip($0)", new language.Span(startIndex, length), "(function) skip(originalValue, numberToSkip)", "Returns an array or string with all of the elements or characters after the specified number in the array or string.", Completion.CompletionKind.Function); } function splitCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("split", "split($0)", new language.Span(startIndex, length), "(function) split(inputString, delimiter)", "Returns an array of strings that contains the substrings of the input string that are delimited by the sent delimiters.", Completion.Type.Function); + return new Completion.Item("split", "split($0)", new language.Span(startIndex, length), "(function) split(inputString, delimiter)", "Returns an array of strings that contains the substrings of the input string that are delimited by the sent delimiters.", Completion.CompletionKind.Function); } function stringCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("string", "string($0)", new language.Span(startIndex, length), "(function) string(valueToConvert)", "Converts the specified value to String.", Completion.Type.Function); + return new Completion.Item("string", "string($0)", new language.Span(startIndex, length), "(function) string(valueToConvert)", "Converts the specified value to String.", Completion.CompletionKind.Function); } function subCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("sub", "sub($0)", new language.Span(startIndex, length), "(function) sub(operand1, operand2)", "Returns the subtraction of the two provided integers.", Completion.Type.Function); + return new Completion.Item("sub", "sub($0)", new language.Span(startIndex, length), "(function) sub(operand1, operand2)", "Returns the subtraction of the two provided integers.", Completion.CompletionKind.Function); } function subscriptionCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("subscription", "subscription()$0", new language.Span(startIndex, length), "(function) subscription()", "Returns details about the subscription.", Completion.Type.Function); + return new Completion.Item("subscription", "subscription()$0", new language.Span(startIndex, length), "(function) subscription()", "Returns details about the subscription.", Completion.CompletionKind.Function); } function substringCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("substring", "substring($0)", new language.Span(startIndex, length), "(function) substring(stringToParse, startIndex, length)", "Returns a substring that starts at the specified character position and contains the specified number of characters.", Completion.Type.Function); + return new Completion.Item("substring", "substring($0)", new language.Span(startIndex, length), "(function) substring(stringToParse, startIndex, length)", "Returns a substring that starts at the specified character position and contains the specified number of characters.", Completion.CompletionKind.Function); } function takeCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("take", "take($0)", new language.Span(startIndex, length), "(function) take(originalValue, numberToTake)", "Returns an array or string with the specified number of elements or characters from the start of the array or string.", Completion.Type.Function); + return new Completion.Item("take", "take($0)", new language.Span(startIndex, length), "(function) take(originalValue, numberToTake)", "Returns an array or string with the specified number of elements or characters from the start of the array or string.", Completion.CompletionKind.Function); } function toLowerCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("toLower", "toLower($0)", new language.Span(startIndex, length), "(function) toLower(string)", "Converts the specified string to lower case.", Completion.Type.Function); + return new Completion.Item("toLower", "toLower($0)", new language.Span(startIndex, length), "(function) toLower(string)", "Converts the specified string to lower case.", Completion.CompletionKind.Function); } function toUpperCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("toUpper", "toUpper($0)", new language.Span(startIndex, length), "(function) toUpper(string)", "Converts the specified string to upper case.", Completion.Type.Function); + return new Completion.Item("toUpper", "toUpper($0)", new language.Span(startIndex, length), "(function) toUpper(string)", "Converts the specified string to upper case.", Completion.CompletionKind.Function); } function trimCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("trim", "trim($0)", new language.Span(startIndex, length), "(function) trim(stringToTrim)", "Removes all leading and trailing white-space characters from the specified string.", Completion.Type.Function); + return new Completion.Item("trim", "trim($0)", new language.Span(startIndex, length), "(function) trim(stringToTrim)", "Removes all leading and trailing white-space characters from the specified string.", Completion.CompletionKind.Function); } function uniqueStringCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("uniqueString", "uniqueString($0)", new language.Span(startIndex, length), "(function) uniqueString(stringForCreatingUniqueString, ...)", "Performs a 64-bit hash of the provided strings to create a unique string. This function is helpful when you need to create a unique name for a resource. You provide parameter values that represent the level of uniqueness for the result. You can specify whether the name is unique for your subscription, resource group, or deployment.", Completion.Type.Function); + return new Completion.Item("uniqueString", "uniqueString($0)", new language.Span(startIndex, length), "(function) uniqueString(stringForCreatingUniqueString, ...)", "Performs a 64-bit hash of the provided strings to create a unique string. This function is helpful when you need to create a unique name for a resource. You provide parameter values that represent the level of uniqueness for the result. You can specify whether the name is unique for your subscription, resource group, or deployment.", Completion.CompletionKind.Function); } function uriCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("uri", "uri($0)", new language.Span(startIndex, length), "(function) uri(baseUri, relativeUri)", "Creates an absolute URI by combining the baseUri and the relativeUri string.", Completion.Type.Function); + return new Completion.Item("uri", "uri($0)", new language.Span(startIndex, length), "(function) uri(baseUri, relativeUri)", "Creates an absolute URI by combining the baseUri and the relativeUri string.", Completion.CompletionKind.Function); } function variablesCompletion(startIndex: number, length: number): Completion.Item { - return new Completion.Item("variables", "variables($0)", new language.Span(startIndex, length), "(function) variables(variableName)", "Returns the value of variable. The specified variable name must be defined in the variables section of the template.", Completion.Type.Function); + return new Completion.Item("variables", "variables($0)", new language.Span(startIndex, length), "(function) variables(variableName)", "Returns the value of variable. The specified variable name must be defined in the variables section of the template.", Completion.CompletionKind.Function); } function parameterCompletion(parameterName: string, startIndex: number, length: number, includeRightParenthesis: boolean = true): Completion.Item { - return new Completion.Item(`'${parameterName}'`, `'${parameterName}'${includeRightParenthesis ? ")" : ""}$0`, new language.Span(startIndex, length), "(parameter)", null, Completion.Type.Parameter); + return new Completion.Item(`'${parameterName}'`, `'${parameterName}'${includeRightParenthesis ? ")" : ""}$0`, new language.Span(startIndex, length), "(parameter)", null, Completion.CompletionKind.Parameter); } function propertyCompletion(propertyName: string, startIndex: number, length: number): Completion.Item { - return new Completion.Item(propertyName, `${propertyName}$0`, new language.Span(startIndex, length), "(property)", "", Completion.Type.Property); + return new Completion.Item(propertyName, `${propertyName}$0`, new language.Span(startIndex, length), "(property)", "", Completion.CompletionKind.Property); } function variableCompletion(variableName: string, startIndex: number, length: number, includeRightParenthesis: boolean = true): Completion.Item { - return new Completion.Item(`'${variableName}'`, `'${variableName}'${includeRightParenthesis ? ")" : ""}$0`, new language.Span(startIndex, length), "(variable)", "", Completion.Type.Variable); + return new Completion.Item(`'${variableName}'`, `'${variableName}'${includeRightParenthesis ? ")" : ""}$0`, new language.Span(startIndex, length), "(variable)", "", Completion.CompletionKind.Variable); } for (let i = 0; i <= 24; ++i) { diff --git a/test/Reference.test.ts b/test/Reference.test.ts index 0eff5454a..b41a82e4b 100644 --- a/test/Reference.test.ts +++ b/test/Reference.test.ts @@ -19,26 +19,26 @@ suite("Reference", () => { }); test("with null spans", () => { - assert.throws(() => { new Reference.List(Reference.Type.Parameter, null); }); + assert.throws(() => { new Reference.List(Reference.ReferenceKind.Parameter, null); }); }); test("with undefined spans", () => { - const list = new Reference.List(Reference.Type.Parameter, undefined); - assert.deepStrictEqual(list.type, Reference.Type.Parameter); + const list = new Reference.List(Reference.ReferenceKind.Parameter, undefined); + assert.deepStrictEqual(list.kind, Reference.ReferenceKind.Parameter); assert.deepStrictEqual(list.spans, []); assert.deepStrictEqual(list.length, 0); }); test("with empty spans", () => { - const list = new Reference.List(Reference.Type.Parameter, []); - assert.deepStrictEqual(list.type, Reference.Type.Parameter); + const list = new Reference.List(Reference.ReferenceKind.Parameter, []); + assert.deepStrictEqual(list.kind, Reference.ReferenceKind.Parameter); assert.deepStrictEqual(list.spans, []); assert.deepStrictEqual(list.length, 0); }); test("with non-empty spans", () => { - const list = new Reference.List(Reference.Type.Parameter, [new language.Span(0, 1), new language.Span(2, 3)]); - assert.deepStrictEqual(list.type, Reference.Type.Parameter); + const list = new Reference.List(Reference.ReferenceKind.Parameter, [new language.Span(0, 1), new language.Span(2, 3)]); + assert.deepStrictEqual(list.kind, Reference.ReferenceKind.Parameter); assert.deepStrictEqual(list.spans, [new language.Span(0, 1), new language.Span(2, 3)]); assert.deepStrictEqual(list.length, 2); }); @@ -46,66 +46,66 @@ suite("Reference", () => { suite("add(Span)", () => { test("with null", () => { - const list = new Reference.List(Reference.Type.Variable); + const list = new Reference.List(Reference.ReferenceKind.Variable); assert.throws(() => { list.add(null); }); }); test("with undefined", () => { - const list = new Reference.List(Reference.Type.Variable); + const list = new Reference.List(Reference.ReferenceKind.Variable); assert.throws(() => { list.add(undefined); }); }); }); suite("addAll(Reference.List)", () => { test("with null", () => { - const list = new Reference.List(Reference.Type.Variable); + const list = new Reference.List(Reference.ReferenceKind.Variable); assert.throws(() => { list.addAll(null); }); }); test("with undefined", () => { - const list = new Reference.List(Reference.Type.Variable); + const list = new Reference.List(Reference.ReferenceKind.Variable); assert.throws(() => { list.addAll(undefined); }); }); test("with empty list of the same type", () => { - const list = new Reference.List(Reference.Type.Variable); - list.addAll(new Reference.List(Reference.Type.Variable)); + const list = new Reference.List(Reference.ReferenceKind.Variable); + list.addAll(new Reference.List(Reference.ReferenceKind.Variable)); assert.deepStrictEqual(list.length, 0); assert.deepStrictEqual(list.spans, []); }); test("with empty list of a different type", () => { - const list = new Reference.List(Reference.Type.Variable); - assert.throws(() => { list.addAll(new Reference.List(Reference.Type.Parameter)); }); + const list = new Reference.List(Reference.ReferenceKind.Variable); + assert.throws(() => { list.addAll(new Reference.List(Reference.ReferenceKind.Parameter)); }); }); test("with non-empty list", () => { - const list = new Reference.List(Reference.Type.Variable); - list.addAll(new Reference.List(Reference.Type.Variable, [new language.Span(10, 20)])); + const list = new Reference.List(Reference.ReferenceKind.Variable); + list.addAll(new Reference.List(Reference.ReferenceKind.Variable, [new language.Span(10, 20)])); assert.deepStrictEqual(list.spans, [new language.Span(10, 20)]); }); }); suite("translate(number)", () => { test("with empty list", () => { - const list = new Reference.List(Reference.Type.Parameter); + const list = new Reference.List(Reference.ReferenceKind.Parameter); const list2 = list.translate(17); assert.deepStrictEqual(list, list2); }); test("with non-empty list", () => { - const list = new Reference.List(Reference.Type.Parameter, [new language.Span(10, 20)]); + const list = new Reference.List(Reference.ReferenceKind.Parameter, [new language.Span(10, 20)]); const list2 = list.translate(17); - assert.deepStrictEqual(list2, new Reference.List(Reference.Type.Parameter, [new language.Span(27, 20)])); + assert.deepStrictEqual(list2, new Reference.List(Reference.ReferenceKind.Parameter, [new language.Span(27, 20)])); }); test("with null movement", () => { - const list = new Reference.List(Reference.Type.Parameter, [new language.Span(10, 20)]); + const list = new Reference.List(Reference.ReferenceKind.Parameter, [new language.Span(10, 20)]); assert.throws(() => { list.translate(null); }); }); test("with undefined movement", () => { - const list = new Reference.List(Reference.Type.Parameter, [new language.Span(10, 20)]); + const list = new Reference.List(Reference.ReferenceKind.Parameter, [new language.Span(10, 20)]); assert.throws(() => { list.translate(undefined); }); }); }); diff --git a/test/TLE.test.ts b/test/TLE.test.ts index ec8dd609f..c16e002c4 100644 --- a/test/TLE.test.ts +++ b/test/TLE.test.ts @@ -2037,24 +2037,24 @@ suite("TLE", () => { suite("FindReferencesVisitor", () => { suite("visit(tle.Value,string,string)", () => { test("with null TLE", () => { - const visitor = TLE.FindReferencesVisitor.visit(null, Reference.Type.Parameter, "pName"); + const visitor = TLE.FindReferencesVisitor.visit(null, Reference.ReferenceKind.Parameter, "pName"); assert(visitor); - assert.deepStrictEqual(visitor.references, new Reference.List(Reference.Type.Parameter)); + assert.deepStrictEqual(visitor.references, new Reference.List(Reference.ReferenceKind.Parameter)); }); test("with undefined TLE", () => { - const visitor = TLE.FindReferencesVisitor.visit(undefined, Reference.Type.Parameter, "pName"); + const visitor = TLE.FindReferencesVisitor.visit(undefined, Reference.ReferenceKind.Parameter, "pName"); assert(visitor); - assert.deepStrictEqual(visitor.references, new Reference.List(Reference.Type.Parameter)); + assert.deepStrictEqual(visitor.references, new Reference.List(Reference.ReferenceKind.Parameter)); }); test("with TLE", () => { const pr: TLE.ParseResult = TLE.Parser.parse(`"[parameters('pName')]"`) - const visitor = TLE.FindReferencesVisitor.visit(pr.expression, Reference.Type.Parameter, "pName"); + const visitor = TLE.FindReferencesVisitor.visit(pr.expression, Reference.ReferenceKind.Parameter, "pName"); assert(visitor); assert.deepStrictEqual( visitor.references, - new Reference.List(Reference.Type.Parameter, [new language.Span(14, 5)])); + new Reference.List(Reference.ReferenceKind.Parameter, [new language.Span(14, 5)])); }); }); }); diff --git a/test/Tokenizer.test.ts b/test/Tokenizer.test.ts index c38bd09e2..e61204be3 100644 --- a/test/Tokenizer.test.ts +++ b/test/Tokenizer.test.ts @@ -9,12 +9,12 @@ import * as utilities from "../src/Utilities"; suite("Tokenizer", () => { suite("Token", () => { - function constructorTest(text: string, type: basic.TokenType): void { + function constructorTest(text: string, tokenType: basic.TokenType): void { test(`with ${utilities.escapeAndQuote(text)}`, () => { - const token = new basic.Token(text, type); + const token = new basic.Token(text, tokenType); assert.deepStrictEqual(token.toString(), text); assert.deepStrictEqual(token.length(), text.length); - assert.deepStrictEqual(token.getType(), type); + assert.deepStrictEqual(token.getType(), tokenType); }); } diff --git a/tslint.json b/tslint.json index 792805c26..a092890ca 100644 --- a/tslint.json +++ b/tslint.json @@ -17,7 +17,7 @@ ], "no-inner-html": true, "no-octal-literal": true, - // TODO: "no-reserved-keywords": true, + "no-reserved-keywords": true, "no-string-based-set-immediate": true, "no-string-based-set-interval": true, "no-string-based-set-timeout": true,