From 8b87d79d1ec59241d90160729415e59d53e416a3 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 15 Jun 2017 12:46:28 -0700 Subject: [PATCH 1/6] Revert "Convert Extension to a string enum (#16425)" This reverts commit 09321b3834af09d7ae55ee86c7664850f189a708. --- src/compiler/core.ts | 36 ++++++++++++++++------- src/compiler/moduleNameResolver.ts | 10 +++---- src/compiler/parser.ts | 2 +- src/compiler/program.ts | 2 +- src/compiler/types.ts | 13 ++++---- src/compiler/utilities.ts | 14 ++++----- src/harness/compilerRunner.ts | 2 +- src/harness/fourslash.ts | 4 +-- src/harness/harness.ts | 18 ++++++------ src/harness/projectsRunner.ts | 8 ++--- src/harness/unittests/compileOnSave.ts | 4 +-- src/harness/unittests/moduleResolution.ts | 2 +- src/harness/unittests/transpile.ts | 4 +-- src/server/project.ts | 2 +- src/server/session.ts | 2 +- src/services/navigateTo.ts | 2 +- 16 files changed, 70 insertions(+), 55 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 551b3d6059012..e02fcdda178fb 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2131,13 +2131,13 @@ namespace ts { export function getScriptKindFromFileName(fileName: string): ScriptKind { const ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case Extension.Js: + case ".js": return ScriptKind.JS; - case Extension.Jsx: + case ".jsx": return ScriptKind.JSX; - case Extension.Ts: + case ".ts": return ScriptKind.TS; - case Extension.Tsx: + case ".tsx": return ScriptKind.TSX; default: return ScriptKind.Unknown; @@ -2147,10 +2147,10 @@ namespace ts { /** * List of supported extensions in order of file resolution precedence. */ - export const supportedTypeScriptExtensions = [Extension.Ts, Extension.Tsx, Extension.Dts]; + export const supportedTypeScriptExtensions = [".ts", ".tsx", ".d.ts"]; /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - export const supportedTypescriptExtensionsForExtractExtension = [Extension.Dts, Extension.Ts, Extension.Tsx]; - export const supportedJavascriptExtensions = [Extension.Js, Extension.Jsx]; + export const supportedTypescriptExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"]; + export const supportedJavascriptExtensions = [".js", ".jsx"]; const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions); export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: JsFileExtensionInfo[]): string[] { @@ -2158,7 +2158,7 @@ namespace ts { if (!extraFileExtensions || extraFileExtensions.length === 0 || !needAllExtensions) { return needAllExtensions ? allSupportedExtensions : supportedTypeScriptExtensions; } - const extensions: string[] = allSupportedExtensions.slice(0); + const extensions = allSupportedExtensions.slice(0); for (const extInfo of extraFileExtensions) { if (extensions.indexOf(extInfo.extension) === -1) { extensions.push(extInfo.extension); @@ -2237,7 +2237,7 @@ namespace ts { } } - const extensionsToRemove = [Extension.Dts, Extension.Ts, Extension.Js, Extension.Tsx, Extension.Jsx]; + const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; export function removeFileExtension(path: string): string { for (const ext of extensionsToRemove) { const extensionless = tryRemoveExtension(path, ext); @@ -2491,7 +2491,7 @@ namespace ts { /** True if an extension is one of the supported TypeScript extensions. */ export function extensionIsTypeScript(ext: Extension): boolean { - return ext === Extension.Ts || ext === Extension.Tsx || ext === Extension.Dts; + return ext <= Extension.LastTypeScriptExtension; } /** @@ -2506,7 +2506,21 @@ namespace ts { Debug.fail(`File ${path} has unknown extension.`); } export function tryGetExtensionFromPath(path: string): Extension | undefined { - return find(supportedTypescriptExtensionsForExtractExtension, e => fileExtensionIs(path, e)) || find(supportedJavascriptExtensions, e => fileExtensionIs(path, e)); + if (fileExtensionIs(path, ".d.ts")) { + return Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return Extension.Jsx; + } } export function isCheckJsEnabledForFile(sourceFile: SourceFile, compilerOptions: CompilerOptions) { diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 4ea590977e173..4c6616c36d46a 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -815,15 +815,15 @@ namespace ts { switch (extensions) { case Extensions.DtsOnly: - return tryExtension(Extension.Dts); + return tryExtension(".d.ts", Extension.Dts); case Extensions.TypeScript: - return tryExtension(Extension.Ts) || tryExtension(Extension.Tsx) || tryExtension(Extension.Dts); + return tryExtension(".ts", Extension.Ts) || tryExtension(".tsx", Extension.Tsx) || tryExtension(".d.ts", Extension.Dts); case Extensions.JavaScript: - return tryExtension(Extension.Js) || tryExtension(Extension.Jsx); + return tryExtension(".js", Extension.Js) || tryExtension(".jsx", Extension.Jsx); } - function tryExtension(extension: Extension): Resolved | undefined { - const path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); + function tryExtension(ext: string, extension: Extension): Resolved | undefined { + const path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); return path && { path, extension }; } } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 572f813baed9f..53c6b4e3f04e5 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -764,7 +764,7 @@ namespace ts { sourceFile.languageVersion = languageVersion; sourceFile.fileName = normalizePath(fileName); sourceFile.languageVariant = getLanguageVariant(scriptKind); - sourceFile.isDeclarationFile = fileExtensionIs(sourceFile.fileName, Extension.Dts); + sourceFile.isDeclarationFile = fileExtensionIs(sourceFile.fileName, ".d.ts"); sourceFile.scriptKind = scriptKind; return sourceFile; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index cc6ae1a5813ab..3ca9d03466e4c 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1495,7 +1495,7 @@ namespace ts { } const sourceFileWithAddedExtension = forEach(supportedExtensions, extension => getSourceFile(fileName + extension)); - if (fail && !sourceFileWithAddedExtension) fail(Diagnostics.File_0_not_found, fileName + Extension.Ts); + if (fail && !sourceFileWithAddedExtension) fail(Diagnostics.File_0_not_found, fileName + ".ts"); return sourceFileWithAddedExtension; } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 76be7b20b1da2..429b6113265c6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3883,12 +3883,13 @@ namespace ts { extension: Extension; } - export const enum Extension { - Ts = ".ts", - Tsx = ".tsx", - Dts = ".d.ts", - Js = ".js", - Jsx = ".jsx" + export enum Extension { + Ts, + Tsx, + Dts, + Js, + Jsx, + LastTypeScriptExtension = Dts } export interface ResolvedModuleWithFailedLookupLocations { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 3833fc3087544..d99bcf399c31a 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2501,7 +2501,7 @@ namespace ts { const path = outputDir ? getSourceFilePathInNewDir(sourceFile, host, outputDir) : sourceFile.fileName; - return removeFileExtension(path) + Extension.Dts; + return removeFileExtension(path) + ".d.ts"; } export interface EmitFileNames { @@ -2560,7 +2560,7 @@ namespace ts { if (sourceFiles.length) { const jsFilePath = options.outFile || options.out; const sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - const declarationFilePath = options.declaration ? removeFileExtension(jsFilePath) + Extension.Dts : ""; + const declarationFilePath = options.declaration ? removeFileExtension(jsFilePath) + ".d.ts" : ""; action({ jsFilePath, sourceMapFilePath, declarationFilePath }, createBundle(sourceFiles), emitOnlyDtsFiles); } } @@ -2581,19 +2581,19 @@ namespace ts { // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve - function getOutputExtension(sourceFile: SourceFile, options: CompilerOptions): Extension { + function getOutputExtension(sourceFile: SourceFile, options: CompilerOptions): string { if (options.jsx === JsxEmit.Preserve) { if (isSourceFileJavaScript(sourceFile)) { - if (fileExtensionIs(sourceFile.fileName, Extension.Jsx)) { - return Extension.Jsx; + if (fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; } } else if (sourceFile.languageVariant === LanguageVariant.JSX) { // TypeScript source file preserving JSX syntax - return Extension.Jsx; + return ".jsx"; } } - return Extension.Js; + return ".js"; } export function getSourceFilePathInNewDir(sourceFile: SourceFile, host: EmitHost, newDirPath: string) { diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index ff418ab34de94..d0eee02efd7bf 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -90,7 +90,7 @@ class CompilerBaselineRunner extends RunnerBase { } lastUnit = units[units.length - 1]; - hasNonDtsFiles = ts.forEach(units, unit => !ts.fileExtensionIs(unit.name, ts.Extension.Dts)); + hasNonDtsFiles = ts.forEach(units, unit => !ts.fileExtensionIs(unit.name, ".d.ts")); // We need to assemble the list of input files for the compiler and other related files on the 'filesystem' (ie in a multi-file test) // If the last file in a test uses require or a triple slash reference we'll assume all other files will be brought in via references, // otherwise, assume all files are just meant to be in the same compilation session without explicit references to one another. diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 7fdbef74ad7a8..7804e536daf69 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1467,7 +1467,7 @@ namespace FourSlash { let baselineFile = this.testData.globalOptions[metadataOptionNames.baselineFile]; if (!baselineFile) { baselineFile = this.activeFile.fileName.replace(this.basePath + "/breakpointValidation", "bpSpan"); - baselineFile = baselineFile.replace(ts.Extension.Ts, ".baseline"); + baselineFile = baselineFile.replace(".ts", ".baseline"); } Harness.Baseline.runBaseline( @@ -1537,7 +1537,7 @@ namespace FourSlash { public baselineQuickInfo() { let baselineFile = this.testData.globalOptions[metadataOptionNames.baselineFile]; if (!baselineFile) { - baselineFile = ts.getBaseFileName(this.activeFile.fileName).replace(ts.Extension.Ts, ".baseline"); + baselineFile = ts.getBaseFileName(this.activeFile.fileName).replace(".ts", ".baseline"); } Harness.Baseline.runBaseline( diff --git a/src/harness/harness.ts b/src/harness/harness.ts index e944e68f11ea7..0e34744c1b605 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1249,7 +1249,7 @@ namespace Harness { sourceFileName = outFile; } - const dTsFileName = ts.removeFileExtension(sourceFileName) + ts.Extension.Dts; + const dTsFileName = ts.removeFileExtension(sourceFileName) + ".d.ts"; return ts.forEach(result.declFilesCode, declFile => declFile.fileName === dTsFileName ? declFile : undefined); } @@ -1465,7 +1465,7 @@ namespace Harness { // When calling this function from rwc-runner, the baselinePath will have no extension. // As rwc test- file is stored in json which ".json" will get stripped off. // When calling this function from compiler-runner, the baselinePath will then has either ".ts" or ".tsx" extension - const outputFileName = ts.endsWith(baselinePath, ts.Extension.Ts) || ts.endsWith(baselinePath, ts.Extension.Tsx) ? + const outputFileName = ts.endsWith(baselinePath, ".ts") || ts.endsWith(baselinePath, ".tsx") ? baselinePath.replace(/\.tsx?/, fullExtension) : baselinePath.concat(fullExtension); Harness.Baseline.runBaseline(outputFileName, () => fullBaseLine, opts); } @@ -1563,7 +1563,7 @@ namespace Harness { } // check js output - Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, ts.Extension.Js), () => { + Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, ".js"), () => { let tsCode = ""; const tsSources = otherFiles.concat(toBeCompiled); if (tsSources.length > 1) { @@ -1651,22 +1651,22 @@ namespace Harness { } export function isTS(fileName: string) { - return ts.endsWith(fileName, ts.Extension.Ts); + return ts.endsWith(fileName, ".ts"); } export function isTSX(fileName: string) { - return ts.endsWith(fileName, ts.Extension.Tsx); + return ts.endsWith(fileName, ".tsx"); } export function isDTS(fileName: string) { - return ts.endsWith(fileName, ts.Extension.Dts); + return ts.endsWith(fileName, ".d.ts"); } export function isJS(fileName: string) { - return ts.endsWith(fileName, ts.Extension.Js); + return ts.endsWith(fileName, ".js"); } export function isJSX(fileName: string) { - return ts.endsWith(fileName, ts.Extension.Jsx); + return ts.endsWith(fileName, ".jsx"); } export function isJSMap(fileName: string) { @@ -1973,7 +1973,7 @@ namespace Harness { export function isDefaultLibraryFile(filePath: string): boolean { // We need to make sure that the filePath is prefixed with "lib." not just containing "lib." and end with ".d.ts" const fileName = ts.getBaseFileName(ts.normalizeSlashes(filePath)); - return ts.startsWith(fileName, "lib.") && ts.endsWith(fileName, ts.Extension.Dts); + return ts.startsWith(fileName, "lib.") && ts.endsWith(fileName, ".d.ts"); } export function isBuiltFile(filePath: string): boolean { diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 5d4d5a41f3adf..28d59fe35bd14 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -325,8 +325,8 @@ class ProjectRunner extends RunnerBase { // we need to instead create files that can live in the project reference folder // but make sure extension of these files matches with the fileName the compiler asked to write diskRelativeName = "diskFile" + nonSubfolderDiskFiles + - (Harness.Compiler.isDTS(fileName) ? ts.Extension.Dts : - Harness.Compiler.isJS(fileName) ? ts.Extension.Js : ".js.map"); + (Harness.Compiler.isDTS(fileName) ? ".d.ts" : + Harness.Compiler.isJS(fileName) ? ".js" : ".js.map"); nonSubfolderDiskFiles++; } @@ -386,14 +386,14 @@ class ProjectRunner extends RunnerBase { emitOutputFilePathWithoutExtension = ts.removeFileExtension(sourceFile.fileName); } - const outputDtsFileName = emitOutputFilePathWithoutExtension + ts.Extension.Dts; + const outputDtsFileName = emitOutputFilePathWithoutExtension + ".d.ts"; const file = findOutputDtsFile(outputDtsFileName); if (file) { allInputFiles.unshift(file); } } else { - const outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ts.Extension.Dts; + const outputDtsFileName = ts.removeFileExtension(compilerOptions.outFile || compilerOptions.out) + ".d.ts"; const outputDtsFile = findOutputDtsFile(outputDtsFileName); if (!ts.contains(allInputFiles, outputDtsFile)) { allInputFiles.unshift(outputDtsFile); diff --git a/src/harness/unittests/compileOnSave.ts b/src/harness/unittests/compileOnSave.ts index 7e262a1b2573d..eaab86b4ebc45 100644 --- a/src/harness/unittests/compileOnSave.ts +++ b/src/harness/unittests/compileOnSave.ts @@ -513,7 +513,7 @@ namespace ts.projectSystem { const lines = ["var x = 1;", "var y = 2;"]; const path = "/a/app"; const f = { - path: path + ts.Extension.Ts, + path: path + ".ts", content: lines.join(newLine) }; const host = createServerHost([f], { newLine }); @@ -530,7 +530,7 @@ namespace ts.projectSystem { command: "compileOnSaveEmitFile", arguments: { file: f.path } }); - const emitOutput = host.readFile(path + ts.Extension.Js); + const emitOutput = host.readFile(path + ".js"); assert.equal(emitOutput, f.content + newLine, "content of emit output should be identical with the input + newline"); } }); diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index 87ec4ea81494f..a4220f503218f 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -5,7 +5,7 @@ namespace ts { if (!expected === !actual) { if (expected) { assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); - assert.isTrue(expected.extension === actual.extension, `'ext': expected '${expected.extension}' to be equal to '${actual.extension}'`); + assert.isTrue(expected.extension === actual.extension, `'ext': expected '${Extension[expected.extension]}' to be equal to '${Extension[actual.extension]}'`); assert.isTrue(expected.isExternalLibraryImport === actual.isExternalLibraryImport, `'isExternalLibraryImport': expected '${expected.isExternalLibraryImport}' to be equal to '${actual.isExternalLibraryImport}'`); } return true; diff --git a/src/harness/unittests/transpile.ts b/src/harness/unittests/transpile.ts index e0c96797827f0..20552ab9c2e14 100644 --- a/src/harness/unittests/transpile.ts +++ b/src/harness/unittests/transpile.ts @@ -36,7 +36,7 @@ namespace ts { transpileOptions.reportDiagnostics = true; - justName = "transpile/" + name.replace(/[^a-z0-9\-. ]/ig, "") + (transpileOptions.compilerOptions.jsx ? Extension.Tsx : Extension.Ts); + justName = "transpile/" + name.replace(/[^a-z0-9\-. ]/ig, "") + (transpileOptions.compilerOptions.jsx ? ".tsx" : ".ts"); toBeCompiled = [{ unitName: transpileOptions.fileName, content: input @@ -88,7 +88,7 @@ namespace ts { } it("Correct output for " + justName, () => { - Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ts.Extension.Js), () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".js"), () => { if (transpileResult.outputText) { return transpileResult.outputText; } diff --git a/src/server/project.ts b/src/server/project.ts index 0b9df73ccac43..33b345af8334e 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -25,7 +25,7 @@ namespace ts.server { result.jsx += 1; break; case ScriptKind.TS: - fileExtensionIs(info.fileName, Extension.Dts) + fileExtensionIs(info.fileName, ".d.ts") ? result.dts += 1 : result.ts += 1; break; diff --git a/src/server/session.ts b/src/server/session.ts index c06e33eb9797f..064c9dc8c911d 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1575,7 +1575,7 @@ namespace ts.server { else { const info = this.projectService.getScriptInfo(fileNameInProject); if (!info.isScriptOpen()) { - if (fileNameInProject.indexOf(Extension.Dts) > 0) { + if (fileNameInProject.indexOf(".d.ts") > 0) { veryLowPriorityFiles.push(fileNameInProject); } else { diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 304f64f3cdbbb..d4adeaea97492 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -10,7 +10,7 @@ namespace ts.NavigateTo { for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); - if (excludeDtsFiles && fileExtensionIs(sourceFile.fileName, Extension.Dts)) { + if (excludeDtsFiles && fileExtensionIs(sourceFile.fileName, ".d.ts")) { continue; } From e4fa5f20158af9193dda2b4af26572954f9e63c4 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 15 Jun 2017 13:00:10 -0700 Subject: [PATCH 2/6] Revert "Also convert ClassificationTypeNames and CommandTypes/CommandNames" This reverts commit f94818da36c58f9fc0d6d535677f6500a096f6de. --- src/harness/fourslash.ts | 105 ++++++++++++-------------- src/server/protocol.ts | 151 +++++++++++++++++++------------------ src/server/session.ts | 110 +++++++++++++++++++++++++-- src/services/classifier.ts | 2 +- src/services/types.ts | 76 +++++++++---------- 5 files changed, 269 insertions(+), 175 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 7804e536daf69..9a371089548d3 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2182,7 +2182,7 @@ namespace FourSlash { } ts.zipWith(expected, actual, (expectedClassification, actualClassification) => { - const expectedType = expectedClassification.classificationType; + const expectedType: string = (ts.ClassificationTypeNames)[expectedClassification.classificationType]; if (expectedType !== actualClassification.classificationType) { this.raiseError("verifyClassifications failed - expected classifications type to be " + expectedType + ", but was " + @@ -3918,7 +3918,7 @@ namespace FourSlashInterface { /** * This method *requires* an ordered stream of classifications for a file, and spans are highly recommended. */ - public semanticClassificationsAre(...classifications: Classification[]) { + public semanticClassificationsAre(...classifications: { classificationType: string; text: string; textSpan?: FourSlash.TextSpan }[]) { this.state.verifySemanticClassifications(classifications); } @@ -4113,107 +4113,102 @@ namespace FourSlashInterface { } } - interface Classification { - classificationType: ts.ClassificationTypeNames; - text: string; - textSpan?: FourSlash.TextSpan; - } export namespace Classification { - export function comment(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.comment, text, position); + export function comment(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("comment", text, position); } - export function identifier(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.identifier, text, position); + export function identifier(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("identifier", text, position); } - export function keyword(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.keyword, text, position); + export function keyword(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("keyword", text, position); } - export function numericLiteral(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.numericLiteral, text, position); + export function numericLiteral(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("numericLiteral", text, position); } - export function operator(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.operator, text, position); + export function operator(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("operator", text, position); } - export function stringLiteral(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.stringLiteral, text, position); + export function stringLiteral(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("stringLiteral", text, position); } - export function whiteSpace(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.whiteSpace, text, position); + export function whiteSpace(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("whiteSpace", text, position); } - export function text(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.text, text, position); + export function text(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("text", text, position); } - export function punctuation(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.punctuation, text, position); + export function punctuation(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("punctuation", text, position); } - export function docCommentTagName(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.docCommentTagName, text, position); + export function docCommentTagName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("docCommentTagName", text, position); } - export function className(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.className, text, position); + export function className(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("className", text, position); } - export function enumName(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.enumName, text, position); + export function enumName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("enumName", text, position); } - export function interfaceName(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.interfaceName, text, position); + export function interfaceName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("interfaceName", text, position); } - export function moduleName(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.moduleName, text, position); + export function moduleName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("moduleName", text, position); } - export function typeParameterName(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.typeParameterName, text, position); + export function typeParameterName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("typeParameterName", text, position); } - export function parameterName(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.parameterName, text, position); + export function parameterName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("parameterName", text, position); } - export function typeAliasName(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.typeAliasName, text, position); + export function typeAliasName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("typeAliasName", text, position); } - export function jsxOpenTagName(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.jsxOpenTagName, text, position); + export function jsxOpenTagName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("jsxOpenTagName", text, position); } - export function jsxCloseTagName(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.jsxCloseTagName, text, position); + export function jsxCloseTagName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("jsxCloseTagName", text, position); } - export function jsxSelfClosingTagName(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.jsxSelfClosingTagName, text, position); + export function jsxSelfClosingTagName(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("jsxSelfClosingTagName", text, position); } - export function jsxAttribute(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.jsxAttribute, text, position); + export function jsxAttribute(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("jsxAttribute", text, position); } - export function jsxText(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.jsxText, text, position); + export function jsxText(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("jsxText", text, position); } - export function jsxAttributeStringLiteralValue(text: string, position?: number): Classification { - return getClassification(ts.ClassificationTypeNames.jsxAttributeStringLiteralValue, text, position); + export function jsxAttributeStringLiteralValue(text: string, position?: number): { classificationType: string; text: string; textSpan?: FourSlash.TextSpan } { + return getClassification("jsxAttributeStringLiteralValue", text, position); } - function getClassification(classificationType: ts.ClassificationTypeNames, text: string, position?: number): Classification { + function getClassification(type: string, text: string, position?: number) { return { - classificationType, + classificationType: type, text: text, textSpan: position === undefined ? undefined : { start: position, end: position + text.length } }; diff --git a/src/server/protocol.ts b/src/server/protocol.ts index f79774abf2058..55af5b2c11167 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2,107 +2,110 @@ * Declaration module describing the TypeScript Server protocol */ namespace ts.server.protocol { - // NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`. - export const enum CommandTypes { - Brace = "brace", + + export namespace CommandTypes { + export type Brace = "brace"; /* @internal */ - BraceFull = "brace-full", - BraceCompletion = "braceCompletion", - Change = "change", - Close = "close", - Completions = "completions", + export type BraceFull = "brace-full"; + export type BraceCompletion = "braceCompletion"; + export type Change = "change"; + export type Close = "close"; + export type Completions = "completions"; /* @internal */ - CompletionsFull = "completions-full", - CompletionDetails = "completionEntryDetails", - CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList", - CompileOnSaveEmitFile = "compileOnSaveEmitFile", - Configure = "configure", - Definition = "definition", + export type CompletionsFull = "completions-full"; + export type CompletionDetails = "completionEntryDetails"; + export type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + export type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + export type Configure = "configure"; + export type Definition = "definition"; /* @internal */ - DefinitionFull = "definition-full", - Implementation = "implementation", + export type DefinitionFull = "definition-full"; + export type Implementation = "implementation"; /* @internal */ - ImplementationFull = "implementation-full", - Exit = "exit", - Format = "format", - Formatonkey = "formatonkey", + export type ImplementationFull = "implementation-full"; + export type Exit = "exit"; + export type Format = "format"; + export type Formatonkey = "formatonkey"; /* @internal */ - FormatFull = "format-full", + export type FormatFull = "format-full"; /* @internal */ - FormatonkeyFull = "formatonkey-full", + export type FormatonkeyFull = "formatonkey-full"; /* @internal */ - FormatRangeFull = "formatRange-full", - Geterr = "geterr", - GeterrForProject = "geterrForProject", - SemanticDiagnosticsSync = "semanticDiagnosticsSync", - SyntacticDiagnosticsSync = "syntacticDiagnosticsSync", - NavBar = "navbar", + export type FormatRangeFull = "formatRange-full"; + export type Geterr = "geterr"; + export type GeterrForProject = "geterrForProject"; + export type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + export type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + export type NavBar = "navbar"; /* @internal */ - NavBarFull = "navbar-full", - Navto = "navto", + export type NavBarFull = "navbar-full"; + export type Navto = "navto"; /* @internal */ - NavtoFull = "navto-full", - NavTree = "navtree", - NavTreeFull = "navtree-full", - Occurrences = "occurrences", - DocumentHighlights = "documentHighlights", + export type NavtoFull = "navto-full"; + export type NavTree = "navtree"; + export type NavTreeFull = "navtree-full"; + export type Occurrences = "occurrences"; + export type DocumentHighlights = "documentHighlights"; /* @internal */ - DocumentHighlightsFull = "documentHighlights-full", - Open = "open", - Quickinfo = "quickinfo", + export type DocumentHighlightsFull = "documentHighlights-full"; + export type Open = "open"; + export type Quickinfo = "quickinfo"; /* @internal */ - QuickinfoFull = "quickinfo-full", - References = "references", + export type QuickinfoFull = "quickinfo-full"; + export type References = "references"; /* @internal */ - ReferencesFull = "references-full", - Reload = "reload", - Rename = "rename", + export type ReferencesFull = "references-full"; + export type Reload = "reload"; + export type Rename = "rename"; /* @internal */ - RenameInfoFull = "rename-full", + export type RenameInfoFull = "rename-full"; /* @internal */ - RenameLocationsFull = "renameLocations-full", - Saveto = "saveto", - SignatureHelp = "signatureHelp", + export type RenameLocationsFull = "renameLocations-full"; + export type Saveto = "saveto"; + export type SignatureHelp = "signatureHelp"; /* @internal */ - SignatureHelpFull = "signatureHelp-full", - TypeDefinition = "typeDefinition", - ProjectInfo = "projectInfo", - ReloadProjects = "reloadProjects", - Unknown = "unknown", - OpenExternalProject = "openExternalProject", - OpenExternalProjects = "openExternalProjects", - CloseExternalProject = "closeExternalProject", + export type SignatureHelpFull = "signatureHelp-full"; + export type TypeDefinition = "typeDefinition"; + export type ProjectInfo = "projectInfo"; + export type ReloadProjects = "reloadProjects"; + export type Unknown = "unknown"; + export type OpenExternalProject = "openExternalProject"; + export type OpenExternalProjects = "openExternalProjects"; + export type CloseExternalProject = "closeExternalProject"; /* @internal */ - SynchronizeProjectList = "synchronizeProjectList", + export type SynchronizeProjectList = "synchronizeProjectList"; /* @internal */ - ApplyChangedToOpenFiles = "applyChangedToOpenFiles", + export type ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; /* @internal */ - EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full", + export type EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; /* @internal */ - Cleanup = "cleanup", + export type Cleanup = "cleanup"; /* @internal */ - OutliningSpans = "outliningSpans", - TodoComments = "todoComments", - Indentation = "indentation", - DocCommentTemplate = "docCommentTemplate", + export type OutliningSpans = "outliningSpans"; + export type TodoComments = "todoComments"; + export type Indentation = "indentation"; + export type DocCommentTemplate = "docCommentTemplate"; /* @internal */ - CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full", + export type CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; /* @internal */ - NameOrDottedNameSpan = "nameOrDottedNameSpan", + export type NameOrDottedNameSpan = "nameOrDottedNameSpan"; /* @internal */ - BreakpointStatement = "breakpointStatement", - CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects", - GetCodeFixes = "getCodeFixes", + export type BreakpointStatement = "breakpointStatement"; + export type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + export type GetCodeFixes = "getCodeFixes"; /* @internal */ - GetCodeFixesFull = "getCodeFixes-full", - GetSupportedCodeFixes = "getSupportedCodeFixes", + export type GetCodeFixesFull = "getCodeFixes-full"; + export type GetSupportedCodeFixes = "getSupportedCodeFixes"; - GetApplicableRefactors = "getApplicableRefactors", - GetEditsForRefactor = "getEditsForRefactor", + // NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`. + export type GetApplicableRefactors = "getApplicableRefactors"; + export type GetRefactorCodeActions = "getRefactorCodeActions"; /* @internal */ - GetEditsForRefactorFull = "getEditsForRefactor-full", + export type GetRefactorCodeActionsFull = "getRefactorCodeActions-full"; - // NOTE: If updating this, be sure to also update `allCommandNames` in `harness/unittests/session.ts`. + export type GetEditsForRefactor = "getEditsForRefactor"; + /* @internal */ + export type GetEditsForRefactorFull = "getEditsForRefactor-full"; } /** diff --git a/src/server/session.ts b/src/server/session.ts index 064c9dc8c911d..d09f2f3dd2711 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -112,13 +112,109 @@ namespace ts.server { return true; } - // CommandNames used to be exposed before TS 2.4 as a namespace - // In TS 2.4 we switched to an enum, keep this for backward compatibility - // The var assignment ensures that even though CommandTypes are a const enum - // we want to ensure the value is maintained in the out since the file is - // built using --preseveConstEnum. - export type CommandNames = protocol.CommandTypes; - export const CommandNames = (protocol).CommandTypes; + export namespace CommandNames { + export const Brace: protocol.CommandTypes.Brace = "brace"; + /* @internal */ + export const BraceFull: protocol.CommandTypes.BraceFull = "brace-full"; + export const BraceCompletion: protocol.CommandTypes.BraceCompletion = "braceCompletion"; + export const Change: protocol.CommandTypes.Change = "change"; + export const Close: protocol.CommandTypes.Close = "close"; + export const Completions: protocol.CommandTypes.Completions = "completions"; + /* @internal */ + export const CompletionsFull: protocol.CommandTypes.CompletionsFull = "completions-full"; + export const CompletionDetails: protocol.CommandTypes.CompletionDetails = "completionEntryDetails"; + export const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + export const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + export const Configure: protocol.CommandTypes.Configure = "configure"; + export const Definition: protocol.CommandTypes.Definition = "definition"; + /* @internal */ + export const DefinitionFull: protocol.CommandTypes.DefinitionFull = "definition-full"; + export const Exit: protocol.CommandTypes.Exit = "exit"; + export const Format: protocol.CommandTypes.Format = "format"; + export const Formatonkey: protocol.CommandTypes.Formatonkey = "formatonkey"; + /* @internal */ + export const FormatFull: protocol.CommandTypes.FormatFull = "format-full"; + /* @internal */ + export const FormatonkeyFull: protocol.CommandTypes.FormatonkeyFull = "formatonkey-full"; + /* @internal */ + export const FormatRangeFull: protocol.CommandTypes.FormatRangeFull = "formatRange-full"; + export const Geterr: protocol.CommandTypes.Geterr = "geterr"; + export const GeterrForProject: protocol.CommandTypes.GeterrForProject = "geterrForProject"; + export const Implementation: protocol.CommandTypes.Implementation = "implementation"; + /* @internal */ + export const ImplementationFull: protocol.CommandTypes.ImplementationFull = "implementation-full"; + export const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + export const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + export const NavBar: protocol.CommandTypes.NavBar = "navbar"; + /* @internal */ + export const NavBarFull: protocol.CommandTypes.NavBarFull = "navbar-full"; + export const NavTree: protocol.CommandTypes.NavTree = "navtree"; + export const NavTreeFull: protocol.CommandTypes.NavTreeFull = "navtree-full"; + export const Navto: protocol.CommandTypes.Navto = "navto"; + /* @internal */ + export const NavtoFull: protocol.CommandTypes.NavtoFull = "navto-full"; + export const Occurrences: protocol.CommandTypes.Occurrences = "occurrences"; + export const DocumentHighlights: protocol.CommandTypes.DocumentHighlights = "documentHighlights"; + /* @internal */ + export const DocumentHighlightsFull: protocol.CommandTypes.DocumentHighlightsFull = "documentHighlights-full"; + export const Open: protocol.CommandTypes.Open = "open"; + export const Quickinfo: protocol.CommandTypes.Quickinfo = "quickinfo"; + /* @internal */ + export const QuickinfoFull: protocol.CommandTypes.QuickinfoFull = "quickinfo-full"; + export const References: protocol.CommandTypes.References = "references"; + /* @internal */ + export const ReferencesFull: protocol.CommandTypes.ReferencesFull = "references-full"; + export const Reload: protocol.CommandTypes.Reload = "reload"; + export const Rename: protocol.CommandTypes.Rename = "rename"; + /* @internal */ + export const RenameInfoFull: protocol.CommandTypes.RenameInfoFull = "rename-full"; + /* @internal */ + export const RenameLocationsFull: protocol.CommandTypes.RenameLocationsFull = "renameLocations-full"; + export const Saveto: protocol.CommandTypes.Saveto = "saveto"; + export const SignatureHelp: protocol.CommandTypes.SignatureHelp = "signatureHelp"; + /* @internal */ + export const SignatureHelpFull: protocol.CommandTypes.SignatureHelpFull = "signatureHelp-full"; + export const TypeDefinition: protocol.CommandTypes.TypeDefinition = "typeDefinition"; + export const ProjectInfo: protocol.CommandTypes.ProjectInfo = "projectInfo"; + export const ReloadProjects: protocol.CommandTypes.ReloadProjects = "reloadProjects"; + export const Unknown: protocol.CommandTypes.Unknown = "unknown"; + export const OpenExternalProject: protocol.CommandTypes.OpenExternalProject = "openExternalProject"; + export const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects = "openExternalProjects"; + export const CloseExternalProject: protocol.CommandTypes.CloseExternalProject = "closeExternalProject"; + /* @internal */ + export const SynchronizeProjectList: protocol.CommandTypes.SynchronizeProjectList = "synchronizeProjectList"; + /* @internal */ + export const ApplyChangedToOpenFiles: protocol.CommandTypes.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + /* @internal */ + export const EncodedSemanticClassificationsFull: protocol.CommandTypes.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + /* @internal */ + export const Cleanup: protocol.CommandTypes.Cleanup = "cleanup"; + /* @internal */ + export const OutliningSpans: protocol.CommandTypes.OutliningSpans = "outliningSpans"; + export const TodoComments: protocol.CommandTypes.TodoComments = "todoComments"; + export const Indentation: protocol.CommandTypes.Indentation = "indentation"; + export const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate = "docCommentTemplate"; + /* @internal */ + export const CompilerOptionsDiagnosticsFull: protocol.CommandTypes.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + /* @internal */ + export const NameOrDottedNameSpan: protocol.CommandTypes.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + /* @internal */ + export const BreakpointStatement: protocol.CommandTypes.BreakpointStatement = "breakpointStatement"; + export const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + export const GetCodeFixes: protocol.CommandTypes.GetCodeFixes = "getCodeFixes"; + /* @internal */ + export const GetCodeFixesFull: protocol.CommandTypes.GetCodeFixesFull = "getCodeFixes-full"; + export const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes = "getSupportedCodeFixes"; + + export const GetApplicableRefactors: protocol.CommandTypes.GetApplicableRefactors = "getApplicableRefactors"; + export const GetRefactorCodeActions: protocol.CommandTypes.GetRefactorCodeActions = "getRefactorCodeActions"; + /* @internal */ + export const GetRefactorCodeActionsFull: protocol.CommandTypes.GetRefactorCodeActionsFull = "getRefactorCodeActions-full"; + + export const GetEditsForRefactor: protocol.CommandTypes.GetEditsForRefactor = "getEditsForRefactor"; + /* @internal */ + export const GetEditsForRefactorFull: protocol.CommandTypes.GetEditsForRefactorFull = "getEditsForRefactor-full" + } export function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string { const verboseLogging = logger.hasLevel(LogLevel.verbose); diff --git a/src/services/classifier.ts b/src/services/classifier.ts index ff33059630d82..d2db40be5b549 100644 --- a/src/services/classifier.ts +++ b/src/services/classifier.ts @@ -573,7 +573,7 @@ namespace ts { } } - function getClassificationTypeName(type: ClassificationType): ClassificationTypeNames { + function getClassificationTypeName(type: ClassificationType) { switch (type) { case ClassificationType.comment: return ClassificationTypeNames.comment; case ClassificationType.identifier: return ClassificationTypeNames.identifier; diff --git a/src/services/types.ts b/src/services/types.ts index 2d47da2fd1d08..8eaa220a4a4e6 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -291,7 +291,7 @@ namespace ts { export interface ClassifiedSpan { textSpan: TextSpan; - classificationType: ClassificationTypeNames; + classificationType: string; // ClassificationTypeNames } /** @@ -858,43 +858,43 @@ namespace ts { jsxAttribute = "JSX attribute", } - export const enum ScriptElementKindModifier { - none = "", - publicMemberModifier = "public", - privateMemberModifier = "private", - protectedMemberModifier = "protected", - exportedModifier = "export", - ambientModifier = "declare", - staticModifier = "static", - abstractModifier = "abstract", - } - - export const enum ClassificationTypeNames { - comment = "comment", - identifier = "identifier", - keyword = "keyword", - numericLiteral = "number", - operator = "operator", - stringLiteral = "string", - whiteSpace = "whitespace", - text = "text", - - punctuation = "punctuation", - - className = "class name", - enumName = "enum name", - interfaceName = "interface name", - moduleName = "module name", - typeParameterName = "type parameter name", - typeAliasName = "type alias name", - parameterName = "parameter name", - docCommentTagName = "doc comment tag name", - jsxOpenTagName = "jsx open tag name", - jsxCloseTagName = "jsx close tag name", - jsxSelfClosingTagName = "jsx self closing tag name", - jsxAttribute = "jsx attribute", - jsxText = "jsx text", - jsxAttributeStringLiteralValue = "jsx attribute string literal value", + export namespace ScriptElementKindModifier { + export const none = ""; + export const publicMemberModifier = "public"; + export const privateMemberModifier = "private"; + export const protectedMemberModifier = "protected"; + export const exportedModifier = "export"; + export const ambientModifier = "declare"; + export const staticModifier = "static"; + export const abstractModifier = "abstract"; + } + + export class ClassificationTypeNames { + public static comment = "comment"; + public static identifier = "identifier"; + public static keyword = "keyword"; + public static numericLiteral = "number"; + public static operator = "operator"; + public static stringLiteral = "string"; + public static whiteSpace = "whitespace"; + public static text = "text"; + + public static punctuation = "punctuation"; + + public static className = "class name"; + public static enumName = "enum name"; + public static interfaceName = "interface name"; + public static moduleName = "module name"; + public static typeParameterName = "type parameter name"; + public static typeAliasName = "type alias name"; + public static parameterName = "parameter name"; + public static docCommentTagName = "doc comment tag name"; + public static jsxOpenTagName = "jsx open tag name"; + public static jsxCloseTagName = "jsx close tag name"; + public static jsxSelfClosingTagName = "jsx self closing tag name"; + public static jsxAttribute = "jsx attribute"; + public static jsxText = "jsx text"; + public static jsxAttributeStringLiteralValue = "jsx attribute string literal value"; } export const enum ClassificationType { From 57df9addb92480bb5d6a90c16fcb0cb81bb3f056 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 15 Jun 2017 13:04:53 -0700 Subject: [PATCH 3/6] Revert "Make ScriptElementKind and HighlightSpanKind string enums" This reverts commit b162097c3c7f5e5174eb70124de8888669775dbd. --- src/server/client.ts | 12 ++-- src/server/protocol.ts | 19 +++--- src/services/findAllReferences.ts | 6 +- src/services/goToDefinition.ts | 18 +++-- src/services/navigateTo.ts | 2 +- src/services/pathCompletions.ts | 2 +- src/services/rename.ts | 2 +- src/services/symbolDisplay.ts | 4 +- src/services/types.ts | 108 +++++++++++++++--------------- src/services/utilities.ts | 4 +- 10 files changed, 92 insertions(+), 85 deletions(-) diff --git a/src/server/client.ts b/src/server/client.ts index 2cfe32f521a05..bbd44891efcca 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -224,7 +224,7 @@ namespace ts.server { return { name, kind, kindModifiers, sortText, replacementSpan: convertedSpan }; } - return entry as { name: string, kind: ScriptElementKind, kindModifiers: string, sortText: string }; + return entry as { name: string, kind: string, kindModifiers: string, sortText: string }; }) }; } @@ -265,7 +265,7 @@ namespace ts.server { return { name: entry.name, containerName: entry.containerName || "", - containerKind: entry.containerKind || ScriptElementKind.unknown, + containerKind: entry.containerKind || "", kind: entry.kind, kindModifiers: entry.kindModifiers, matchKind: entry.matchKind, @@ -330,11 +330,11 @@ namespace ts.server { const start = this.lineOffsetToPosition(fileName, entry.start); const end = this.lineOffsetToPosition(fileName, entry.end); return { - containerKind: ScriptElementKind.unknown, + containerKind: "", containerName: "", fileName: fileName, textSpan: ts.createTextSpanFromBounds(start, end), - kind: ScriptElementKind.unknown, + kind: "", name: "" }; }); @@ -356,11 +356,11 @@ namespace ts.server { const start = this.lineOffsetToPosition(fileName, entry.start); const end = this.lineOffsetToPosition(fileName, entry.end); return { - containerKind: ScriptElementKind.unknown, + containerKind: "", containerName: "", fileName: fileName, textSpan: ts.createTextSpanFromBounds(start, end), - kind: ScriptElementKind.unknown, + kind: "", name: "" }; }); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 55af5b2c11167..6b0651c7e8a18 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -751,9 +751,10 @@ namespace ts.server.protocol { /** * Span augmented with extra information that denotes the kind of the highlighting to be used for span. + * Kind is taken from HighlightSpanKind type. */ export interface HighlightSpan extends TextSpan { - kind: HighlightSpanKind; + kind: string; } /** @@ -890,7 +891,7 @@ namespace ts.server.protocol { /** * The items's kind (such as 'className' or 'parameterName' or plain 'text'). */ - kind: ScriptElementKind; + kind: string; /** * Optional modifiers for the kind (such as 'public'). @@ -1404,7 +1405,7 @@ namespace ts.server.protocol { /** * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). */ - kind: ScriptElementKind; + kind: string; /** * Optional modifiers for the kind (such as 'public'). @@ -1623,7 +1624,7 @@ namespace ts.server.protocol { /** * The symbol's kind (such as 'className' or 'parameterName'). */ - kind: ScriptElementKind; + kind: string; /** * Optional modifiers for the kind (such as 'public'). */ @@ -1651,7 +1652,7 @@ namespace ts.server.protocol { /** * The symbol's kind (such as 'className' or 'parameterName'). */ - kind: ScriptElementKind; + kind: string; /** * Optional modifiers for the kind (such as 'public'). */ @@ -2110,7 +2111,7 @@ namespace ts.server.protocol { /** * The symbol's kind (such as 'className' or 'parameterName'). */ - kind: ScriptElementKind; + kind: string; /** * exact, substring, or prefix. @@ -2151,7 +2152,7 @@ namespace ts.server.protocol { /** * Kind of symbol's container symbol (if any). */ - containerKind?: ScriptElementKind; + containerKind?: string; } /** @@ -2224,7 +2225,7 @@ namespace ts.server.protocol { /** * The symbol's kind (such as 'className' or 'parameterName'). */ - kind: ScriptElementKind; + kind: string; /** * Optional modifiers for the kind (such as 'public'). @@ -2250,7 +2251,7 @@ namespace ts.server.protocol { /** protocol.NavigationTree is identical to ts.NavigationTree, except using protocol.TextSpan instead of ts.TextSpan */ export interface NavigationTree { text: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; spans: TextSpan[]; childItems?: NavigationTree[]; diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 192895cde591c..aba3a0ae9aa1f 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -150,7 +150,7 @@ namespace ts.FindAllReferences { const { node, name, kind, displayParts } = info; const sourceFile = node.getSourceFile(); return { - containerKind: ScriptElementKind.unknown, + containerKind: "", containerName: "", fileName: sourceFile.fileName, kind, @@ -160,7 +160,7 @@ namespace ts.FindAllReferences { }; } - function getDefinitionKindAndDisplayParts(symbol: Symbol, node: Node, checker: TypeChecker): { displayParts: SymbolDisplayPart[], kind: ScriptElementKind } { + function getDefinitionKindAndDisplayParts(symbol: Symbol, node: Node, checker: TypeChecker): { displayParts: SymbolDisplayPart[], kind: string } { const { displayParts, symbolKind } = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), getContainerNode(node), node); return { displayParts, kind: symbolKind }; @@ -192,7 +192,7 @@ namespace ts.FindAllReferences { } } - function implementationKindDisplayParts(node: ts.Node, checker: ts.TypeChecker): { kind: ScriptElementKind, displayParts: SymbolDisplayPart[] } { + function implementationKindDisplayParts(node: ts.Node, checker: ts.TypeChecker): { kind: string, displayParts: SymbolDisplayPart[] } { const symbol = checker.getSymbolAtLocation(isDeclaration(node) && node.name ? node.name : node); if (symbol) { return getDefinitionKindAndDisplayParts(symbol, node, checker); diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index ac60ba7942c05..d57b0cdfa8a25 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -165,7 +165,7 @@ namespace ts.GoToDefinition { return result; - function tryAddConstructSignature(symbol: Symbol, location: Node, symbolKind: ScriptElementKind, symbolName: string, containerName: string, result: DefinitionInfo[]) { + function tryAddConstructSignature(symbol: Symbol, location: Node, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class if (isNewExpressionTarget(location) || location.kind === SyntaxKind.ConstructorKeyword) { @@ -173,8 +173,12 @@ namespace ts.GoToDefinition { // Find the first class-like declaration and try to get the construct signature. for (const declaration of symbol.getDeclarations()) { if (isClassLike(declaration)) { - return tryAddSignature( - declaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, + symbolKind, + symbolName, + containerName, + result); } } @@ -184,14 +188,14 @@ namespace ts.GoToDefinition { return false; } - function tryAddCallSignature(symbol: Symbol, location: Node, symbolKind: ScriptElementKind, symbolName: string, containerName: string, result: DefinitionInfo[]) { + function tryAddCallSignature(symbol: Symbol, location: Node, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { if (isCallExpressionTarget(location) || isNewExpressionTarget(location) || isNameOfFunctionDeclaration(location)) { return tryAddSignature(symbol.declarations, /*selectConstructors*/ false, symbolKind, symbolName, containerName, result); } return false; } - function tryAddSignature(signatureDeclarations: Declaration[] | undefined, selectConstructors: boolean, symbolKind: ScriptElementKind, symbolName: string, containerName: string, result: DefinitionInfo[]) { + function tryAddSignature(signatureDeclarations: Declaration[] | undefined, selectConstructors: boolean, symbolKind: string, symbolName: string, containerName: string, result: DefinitionInfo[]) { if (!signatureDeclarations) { return false; } @@ -227,12 +231,12 @@ namespace ts.GoToDefinition { } /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ - function createDefinitionInfo(node: Declaration, symbolKind: ScriptElementKind, symbolName: string, containerName: string): DefinitionInfo { + function createDefinitionInfo(node: Declaration, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { return createDefinitionInfoFromName(getNameOfDeclaration(node) || node, symbolKind, symbolName, containerName); } /** Creates a DefinitionInfo directly from the name of a declaration. */ - function createDefinitionInfoFromName(name: Node, symbolKind: ScriptElementKind, symbolName: string, containerName: string): DefinitionInfo { + function createDefinitionInfoFromName(name: Node, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { const sourceFile = name.getSourceFile(); return { fileName: sourceFile.fileName, diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index d4adeaea97492..2fdc567b9bbcf 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -205,7 +205,7 @@ namespace ts.NavigateTo { textSpan: createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? (containerName).text : "", - containerKind: containerName ? getNodeKind(container) : ScriptElementKind.unknown + containerKind: containerName ? getNodeKind(container) : "" }; } } diff --git a/src/services/pathCompletions.ts b/src/services/pathCompletions.ts index 3ded126ab6552..c36ad7ab50b74 100644 --- a/src/services/pathCompletions.ts +++ b/src/services/pathCompletions.ts @@ -455,7 +455,7 @@ namespace ts.Completions.PathCompletions { } } - function createCompletionEntryForModule(name: string, kind: ScriptElementKind, replacementSpan: TextSpan): CompletionEntry { + function createCompletionEntryForModule(name: string, kind: string, replacementSpan: TextSpan): CompletionEntry { return { name, kind, kindModifiers: ScriptElementKindModifier.none, sortText: name, replacementSpan }; } diff --git a/src/services/rename.ts b/src/services/rename.ts index 6091c0b2d039b..27c47179052f3 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -53,7 +53,7 @@ namespace ts.Rename { } } - function getRenameInfoSuccess(displayName: string, fullDisplayName: string, kind: ScriptElementKind, kindModifiers: string, node: Node, sourceFile: SourceFile): RenameInfo { + function getRenameInfoSuccess(displayName: string, fullDisplayName: string, kind: string, kindModifiers: string, node: Node, sourceFile: SourceFile): RenameInfo { return { canRename: true, kind, diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 345f0718fe315..142a0d487ab52 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -1,7 +1,7 @@ /* @internal */ namespace ts.SymbolDisplay { // TODO(drosen): use contextual SemanticMeaning. - export function getSymbolKind(typeChecker: TypeChecker, symbol: Symbol, location: Node): ScriptElementKind { + export function getSymbolKind(typeChecker: TypeChecker, symbol: Symbol, location: Node): string { const { flags } = symbol; if (flags & SymbolFlags.Class) { @@ -24,7 +24,7 @@ namespace ts.SymbolDisplay { return result; } - function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker: TypeChecker, symbol: Symbol, location: Node): ScriptElementKind { + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker: TypeChecker, symbol: Symbol, location: Node) { if (typeChecker.isUndefinedSymbol(symbol)) { return ScriptElementKind.variableElement; } diff --git a/src/services/types.ts b/src/services/types.ts index 8eaa220a4a4e6..51c633a2db804 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -302,7 +302,7 @@ namespace ts { */ export interface NavigationBarItem { text: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; spans: TextSpan[]; childItems: NavigationBarItem[]; @@ -318,7 +318,8 @@ namespace ts { export interface NavigationTree { /** Name of the declaration, or a short description, e.g. "". */ text: string; - kind: ScriptElementKind; + /** A ScriptElementKind */ + kind: string; /** ScriptElementKindModifier separated by commas, e.g. "public,abstract" */ kindModifiers: string; /** @@ -433,7 +434,7 @@ namespace ts { } export interface ImplementationLocation extends DocumentSpan { - kind: ScriptElementKind; + kind: string; displayParts: SymbolDisplayPart[]; } @@ -442,30 +443,30 @@ namespace ts { highlightSpans: HighlightSpan[]; } - export const enum HighlightSpanKind { - none = "none", - definition = "definition", - reference = "reference", - writtenReference = "writtenReference", + export namespace HighlightSpanKind { + export const none = "none"; + export const definition = "definition"; + export const reference = "reference"; + export const writtenReference = "writtenReference"; } export interface HighlightSpan { fileName?: string; isInString?: true; textSpan: TextSpan; - kind: HighlightSpanKind; + kind: string; } export interface NavigateToItem { name: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; - matchKind: string; // TODO: keyof typeof PatternMatchKind; (https://github.com/Microsoft/TypeScript/issues/15102) + matchKind: string; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; containerName: string; - containerKind: ScriptElementKind; + containerKind: string; } export enum IndentStyle { @@ -533,9 +534,9 @@ namespace ts { export interface DefinitionInfo { fileName: string; textSpan: TextSpan; - kind: ScriptElementKind; + kind: string; name: string; - containerKind: ScriptElementKind; + containerKind: string; containerName: string; } @@ -575,7 +576,7 @@ namespace ts { export interface SymbolDisplayPart { text: string; - kind: string; + kind: string; // A ScriptElementKind } export interface JSDocTagInfo { @@ -584,7 +585,7 @@ namespace ts { } export interface QuickInfo { - kind: ScriptElementKind; + kind: string; kindModifiers: string; textSpan: TextSpan; displayParts: SymbolDisplayPart[]; @@ -597,7 +598,7 @@ namespace ts { localizedErrorMessage: string; displayName: string; fullDisplayName: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; triggerSpan: TextSpan; } @@ -650,7 +651,7 @@ namespace ts { export interface CompletionEntry { name: string; - kind: ScriptElementKind; + kind: string; // see ScriptElementKind kindModifiers: string; // see ScriptElementKindModifier, comma separated sortText: string; /** @@ -663,7 +664,7 @@ namespace ts { export interface CompletionEntryDetails { name: string; - kind: ScriptElementKind; + kind: string; // see ScriptElementKind kindModifiers: string; // see ScriptElementKindModifier, comma separated displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; @@ -761,101 +762,102 @@ namespace ts { getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; } - export const enum ScriptElementKind { - unknown = "", - warning = "warning", + // TODO: move these to enums + export namespace ScriptElementKind { + export const unknown = ""; + export const warning = "warning"; /** predefined type (void) or keyword (class) */ - keyword = "keyword", + export const keyword = "keyword"; /** top level script node */ - scriptElement = "script", + export const scriptElement = "script"; /** module foo {} */ - moduleElement = "module", + export const moduleElement = "module"; /** class X {} */ - classElement = "class", + export const classElement = "class"; /** var x = class X {} */ - localClassElement = "local class", + export const localClassElement = "local class"; /** interface Y {} */ - interfaceElement = "interface", + export const interfaceElement = "interface"; /** type T = ... */ - typeElement = "type", + export const typeElement = "type"; /** enum E */ - enumElement = "enum", - enumMemberElement = "enum member", + export const enumElement = "enum"; + export const enumMemberElement = "enum member"; /** * Inside module and script only * const v = .. */ - variableElement = "var", + export const variableElement = "var"; /** Inside function */ - localVariableElement = "local var", + export const localVariableElement = "local var"; /** * Inside module and script only * function f() { } */ - functionElement = "function", + export const functionElement = "function"; /** Inside function */ - localFunctionElement = "local function", + export const localFunctionElement = "local function"; /** class X { [public|private]* foo() {} } */ - memberFunctionElement = "method", + export const memberFunctionElement = "method"; /** class X { [public|private]* [get|set] foo:number; } */ - memberGetAccessorElement = "getter", - memberSetAccessorElement = "setter", + export const memberGetAccessorElement = "getter"; + export const memberSetAccessorElement = "setter"; /** * class X { [public|private]* foo:number; } * interface Y { foo:number; } */ - memberVariableElement = "property", + export const memberVariableElement = "property"; /** class X { constructor() { } } */ - constructorImplementationElement = "constructor", + export const constructorImplementationElement = "constructor"; /** interface Y { ():number; } */ - callSignatureElement = "call", + export const callSignatureElement = "call"; /** interface Y { []:number; } */ - indexSignatureElement = "index", + export const indexSignatureElement = "index"; /** interface Y { new():Y; } */ - constructSignatureElement = "construct", + export const constructSignatureElement = "construct"; /** function foo(*Y*: string) */ - parameterElement = "parameter", + export const parameterElement = "parameter"; - typeParameterElement = "type parameter", + export const typeParameterElement = "type parameter"; - primitiveType = "primitive type", + export const primitiveType = "primitive type"; - label = "label", + export const label = "label"; - alias = "alias", + export const alias = "alias"; - constElement = "const", + export const constElement = "const"; - letElement = "let", + export const letElement = "let"; - directory = "directory", + export const directory = "directory"; - externalModuleName = "external module name", + export const externalModuleName = "external module name"; /** * */ - jsxAttribute = "JSX attribute", + export const jsxAttribute = "JSX attribute"; } export namespace ScriptElementKindModifier { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index b7717edd86723..9a03e3da0c0b2 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -297,7 +297,7 @@ namespace ts { } } - export function getNodeKind(node: Node): ScriptElementKind { + export function getNodeKind(node: Node): string { switch (node.kind) { case SyntaxKind.SourceFile: return isExternalModule(node) ? ScriptElementKind.moduleElement : ScriptElementKind.scriptElement; @@ -344,7 +344,7 @@ namespace ts { return ScriptElementKind.unknown; } - function getKindOfVariableDeclaration(v: VariableDeclaration): ScriptElementKind { + function getKindOfVariableDeclaration(v: VariableDeclaration): string { return isConst(v) ? ScriptElementKind.constElement : isLet(v) From 09c9f1e7aab9331fd9d8bf3c45788330548549a2 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 22 May 2017 10:47:28 -0700 Subject: [PATCH 4/6] Revert "Make ScriptElementKind and HighlightSpanKind string enums" This reverts commit b162097c3c7f5e5174eb70124de8888669775dbd. # Conflicts: # lib/lib.d.ts # lib/lib.es2016.full.d.ts # lib/lib.es2017.full.d.ts # lib/lib.es5.d.ts # lib/lib.es6.d.ts # lib/lib.esnext.full.d.ts # lib/tsc.js # lib/tsserver.js # lib/tsserverlibrary.d.ts # lib/tsserverlibrary.js # lib/typescript.d.ts # lib/typescript.js # lib/typescriptServices.d.ts # lib/typescriptServices.js # lib/typingsInstaller.js --- src/harness/unittests/session.ts | 12 +++--- src/server/protocol.ts | 68 +++++++++++++++++++------------- 2 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 067cd351ec727..407f9f70aaaa0 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -134,7 +134,7 @@ namespace ts.server { type: "request", arguments: { formatOptions: { - indentStyle: protocol.IndentStyle.Block, + indentStyle: "Block" } } }; @@ -149,11 +149,11 @@ namespace ts.server { type: "request", arguments: { options: { - module: protocol.ModuleKind.System, - target: protocol.ScriptTarget.ES5, - jsx: protocol.JsxEmit.React, - newLine: protocol.NewLineKind.Lf, - moduleResolution: protocol.ModuleResolutionKind.Node, + module: "System", + target: "ES5", + jsx: "React", + newLine: "Lf", + moduleResolution: "Node" } } }; diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 6b0651c7e8a18..b43dbf42d9273 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2345,12 +2345,14 @@ namespace ts.server.protocol { body?: NavigationTree; } - export const enum IndentStyle { - None = "None", - Block = "Block", - Smart = "Smart", + export namespace IndentStyle { + export type None = "None"; + export type Block = "Block"; + export type Smart = "Smart"; } + export type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; + export interface EditorSettings { baseIndentSize?: number; indentSize?: number; @@ -2447,37 +2449,47 @@ namespace ts.server.protocol { [option: string]: CompilerOptionsValue | undefined; } - export const enum JsxEmit { - None = "None", - Preserve = "Preserve", - ReactNative = "ReactNative", - React = "React", + export namespace JsxEmit { + export type None = "None"; + export type Preserve = "Preserve"; + export type ReactNative = "ReactNative"; + export type React = "React"; } - export const enum ModuleKind { - None = "None", - CommonJS = "CommonJS", - AMD = "AMD", - UMD = "UMD", - System = "System", - ES6 = "ES6", - ES2015 = "ES2015", + export type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative; + + export namespace ModuleKind { + export type None = "None"; + export type CommonJS = "CommonJS"; + export type AMD = "AMD"; + export type UMD = "UMD"; + export type System = "System"; + export type ES6 = "ES6"; + export type ES2015 = "ES2015"; } - export const enum ModuleResolutionKind { - Classic = "Classic", - Node = "Node", + export type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; + + export namespace ModuleResolutionKind { + export type Classic = "Classic"; + export type Node = "Node"; } - export const enum NewLineKind { - Crlf = "Crlf", - Lf = "Lf", + export type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; + + export namespace NewLineKind { + export type Crlf = "Crlf"; + export type Lf = "Lf"; } - export const enum ScriptTarget { - ES3 = "ES3", - ES5 = "ES5", - ES6 = "ES6", - ES2015 = "ES2015", + export type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; + + export namespace ScriptTarget { + export type ES3 = "ES3"; + export type ES5 = "ES5"; + export type ES6 = "ES6"; + export type ES2015 = "ES2015"; } + + export type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; } From 2137bbfd25cf317526c1eb9431f92f7b1f7d96c8 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 15 Jun 2017 13:24:42 -0700 Subject: [PATCH 5/6] Update LKG --- lib/protocol.d.ts | 188 ++++---- lib/tsc.js | 53 ++- lib/tsserver.js | 840 +++++++++++++++++------------------- lib/tsserverlibrary.d.ts | 421 ++++++++++-------- lib/tsserverlibrary.js | 840 +++++++++++++++++------------------- lib/typescript.d.ts | 186 ++++---- lib/typescript.js | 534 ++++++++++++----------- lib/typescriptServices.d.ts | 186 ++++---- lib/typescriptServices.js | 534 ++++++++++++----------- lib/typingsInstaller.js | 43 +- 10 files changed, 1958 insertions(+), 1867 deletions(-) diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index a568f1f1dc074..af133ae982abd 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -2,53 +2,54 @@ * Declaration module describing the TypeScript Server protocol */ declare namespace ts.server.protocol { - const enum CommandTypes { - Brace = "brace", - BraceCompletion = "braceCompletion", - Change = "change", - Close = "close", - Completions = "completions", - CompletionDetails = "completionEntryDetails", - CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList", - CompileOnSaveEmitFile = "compileOnSaveEmitFile", - Configure = "configure", - Definition = "definition", - Implementation = "implementation", - Exit = "exit", - Format = "format", - Formatonkey = "formatonkey", - Geterr = "geterr", - GeterrForProject = "geterrForProject", - SemanticDiagnosticsSync = "semanticDiagnosticsSync", - SyntacticDiagnosticsSync = "syntacticDiagnosticsSync", - NavBar = "navbar", - Navto = "navto", - NavTree = "navtree", - NavTreeFull = "navtree-full", - Occurrences = "occurrences", - DocumentHighlights = "documentHighlights", - Open = "open", - Quickinfo = "quickinfo", - References = "references", - Reload = "reload", - Rename = "rename", - Saveto = "saveto", - SignatureHelp = "signatureHelp", - TypeDefinition = "typeDefinition", - ProjectInfo = "projectInfo", - ReloadProjects = "reloadProjects", - Unknown = "unknown", - OpenExternalProject = "openExternalProject", - OpenExternalProjects = "openExternalProjects", - CloseExternalProject = "closeExternalProject", - TodoComments = "todoComments", - Indentation = "indentation", - DocCommentTemplate = "docCommentTemplate", - CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects", - GetCodeFixes = "getCodeFixes", - GetSupportedCodeFixes = "getSupportedCodeFixes", - GetApplicableRefactors = "getApplicableRefactors", - GetEditsForRefactor = "getEditsForRefactor", + namespace CommandTypes { + type Brace = "brace"; + type BraceCompletion = "braceCompletion"; + type Change = "change"; + type Close = "close"; + type Completions = "completions"; + type CompletionDetails = "completionEntryDetails"; + type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + type Configure = "configure"; + type Definition = "definition"; + type Implementation = "implementation"; + type Exit = "exit"; + type Format = "format"; + type Formatonkey = "formatonkey"; + type Geterr = "geterr"; + type GeterrForProject = "geterrForProject"; + type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + type NavBar = "navbar"; + type Navto = "navto"; + type NavTree = "navtree"; + type NavTreeFull = "navtree-full"; + type Occurrences = "occurrences"; + type DocumentHighlights = "documentHighlights"; + type Open = "open"; + type Quickinfo = "quickinfo"; + type References = "references"; + type Reload = "reload"; + type Rename = "rename"; + type Saveto = "saveto"; + type SignatureHelp = "signatureHelp"; + type TypeDefinition = "typeDefinition"; + type ProjectInfo = "projectInfo"; + type ReloadProjects = "reloadProjects"; + type Unknown = "unknown"; + type OpenExternalProject = "openExternalProject"; + type OpenExternalProjects = "openExternalProjects"; + type CloseExternalProject = "closeExternalProject"; + type TodoComments = "todoComments"; + type Indentation = "indentation"; + type DocCommentTemplate = "docCommentTemplate"; + type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + type GetCodeFixes = "getCodeFixes"; + type GetSupportedCodeFixes = "getSupportedCodeFixes"; + type GetApplicableRefactors = "getApplicableRefactors"; + type GetRefactorCodeActions = "getRefactorCodeActions"; + type GetEditsForRefactor = "getEditsForRefactor"; } /** * A TypeScript Server message @@ -571,9 +572,10 @@ declare namespace ts.server.protocol { } /** * Span augmented with extra information that denotes the kind of the highlighting to be used for span. + * Kind is taken from HighlightSpanKind type. */ interface HighlightSpan extends TextSpan { - kind: HighlightSpanKind; + kind: string; } /** * Represents a set of highligh spans for a give name @@ -691,7 +693,7 @@ declare namespace ts.server.protocol { /** * The items's kind (such as 'className' or 'parameterName' or plain 'text'). */ - kind: ScriptElementKind; + kind: string; /** * Optional modifiers for the kind (such as 'public'). */ @@ -1039,7 +1041,7 @@ declare namespace ts.server.protocol { /** * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). */ - kind: ScriptElementKind; + kind: string; /** * Optional modifiers for the kind (such as 'public'). */ @@ -1225,7 +1227,7 @@ declare namespace ts.server.protocol { /** * The symbol's kind (such as 'className' or 'parameterName'). */ - kind: ScriptElementKind; + kind: string; /** * Optional modifiers for the kind (such as 'public'). */ @@ -1252,7 +1254,7 @@ declare namespace ts.server.protocol { /** * The symbol's kind (such as 'className' or 'parameterName'). */ - kind: ScriptElementKind; + kind: string; /** * Optional modifiers for the kind (such as 'public'). */ @@ -1645,7 +1647,7 @@ declare namespace ts.server.protocol { /** * The symbol's kind (such as 'className' or 'parameterName'). */ - kind: ScriptElementKind; + kind: string; /** * exact, substring, or prefix. */ @@ -1678,7 +1680,7 @@ declare namespace ts.server.protocol { /** * Kind of symbol's container symbol (if any). */ - containerKind?: ScriptElementKind; + containerKind?: string; } /** * Navto response message. Body is an array of navto items. Each @@ -1742,7 +1744,7 @@ declare namespace ts.server.protocol { /** * The symbol's kind (such as 'className' or 'parameterName'). */ - kind: ScriptElementKind; + kind: string; /** * Optional modifiers for the kind (such as 'public'). */ @@ -1763,7 +1765,7 @@ declare namespace ts.server.protocol { /** protocol.NavigationTree is identical to ts.NavigationTree, except using protocol.TextSpan instead of ts.TextSpan */ interface NavigationTree { text: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; spans: TextSpan[]; childItems?: NavigationTree[]; @@ -1838,11 +1840,12 @@ declare namespace ts.server.protocol { interface NavTreeResponse extends Response { body?: NavigationTree; } - const enum IndentStyle { - None = "None", - Block = "Block", - Smart = "Smart", + namespace IndentStyle { + type None = "None"; + type Block = "Block"; + type Smart = "Smart"; } + type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; interface EditorSettings { baseIndentSize?: number; indentSize?: number; @@ -1936,35 +1939,40 @@ declare namespace ts.server.protocol { typeRoots?: string[]; [option: string]: CompilerOptionsValue | undefined; } - const enum JsxEmit { - None = "None", - Preserve = "Preserve", - ReactNative = "ReactNative", - React = "React", - } - const enum ModuleKind { - None = "None", - CommonJS = "CommonJS", - AMD = "AMD", - UMD = "UMD", - System = "System", - ES6 = "ES6", - ES2015 = "ES2015", - } - const enum ModuleResolutionKind { - Classic = "Classic", - Node = "Node", - } - const enum NewLineKind { - Crlf = "Crlf", - Lf = "Lf", - } - const enum ScriptTarget { - ES3 = "ES3", - ES5 = "ES5", - ES6 = "ES6", - ES2015 = "ES2015", - } + namespace JsxEmit { + type None = "None"; + type Preserve = "Preserve"; + type ReactNative = "ReactNative"; + type React = "React"; + } + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative; + namespace ModuleKind { + type None = "None"; + type CommonJS = "CommonJS"; + type AMD = "AMD"; + type UMD = "UMD"; + type System = "System"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; + namespace ModuleResolutionKind { + type Classic = "Classic"; + type Node = "Node"; + } + type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; + namespace NewLineKind { + type Crlf = "Crlf"; + type Lf = "Lf"; + } + type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; + namespace ScriptTarget { + type ES3 = "ES3"; + type ES5 = "ES5"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; } declare namespace ts.server.protocol { @@ -2020,8 +2028,6 @@ declare namespace ts.server.protocol { } declare namespace ts { // these types are empty stubs for types from services and should not be used directly - export type HighlightSpanKind = never; - export type ScriptElementKind = never; export type ScriptKind = never; export type IndentStyle = never; export type JsxEmit = never; diff --git a/lib/tsc.js b/lib/tsc.js index e61de96328782..2d7ba1407d4f3 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -80,6 +80,15 @@ var ts; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 6] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var Extension; + (function (Extension) { + Extension[Extension["Ts"] = 0] = "Ts"; + Extension[Extension["Tsx"] = 1] = "Tsx"; + Extension[Extension["Dts"] = 2] = "Dts"; + Extension[Extension["Js"] = 3] = "Js"; + Extension[Extension["Jsx"] = 4] = "Jsx"; + Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; + })(Extension = ts.Extension || (ts.Extension = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -2123,7 +2132,7 @@ var ts; } ts.positionIsSynthesized = positionIsSynthesized; function extensionIsTypeScript(ext) { - return ext === ".ts" || ext === ".tsx" || ext === ".d.ts"; + return ext <= ts.Extension.LastTypeScriptExtension; } ts.extensionIsTypeScript = extensionIsTypeScript; function extensionFromPath(path) { @@ -2135,7 +2144,21 @@ var ts; } ts.extensionFromPath = extensionFromPath; function tryGetExtensionFromPath(path) { - return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); }); + if (fileExtensionIs(path, ".d.ts")) { + return ts.Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return ts.Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return ts.Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return ts.Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return ts.Extension.Jsx; + } } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; function isCheckJsEnabledForFile(sourceFile, compilerOptions) { @@ -21555,14 +21578,14 @@ var ts; } switch (extensions) { case Extensions.DtsOnly: - return tryExtension(".d.ts"); + return tryExtension(".d.ts", ts.Extension.Dts); case Extensions.TypeScript: - return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts"); + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); case Extensions.JavaScript: - return tryExtension(".js") || tryExtension(".jsx"); + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } - function tryExtension(extension) { - var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); return path && { path: path, extension: extension }; } } @@ -21632,11 +21655,11 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" || extension === ".jsx"; + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; case Extensions.TypeScript: - return extension === ".ts" || extension === ".tsx" || extension === ".d.ts"; + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; case Extensions.DtsOnly: - return extension === ".d.ts"; + return extension === ts.Extension.Dts; } } function pathToPackageJson(directory) { @@ -56483,14 +56506,14 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts": - case ".d.ts": + case ts.Extension.Ts: + case ts.Extension.Dts: return undefined; - case ".tsx": + case ts.Extension.Tsx: return needJsx(); - case ".jsx": + case ts.Extension.Jsx: return needJsx() || needAllowJs(); - case ".js": + case ts.Extension.Js: return needAllowJs(); } function needJsx() { diff --git a/lib/tsserver.js b/lib/tsserver.js index de9b675c9703e..dd82c1b4fee22 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -954,11 +954,12 @@ var ts; })(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {})); var Extension; (function (Extension) { - Extension["Ts"] = ".ts"; - Extension["Tsx"] = ".tsx"; - Extension["Dts"] = ".d.ts"; - Extension["Js"] = ".js"; - Extension["Jsx"] = ".jsx"; + Extension[Extension["Ts"] = 0] = "Ts"; + Extension[Extension["Tsx"] = 1] = "Tsx"; + Extension[Extension["Dts"] = 2] = "Dts"; + Extension[Extension["Js"] = 3] = "Js"; + Extension[Extension["Jsx"] = 4] = "Jsx"; + Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; })(Extension = ts.Extension || (ts.Extension = {})); var TransformFlags; (function (TransformFlags) { @@ -3151,7 +3152,7 @@ var ts; } ts.positionIsSynthesized = positionIsSynthesized; function extensionIsTypeScript(ext) { - return ext === ".ts" || ext === ".tsx" || ext === ".d.ts"; + return ext <= ts.Extension.LastTypeScriptExtension; } ts.extensionIsTypeScript = extensionIsTypeScript; function extensionFromPath(path) { @@ -3163,7 +3164,21 @@ var ts; } ts.extensionFromPath = extensionFromPath; function tryGetExtensionFromPath(path) { - return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); }); + if (fileExtensionIs(path, ".d.ts")) { + return ts.Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return ts.Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return ts.Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return ts.Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return ts.Extension.Jsx; + } } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; function isCheckJsEnabledForFile(sourceFile, compilerOptions) { @@ -5018,14 +5033,14 @@ var ts; } switch (extensions) { case Extensions.DtsOnly: - return tryExtension(".d.ts"); + return tryExtension(".d.ts", ts.Extension.Dts); case Extensions.TypeScript: - return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts"); + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); case Extensions.JavaScript: - return tryExtension(".js") || tryExtension(".jsx"); + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } - function tryExtension(extension) { - var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); return path && { path: path, extension: extension }; } } @@ -5095,11 +5110,11 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" || extension === ".jsx"; + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; case Extensions.TypeScript: - return extension === ".ts" || extension === ".tsx" || extension === ".d.ts"; + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; case Extensions.DtsOnly: - return extension === ".d.ts"; + return extension === ts.Extension.Dts; } } function pathToPackageJson(directory) { @@ -57923,14 +57938,14 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts": - case ".d.ts": + case ts.Extension.Ts: + case ts.Extension.Dts: return undefined; - case ".tsx": + case ts.Extension.Tsx: return needJsx(); - case ".jsx": + case ts.Extension.Jsx: return needJsx() || needAllowJs(); - case ".js": + case ts.Extension.Js: return needAllowJs(); } function needJsx() { @@ -59373,10 +59388,10 @@ var ts; ts.TextChange = TextChange; var HighlightSpanKind; (function (HighlightSpanKind) { - HighlightSpanKind["none"] = "none"; - HighlightSpanKind["definition"] = "definition"; - HighlightSpanKind["reference"] = "reference"; - HighlightSpanKind["writtenReference"] = "writtenReference"; + HighlightSpanKind.none = "none"; + HighlightSpanKind.definition = "definition"; + HighlightSpanKind.reference = "reference"; + HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); var IndentStyle; (function (IndentStyle) { @@ -59439,77 +59454,80 @@ var ts; })(TokenClass = ts.TokenClass || (ts.TokenClass = {})); var ScriptElementKind; (function (ScriptElementKind) { - ScriptElementKind["unknown"] = ""; - ScriptElementKind["warning"] = "warning"; - ScriptElementKind["keyword"] = "keyword"; - ScriptElementKind["scriptElement"] = "script"; - ScriptElementKind["moduleElement"] = "module"; - ScriptElementKind["classElement"] = "class"; - ScriptElementKind["localClassElement"] = "local class"; - ScriptElementKind["interfaceElement"] = "interface"; - ScriptElementKind["typeElement"] = "type"; - ScriptElementKind["enumElement"] = "enum"; - ScriptElementKind["enumMemberElement"] = "enum member"; - ScriptElementKind["variableElement"] = "var"; - ScriptElementKind["localVariableElement"] = "local var"; - ScriptElementKind["functionElement"] = "function"; - ScriptElementKind["localFunctionElement"] = "local function"; - ScriptElementKind["memberFunctionElement"] = "method"; - ScriptElementKind["memberGetAccessorElement"] = "getter"; - ScriptElementKind["memberSetAccessorElement"] = "setter"; - ScriptElementKind["memberVariableElement"] = "property"; - ScriptElementKind["constructorImplementationElement"] = "constructor"; - ScriptElementKind["callSignatureElement"] = "call"; - ScriptElementKind["indexSignatureElement"] = "index"; - ScriptElementKind["constructSignatureElement"] = "construct"; - ScriptElementKind["parameterElement"] = "parameter"; - ScriptElementKind["typeParameterElement"] = "type parameter"; - ScriptElementKind["primitiveType"] = "primitive type"; - ScriptElementKind["label"] = "label"; - ScriptElementKind["alias"] = "alias"; - ScriptElementKind["constElement"] = "const"; - ScriptElementKind["letElement"] = "let"; - ScriptElementKind["directory"] = "directory"; - ScriptElementKind["externalModuleName"] = "external module name"; - ScriptElementKind["jsxAttribute"] = "JSX attribute"; + ScriptElementKind.unknown = ""; + ScriptElementKind.warning = "warning"; + ScriptElementKind.keyword = "keyword"; + ScriptElementKind.scriptElement = "script"; + ScriptElementKind.moduleElement = "module"; + ScriptElementKind.classElement = "class"; + ScriptElementKind.localClassElement = "local class"; + ScriptElementKind.interfaceElement = "interface"; + ScriptElementKind.typeElement = "type"; + ScriptElementKind.enumElement = "enum"; + ScriptElementKind.enumMemberElement = "enum member"; + ScriptElementKind.variableElement = "var"; + ScriptElementKind.localVariableElement = "local var"; + ScriptElementKind.functionElement = "function"; + ScriptElementKind.localFunctionElement = "local function"; + ScriptElementKind.memberFunctionElement = "method"; + ScriptElementKind.memberGetAccessorElement = "getter"; + ScriptElementKind.memberSetAccessorElement = "setter"; + ScriptElementKind.memberVariableElement = "property"; + ScriptElementKind.constructorImplementationElement = "constructor"; + ScriptElementKind.callSignatureElement = "call"; + ScriptElementKind.indexSignatureElement = "index"; + ScriptElementKind.constructSignatureElement = "construct"; + ScriptElementKind.parameterElement = "parameter"; + ScriptElementKind.typeParameterElement = "type parameter"; + ScriptElementKind.primitiveType = "primitive type"; + ScriptElementKind.label = "label"; + ScriptElementKind.alias = "alias"; + ScriptElementKind.constElement = "const"; + ScriptElementKind.letElement = "let"; + ScriptElementKind.directory = "directory"; + ScriptElementKind.externalModuleName = "external module name"; + ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { - ScriptElementKindModifier["none"] = ""; - ScriptElementKindModifier["publicMemberModifier"] = "public"; - ScriptElementKindModifier["privateMemberModifier"] = "private"; - ScriptElementKindModifier["protectedMemberModifier"] = "protected"; - ScriptElementKindModifier["exportedModifier"] = "export"; - ScriptElementKindModifier["ambientModifier"] = "declare"; - ScriptElementKindModifier["staticModifier"] = "static"; - ScriptElementKindModifier["abstractModifier"] = "abstract"; + ScriptElementKindModifier.none = ""; + ScriptElementKindModifier.publicMemberModifier = "public"; + ScriptElementKindModifier.privateMemberModifier = "private"; + ScriptElementKindModifier.protectedMemberModifier = "protected"; + ScriptElementKindModifier.exportedModifier = "export"; + ScriptElementKindModifier.ambientModifier = "declare"; + ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); - var ClassificationTypeNames; - (function (ClassificationTypeNames) { - ClassificationTypeNames["comment"] = "comment"; - ClassificationTypeNames["identifier"] = "identifier"; - ClassificationTypeNames["keyword"] = "keyword"; - ClassificationTypeNames["numericLiteral"] = "number"; - ClassificationTypeNames["operator"] = "operator"; - ClassificationTypeNames["stringLiteral"] = "string"; - ClassificationTypeNames["whiteSpace"] = "whitespace"; - ClassificationTypeNames["text"] = "text"; - ClassificationTypeNames["punctuation"] = "punctuation"; - ClassificationTypeNames["className"] = "class name"; - ClassificationTypeNames["enumName"] = "enum name"; - ClassificationTypeNames["interfaceName"] = "interface name"; - ClassificationTypeNames["moduleName"] = "module name"; - ClassificationTypeNames["typeParameterName"] = "type parameter name"; - ClassificationTypeNames["typeAliasName"] = "type alias name"; - ClassificationTypeNames["parameterName"] = "parameter name"; - ClassificationTypeNames["docCommentTagName"] = "doc comment tag name"; - ClassificationTypeNames["jsxOpenTagName"] = "jsx open tag name"; - ClassificationTypeNames["jsxCloseTagName"] = "jsx close tag name"; - ClassificationTypeNames["jsxSelfClosingTagName"] = "jsx self closing tag name"; - ClassificationTypeNames["jsxAttribute"] = "jsx attribute"; - ClassificationTypeNames["jsxText"] = "jsx text"; - ClassificationTypeNames["jsxAttributeStringLiteralValue"] = "jsx attribute string literal value"; - })(ClassificationTypeNames = ts.ClassificationTypeNames || (ts.ClassificationTypeNames = {})); + var ClassificationTypeNames = (function () { + function ClassificationTypeNames() { + } + ClassificationTypeNames.comment = "comment"; + ClassificationTypeNames.identifier = "identifier"; + ClassificationTypeNames.keyword = "keyword"; + ClassificationTypeNames.numericLiteral = "number"; + ClassificationTypeNames.operator = "operator"; + ClassificationTypeNames.stringLiteral = "string"; + ClassificationTypeNames.whiteSpace = "whitespace"; + ClassificationTypeNames.text = "text"; + ClassificationTypeNames.punctuation = "punctuation"; + ClassificationTypeNames.className = "class name"; + ClassificationTypeNames.enumName = "enum name"; + ClassificationTypeNames.interfaceName = "interface name"; + ClassificationTypeNames.moduleName = "module name"; + ClassificationTypeNames.typeParameterName = "type parameter name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; + ClassificationTypeNames.docCommentTagName = "doc comment tag name"; + ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; + ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; + ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; + ClassificationTypeNames.jsxAttribute = "jsx attribute"; + ClassificationTypeNames.jsxText = "jsx text"; + ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; + return ClassificationTypeNames; + }()); + ts.ClassificationTypeNames = ClassificationTypeNames; var ClassificationType; (function (ClassificationType) { ClassificationType[ClassificationType["comment"] = 1] = "comment"; @@ -59808,15 +59826,15 @@ var ts; function getNodeKind(node) { switch (node.kind) { case 265: - return ts.isExternalModule(node) ? "module" : "script"; + return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; case 233: - return "module"; + return ts.ScriptElementKind.moduleElement; case 229: case 199: - return "class"; - case 230: return "interface"; - case 231: return "type"; - case 232: return "enum"; + return ts.ScriptElementKind.classElement; + case 230: return ts.ScriptElementKind.interfaceElement; + case 231: return ts.ScriptElementKind.typeElement; + case 232: return ts.ScriptElementKind.enumElement; case 226: return getKindOfVariableDeclaration(node); case 176: @@ -59824,39 +59842,39 @@ var ts; case 187: case 228: case 186: - return "function"; - case 153: return "getter"; - case 154: return "setter"; + return ts.ScriptElementKind.functionElement; + case 153: return ts.ScriptElementKind.memberGetAccessorElement; + case 154: return ts.ScriptElementKind.memberSetAccessorElement; case 151: case 150: - return "method"; + return ts.ScriptElementKind.memberFunctionElement; case 149: case 148: - return "property"; - case 157: return "index"; - case 156: return "construct"; - case 155: return "call"; - case 152: return "constructor"; - case 145: return "type parameter"; - case 264: return "enum member"; - case 146: return ts.hasModifier(node, 92) ? "property" : "parameter"; + return ts.ScriptElementKind.memberVariableElement; + case 157: return ts.ScriptElementKind.indexSignatureElement; + case 156: return ts.ScriptElementKind.constructSignatureElement; + case 155: return ts.ScriptElementKind.callSignatureElement; + case 152: return ts.ScriptElementKind.constructorImplementationElement; + case 145: return ts.ScriptElementKind.typeParameterElement; + case 264: return ts.ScriptElementKind.enumMemberElement; + case 146: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; case 237: case 242: case 239: case 246: case 240: - return "alias"; + return ts.ScriptElementKind.alias; case 291: - return "type"; + return ts.ScriptElementKind.typeElement; default: - return ""; + return ts.ScriptElementKind.unknown; } function getKindOfVariableDeclaration(v) { return ts.isConst(v) - ? "const" + ? ts.ScriptElementKind.constElement : ts.isLet(v) - ? "let" - : "var"; + ? ts.ScriptElementKind.letElement + : ts.ScriptElementKind.variableElement; } } ts.getNodeKind = getNodeKind; @@ -60261,20 +60279,20 @@ var ts; var flags = ts.getCombinedModifierFlags(node); var result = []; if (flags & 8) - result.push("private"); + result.push(ts.ScriptElementKindModifier.privateMemberModifier); if (flags & 16) - result.push("protected"); + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); if (flags & 4) - result.push("public"); + result.push(ts.ScriptElementKindModifier.publicMemberModifier); if (flags & 32) - result.push("static"); + result.push(ts.ScriptElementKindModifier.staticModifier); if (flags & 128) - result.push("abstract"); + result.push(ts.ScriptElementKindModifier.abstractModifier); if (flags & 1) - result.push("export"); + result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) - result.push("declare"); - return result.length > 0 ? result.join(",") : ""; + result.push(ts.ScriptElementKindModifier.ambientModifier); + return result.length > 0 ? result.join(",") : ts.ScriptElementKindModifier.none; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { @@ -61578,29 +61596,29 @@ var ts; ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function getClassificationTypeName(type) { switch (type) { - case 1: return "comment"; - case 2: return "identifier"; - case 3: return "keyword"; - case 4: return "number"; - case 5: return "operator"; - case 6: return "string"; - case 8: return "whitespace"; - case 9: return "text"; - case 10: return "punctuation"; - case 11: return "class name"; - case 12: return "enum name"; - case 13: return "interface name"; - case 14: return "module name"; - case 15: return "type parameter name"; - case 16: return "type alias name"; - case 17: return "parameter name"; - case 18: return "doc comment tag name"; - case 19: return "jsx open tag name"; - case 20: return "jsx close tag name"; - case 21: return "jsx self closing tag name"; - case 22: return "jsx attribute"; - case 23: return "jsx text"; - case 24: return "jsx attribute string literal value"; + case 1: return ts.ClassificationTypeNames.comment; + case 2: return ts.ClassificationTypeNames.identifier; + case 3: return ts.ClassificationTypeNames.keyword; + case 4: return ts.ClassificationTypeNames.numericLiteral; + case 5: return ts.ClassificationTypeNames.operator; + case 6: return ts.ClassificationTypeNames.stringLiteral; + case 8: return ts.ClassificationTypeNames.whiteSpace; + case 9: return ts.ClassificationTypeNames.text; + case 10: return ts.ClassificationTypeNames.punctuation; + case 11: return ts.ClassificationTypeNames.className; + case 12: return ts.ClassificationTypeNames.enumName; + case 13: return ts.ClassificationTypeNames.interfaceName; + case 14: return ts.ClassificationTypeNames.moduleName; + case 15: return ts.ClassificationTypeNames.typeParameterName; + case 16: return ts.ClassificationTypeNames.typeAliasName; + case 17: return ts.ClassificationTypeNames.parameterName; + case 18: return ts.ClassificationTypeNames.docCommentTagName; + case 19: return ts.ClassificationTypeNames.jsxOpenTagName; + case 20: return ts.ClassificationTypeNames.jsxCloseTagName; + case 21: return ts.ClassificationTypeNames.jsxSelfClosingTagName; + case 22: return ts.ClassificationTypeNames.jsxAttribute; + case 23: return ts.ClassificationTypeNames.jsxText; + case 24: return ts.ClassificationTypeNames.jsxAttributeStringLiteralValue; } } function convertClassifications(classifications) { @@ -61987,7 +62005,7 @@ var ts; } } ts.forEachKey(foundFiles, function (foundFile) { - result.push(createCompletionEntryForModule(foundFile, "script", span)); + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); }); } var directories = tryGetDirectories(host, baseDirectory); @@ -61995,7 +62013,7 @@ var ts; for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { var directory = directories_2[_a]; var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, "directory", span)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); } } } @@ -62018,7 +62036,7 @@ var ts; var pattern = _a[_i]; for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { var match = _c[_b]; - result.push(createCompletionEntryForModule(match, "external module name", span)); + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); } } } @@ -62026,7 +62044,7 @@ var ts; else if (ts.startsWith(path, fragment)) { var entry = paths[path] && paths[path].length === 1 && paths[path][0]; if (entry) { - result.push(createCompletionEntryForModule(path, "external module name", span)); + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); } } } @@ -62039,7 +62057,7 @@ var ts; getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, "external module name", span)); + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); } return result; } @@ -62150,7 +62168,7 @@ var ts; if (options.types) { for (var _i = 0, _a = options.types; _i < _a.length; _i++) { var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, "external module name", span)); + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); } } else if (host.getDirectories) { @@ -62182,7 +62200,7 @@ var ts; for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { var typeDirectory = directories_3[_i]; typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), "external module name", span)); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); } } } @@ -62253,7 +62271,7 @@ var ts; } } function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: "", sortText: name, replacementSpan: replacementSpan }; + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; } function getDirectoryFragmentTextSpan(text, textStart) { var index = text.lastIndexOf(ts.directorySeparator); @@ -62328,7 +62346,7 @@ var ts; return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, entries: [{ name: tagName.getFullText(), - kind: "class", + kind: ts.ScriptElementKind.classElement, kindModifiers: undefined, sortText: "0", }] }; @@ -62376,7 +62394,7 @@ var ts; if (displayName) { var entry = { name: displayName, - kind: "warning", + kind: ts.ScriptElementKind.warning, kindModifiers: "", sortText: "1" }; @@ -62512,8 +62530,8 @@ var ts; uniques.set(name, true); result.push({ name: name, - kindModifiers: "", - kind: "var", + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, sortText: "0" }); } @@ -62540,8 +62558,8 @@ var ts; if (keywordCompletion) { return { name: entryName, - kind: "keyword", - kindModifiers: "", + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], documentation: undefined, tags: undefined @@ -63379,8 +63397,8 @@ var ts; for (var i = 72; i <= 142; i++) { keywordCompletions.push({ name: ts.tokenToString(i), - kind: "keyword", - kindModifiers: "", + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, sortText: "0" }); } @@ -63467,7 +63485,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node, sourceFile), - kind: "none" + kind: ts.HighlightSpanKind.none }; } function getSemanticDocumentHighlights(node, program, cancellationToken, sourceFilesToSearch) { @@ -63914,7 +63932,7 @@ var ts; result.push({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: "reference" + kind: ts.HighlightSpanKind.reference }); i++; continue; @@ -64623,22 +64641,22 @@ var ts; } case "label": { var node_3 = def.node; - return { node: node_3, name: node_3.text, kind: "label", displayParts: [ts.displayPart(node_3.text, ts.SymbolDisplayPartKind.text)] }; + return { node: node_3, name: node_3.text, kind: ts.ScriptElementKind.label, displayParts: [ts.displayPart(node_3.text, ts.SymbolDisplayPartKind.text)] }; } case "keyword": { var node_4 = def.node; var name_4 = ts.tokenToString(node_4.kind); - return { node: node_4, name: name_4, kind: "keyword", displayParts: [{ text: name_4, kind: "keyword" }] }; + return { node: node_4, name: name_4, kind: ts.ScriptElementKind.keyword, displayParts: [{ text: name_4, kind: ts.ScriptElementKind.keyword }] }; } case "this": { var node_5 = def.node; var symbol = checker.getSymbolAtLocation(node_5); var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node_5.getSourceFile(), ts.getContainerNode(node_5), node_5).displayParts; - return { node: node_5, name: "this", kind: "var", displayParts: displayParts_2 }; + return { node: node_5, name: "this", kind: ts.ScriptElementKind.variableElement, displayParts: displayParts_2 }; } case "string": { var node_6 = def.node; - return { node: node_6, name: node_6.text, kind: "var", displayParts: [ts.displayPart(ts.getTextOfNode(node_6), ts.SymbolDisplayPartKind.stringLiteral)] }; + return { node: node_6, name: node_6.text, kind: ts.ScriptElementKind.variableElement, displayParts: [ts.displayPart(ts.getTextOfNode(node_6), ts.SymbolDisplayPartKind.stringLiteral)] }; } } })(); @@ -64681,7 +64699,7 @@ var ts; } else { var textSpan = entry.textSpan, fileName = entry.fileName; - return { textSpan: textSpan, fileName: fileName, kind: "", displayParts: [] }; + return { textSpan: textSpan, fileName: fileName, kind: ts.ScriptElementKind.unknown, displayParts: [] }; } } function implementationKindDisplayParts(node, checker) { @@ -64691,13 +64709,13 @@ var ts; } else if (node.kind === 178) { return { - kind: "interface", + kind: ts.ScriptElementKind.interfaceElement, displayParts: [ts.punctuationPart(19), ts.textPart("object literal"), ts.punctuationPart(20)] }; } else if (node.kind === 199) { return { - kind: "local class", + kind: ts.ScriptElementKind.localClassElement, displayParts: [ts.punctuationPart(19), ts.textPart("anonymous local class"), ts.punctuationPart(20)] }; } @@ -64708,14 +64726,14 @@ var ts; function toHighlightSpan(entry) { if (entry.type === "span") { var fileName_1 = entry.fileName, textSpan = entry.textSpan; - return { fileName: fileName_1, span: { textSpan: textSpan, kind: "reference" } }; + return { fileName: fileName_1, span: { textSpan: textSpan, kind: ts.HighlightSpanKind.reference } }; } var node = entry.node, isInString = entry.isInString; var fileName = entry.node.getSourceFile().fileName; var writeAccess = isWriteAccess(node); var span = { textSpan: getTextSpan(node), - kind: writeAccess ? "writtenReference" : "reference", + kind: writeAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference, isInString: isInString }; return { fileName: fileName, span: span }; @@ -65816,7 +65834,7 @@ var ts; if (ts.isJumpStatementTarget(node)) { var labelName = node.text; var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(label, "label", labelName, undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ts.ScriptElementKind.label, labelName, undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -65999,7 +66017,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: "script", + kind: ts.ScriptElementKind.scriptElement, name: name, containerName: undefined, containerKind: undefined @@ -66133,7 +66151,7 @@ var ts; return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: "keyword", + kind: ts.ScriptElementKind.keyword, kindModifiers: "", sortText: "0", }; @@ -66144,7 +66162,7 @@ var ts; return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: "@" + tagName, - kind: "keyword", + kind: ts.ScriptElementKind.keyword, kindModifiers: "", sortText: "0" }; @@ -66165,7 +66183,7 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter", kindModifiers: "", sortText: "0" }; + return { name: name, kind: ts.ScriptElementKind.parameterElement, kindModifiers: "", sortText: "0" }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; @@ -68007,7 +68025,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } var displayName = ts.stripQuotes(node.text); - return getRenameInfoSuccess(displayName, displayName, "var", "", node, sourceFile); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); } } function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { @@ -68389,92 +68407,92 @@ var ts; var flags = symbol.flags; if (flags & 32) { return ts.getDeclarationOfKind(symbol, 199) ? - "local class" : "class"; + ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; } if (flags & 384) - return "enum"; + return ts.ScriptElementKind.enumElement; if (flags & 524288) - return "type"; + return ts.ScriptElementKind.typeElement; if (flags & 64) - return "interface"; + return ts.ScriptElementKind.interfaceElement; if (flags & 262144) - return "type parameter"; + return ts.ScriptElementKind.typeParameterElement; var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - if (result === "") { + if (result === ts.ScriptElementKind.unknown) { if (flags & 262144) - return "type parameter"; + return ts.ScriptElementKind.typeParameterElement; if (flags & 8) - return "enum member"; + return ts.ScriptElementKind.enumMemberElement; if (flags & 8388608) - return "alias"; + return ts.ScriptElementKind.alias; if (flags & 1536) - return "module"; + return ts.ScriptElementKind.moduleElement; } return result; } SymbolDisplay.getSymbolKind = getSymbolKind; function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) { if (typeChecker.isUndefinedSymbol(symbol)) { - return "var"; + return ts.ScriptElementKind.variableElement; } if (typeChecker.isArgumentsSymbol(symbol)) { - return "local var"; + return ts.ScriptElementKind.localVariableElement; } if (location.kind === 99 && ts.isExpression(location)) { - return "parameter"; + return ts.ScriptElementKind.parameterElement; } var flags = symbol.flags; if (flags & 3) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return "parameter"; + return ts.ScriptElementKind.parameterElement; } else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { - return "const"; + return ts.ScriptElementKind.constElement; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return "let"; + return ts.ScriptElementKind.letElement; } - return isLocalVariableOrFunction(symbol) ? "local var" : "var"; + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localVariableElement : ts.ScriptElementKind.variableElement; } if (flags & 16) - return isLocalVariableOrFunction(symbol) ? "local function" : "function"; + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localFunctionElement : ts.ScriptElementKind.functionElement; if (flags & 32768) - return "getter"; + return ts.ScriptElementKind.memberGetAccessorElement; if (flags & 65536) - return "setter"; + return ts.ScriptElementKind.memberSetAccessorElement; if (flags & 8192) - return "method"; + return ts.ScriptElementKind.memberFunctionElement; if (flags & 16384) - return "constructor"; + return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4) { if (flags & 134217728 && symbol.checkFlags & 6) { var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 | 3)) { - return "property"; + return ts.ScriptElementKind.memberVariableElement; } ts.Debug.assert(!!(rootSymbolFlags & 8192)); }); if (!unionPropertyKind) { var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return "method"; + return ts.ScriptElementKind.memberFunctionElement; } - return "property"; + return ts.ScriptElementKind.memberVariableElement; } return unionPropertyKind; } if (location.parent && ts.isJsxAttribute(location.parent)) { - return "JSX attribute"; + return ts.ScriptElementKind.jsxAttribute; } - return "property"; + return ts.ScriptElementKind.memberVariableElement; } - return ""; + return ts.ScriptElementKind.unknown; } function getSymbolModifiers(symbol) { return symbol && symbol.declarations && symbol.declarations.length > 0 ? ts.getNodeModifiers(symbol.declarations[0]) - : ""; + : ts.ScriptElementKindModifier.none; } SymbolDisplay.getSymbolModifiers = getSymbolModifiers; function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) { @@ -68487,9 +68505,9 @@ var ts; var hasAddedSymbolInfo; var isThisExpression = location.kind === 99 && ts.isExpression(location); var type; - if (symbolKind !== "" || symbolFlags & 32 || symbolFlags & 8388608) { - if (symbolKind === "getter" || symbolKind === "setter") { - symbolKind = "property"; + if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 || symbolFlags & 8388608) { + if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { + symbolKind = ts.ScriptElementKind.memberVariableElement; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); @@ -68523,11 +68541,11 @@ var ts; } if (signature) { if (useConstructSignatures && (symbolFlags & 32)) { - symbolKind = "constructor"; + symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else if (symbolFlags & 8388608) { - symbolKind = "alias"; + symbolKind = ts.ScriptElementKind.alias; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { @@ -68540,13 +68558,13 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case "JSX attribute": - case "property": - case "var": - case "const": - case "let": - case "parameter": - case "local var": + case ts.ScriptElementKind.jsxAttribute: + case ts.ScriptElementKind.memberVariableElement: + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.parameterElement: + case ts.ScriptElementKind.localVariableElement: displayParts.push(ts.punctuationPart(56)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { @@ -68579,7 +68597,7 @@ var ts; signature = allSignatures[0]; } if (functionDeclaration_1.kind === 152) { - symbolKind = "constructor"; + symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { @@ -68594,7 +68612,7 @@ var ts; } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { if (ts.getDeclarationOfKind(symbol, 199)) { - pushTypePart("local class"); + pushTypePart(ts.ScriptElementKind.localClassElement); } else { displayParts.push(ts.keywordPart(75)); @@ -68679,7 +68697,7 @@ var ts; } } if (symbolFlags & 8) { - symbolKind = "enum member"; + symbolKind = ts.ScriptElementKind.enumMemberElement; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; if (declaration.kind === 264) { @@ -68730,7 +68748,7 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== "") { + if (symbolKind !== ts.ScriptElementKind.unknown) { if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); @@ -68739,10 +68757,10 @@ var ts; else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } - if (symbolKind === "property" || - symbolKind === "JSX attribute" || + if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolKind === ts.ScriptElementKind.jsxAttribute || symbolFlags & 3 || - symbolKind === "local var" || + symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { displayParts.push(ts.punctuationPart(56)); displayParts.push(ts.spacePart()); @@ -68761,7 +68779,7 @@ var ts; symbolFlags & 16384 || symbolFlags & 131072 || symbolFlags & 98304 || - symbolKind === "method") { + symbolKind === ts.ScriptElementKind.memberFunctionElement) { var allSignatures = type.getNonNullableType().getCallSignatures(); addSignatureDisplayParts(allSignatures[0], allSignatures); } @@ -68819,11 +68837,11 @@ var ts; } function pushTypePart(symbolKind) { switch (symbolKind) { - case "var": - case "function": - case "let": - case "const": - case "constructor": + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.functionElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.constructorImplementationElement: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: @@ -74370,8 +74388,8 @@ var ts; var type = typeChecker.getTypeAtLocation(node); if (type) { return { - kind: "", - kindModifiers: "", + kind: ts.ScriptElementKind.unknown, + kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined, @@ -74431,7 +74449,7 @@ var ts; result.push({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, - isWriteAccess: highlightSpan.kind === "writtenReference", + isWriteAccess: highlightSpan.kind === ts.HighlightSpanKind.writtenReference, isDefinition: false, isInString: highlightSpan.isInString, }); @@ -75440,7 +75458,7 @@ var ts; var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (result.resolvedModule && result.resolvedModule.extension !== ".ts" && result.resolvedModule.extension !== ".tsx" && result.resolvedModule.extension !== ".d.ts") { + if (result.resolvedModule && result.resolvedModule.extension !== ts.Extension.Ts && result.resolvedModule.extension !== ts.Extension.Tsx && result.resolvedModule.extension !== ts.Extension.Dts) { resolvedFileName = undefined; } return { @@ -75862,129 +75880,6 @@ var ts; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var server; - (function (server) { - var protocol; - (function (protocol) { - var CommandTypes; - (function (CommandTypes) { - CommandTypes["Brace"] = "brace"; - CommandTypes["BraceFull"] = "brace-full"; - CommandTypes["BraceCompletion"] = "braceCompletion"; - CommandTypes["Change"] = "change"; - CommandTypes["Close"] = "close"; - CommandTypes["Completions"] = "completions"; - CommandTypes["CompletionsFull"] = "completions-full"; - CommandTypes["CompletionDetails"] = "completionEntryDetails"; - CommandTypes["CompileOnSaveAffectedFileList"] = "compileOnSaveAffectedFileList"; - CommandTypes["CompileOnSaveEmitFile"] = "compileOnSaveEmitFile"; - CommandTypes["Configure"] = "configure"; - CommandTypes["Definition"] = "definition"; - CommandTypes["DefinitionFull"] = "definition-full"; - CommandTypes["Implementation"] = "implementation"; - CommandTypes["ImplementationFull"] = "implementation-full"; - CommandTypes["Exit"] = "exit"; - CommandTypes["Format"] = "format"; - CommandTypes["Formatonkey"] = "formatonkey"; - CommandTypes["FormatFull"] = "format-full"; - CommandTypes["FormatonkeyFull"] = "formatonkey-full"; - CommandTypes["FormatRangeFull"] = "formatRange-full"; - CommandTypes["Geterr"] = "geterr"; - CommandTypes["GeterrForProject"] = "geterrForProject"; - CommandTypes["SemanticDiagnosticsSync"] = "semanticDiagnosticsSync"; - CommandTypes["SyntacticDiagnosticsSync"] = "syntacticDiagnosticsSync"; - CommandTypes["NavBar"] = "navbar"; - CommandTypes["NavBarFull"] = "navbar-full"; - CommandTypes["Navto"] = "navto"; - CommandTypes["NavtoFull"] = "navto-full"; - CommandTypes["NavTree"] = "navtree"; - CommandTypes["NavTreeFull"] = "navtree-full"; - CommandTypes["Occurrences"] = "occurrences"; - CommandTypes["DocumentHighlights"] = "documentHighlights"; - CommandTypes["DocumentHighlightsFull"] = "documentHighlights-full"; - CommandTypes["Open"] = "open"; - CommandTypes["Quickinfo"] = "quickinfo"; - CommandTypes["QuickinfoFull"] = "quickinfo-full"; - CommandTypes["References"] = "references"; - CommandTypes["ReferencesFull"] = "references-full"; - CommandTypes["Reload"] = "reload"; - CommandTypes["Rename"] = "rename"; - CommandTypes["RenameInfoFull"] = "rename-full"; - CommandTypes["RenameLocationsFull"] = "renameLocations-full"; - CommandTypes["Saveto"] = "saveto"; - CommandTypes["SignatureHelp"] = "signatureHelp"; - CommandTypes["SignatureHelpFull"] = "signatureHelp-full"; - CommandTypes["TypeDefinition"] = "typeDefinition"; - CommandTypes["ProjectInfo"] = "projectInfo"; - CommandTypes["ReloadProjects"] = "reloadProjects"; - CommandTypes["Unknown"] = "unknown"; - CommandTypes["OpenExternalProject"] = "openExternalProject"; - CommandTypes["OpenExternalProjects"] = "openExternalProjects"; - CommandTypes["CloseExternalProject"] = "closeExternalProject"; - CommandTypes["SynchronizeProjectList"] = "synchronizeProjectList"; - CommandTypes["ApplyChangedToOpenFiles"] = "applyChangedToOpenFiles"; - CommandTypes["EncodedSemanticClassificationsFull"] = "encodedSemanticClassifications-full"; - CommandTypes["Cleanup"] = "cleanup"; - CommandTypes["OutliningSpans"] = "outliningSpans"; - CommandTypes["TodoComments"] = "todoComments"; - CommandTypes["Indentation"] = "indentation"; - CommandTypes["DocCommentTemplate"] = "docCommentTemplate"; - CommandTypes["CompilerOptionsDiagnosticsFull"] = "compilerOptionsDiagnostics-full"; - CommandTypes["NameOrDottedNameSpan"] = "nameOrDottedNameSpan"; - CommandTypes["BreakpointStatement"] = "breakpointStatement"; - CommandTypes["CompilerOptionsForInferredProjects"] = "compilerOptionsForInferredProjects"; - CommandTypes["GetCodeFixes"] = "getCodeFixes"; - CommandTypes["GetCodeFixesFull"] = "getCodeFixes-full"; - CommandTypes["GetSupportedCodeFixes"] = "getSupportedCodeFixes"; - CommandTypes["GetApplicableRefactors"] = "getApplicableRefactors"; - CommandTypes["GetEditsForRefactor"] = "getEditsForRefactor"; - CommandTypes["GetEditsForRefactorFull"] = "getEditsForRefactor-full"; - })(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {})); - var IndentStyle; - (function (IndentStyle) { - IndentStyle["None"] = "None"; - IndentStyle["Block"] = "Block"; - IndentStyle["Smart"] = "Smart"; - })(IndentStyle = protocol.IndentStyle || (protocol.IndentStyle = {})); - var JsxEmit; - (function (JsxEmit) { - JsxEmit["None"] = "None"; - JsxEmit["Preserve"] = "Preserve"; - JsxEmit["ReactNative"] = "ReactNative"; - JsxEmit["React"] = "React"; - })(JsxEmit = protocol.JsxEmit || (protocol.JsxEmit = {})); - var ModuleKind; - (function (ModuleKind) { - ModuleKind["None"] = "None"; - ModuleKind["CommonJS"] = "CommonJS"; - ModuleKind["AMD"] = "AMD"; - ModuleKind["UMD"] = "UMD"; - ModuleKind["System"] = "System"; - ModuleKind["ES6"] = "ES6"; - ModuleKind["ES2015"] = "ES2015"; - })(ModuleKind = protocol.ModuleKind || (protocol.ModuleKind = {})); - var ModuleResolutionKind; - (function (ModuleResolutionKind) { - ModuleResolutionKind["Classic"] = "Classic"; - ModuleResolutionKind["Node"] = "Node"; - })(ModuleResolutionKind = protocol.ModuleResolutionKind || (protocol.ModuleResolutionKind = {})); - var NewLineKind; - (function (NewLineKind) { - NewLineKind["Crlf"] = "Crlf"; - NewLineKind["Lf"] = "Lf"; - })(NewLineKind = protocol.NewLineKind || (protocol.NewLineKind = {})); - var ScriptTarget; - (function (ScriptTarget) { - ScriptTarget["ES3"] = "ES3"; - ScriptTarget["ES5"] = "ES5"; - ScriptTarget["ES6"] = "ES6"; - ScriptTarget["ES2015"] = "ES2015"; - })(ScriptTarget = protocol.ScriptTarget || (protocol.ScriptTarget = {})); - })(protocol = server.protocol || (server.protocol = {})); - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var server; (function (server) { @@ -79151,7 +79046,82 @@ var ts; } return true; } - server.CommandNames = server.protocol.CommandTypes; + var CommandNames; + (function (CommandNames) { + CommandNames.Brace = "brace"; + CommandNames.BraceFull = "brace-full"; + CommandNames.BraceCompletion = "braceCompletion"; + CommandNames.Change = "change"; + CommandNames.Close = "close"; + CommandNames.Completions = "completions"; + CommandNames.CompletionsFull = "completions-full"; + CommandNames.CompletionDetails = "completionEntryDetails"; + CommandNames.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + CommandNames.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + CommandNames.Configure = "configure"; + CommandNames.Definition = "definition"; + CommandNames.DefinitionFull = "definition-full"; + CommandNames.Exit = "exit"; + CommandNames.Format = "format"; + CommandNames.Formatonkey = "formatonkey"; + CommandNames.FormatFull = "format-full"; + CommandNames.FormatonkeyFull = "formatonkey-full"; + CommandNames.FormatRangeFull = "formatRange-full"; + CommandNames.Geterr = "geterr"; + CommandNames.GeterrForProject = "geterrForProject"; + CommandNames.Implementation = "implementation"; + CommandNames.ImplementationFull = "implementation-full"; + CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + CommandNames.NavBar = "navbar"; + CommandNames.NavBarFull = "navbar-full"; + CommandNames.NavTree = "navtree"; + CommandNames.NavTreeFull = "navtree-full"; + CommandNames.Navto = "navto"; + CommandNames.NavtoFull = "navto-full"; + CommandNames.Occurrences = "occurrences"; + CommandNames.DocumentHighlights = "documentHighlights"; + CommandNames.DocumentHighlightsFull = "documentHighlights-full"; + CommandNames.Open = "open"; + CommandNames.Quickinfo = "quickinfo"; + CommandNames.QuickinfoFull = "quickinfo-full"; + CommandNames.References = "references"; + CommandNames.ReferencesFull = "references-full"; + CommandNames.Reload = "reload"; + CommandNames.Rename = "rename"; + CommandNames.RenameInfoFull = "rename-full"; + CommandNames.RenameLocationsFull = "renameLocations-full"; + CommandNames.Saveto = "saveto"; + CommandNames.SignatureHelp = "signatureHelp"; + CommandNames.SignatureHelpFull = "signatureHelp-full"; + CommandNames.TypeDefinition = "typeDefinition"; + CommandNames.ProjectInfo = "projectInfo"; + CommandNames.ReloadProjects = "reloadProjects"; + CommandNames.Unknown = "unknown"; + CommandNames.OpenExternalProject = "openExternalProject"; + CommandNames.OpenExternalProjects = "openExternalProjects"; + CommandNames.CloseExternalProject = "closeExternalProject"; + CommandNames.SynchronizeProjectList = "synchronizeProjectList"; + CommandNames.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + CommandNames.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + CommandNames.Cleanup = "cleanup"; + CommandNames.OutliningSpans = "outliningSpans"; + CommandNames.TodoComments = "todoComments"; + CommandNames.Indentation = "indentation"; + CommandNames.DocCommentTemplate = "docCommentTemplate"; + CommandNames.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + CommandNames.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + CommandNames.BreakpointStatement = "breakpointStatement"; + CommandNames.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + CommandNames.GetCodeFixes = "getCodeFixes"; + CommandNames.GetCodeFixesFull = "getCodeFixes-full"; + CommandNames.GetSupportedCodeFixes = "getSupportedCodeFixes"; + CommandNames.GetApplicableRefactors = "getApplicableRefactors"; + CommandNames.GetRefactorCodeActions = "getRefactorCodeActions"; + CommandNames.GetRefactorCodeActionsFull = "getRefactorCodeActions-full"; + CommandNames.GetEditsForRefactor = "getEditsForRefactor"; + CommandNames.GetEditsForRefactorFull = "getEditsForRefactor-full"; + })(CommandNames = server.CommandNames || (server.CommandNames = {})); function formatMessage(msg, logger, byteLength, newLine) { var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); @@ -79248,19 +79218,19 @@ var ts; var _this = this; this.changeSeq = 0; this.handlers = ts.createMapFromTemplate((_a = {}, - _a[server.CommandNames.OpenExternalProject] = function (request) { + _a[CommandNames.OpenExternalProject] = function (request) { _this.projectService.openExternalProject(request.arguments, false); return _this.requiredResponse(true); }, - _a[server.CommandNames.OpenExternalProjects] = function (request) { + _a[CommandNames.OpenExternalProjects] = function (request) { _this.projectService.openExternalProjects(request.arguments.projects); return _this.requiredResponse(true); }, - _a[server.CommandNames.CloseExternalProject] = function (request) { + _a[CommandNames.CloseExternalProject] = function (request) { _this.projectService.closeExternalProject(request.arguments.projectFileName); return _this.requiredResponse(true); }, - _a[server.CommandNames.SynchronizeProjectList] = function (request) { + _a[CommandNames.SynchronizeProjectList] = function (request) { var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); if (!result.some(function (p) { return p.projectErrors && p.projectErrors.length !== 0; })) { return _this.requiredResponse(result); @@ -79278,219 +79248,219 @@ var ts; }); return _this.requiredResponse(converted); }, - _a[server.CommandNames.ApplyChangedToOpenFiles] = function (request) { + _a[CommandNames.ApplyChangedToOpenFiles] = function (request) { _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); _this.changeSeq++; return _this.requiredResponse(true); }, - _a[server.CommandNames.Exit] = function () { + _a[CommandNames.Exit] = function () { _this.exit(); return _this.notRequired(); }, - _a[server.CommandNames.Definition] = function (request) { + _a[CommandNames.Definition] = function (request) { return _this.requiredResponse(_this.getDefinition(request.arguments, true)); }, - _a[server.CommandNames.DefinitionFull] = function (request) { + _a[CommandNames.DefinitionFull] = function (request) { return _this.requiredResponse(_this.getDefinition(request.arguments, false)); }, - _a[server.CommandNames.TypeDefinition] = function (request) { + _a[CommandNames.TypeDefinition] = function (request) { return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); }, - _a[server.CommandNames.Implementation] = function (request) { + _a[CommandNames.Implementation] = function (request) { return _this.requiredResponse(_this.getImplementation(request.arguments, true)); }, - _a[server.CommandNames.ImplementationFull] = function (request) { + _a[CommandNames.ImplementationFull] = function (request) { return _this.requiredResponse(_this.getImplementation(request.arguments, false)); }, - _a[server.CommandNames.References] = function (request) { + _a[CommandNames.References] = function (request) { return _this.requiredResponse(_this.getReferences(request.arguments, true)); }, - _a[server.CommandNames.ReferencesFull] = function (request) { + _a[CommandNames.ReferencesFull] = function (request) { return _this.requiredResponse(_this.getReferences(request.arguments, false)); }, - _a[server.CommandNames.Rename] = function (request) { + _a[CommandNames.Rename] = function (request) { return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); }, - _a[server.CommandNames.RenameLocationsFull] = function (request) { + _a[CommandNames.RenameLocationsFull] = function (request) { return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); }, - _a[server.CommandNames.RenameInfoFull] = function (request) { + _a[CommandNames.RenameInfoFull] = function (request) { return _this.requiredResponse(_this.getRenameInfo(request.arguments)); }, - _a[server.CommandNames.Open] = function (request) { + _a[CommandNames.Open] = function (request) { _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName), request.arguments.projectRootPath ? server.toNormalizedPath(request.arguments.projectRootPath) : undefined); return _this.notRequired(); }, - _a[server.CommandNames.Quickinfo] = function (request) { + _a[CommandNames.Quickinfo] = function (request) { return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); }, - _a[server.CommandNames.QuickinfoFull] = function (request) { + _a[CommandNames.QuickinfoFull] = function (request) { return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); }, - _a[server.CommandNames.OutliningSpans] = function (request) { + _a[CommandNames.OutliningSpans] = function (request) { return _this.requiredResponse(_this.getOutliningSpans(request.arguments)); }, - _a[server.CommandNames.TodoComments] = function (request) { + _a[CommandNames.TodoComments] = function (request) { return _this.requiredResponse(_this.getTodoComments(request.arguments)); }, - _a[server.CommandNames.Indentation] = function (request) { + _a[CommandNames.Indentation] = function (request) { return _this.requiredResponse(_this.getIndentation(request.arguments)); }, - _a[server.CommandNames.NameOrDottedNameSpan] = function (request) { + _a[CommandNames.NameOrDottedNameSpan] = function (request) { return _this.requiredResponse(_this.getNameOrDottedNameSpan(request.arguments)); }, - _a[server.CommandNames.BreakpointStatement] = function (request) { + _a[CommandNames.BreakpointStatement] = function (request) { return _this.requiredResponse(_this.getBreakpointStatement(request.arguments)); }, - _a[server.CommandNames.BraceCompletion] = function (request) { + _a[CommandNames.BraceCompletion] = function (request) { return _this.requiredResponse(_this.isValidBraceCompletion(request.arguments)); }, - _a[server.CommandNames.DocCommentTemplate] = function (request) { + _a[CommandNames.DocCommentTemplate] = function (request) { return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); }, - _a[server.CommandNames.Format] = function (request) { + _a[CommandNames.Format] = function (request) { return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); }, - _a[server.CommandNames.Formatonkey] = function (request) { + _a[CommandNames.Formatonkey] = function (request) { return _this.requiredResponse(_this.getFormattingEditsAfterKeystroke(request.arguments)); }, - _a[server.CommandNames.FormatFull] = function (request) { + _a[CommandNames.FormatFull] = function (request) { return _this.requiredResponse(_this.getFormattingEditsForDocumentFull(request.arguments)); }, - _a[server.CommandNames.FormatonkeyFull] = function (request) { + _a[CommandNames.FormatonkeyFull] = function (request) { return _this.requiredResponse(_this.getFormattingEditsAfterKeystrokeFull(request.arguments)); }, - _a[server.CommandNames.FormatRangeFull] = function (request) { + _a[CommandNames.FormatRangeFull] = function (request) { return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); }, - _a[server.CommandNames.Completions] = function (request) { + _a[CommandNames.Completions] = function (request) { return _this.requiredResponse(_this.getCompletions(request.arguments, true)); }, - _a[server.CommandNames.CompletionsFull] = function (request) { + _a[CommandNames.CompletionsFull] = function (request) { return _this.requiredResponse(_this.getCompletions(request.arguments, false)); }, - _a[server.CommandNames.CompletionDetails] = function (request) { + _a[CommandNames.CompletionDetails] = function (request) { return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments)); }, - _a[server.CommandNames.CompileOnSaveAffectedFileList] = function (request) { + _a[CommandNames.CompileOnSaveAffectedFileList] = function (request) { return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); }, - _a[server.CommandNames.CompileOnSaveEmitFile] = function (request) { + _a[CommandNames.CompileOnSaveEmitFile] = function (request) { return _this.requiredResponse(_this.emitFile(request.arguments)); }, - _a[server.CommandNames.SignatureHelp] = function (request) { + _a[CommandNames.SignatureHelp] = function (request) { return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); }, - _a[server.CommandNames.SignatureHelpFull] = function (request) { + _a[CommandNames.SignatureHelpFull] = function (request) { return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); }, - _a[server.CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { + _a[CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); }, - _a[server.CommandNames.EncodedSemanticClassificationsFull] = function (request) { + _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); }, - _a[server.CommandNames.Cleanup] = function () { + _a[CommandNames.Cleanup] = function () { _this.cleanup(); return _this.requiredResponse(true); }, - _a[server.CommandNames.SemanticDiagnosticsSync] = function (request) { + _a[CommandNames.SemanticDiagnosticsSync] = function (request) { return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); }, - _a[server.CommandNames.SyntacticDiagnosticsSync] = function (request) { + _a[CommandNames.SyntacticDiagnosticsSync] = function (request) { return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); }, - _a[server.CommandNames.Geterr] = function (request) { + _a[CommandNames.Geterr] = function (request) { _this.errorCheck.startNew(function (next) { return _this.getDiagnostics(next, request.arguments.delay, request.arguments.files); }); return _this.notRequired(); }, - _a[server.CommandNames.GeterrForProject] = function (request) { + _a[CommandNames.GeterrForProject] = function (request) { _this.errorCheck.startNew(function (next) { return _this.getDiagnosticsForProject(next, request.arguments.delay, request.arguments.file); }); return _this.notRequired(); }, - _a[server.CommandNames.Change] = function (request) { + _a[CommandNames.Change] = function (request) { _this.change(request.arguments); return _this.notRequired(); }, - _a[server.CommandNames.Configure] = function (request) { + _a[CommandNames.Configure] = function (request) { _this.projectService.setHostConfiguration(request.arguments); - _this.output(undefined, server.CommandNames.Configure, request.seq); + _this.output(undefined, CommandNames.Configure, request.seq); return _this.notRequired(); }, - _a[server.CommandNames.Reload] = function (request) { + _a[CommandNames.Reload] = function (request) { _this.reload(request.arguments, request.seq); return _this.requiredResponse({ reloadFinished: true }); }, - _a[server.CommandNames.Saveto] = function (request) { + _a[CommandNames.Saveto] = function (request) { var savetoArgs = request.arguments; _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); return _this.notRequired(); }, - _a[server.CommandNames.Close] = function (request) { + _a[CommandNames.Close] = function (request) { var closeArgs = request.arguments; _this.closeClientFile(closeArgs.file); return _this.notRequired(); }, - _a[server.CommandNames.Navto] = function (request) { + _a[CommandNames.Navto] = function (request) { return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); }, - _a[server.CommandNames.NavtoFull] = function (request) { + _a[CommandNames.NavtoFull] = function (request) { return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); }, - _a[server.CommandNames.Brace] = function (request) { + _a[CommandNames.Brace] = function (request) { return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); }, - _a[server.CommandNames.BraceFull] = function (request) { + _a[CommandNames.BraceFull] = function (request) { return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); }, - _a[server.CommandNames.NavBar] = function (request) { + _a[CommandNames.NavBar] = function (request) { return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); }, - _a[server.CommandNames.NavBarFull] = function (request) { + _a[CommandNames.NavBarFull] = function (request) { return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); }, - _a[server.CommandNames.NavTree] = function (request) { + _a[CommandNames.NavTree] = function (request) { return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); }, - _a[server.CommandNames.NavTreeFull] = function (request) { + _a[CommandNames.NavTreeFull] = function (request) { return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); }, - _a[server.CommandNames.Occurrences] = function (request) { + _a[CommandNames.Occurrences] = function (request) { return _this.requiredResponse(_this.getOccurrences(request.arguments)); }, - _a[server.CommandNames.DocumentHighlights] = function (request) { + _a[CommandNames.DocumentHighlights] = function (request) { return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); }, - _a[server.CommandNames.DocumentHighlightsFull] = function (request) { + _a[CommandNames.DocumentHighlightsFull] = function (request) { return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); }, - _a[server.CommandNames.CompilerOptionsForInferredProjects] = function (request) { + _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { _this.setCompilerOptionsForInferredProjects(request.arguments); return _this.requiredResponse(true); }, - _a[server.CommandNames.ProjectInfo] = function (request) { + _a[CommandNames.ProjectInfo] = function (request) { return _this.requiredResponse(_this.getProjectInfo(request.arguments)); }, - _a[server.CommandNames.ReloadProjects] = function () { + _a[CommandNames.ReloadProjects] = function () { _this.projectService.reloadProjects(); return _this.notRequired(); }, - _a[server.CommandNames.GetCodeFixes] = function (request) { + _a[CommandNames.GetCodeFixes] = function (request) { return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); }, - _a[server.CommandNames.GetCodeFixesFull] = function (request) { + _a[CommandNames.GetCodeFixesFull] = function (request) { return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); }, - _a[server.CommandNames.GetSupportedCodeFixes] = function () { + _a[CommandNames.GetSupportedCodeFixes] = function () { return _this.requiredResponse(_this.getSupportedCodeFixes()); }, - _a[server.CommandNames.GetApplicableRefactors] = function (request) { + _a[CommandNames.GetApplicableRefactors] = function (request) { return _this.requiredResponse(_this.getApplicableRefactors(request.arguments)); }, - _a[server.CommandNames.GetEditsForRefactor] = function (request) { + _a[CommandNames.GetEditsForRefactor] = function (request) { return _this.requiredResponse(_this.getEditsForRefactor(request.arguments, true)); }, - _a[server.CommandNames.GetEditsForRefactorFull] = function (request) { + _a[CommandNames.GetEditsForRefactorFull] = function (request) { return _this.requiredResponse(_this.getEditsForRefactor(request.arguments, false)); }, _a)); @@ -80338,7 +80308,7 @@ var ts; if (project) { this.changeSeq++; if (project.reloadScript(file, tempFileName)) { - this.output(undefined, server.CommandNames.Reload, reqSeq); + this.output(undefined, CommandNames.Reload, reqSeq); } } }; @@ -80679,7 +80649,7 @@ var ts; } else { this.logger.msg("Unrecognized JSON command: " + JSON.stringify(request), server.Msg.Err); - this.output(undefined, server.CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); + this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); return { responseRequired: false }; } }; @@ -80718,7 +80688,7 @@ var ts; return; } this.logError(err, message); - this.output(undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message + "\n" + err.stack); + this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message + "\n" + err.stack); } }; return Session; diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 781a1fd31d1c1..2537e5f3577e6 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -2201,11 +2201,12 @@ declare namespace ts { extension: Extension; } enum Extension { - Ts = ".ts", - Tsx = ".tsx", - Dts = ".d.ts", - Js = ".js", - Jsx = ".jsx", + Ts = 0, + Tsx = 1, + Dts = 2, + Js = 3, + Jsx = 4, + LastTypeScriptExtension = 2, } interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; @@ -3215,11 +3216,11 @@ declare namespace ts { } interface ClassifiedSpan { textSpan: TextSpan; - classificationType: ClassificationTypeNames; + classificationType: string; } interface NavigationBarItem { text: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; spans: TextSpan[]; childItems: NavigationBarItem[]; @@ -3229,7 +3230,7 @@ declare namespace ts { } interface NavigationTree { text: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; spans: TextSpan[]; childItems?: NavigationTree[]; @@ -3286,35 +3287,35 @@ declare namespace ts { isInString?: true; } interface ImplementationLocation extends DocumentSpan { - kind: ScriptElementKind; + kind: string; displayParts: SymbolDisplayPart[]; } interface DocumentHighlights { fileName: string; highlightSpans: HighlightSpan[]; } - enum HighlightSpanKind { - none = "none", - definition = "definition", - reference = "reference", - writtenReference = "writtenReference", + namespace HighlightSpanKind { + const none = "none"; + const definition = "definition"; + const reference = "reference"; + const writtenReference = "writtenReference"; } interface HighlightSpan { fileName?: string; isInString?: true; textSpan: TextSpan; - kind: HighlightSpanKind; + kind: string; } interface NavigateToItem { name: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; matchKind: string; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; containerName: string; - containerKind: ScriptElementKind; + containerKind: string; } enum IndentStyle { None = 0, @@ -3374,9 +3375,9 @@ declare namespace ts { interface DefinitionInfo { fileName: string; textSpan: TextSpan; - kind: ScriptElementKind; + kind: string; name: string; - containerKind: ScriptElementKind; + containerKind: string; containerName: string; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -3419,7 +3420,7 @@ declare namespace ts { text?: string; } interface QuickInfo { - kind: ScriptElementKind; + kind: string; kindModifiers: string; textSpan: TextSpan; displayParts: SymbolDisplayPart[]; @@ -3431,7 +3432,7 @@ declare namespace ts { localizedErrorMessage: string; displayName: string; fullDisplayName: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; triggerSpan: TextSpan; } @@ -3465,14 +3466,14 @@ declare namespace ts { } interface CompletionEntry { name: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; sortText: string; replacementSpan?: TextSpan; } interface CompletionEntryDetails { name: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; @@ -3530,75 +3531,75 @@ declare namespace ts { getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; } - enum ScriptElementKind { - unknown = "", - warning = "warning", - keyword = "keyword", - scriptElement = "script", - moduleElement = "module", - classElement = "class", - localClassElement = "local class", - interfaceElement = "interface", - typeElement = "type", - enumElement = "enum", - enumMemberElement = "enum member", - variableElement = "var", - localVariableElement = "local var", - functionElement = "function", - localFunctionElement = "local function", - memberFunctionElement = "method", - memberGetAccessorElement = "getter", - memberSetAccessorElement = "setter", - memberVariableElement = "property", - constructorImplementationElement = "constructor", - callSignatureElement = "call", - indexSignatureElement = "index", - constructSignatureElement = "construct", - parameterElement = "parameter", - typeParameterElement = "type parameter", - primitiveType = "primitive type", - label = "label", - alias = "alias", - constElement = "const", - letElement = "let", - directory = "directory", - externalModuleName = "external module name", - jsxAttribute = "JSX attribute", - } - enum ScriptElementKindModifier { - none = "", - publicMemberModifier = "public", - privateMemberModifier = "private", - protectedMemberModifier = "protected", - exportedModifier = "export", - ambientModifier = "declare", - staticModifier = "static", - abstractModifier = "abstract", - } - enum ClassificationTypeNames { - comment = "comment", - identifier = "identifier", - keyword = "keyword", - numericLiteral = "number", - operator = "operator", - stringLiteral = "string", - whiteSpace = "whitespace", - text = "text", - punctuation = "punctuation", - className = "class name", - enumName = "enum name", - interfaceName = "interface name", - moduleName = "module name", - typeParameterName = "type parameter name", - typeAliasName = "type alias name", - parameterName = "parameter name", - docCommentTagName = "doc comment tag name", - jsxOpenTagName = "jsx open tag name", - jsxCloseTagName = "jsx close tag name", - jsxSelfClosingTagName = "jsx self closing tag name", - jsxAttribute = "jsx attribute", - jsxText = "jsx text", - jsxAttributeStringLiteralValue = "jsx attribute string literal value", + namespace ScriptElementKind { + const unknown = ""; + const warning = "warning"; + const keyword = "keyword"; + const scriptElement = "script"; + const moduleElement = "module"; + const classElement = "class"; + const localClassElement = "local class"; + const interfaceElement = "interface"; + const typeElement = "type"; + const enumElement = "enum"; + const enumMemberElement = "enum member"; + const variableElement = "var"; + const localVariableElement = "local var"; + const functionElement = "function"; + const localFunctionElement = "local function"; + const memberFunctionElement = "method"; + const memberGetAccessorElement = "getter"; + const memberSetAccessorElement = "setter"; + const memberVariableElement = "property"; + const constructorImplementationElement = "constructor"; + const callSignatureElement = "call"; + const indexSignatureElement = "index"; + const constructSignatureElement = "construct"; + const parameterElement = "parameter"; + const typeParameterElement = "type parameter"; + const primitiveType = "primitive type"; + const label = "label"; + const alias = "alias"; + const constElement = "const"; + const letElement = "let"; + const directory = "directory"; + const externalModuleName = "external module name"; + const jsxAttribute = "JSX attribute"; + } + namespace ScriptElementKindModifier { + const none = ""; + const publicMemberModifier = "public"; + const privateMemberModifier = "private"; + const protectedMemberModifier = "protected"; + const exportedModifier = "export"; + const ambientModifier = "declare"; + const staticModifier = "static"; + const abstractModifier = "abstract"; + } + class ClassificationTypeNames { + static comment: string; + static identifier: string; + static keyword: string; + static numericLiteral: string; + static operator: string; + static stringLiteral: string; + static whiteSpace: string; + static text: string; + static punctuation: string; + static className: string; + static enumName: string; + static interfaceName: string; + static moduleName: string; + static typeParameterName: string; + static typeAliasName: string; + static parameterName: string; + static docCommentTagName: string; + static jsxOpenTagName: string; + static jsxCloseTagName: string; + static jsxSelfClosingTagName: string; + static jsxAttribute: string; + static jsxText: string; + static jsxAttributeStringLiteralValue: string; } enum ClassificationType { comment = 1, @@ -3860,53 +3861,54 @@ declare namespace ts.server { } } declare namespace ts.server.protocol { - enum CommandTypes { - Brace = "brace", - BraceCompletion = "braceCompletion", - Change = "change", - Close = "close", - Completions = "completions", - CompletionDetails = "completionEntryDetails", - CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList", - CompileOnSaveEmitFile = "compileOnSaveEmitFile", - Configure = "configure", - Definition = "definition", - Implementation = "implementation", - Exit = "exit", - Format = "format", - Formatonkey = "formatonkey", - Geterr = "geterr", - GeterrForProject = "geterrForProject", - SemanticDiagnosticsSync = "semanticDiagnosticsSync", - SyntacticDiagnosticsSync = "syntacticDiagnosticsSync", - NavBar = "navbar", - Navto = "navto", - NavTree = "navtree", - NavTreeFull = "navtree-full", - Occurrences = "occurrences", - DocumentHighlights = "documentHighlights", - Open = "open", - Quickinfo = "quickinfo", - References = "references", - Reload = "reload", - Rename = "rename", - Saveto = "saveto", - SignatureHelp = "signatureHelp", - TypeDefinition = "typeDefinition", - ProjectInfo = "projectInfo", - ReloadProjects = "reloadProjects", - Unknown = "unknown", - OpenExternalProject = "openExternalProject", - OpenExternalProjects = "openExternalProjects", - CloseExternalProject = "closeExternalProject", - TodoComments = "todoComments", - Indentation = "indentation", - DocCommentTemplate = "docCommentTemplate", - CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects", - GetCodeFixes = "getCodeFixes", - GetSupportedCodeFixes = "getSupportedCodeFixes", - GetApplicableRefactors = "getApplicableRefactors", - GetEditsForRefactor = "getEditsForRefactor", + namespace CommandTypes { + type Brace = "brace"; + type BraceCompletion = "braceCompletion"; + type Change = "change"; + type Close = "close"; + type Completions = "completions"; + type CompletionDetails = "completionEntryDetails"; + type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + type CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + type Configure = "configure"; + type Definition = "definition"; + type Implementation = "implementation"; + type Exit = "exit"; + type Format = "format"; + type Formatonkey = "formatonkey"; + type Geterr = "geterr"; + type GeterrForProject = "geterrForProject"; + type SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + type NavBar = "navbar"; + type Navto = "navto"; + type NavTree = "navtree"; + type NavTreeFull = "navtree-full"; + type Occurrences = "occurrences"; + type DocumentHighlights = "documentHighlights"; + type Open = "open"; + type Quickinfo = "quickinfo"; + type References = "references"; + type Reload = "reload"; + type Rename = "rename"; + type Saveto = "saveto"; + type SignatureHelp = "signatureHelp"; + type TypeDefinition = "typeDefinition"; + type ProjectInfo = "projectInfo"; + type ReloadProjects = "reloadProjects"; + type Unknown = "unknown"; + type OpenExternalProject = "openExternalProject"; + type OpenExternalProjects = "openExternalProjects"; + type CloseExternalProject = "closeExternalProject"; + type TodoComments = "todoComments"; + type Indentation = "indentation"; + type DocCommentTemplate = "docCommentTemplate"; + type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + type GetCodeFixes = "getCodeFixes"; + type GetSupportedCodeFixes = "getSupportedCodeFixes"; + type GetApplicableRefactors = "getApplicableRefactors"; + type GetRefactorCodeActions = "getRefactorCodeActions"; + type GetEditsForRefactor = "getEditsForRefactor"; } interface Message { seq: number; @@ -4119,7 +4121,7 @@ declare namespace ts.server.protocol { arguments: DocumentHighlightsRequestArgs; } interface HighlightSpan extends TextSpan { - kind: HighlightSpanKind; + kind: string; } interface DocumentHighlightsItem { file: string; @@ -4158,7 +4160,7 @@ declare namespace ts.server.protocol { localizedErrorMessage?: string; displayName: string; fullDisplayName: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; } interface SpanGroup { @@ -4278,7 +4280,7 @@ declare namespace ts.server.protocol { command: CommandTypes.Quickinfo; } interface QuickInfoResponseBody { - kind: ScriptElementKind; + kind: string; kindModifiers: string; start: Location; end: Location; @@ -4345,14 +4347,14 @@ declare namespace ts.server.protocol { } interface CompletionEntry { name: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; sortText: string; replacementSpan?: TextSpan; } interface CompletionEntryDetails { name: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; @@ -4500,7 +4502,7 @@ declare namespace ts.server.protocol { } interface NavtoItem { name: string; - kind: ScriptElementKind; + kind: string; matchKind?: string; isCaseSensitive?: boolean; kindModifiers?: string; @@ -4508,7 +4510,7 @@ declare namespace ts.server.protocol { start: Location; end: Location; containerName?: string; - containerKind?: ScriptElementKind; + containerKind?: string; } interface NavtoResponse extends Response { body?: NavtoItem[]; @@ -4534,7 +4536,7 @@ declare namespace ts.server.protocol { } interface NavigationBarItem { text: string; - kind: ScriptElementKind; + kind: string; kindModifiers?: string; spans: TextSpan[]; childItems?: NavigationBarItem[]; @@ -4542,7 +4544,7 @@ declare namespace ts.server.protocol { } interface NavigationTree { text: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; spans: TextSpan[]; childItems?: NavigationTree[]; @@ -4599,11 +4601,12 @@ declare namespace ts.server.protocol { interface NavTreeResponse extends Response { body?: NavigationTree; } - enum IndentStyle { - None = "None", - Block = "Block", - Smart = "Smart", + namespace IndentStyle { + type None = "None"; + type Block = "Block"; + type Smart = "Smart"; } + type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart; interface EditorSettings { baseIndentSize?: number; indentSize?: number; @@ -4696,35 +4699,40 @@ declare namespace ts.server.protocol { typeRoots?: string[]; [option: string]: CompilerOptionsValue | undefined; } - enum JsxEmit { - None = "None", - Preserve = "Preserve", - ReactNative = "ReactNative", - React = "React", - } - enum ModuleKind { - None = "None", - CommonJS = "CommonJS", - AMD = "AMD", - UMD = "UMD", - System = "System", - ES6 = "ES6", - ES2015 = "ES2015", - } - enum ModuleResolutionKind { - Classic = "Classic", - Node = "Node", - } - enum NewLineKind { - Crlf = "Crlf", - Lf = "Lf", - } - enum ScriptTarget { - ES3 = "ES3", - ES5 = "ES5", - ES6 = "ES6", - ES2015 = "ES2015", - } + namespace JsxEmit { + type None = "None"; + type Preserve = "Preserve"; + type ReactNative = "ReactNative"; + type React = "React"; + } + type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative; + namespace ModuleKind { + type None = "None"; + type CommonJS = "CommonJS"; + type AMD = "AMD"; + type UMD = "UMD"; + type System = "System"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015; + namespace ModuleResolutionKind { + type Classic = "Classic"; + type Node = "Node"; + } + type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node; + namespace NewLineKind { + type Crlf = "Crlf"; + type Lf = "Lf"; + } + type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf; + namespace ScriptTarget { + type ES3 = "ES3"; + type ES5 = "ES5"; + type ES6 = "ES6"; + type ES2015 = "ES2015"; + } + type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015; } declare namespace ts.server { interface ServerCancellationToken extends HostCancellationToken { @@ -4739,8 +4747,55 @@ declare namespace ts.server { interface EventSender { event(payload: T, eventName: string): void; } - type CommandNames = protocol.CommandTypes; - const CommandNames: any; + namespace CommandNames { + const Brace: protocol.CommandTypes.Brace; + const BraceCompletion: protocol.CommandTypes.BraceCompletion; + const Change: protocol.CommandTypes.Change; + const Close: protocol.CommandTypes.Close; + const Completions: protocol.CommandTypes.Completions; + const CompletionDetails: protocol.CommandTypes.CompletionDetails; + const CompileOnSaveAffectedFileList: protocol.CommandTypes.CompileOnSaveAffectedFileList; + const CompileOnSaveEmitFile: protocol.CommandTypes.CompileOnSaveEmitFile; + const Configure: protocol.CommandTypes.Configure; + const Definition: protocol.CommandTypes.Definition; + const Exit: protocol.CommandTypes.Exit; + const Format: protocol.CommandTypes.Format; + const Formatonkey: protocol.CommandTypes.Formatonkey; + const Geterr: protocol.CommandTypes.Geterr; + const GeterrForProject: protocol.CommandTypes.GeterrForProject; + const Implementation: protocol.CommandTypes.Implementation; + const SemanticDiagnosticsSync: protocol.CommandTypes.SemanticDiagnosticsSync; + const SyntacticDiagnosticsSync: protocol.CommandTypes.SyntacticDiagnosticsSync; + const NavBar: protocol.CommandTypes.NavBar; + const NavTree: protocol.CommandTypes.NavTree; + const NavTreeFull: protocol.CommandTypes.NavTreeFull; + const Navto: protocol.CommandTypes.Navto; + const Occurrences: protocol.CommandTypes.Occurrences; + const DocumentHighlights: protocol.CommandTypes.DocumentHighlights; + const Open: protocol.CommandTypes.Open; + const Quickinfo: protocol.CommandTypes.Quickinfo; + const References: protocol.CommandTypes.References; + const Reload: protocol.CommandTypes.Reload; + const Rename: protocol.CommandTypes.Rename; + const Saveto: protocol.CommandTypes.Saveto; + const SignatureHelp: protocol.CommandTypes.SignatureHelp; + const TypeDefinition: protocol.CommandTypes.TypeDefinition; + const ProjectInfo: protocol.CommandTypes.ProjectInfo; + const ReloadProjects: protocol.CommandTypes.ReloadProjects; + const Unknown: protocol.CommandTypes.Unknown; + const OpenExternalProject: protocol.CommandTypes.OpenExternalProject; + const OpenExternalProjects: protocol.CommandTypes.OpenExternalProjects; + const CloseExternalProject: protocol.CommandTypes.CloseExternalProject; + const TodoComments: protocol.CommandTypes.TodoComments; + const Indentation: protocol.CommandTypes.Indentation; + const DocCommentTemplate: protocol.CommandTypes.DocCommentTemplate; + const CompilerOptionsForInferredProjects: protocol.CommandTypes.CompilerOptionsForInferredProjects; + const GetCodeFixes: protocol.CommandTypes.GetCodeFixes; + const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes; + const GetApplicableRefactors: protocol.CommandTypes.GetApplicableRefactors; + const GetRefactorCodeActions: protocol.CommandTypes.GetRefactorCodeActions; + const GetEditsForRefactor: protocol.CommandTypes.GetEditsForRefactor; + } function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; interface SessionOptions { host: ServerHost; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 397e78f97089a..12658b28268d4 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -954,11 +954,12 @@ var ts; })(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {})); var Extension; (function (Extension) { - Extension["Ts"] = ".ts"; - Extension["Tsx"] = ".tsx"; - Extension["Dts"] = ".d.ts"; - Extension["Js"] = ".js"; - Extension["Jsx"] = ".jsx"; + Extension[Extension["Ts"] = 0] = "Ts"; + Extension[Extension["Tsx"] = 1] = "Tsx"; + Extension[Extension["Dts"] = 2] = "Dts"; + Extension[Extension["Js"] = 3] = "Js"; + Extension[Extension["Jsx"] = 4] = "Jsx"; + Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; })(Extension = ts.Extension || (ts.Extension = {})); var TransformFlags; (function (TransformFlags) { @@ -3151,7 +3152,7 @@ var ts; } ts.positionIsSynthesized = positionIsSynthesized; function extensionIsTypeScript(ext) { - return ext === ".ts" || ext === ".tsx" || ext === ".d.ts"; + return ext <= ts.Extension.LastTypeScriptExtension; } ts.extensionIsTypeScript = extensionIsTypeScript; function extensionFromPath(path) { @@ -3163,7 +3164,21 @@ var ts; } ts.extensionFromPath = extensionFromPath; function tryGetExtensionFromPath(path) { - return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); }); + if (fileExtensionIs(path, ".d.ts")) { + return ts.Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return ts.Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return ts.Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return ts.Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return ts.Extension.Jsx; + } } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; function isCheckJsEnabledForFile(sourceFile, compilerOptions) { @@ -8004,14 +8019,14 @@ var ts; } switch (extensions) { case Extensions.DtsOnly: - return tryExtension(".d.ts"); + return tryExtension(".d.ts", ts.Extension.Dts); case Extensions.TypeScript: - return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts"); + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); case Extensions.JavaScript: - return tryExtension(".js") || tryExtension(".jsx"); + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } - function tryExtension(extension) { - var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); return path && { path: path, extension: extension }; } } @@ -8081,11 +8096,11 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" || extension === ".jsx"; + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; case Extensions.TypeScript: - return extension === ".ts" || extension === ".tsx" || extension === ".d.ts"; + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; case Extensions.DtsOnly: - return extension === ".d.ts"; + return extension === ts.Extension.Dts; } } function pathToPackageJson(directory) { @@ -59320,14 +59335,14 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts": - case ".d.ts": + case ts.Extension.Ts: + case ts.Extension.Dts: return undefined; - case ".tsx": + case ts.Extension.Tsx: return needJsx(); - case ".jsx": + case ts.Extension.Jsx: return needJsx() || needAllowJs(); - case ".js": + case ts.Extension.Js: return needAllowJs(); } function needJsx() { @@ -59373,10 +59388,10 @@ var ts; ts.TextChange = TextChange; var HighlightSpanKind; (function (HighlightSpanKind) { - HighlightSpanKind["none"] = "none"; - HighlightSpanKind["definition"] = "definition"; - HighlightSpanKind["reference"] = "reference"; - HighlightSpanKind["writtenReference"] = "writtenReference"; + HighlightSpanKind.none = "none"; + HighlightSpanKind.definition = "definition"; + HighlightSpanKind.reference = "reference"; + HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); var IndentStyle; (function (IndentStyle) { @@ -59439,77 +59454,80 @@ var ts; })(TokenClass = ts.TokenClass || (ts.TokenClass = {})); var ScriptElementKind; (function (ScriptElementKind) { - ScriptElementKind["unknown"] = ""; - ScriptElementKind["warning"] = "warning"; - ScriptElementKind["keyword"] = "keyword"; - ScriptElementKind["scriptElement"] = "script"; - ScriptElementKind["moduleElement"] = "module"; - ScriptElementKind["classElement"] = "class"; - ScriptElementKind["localClassElement"] = "local class"; - ScriptElementKind["interfaceElement"] = "interface"; - ScriptElementKind["typeElement"] = "type"; - ScriptElementKind["enumElement"] = "enum"; - ScriptElementKind["enumMemberElement"] = "enum member"; - ScriptElementKind["variableElement"] = "var"; - ScriptElementKind["localVariableElement"] = "local var"; - ScriptElementKind["functionElement"] = "function"; - ScriptElementKind["localFunctionElement"] = "local function"; - ScriptElementKind["memberFunctionElement"] = "method"; - ScriptElementKind["memberGetAccessorElement"] = "getter"; - ScriptElementKind["memberSetAccessorElement"] = "setter"; - ScriptElementKind["memberVariableElement"] = "property"; - ScriptElementKind["constructorImplementationElement"] = "constructor"; - ScriptElementKind["callSignatureElement"] = "call"; - ScriptElementKind["indexSignatureElement"] = "index"; - ScriptElementKind["constructSignatureElement"] = "construct"; - ScriptElementKind["parameterElement"] = "parameter"; - ScriptElementKind["typeParameterElement"] = "type parameter"; - ScriptElementKind["primitiveType"] = "primitive type"; - ScriptElementKind["label"] = "label"; - ScriptElementKind["alias"] = "alias"; - ScriptElementKind["constElement"] = "const"; - ScriptElementKind["letElement"] = "let"; - ScriptElementKind["directory"] = "directory"; - ScriptElementKind["externalModuleName"] = "external module name"; - ScriptElementKind["jsxAttribute"] = "JSX attribute"; + ScriptElementKind.unknown = ""; + ScriptElementKind.warning = "warning"; + ScriptElementKind.keyword = "keyword"; + ScriptElementKind.scriptElement = "script"; + ScriptElementKind.moduleElement = "module"; + ScriptElementKind.classElement = "class"; + ScriptElementKind.localClassElement = "local class"; + ScriptElementKind.interfaceElement = "interface"; + ScriptElementKind.typeElement = "type"; + ScriptElementKind.enumElement = "enum"; + ScriptElementKind.enumMemberElement = "enum member"; + ScriptElementKind.variableElement = "var"; + ScriptElementKind.localVariableElement = "local var"; + ScriptElementKind.functionElement = "function"; + ScriptElementKind.localFunctionElement = "local function"; + ScriptElementKind.memberFunctionElement = "method"; + ScriptElementKind.memberGetAccessorElement = "getter"; + ScriptElementKind.memberSetAccessorElement = "setter"; + ScriptElementKind.memberVariableElement = "property"; + ScriptElementKind.constructorImplementationElement = "constructor"; + ScriptElementKind.callSignatureElement = "call"; + ScriptElementKind.indexSignatureElement = "index"; + ScriptElementKind.constructSignatureElement = "construct"; + ScriptElementKind.parameterElement = "parameter"; + ScriptElementKind.typeParameterElement = "type parameter"; + ScriptElementKind.primitiveType = "primitive type"; + ScriptElementKind.label = "label"; + ScriptElementKind.alias = "alias"; + ScriptElementKind.constElement = "const"; + ScriptElementKind.letElement = "let"; + ScriptElementKind.directory = "directory"; + ScriptElementKind.externalModuleName = "external module name"; + ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { - ScriptElementKindModifier["none"] = ""; - ScriptElementKindModifier["publicMemberModifier"] = "public"; - ScriptElementKindModifier["privateMemberModifier"] = "private"; - ScriptElementKindModifier["protectedMemberModifier"] = "protected"; - ScriptElementKindModifier["exportedModifier"] = "export"; - ScriptElementKindModifier["ambientModifier"] = "declare"; - ScriptElementKindModifier["staticModifier"] = "static"; - ScriptElementKindModifier["abstractModifier"] = "abstract"; + ScriptElementKindModifier.none = ""; + ScriptElementKindModifier.publicMemberModifier = "public"; + ScriptElementKindModifier.privateMemberModifier = "private"; + ScriptElementKindModifier.protectedMemberModifier = "protected"; + ScriptElementKindModifier.exportedModifier = "export"; + ScriptElementKindModifier.ambientModifier = "declare"; + ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); - var ClassificationTypeNames; - (function (ClassificationTypeNames) { - ClassificationTypeNames["comment"] = "comment"; - ClassificationTypeNames["identifier"] = "identifier"; - ClassificationTypeNames["keyword"] = "keyword"; - ClassificationTypeNames["numericLiteral"] = "number"; - ClassificationTypeNames["operator"] = "operator"; - ClassificationTypeNames["stringLiteral"] = "string"; - ClassificationTypeNames["whiteSpace"] = "whitespace"; - ClassificationTypeNames["text"] = "text"; - ClassificationTypeNames["punctuation"] = "punctuation"; - ClassificationTypeNames["className"] = "class name"; - ClassificationTypeNames["enumName"] = "enum name"; - ClassificationTypeNames["interfaceName"] = "interface name"; - ClassificationTypeNames["moduleName"] = "module name"; - ClassificationTypeNames["typeParameterName"] = "type parameter name"; - ClassificationTypeNames["typeAliasName"] = "type alias name"; - ClassificationTypeNames["parameterName"] = "parameter name"; - ClassificationTypeNames["docCommentTagName"] = "doc comment tag name"; - ClassificationTypeNames["jsxOpenTagName"] = "jsx open tag name"; - ClassificationTypeNames["jsxCloseTagName"] = "jsx close tag name"; - ClassificationTypeNames["jsxSelfClosingTagName"] = "jsx self closing tag name"; - ClassificationTypeNames["jsxAttribute"] = "jsx attribute"; - ClassificationTypeNames["jsxText"] = "jsx text"; - ClassificationTypeNames["jsxAttributeStringLiteralValue"] = "jsx attribute string literal value"; - })(ClassificationTypeNames = ts.ClassificationTypeNames || (ts.ClassificationTypeNames = {})); + var ClassificationTypeNames = (function () { + function ClassificationTypeNames() { + } + ClassificationTypeNames.comment = "comment"; + ClassificationTypeNames.identifier = "identifier"; + ClassificationTypeNames.keyword = "keyword"; + ClassificationTypeNames.numericLiteral = "number"; + ClassificationTypeNames.operator = "operator"; + ClassificationTypeNames.stringLiteral = "string"; + ClassificationTypeNames.whiteSpace = "whitespace"; + ClassificationTypeNames.text = "text"; + ClassificationTypeNames.punctuation = "punctuation"; + ClassificationTypeNames.className = "class name"; + ClassificationTypeNames.enumName = "enum name"; + ClassificationTypeNames.interfaceName = "interface name"; + ClassificationTypeNames.moduleName = "module name"; + ClassificationTypeNames.typeParameterName = "type parameter name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; + ClassificationTypeNames.docCommentTagName = "doc comment tag name"; + ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; + ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; + ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; + ClassificationTypeNames.jsxAttribute = "jsx attribute"; + ClassificationTypeNames.jsxText = "jsx text"; + ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; + return ClassificationTypeNames; + }()); + ts.ClassificationTypeNames = ClassificationTypeNames; var ClassificationType; (function (ClassificationType) { ClassificationType[ClassificationType["comment"] = 1] = "comment"; @@ -59808,15 +59826,15 @@ var ts; function getNodeKind(node) { switch (node.kind) { case 265: - return ts.isExternalModule(node) ? "module" : "script"; + return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; case 233: - return "module"; + return ts.ScriptElementKind.moduleElement; case 229: case 199: - return "class"; - case 230: return "interface"; - case 231: return "type"; - case 232: return "enum"; + return ts.ScriptElementKind.classElement; + case 230: return ts.ScriptElementKind.interfaceElement; + case 231: return ts.ScriptElementKind.typeElement; + case 232: return ts.ScriptElementKind.enumElement; case 226: return getKindOfVariableDeclaration(node); case 176: @@ -59824,39 +59842,39 @@ var ts; case 187: case 228: case 186: - return "function"; - case 153: return "getter"; - case 154: return "setter"; + return ts.ScriptElementKind.functionElement; + case 153: return ts.ScriptElementKind.memberGetAccessorElement; + case 154: return ts.ScriptElementKind.memberSetAccessorElement; case 151: case 150: - return "method"; + return ts.ScriptElementKind.memberFunctionElement; case 149: case 148: - return "property"; - case 157: return "index"; - case 156: return "construct"; - case 155: return "call"; - case 152: return "constructor"; - case 145: return "type parameter"; - case 264: return "enum member"; - case 146: return ts.hasModifier(node, 92) ? "property" : "parameter"; + return ts.ScriptElementKind.memberVariableElement; + case 157: return ts.ScriptElementKind.indexSignatureElement; + case 156: return ts.ScriptElementKind.constructSignatureElement; + case 155: return ts.ScriptElementKind.callSignatureElement; + case 152: return ts.ScriptElementKind.constructorImplementationElement; + case 145: return ts.ScriptElementKind.typeParameterElement; + case 264: return ts.ScriptElementKind.enumMemberElement; + case 146: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; case 237: case 242: case 239: case 246: case 240: - return "alias"; + return ts.ScriptElementKind.alias; case 291: - return "type"; + return ts.ScriptElementKind.typeElement; default: - return ""; + return ts.ScriptElementKind.unknown; } function getKindOfVariableDeclaration(v) { return ts.isConst(v) - ? "const" + ? ts.ScriptElementKind.constElement : ts.isLet(v) - ? "let" - : "var"; + ? ts.ScriptElementKind.letElement + : ts.ScriptElementKind.variableElement; } } ts.getNodeKind = getNodeKind; @@ -60261,20 +60279,20 @@ var ts; var flags = ts.getCombinedModifierFlags(node); var result = []; if (flags & 8) - result.push("private"); + result.push(ts.ScriptElementKindModifier.privateMemberModifier); if (flags & 16) - result.push("protected"); + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); if (flags & 4) - result.push("public"); + result.push(ts.ScriptElementKindModifier.publicMemberModifier); if (flags & 32) - result.push("static"); + result.push(ts.ScriptElementKindModifier.staticModifier); if (flags & 128) - result.push("abstract"); + result.push(ts.ScriptElementKindModifier.abstractModifier); if (flags & 1) - result.push("export"); + result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) - result.push("declare"); - return result.length > 0 ? result.join(",") : ""; + result.push(ts.ScriptElementKindModifier.ambientModifier); + return result.length > 0 ? result.join(",") : ts.ScriptElementKindModifier.none; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { @@ -61578,29 +61596,29 @@ var ts; ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function getClassificationTypeName(type) { switch (type) { - case 1: return "comment"; - case 2: return "identifier"; - case 3: return "keyword"; - case 4: return "number"; - case 5: return "operator"; - case 6: return "string"; - case 8: return "whitespace"; - case 9: return "text"; - case 10: return "punctuation"; - case 11: return "class name"; - case 12: return "enum name"; - case 13: return "interface name"; - case 14: return "module name"; - case 15: return "type parameter name"; - case 16: return "type alias name"; - case 17: return "parameter name"; - case 18: return "doc comment tag name"; - case 19: return "jsx open tag name"; - case 20: return "jsx close tag name"; - case 21: return "jsx self closing tag name"; - case 22: return "jsx attribute"; - case 23: return "jsx text"; - case 24: return "jsx attribute string literal value"; + case 1: return ts.ClassificationTypeNames.comment; + case 2: return ts.ClassificationTypeNames.identifier; + case 3: return ts.ClassificationTypeNames.keyword; + case 4: return ts.ClassificationTypeNames.numericLiteral; + case 5: return ts.ClassificationTypeNames.operator; + case 6: return ts.ClassificationTypeNames.stringLiteral; + case 8: return ts.ClassificationTypeNames.whiteSpace; + case 9: return ts.ClassificationTypeNames.text; + case 10: return ts.ClassificationTypeNames.punctuation; + case 11: return ts.ClassificationTypeNames.className; + case 12: return ts.ClassificationTypeNames.enumName; + case 13: return ts.ClassificationTypeNames.interfaceName; + case 14: return ts.ClassificationTypeNames.moduleName; + case 15: return ts.ClassificationTypeNames.typeParameterName; + case 16: return ts.ClassificationTypeNames.typeAliasName; + case 17: return ts.ClassificationTypeNames.parameterName; + case 18: return ts.ClassificationTypeNames.docCommentTagName; + case 19: return ts.ClassificationTypeNames.jsxOpenTagName; + case 20: return ts.ClassificationTypeNames.jsxCloseTagName; + case 21: return ts.ClassificationTypeNames.jsxSelfClosingTagName; + case 22: return ts.ClassificationTypeNames.jsxAttribute; + case 23: return ts.ClassificationTypeNames.jsxText; + case 24: return ts.ClassificationTypeNames.jsxAttributeStringLiteralValue; } } function convertClassifications(classifications) { @@ -61987,7 +62005,7 @@ var ts; } } ts.forEachKey(foundFiles, function (foundFile) { - result.push(createCompletionEntryForModule(foundFile, "script", span)); + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); }); } var directories = tryGetDirectories(host, baseDirectory); @@ -61995,7 +62013,7 @@ var ts; for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { var directory = directories_2[_a]; var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, "directory", span)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); } } } @@ -62018,7 +62036,7 @@ var ts; var pattern = _a[_i]; for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { var match = _c[_b]; - result.push(createCompletionEntryForModule(match, "external module name", span)); + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); } } } @@ -62026,7 +62044,7 @@ var ts; else if (ts.startsWith(path, fragment)) { var entry = paths[path] && paths[path].length === 1 && paths[path][0]; if (entry) { - result.push(createCompletionEntryForModule(path, "external module name", span)); + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); } } } @@ -62039,7 +62057,7 @@ var ts; getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, "external module name", span)); + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); } return result; } @@ -62150,7 +62168,7 @@ var ts; if (options.types) { for (var _i = 0, _a = options.types; _i < _a.length; _i++) { var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, "external module name", span)); + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); } } else if (host.getDirectories) { @@ -62182,7 +62200,7 @@ var ts; for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { var typeDirectory = directories_3[_i]; typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), "external module name", span)); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); } } } @@ -62253,7 +62271,7 @@ var ts; } } function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: "", sortText: name, replacementSpan: replacementSpan }; + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; } function getDirectoryFragmentTextSpan(text, textStart) { var index = text.lastIndexOf(ts.directorySeparator); @@ -62328,7 +62346,7 @@ var ts; return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, entries: [{ name: tagName.getFullText(), - kind: "class", + kind: ts.ScriptElementKind.classElement, kindModifiers: undefined, sortText: "0", }] }; @@ -62376,7 +62394,7 @@ var ts; if (displayName) { var entry = { name: displayName, - kind: "warning", + kind: ts.ScriptElementKind.warning, kindModifiers: "", sortText: "1" }; @@ -62512,8 +62530,8 @@ var ts; uniques.set(name, true); result.push({ name: name, - kindModifiers: "", - kind: "var", + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, sortText: "0" }); } @@ -62540,8 +62558,8 @@ var ts; if (keywordCompletion) { return { name: entryName, - kind: "keyword", - kindModifiers: "", + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], documentation: undefined, tags: undefined @@ -63379,8 +63397,8 @@ var ts; for (var i = 72; i <= 142; i++) { keywordCompletions.push({ name: ts.tokenToString(i), - kind: "keyword", - kindModifiers: "", + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, sortText: "0" }); } @@ -63467,7 +63485,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node, sourceFile), - kind: "none" + kind: ts.HighlightSpanKind.none }; } function getSemanticDocumentHighlights(node, program, cancellationToken, sourceFilesToSearch) { @@ -63914,7 +63932,7 @@ var ts; result.push({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: "reference" + kind: ts.HighlightSpanKind.reference }); i++; continue; @@ -64623,22 +64641,22 @@ var ts; } case "label": { var node_3 = def.node; - return { node: node_3, name: node_3.text, kind: "label", displayParts: [ts.displayPart(node_3.text, ts.SymbolDisplayPartKind.text)] }; + return { node: node_3, name: node_3.text, kind: ts.ScriptElementKind.label, displayParts: [ts.displayPart(node_3.text, ts.SymbolDisplayPartKind.text)] }; } case "keyword": { var node_4 = def.node; var name_4 = ts.tokenToString(node_4.kind); - return { node: node_4, name: name_4, kind: "keyword", displayParts: [{ text: name_4, kind: "keyword" }] }; + return { node: node_4, name: name_4, kind: ts.ScriptElementKind.keyword, displayParts: [{ text: name_4, kind: ts.ScriptElementKind.keyword }] }; } case "this": { var node_5 = def.node; var symbol = checker.getSymbolAtLocation(node_5); var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node_5.getSourceFile(), ts.getContainerNode(node_5), node_5).displayParts; - return { node: node_5, name: "this", kind: "var", displayParts: displayParts_2 }; + return { node: node_5, name: "this", kind: ts.ScriptElementKind.variableElement, displayParts: displayParts_2 }; } case "string": { var node_6 = def.node; - return { node: node_6, name: node_6.text, kind: "var", displayParts: [ts.displayPart(ts.getTextOfNode(node_6), ts.SymbolDisplayPartKind.stringLiteral)] }; + return { node: node_6, name: node_6.text, kind: ts.ScriptElementKind.variableElement, displayParts: [ts.displayPart(ts.getTextOfNode(node_6), ts.SymbolDisplayPartKind.stringLiteral)] }; } } })(); @@ -64681,7 +64699,7 @@ var ts; } else { var textSpan = entry.textSpan, fileName = entry.fileName; - return { textSpan: textSpan, fileName: fileName, kind: "", displayParts: [] }; + return { textSpan: textSpan, fileName: fileName, kind: ts.ScriptElementKind.unknown, displayParts: [] }; } } function implementationKindDisplayParts(node, checker) { @@ -64691,13 +64709,13 @@ var ts; } else if (node.kind === 178) { return { - kind: "interface", + kind: ts.ScriptElementKind.interfaceElement, displayParts: [ts.punctuationPart(19), ts.textPart("object literal"), ts.punctuationPart(20)] }; } else if (node.kind === 199) { return { - kind: "local class", + kind: ts.ScriptElementKind.localClassElement, displayParts: [ts.punctuationPart(19), ts.textPart("anonymous local class"), ts.punctuationPart(20)] }; } @@ -64708,14 +64726,14 @@ var ts; function toHighlightSpan(entry) { if (entry.type === "span") { var fileName_1 = entry.fileName, textSpan = entry.textSpan; - return { fileName: fileName_1, span: { textSpan: textSpan, kind: "reference" } }; + return { fileName: fileName_1, span: { textSpan: textSpan, kind: ts.HighlightSpanKind.reference } }; } var node = entry.node, isInString = entry.isInString; var fileName = entry.node.getSourceFile().fileName; var writeAccess = isWriteAccess(node); var span = { textSpan: getTextSpan(node), - kind: writeAccess ? "writtenReference" : "reference", + kind: writeAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference, isInString: isInString }; return { fileName: fileName, span: span }; @@ -65816,7 +65834,7 @@ var ts; if (ts.isJumpStatementTarget(node)) { var labelName = node.text; var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(label, "label", labelName, undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ts.ScriptElementKind.label, labelName, undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -65999,7 +66017,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: "script", + kind: ts.ScriptElementKind.scriptElement, name: name, containerName: undefined, containerKind: undefined @@ -66133,7 +66151,7 @@ var ts; return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: "keyword", + kind: ts.ScriptElementKind.keyword, kindModifiers: "", sortText: "0", }; @@ -66144,7 +66162,7 @@ var ts; return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: "@" + tagName, - kind: "keyword", + kind: ts.ScriptElementKind.keyword, kindModifiers: "", sortText: "0" }; @@ -66165,7 +66183,7 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter", kindModifiers: "", sortText: "0" }; + return { name: name, kind: ts.ScriptElementKind.parameterElement, kindModifiers: "", sortText: "0" }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; @@ -68007,7 +68025,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } var displayName = ts.stripQuotes(node.text); - return getRenameInfoSuccess(displayName, displayName, "var", "", node, sourceFile); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); } } function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { @@ -68389,92 +68407,92 @@ var ts; var flags = symbol.flags; if (flags & 32) { return ts.getDeclarationOfKind(symbol, 199) ? - "local class" : "class"; + ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; } if (flags & 384) - return "enum"; + return ts.ScriptElementKind.enumElement; if (flags & 524288) - return "type"; + return ts.ScriptElementKind.typeElement; if (flags & 64) - return "interface"; + return ts.ScriptElementKind.interfaceElement; if (flags & 262144) - return "type parameter"; + return ts.ScriptElementKind.typeParameterElement; var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - if (result === "") { + if (result === ts.ScriptElementKind.unknown) { if (flags & 262144) - return "type parameter"; + return ts.ScriptElementKind.typeParameterElement; if (flags & 8) - return "enum member"; + return ts.ScriptElementKind.enumMemberElement; if (flags & 8388608) - return "alias"; + return ts.ScriptElementKind.alias; if (flags & 1536) - return "module"; + return ts.ScriptElementKind.moduleElement; } return result; } SymbolDisplay.getSymbolKind = getSymbolKind; function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) { if (typeChecker.isUndefinedSymbol(symbol)) { - return "var"; + return ts.ScriptElementKind.variableElement; } if (typeChecker.isArgumentsSymbol(symbol)) { - return "local var"; + return ts.ScriptElementKind.localVariableElement; } if (location.kind === 99 && ts.isExpression(location)) { - return "parameter"; + return ts.ScriptElementKind.parameterElement; } var flags = symbol.flags; if (flags & 3) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return "parameter"; + return ts.ScriptElementKind.parameterElement; } else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { - return "const"; + return ts.ScriptElementKind.constElement; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return "let"; + return ts.ScriptElementKind.letElement; } - return isLocalVariableOrFunction(symbol) ? "local var" : "var"; + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localVariableElement : ts.ScriptElementKind.variableElement; } if (flags & 16) - return isLocalVariableOrFunction(symbol) ? "local function" : "function"; + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localFunctionElement : ts.ScriptElementKind.functionElement; if (flags & 32768) - return "getter"; + return ts.ScriptElementKind.memberGetAccessorElement; if (flags & 65536) - return "setter"; + return ts.ScriptElementKind.memberSetAccessorElement; if (flags & 8192) - return "method"; + return ts.ScriptElementKind.memberFunctionElement; if (flags & 16384) - return "constructor"; + return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4) { if (flags & 134217728 && symbol.checkFlags & 6) { var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 | 3)) { - return "property"; + return ts.ScriptElementKind.memberVariableElement; } ts.Debug.assert(!!(rootSymbolFlags & 8192)); }); if (!unionPropertyKind) { var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return "method"; + return ts.ScriptElementKind.memberFunctionElement; } - return "property"; + return ts.ScriptElementKind.memberVariableElement; } return unionPropertyKind; } if (location.parent && ts.isJsxAttribute(location.parent)) { - return "JSX attribute"; + return ts.ScriptElementKind.jsxAttribute; } - return "property"; + return ts.ScriptElementKind.memberVariableElement; } - return ""; + return ts.ScriptElementKind.unknown; } function getSymbolModifiers(symbol) { return symbol && symbol.declarations && symbol.declarations.length > 0 ? ts.getNodeModifiers(symbol.declarations[0]) - : ""; + : ts.ScriptElementKindModifier.none; } SymbolDisplay.getSymbolModifiers = getSymbolModifiers; function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, enclosingDeclaration, location, semanticMeaning) { @@ -68487,9 +68505,9 @@ var ts; var hasAddedSymbolInfo; var isThisExpression = location.kind === 99 && ts.isExpression(location); var type; - if (symbolKind !== "" || symbolFlags & 32 || symbolFlags & 8388608) { - if (symbolKind === "getter" || symbolKind === "setter") { - symbolKind = "property"; + if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 || symbolFlags & 8388608) { + if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { + symbolKind = ts.ScriptElementKind.memberVariableElement; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); @@ -68523,11 +68541,11 @@ var ts; } if (signature) { if (useConstructSignatures && (symbolFlags & 32)) { - symbolKind = "constructor"; + symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else if (symbolFlags & 8388608) { - symbolKind = "alias"; + symbolKind = ts.ScriptElementKind.alias; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { @@ -68540,13 +68558,13 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case "JSX attribute": - case "property": - case "var": - case "const": - case "let": - case "parameter": - case "local var": + case ts.ScriptElementKind.jsxAttribute: + case ts.ScriptElementKind.memberVariableElement: + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.parameterElement: + case ts.ScriptElementKind.localVariableElement: displayParts.push(ts.punctuationPart(56)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { @@ -68579,7 +68597,7 @@ var ts; signature = allSignatures[0]; } if (functionDeclaration_1.kind === 152) { - symbolKind = "constructor"; + symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { @@ -68594,7 +68612,7 @@ var ts; } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { if (ts.getDeclarationOfKind(symbol, 199)) { - pushTypePart("local class"); + pushTypePart(ts.ScriptElementKind.localClassElement); } else { displayParts.push(ts.keywordPart(75)); @@ -68679,7 +68697,7 @@ var ts; } } if (symbolFlags & 8) { - symbolKind = "enum member"; + symbolKind = ts.ScriptElementKind.enumMemberElement; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; if (declaration.kind === 264) { @@ -68730,7 +68748,7 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== "") { + if (symbolKind !== ts.ScriptElementKind.unknown) { if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); @@ -68739,10 +68757,10 @@ var ts; else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); } - if (symbolKind === "property" || - symbolKind === "JSX attribute" || + if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolKind === ts.ScriptElementKind.jsxAttribute || symbolFlags & 3 || - symbolKind === "local var" || + symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { displayParts.push(ts.punctuationPart(56)); displayParts.push(ts.spacePart()); @@ -68761,7 +68779,7 @@ var ts; symbolFlags & 16384 || symbolFlags & 131072 || symbolFlags & 98304 || - symbolKind === "method") { + symbolKind === ts.ScriptElementKind.memberFunctionElement) { var allSignatures = type.getNonNullableType().getCallSignatures(); addSignatureDisplayParts(allSignatures[0], allSignatures); } @@ -68819,11 +68837,11 @@ var ts; } function pushTypePart(symbolKind) { switch (symbolKind) { - case "var": - case "function": - case "let": - case "const": - case "constructor": + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.functionElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.constructorImplementationElement: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: @@ -74370,8 +74388,8 @@ var ts; var type = typeChecker.getTypeAtLocation(node); if (type) { return { - kind: "", - kindModifiers: "", + kind: ts.ScriptElementKind.unknown, + kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined, @@ -74431,7 +74449,7 @@ var ts; result.push({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, - isWriteAccess: highlightSpan.kind === "writtenReference", + isWriteAccess: highlightSpan.kind === ts.HighlightSpanKind.writtenReference, isDefinition: false, isInString: highlightSpan.isInString, }); @@ -75181,129 +75199,6 @@ var ts; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var server; - (function (server) { - var protocol; - (function (protocol) { - var CommandTypes; - (function (CommandTypes) { - CommandTypes["Brace"] = "brace"; - CommandTypes["BraceFull"] = "brace-full"; - CommandTypes["BraceCompletion"] = "braceCompletion"; - CommandTypes["Change"] = "change"; - CommandTypes["Close"] = "close"; - CommandTypes["Completions"] = "completions"; - CommandTypes["CompletionsFull"] = "completions-full"; - CommandTypes["CompletionDetails"] = "completionEntryDetails"; - CommandTypes["CompileOnSaveAffectedFileList"] = "compileOnSaveAffectedFileList"; - CommandTypes["CompileOnSaveEmitFile"] = "compileOnSaveEmitFile"; - CommandTypes["Configure"] = "configure"; - CommandTypes["Definition"] = "definition"; - CommandTypes["DefinitionFull"] = "definition-full"; - CommandTypes["Implementation"] = "implementation"; - CommandTypes["ImplementationFull"] = "implementation-full"; - CommandTypes["Exit"] = "exit"; - CommandTypes["Format"] = "format"; - CommandTypes["Formatonkey"] = "formatonkey"; - CommandTypes["FormatFull"] = "format-full"; - CommandTypes["FormatonkeyFull"] = "formatonkey-full"; - CommandTypes["FormatRangeFull"] = "formatRange-full"; - CommandTypes["Geterr"] = "geterr"; - CommandTypes["GeterrForProject"] = "geterrForProject"; - CommandTypes["SemanticDiagnosticsSync"] = "semanticDiagnosticsSync"; - CommandTypes["SyntacticDiagnosticsSync"] = "syntacticDiagnosticsSync"; - CommandTypes["NavBar"] = "navbar"; - CommandTypes["NavBarFull"] = "navbar-full"; - CommandTypes["Navto"] = "navto"; - CommandTypes["NavtoFull"] = "navto-full"; - CommandTypes["NavTree"] = "navtree"; - CommandTypes["NavTreeFull"] = "navtree-full"; - CommandTypes["Occurrences"] = "occurrences"; - CommandTypes["DocumentHighlights"] = "documentHighlights"; - CommandTypes["DocumentHighlightsFull"] = "documentHighlights-full"; - CommandTypes["Open"] = "open"; - CommandTypes["Quickinfo"] = "quickinfo"; - CommandTypes["QuickinfoFull"] = "quickinfo-full"; - CommandTypes["References"] = "references"; - CommandTypes["ReferencesFull"] = "references-full"; - CommandTypes["Reload"] = "reload"; - CommandTypes["Rename"] = "rename"; - CommandTypes["RenameInfoFull"] = "rename-full"; - CommandTypes["RenameLocationsFull"] = "renameLocations-full"; - CommandTypes["Saveto"] = "saveto"; - CommandTypes["SignatureHelp"] = "signatureHelp"; - CommandTypes["SignatureHelpFull"] = "signatureHelp-full"; - CommandTypes["TypeDefinition"] = "typeDefinition"; - CommandTypes["ProjectInfo"] = "projectInfo"; - CommandTypes["ReloadProjects"] = "reloadProjects"; - CommandTypes["Unknown"] = "unknown"; - CommandTypes["OpenExternalProject"] = "openExternalProject"; - CommandTypes["OpenExternalProjects"] = "openExternalProjects"; - CommandTypes["CloseExternalProject"] = "closeExternalProject"; - CommandTypes["SynchronizeProjectList"] = "synchronizeProjectList"; - CommandTypes["ApplyChangedToOpenFiles"] = "applyChangedToOpenFiles"; - CommandTypes["EncodedSemanticClassificationsFull"] = "encodedSemanticClassifications-full"; - CommandTypes["Cleanup"] = "cleanup"; - CommandTypes["OutliningSpans"] = "outliningSpans"; - CommandTypes["TodoComments"] = "todoComments"; - CommandTypes["Indentation"] = "indentation"; - CommandTypes["DocCommentTemplate"] = "docCommentTemplate"; - CommandTypes["CompilerOptionsDiagnosticsFull"] = "compilerOptionsDiagnostics-full"; - CommandTypes["NameOrDottedNameSpan"] = "nameOrDottedNameSpan"; - CommandTypes["BreakpointStatement"] = "breakpointStatement"; - CommandTypes["CompilerOptionsForInferredProjects"] = "compilerOptionsForInferredProjects"; - CommandTypes["GetCodeFixes"] = "getCodeFixes"; - CommandTypes["GetCodeFixesFull"] = "getCodeFixes-full"; - CommandTypes["GetSupportedCodeFixes"] = "getSupportedCodeFixes"; - CommandTypes["GetApplicableRefactors"] = "getApplicableRefactors"; - CommandTypes["GetEditsForRefactor"] = "getEditsForRefactor"; - CommandTypes["GetEditsForRefactorFull"] = "getEditsForRefactor-full"; - })(CommandTypes = protocol.CommandTypes || (protocol.CommandTypes = {})); - var IndentStyle; - (function (IndentStyle) { - IndentStyle["None"] = "None"; - IndentStyle["Block"] = "Block"; - IndentStyle["Smart"] = "Smart"; - })(IndentStyle = protocol.IndentStyle || (protocol.IndentStyle = {})); - var JsxEmit; - (function (JsxEmit) { - JsxEmit["None"] = "None"; - JsxEmit["Preserve"] = "Preserve"; - JsxEmit["ReactNative"] = "ReactNative"; - JsxEmit["React"] = "React"; - })(JsxEmit = protocol.JsxEmit || (protocol.JsxEmit = {})); - var ModuleKind; - (function (ModuleKind) { - ModuleKind["None"] = "None"; - ModuleKind["CommonJS"] = "CommonJS"; - ModuleKind["AMD"] = "AMD"; - ModuleKind["UMD"] = "UMD"; - ModuleKind["System"] = "System"; - ModuleKind["ES6"] = "ES6"; - ModuleKind["ES2015"] = "ES2015"; - })(ModuleKind = protocol.ModuleKind || (protocol.ModuleKind = {})); - var ModuleResolutionKind; - (function (ModuleResolutionKind) { - ModuleResolutionKind["Classic"] = "Classic"; - ModuleResolutionKind["Node"] = "Node"; - })(ModuleResolutionKind = protocol.ModuleResolutionKind || (protocol.ModuleResolutionKind = {})); - var NewLineKind; - (function (NewLineKind) { - NewLineKind["Crlf"] = "Crlf"; - NewLineKind["Lf"] = "Lf"; - })(NewLineKind = protocol.NewLineKind || (protocol.NewLineKind = {})); - var ScriptTarget; - (function (ScriptTarget) { - ScriptTarget["ES3"] = "ES3"; - ScriptTarget["ES5"] = "ES5"; - ScriptTarget["ES6"] = "ES6"; - ScriptTarget["ES2015"] = "ES2015"; - })(ScriptTarget = protocol.ScriptTarget || (protocol.ScriptTarget = {})); - })(protocol = server.protocol || (server.protocol = {})); - })(server = ts.server || (ts.server = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var server; (function (server) { @@ -75373,7 +75268,82 @@ var ts; } return true; } - server.CommandNames = server.protocol.CommandTypes; + var CommandNames; + (function (CommandNames) { + CommandNames.Brace = "brace"; + CommandNames.BraceFull = "brace-full"; + CommandNames.BraceCompletion = "braceCompletion"; + CommandNames.Change = "change"; + CommandNames.Close = "close"; + CommandNames.Completions = "completions"; + CommandNames.CompletionsFull = "completions-full"; + CommandNames.CompletionDetails = "completionEntryDetails"; + CommandNames.CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList"; + CommandNames.CompileOnSaveEmitFile = "compileOnSaveEmitFile"; + CommandNames.Configure = "configure"; + CommandNames.Definition = "definition"; + CommandNames.DefinitionFull = "definition-full"; + CommandNames.Exit = "exit"; + CommandNames.Format = "format"; + CommandNames.Formatonkey = "formatonkey"; + CommandNames.FormatFull = "format-full"; + CommandNames.FormatonkeyFull = "formatonkey-full"; + CommandNames.FormatRangeFull = "formatRange-full"; + CommandNames.Geterr = "geterr"; + CommandNames.GeterrForProject = "geterrForProject"; + CommandNames.Implementation = "implementation"; + CommandNames.ImplementationFull = "implementation-full"; + CommandNames.SemanticDiagnosticsSync = "semanticDiagnosticsSync"; + CommandNames.SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; + CommandNames.NavBar = "navbar"; + CommandNames.NavBarFull = "navbar-full"; + CommandNames.NavTree = "navtree"; + CommandNames.NavTreeFull = "navtree-full"; + CommandNames.Navto = "navto"; + CommandNames.NavtoFull = "navto-full"; + CommandNames.Occurrences = "occurrences"; + CommandNames.DocumentHighlights = "documentHighlights"; + CommandNames.DocumentHighlightsFull = "documentHighlights-full"; + CommandNames.Open = "open"; + CommandNames.Quickinfo = "quickinfo"; + CommandNames.QuickinfoFull = "quickinfo-full"; + CommandNames.References = "references"; + CommandNames.ReferencesFull = "references-full"; + CommandNames.Reload = "reload"; + CommandNames.Rename = "rename"; + CommandNames.RenameInfoFull = "rename-full"; + CommandNames.RenameLocationsFull = "renameLocations-full"; + CommandNames.Saveto = "saveto"; + CommandNames.SignatureHelp = "signatureHelp"; + CommandNames.SignatureHelpFull = "signatureHelp-full"; + CommandNames.TypeDefinition = "typeDefinition"; + CommandNames.ProjectInfo = "projectInfo"; + CommandNames.ReloadProjects = "reloadProjects"; + CommandNames.Unknown = "unknown"; + CommandNames.OpenExternalProject = "openExternalProject"; + CommandNames.OpenExternalProjects = "openExternalProjects"; + CommandNames.CloseExternalProject = "closeExternalProject"; + CommandNames.SynchronizeProjectList = "synchronizeProjectList"; + CommandNames.ApplyChangedToOpenFiles = "applyChangedToOpenFiles"; + CommandNames.EncodedSemanticClassificationsFull = "encodedSemanticClassifications-full"; + CommandNames.Cleanup = "cleanup"; + CommandNames.OutliningSpans = "outliningSpans"; + CommandNames.TodoComments = "todoComments"; + CommandNames.Indentation = "indentation"; + CommandNames.DocCommentTemplate = "docCommentTemplate"; + CommandNames.CompilerOptionsDiagnosticsFull = "compilerOptionsDiagnostics-full"; + CommandNames.NameOrDottedNameSpan = "nameOrDottedNameSpan"; + CommandNames.BreakpointStatement = "breakpointStatement"; + CommandNames.CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects"; + CommandNames.GetCodeFixes = "getCodeFixes"; + CommandNames.GetCodeFixesFull = "getCodeFixes-full"; + CommandNames.GetSupportedCodeFixes = "getSupportedCodeFixes"; + CommandNames.GetApplicableRefactors = "getApplicableRefactors"; + CommandNames.GetRefactorCodeActions = "getRefactorCodeActions"; + CommandNames.GetRefactorCodeActionsFull = "getRefactorCodeActions-full"; + CommandNames.GetEditsForRefactor = "getEditsForRefactor"; + CommandNames.GetEditsForRefactorFull = "getEditsForRefactor-full"; + })(CommandNames = server.CommandNames || (server.CommandNames = {})); function formatMessage(msg, logger, byteLength, newLine) { var verboseLogging = logger.hasLevel(server.LogLevel.verbose); var json = JSON.stringify(msg); @@ -75470,19 +75440,19 @@ var ts; var _this = this; this.changeSeq = 0; this.handlers = ts.createMapFromTemplate((_a = {}, - _a[server.CommandNames.OpenExternalProject] = function (request) { + _a[CommandNames.OpenExternalProject] = function (request) { _this.projectService.openExternalProject(request.arguments, false); return _this.requiredResponse(true); }, - _a[server.CommandNames.OpenExternalProjects] = function (request) { + _a[CommandNames.OpenExternalProjects] = function (request) { _this.projectService.openExternalProjects(request.arguments.projects); return _this.requiredResponse(true); }, - _a[server.CommandNames.CloseExternalProject] = function (request) { + _a[CommandNames.CloseExternalProject] = function (request) { _this.projectService.closeExternalProject(request.arguments.projectFileName); return _this.requiredResponse(true); }, - _a[server.CommandNames.SynchronizeProjectList] = function (request) { + _a[CommandNames.SynchronizeProjectList] = function (request) { var result = _this.projectService.synchronizeProjectList(request.arguments.knownProjects); if (!result.some(function (p) { return p.projectErrors && p.projectErrors.length !== 0; })) { return _this.requiredResponse(result); @@ -75500,219 +75470,219 @@ var ts; }); return _this.requiredResponse(converted); }, - _a[server.CommandNames.ApplyChangedToOpenFiles] = function (request) { + _a[CommandNames.ApplyChangedToOpenFiles] = function (request) { _this.projectService.applyChangesInOpenFiles(request.arguments.openFiles, request.arguments.changedFiles, request.arguments.closedFiles); _this.changeSeq++; return _this.requiredResponse(true); }, - _a[server.CommandNames.Exit] = function () { + _a[CommandNames.Exit] = function () { _this.exit(); return _this.notRequired(); }, - _a[server.CommandNames.Definition] = function (request) { + _a[CommandNames.Definition] = function (request) { return _this.requiredResponse(_this.getDefinition(request.arguments, true)); }, - _a[server.CommandNames.DefinitionFull] = function (request) { + _a[CommandNames.DefinitionFull] = function (request) { return _this.requiredResponse(_this.getDefinition(request.arguments, false)); }, - _a[server.CommandNames.TypeDefinition] = function (request) { + _a[CommandNames.TypeDefinition] = function (request) { return _this.requiredResponse(_this.getTypeDefinition(request.arguments)); }, - _a[server.CommandNames.Implementation] = function (request) { + _a[CommandNames.Implementation] = function (request) { return _this.requiredResponse(_this.getImplementation(request.arguments, true)); }, - _a[server.CommandNames.ImplementationFull] = function (request) { + _a[CommandNames.ImplementationFull] = function (request) { return _this.requiredResponse(_this.getImplementation(request.arguments, false)); }, - _a[server.CommandNames.References] = function (request) { + _a[CommandNames.References] = function (request) { return _this.requiredResponse(_this.getReferences(request.arguments, true)); }, - _a[server.CommandNames.ReferencesFull] = function (request) { + _a[CommandNames.ReferencesFull] = function (request) { return _this.requiredResponse(_this.getReferences(request.arguments, false)); }, - _a[server.CommandNames.Rename] = function (request) { + _a[CommandNames.Rename] = function (request) { return _this.requiredResponse(_this.getRenameLocations(request.arguments, true)); }, - _a[server.CommandNames.RenameLocationsFull] = function (request) { + _a[CommandNames.RenameLocationsFull] = function (request) { return _this.requiredResponse(_this.getRenameLocations(request.arguments, false)); }, - _a[server.CommandNames.RenameInfoFull] = function (request) { + _a[CommandNames.RenameInfoFull] = function (request) { return _this.requiredResponse(_this.getRenameInfo(request.arguments)); }, - _a[server.CommandNames.Open] = function (request) { + _a[CommandNames.Open] = function (request) { _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName), request.arguments.projectRootPath ? server.toNormalizedPath(request.arguments.projectRootPath) : undefined); return _this.notRequired(); }, - _a[server.CommandNames.Quickinfo] = function (request) { + _a[CommandNames.Quickinfo] = function (request) { return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, true)); }, - _a[server.CommandNames.QuickinfoFull] = function (request) { + _a[CommandNames.QuickinfoFull] = function (request) { return _this.requiredResponse(_this.getQuickInfoWorker(request.arguments, false)); }, - _a[server.CommandNames.OutliningSpans] = function (request) { + _a[CommandNames.OutliningSpans] = function (request) { return _this.requiredResponse(_this.getOutliningSpans(request.arguments)); }, - _a[server.CommandNames.TodoComments] = function (request) { + _a[CommandNames.TodoComments] = function (request) { return _this.requiredResponse(_this.getTodoComments(request.arguments)); }, - _a[server.CommandNames.Indentation] = function (request) { + _a[CommandNames.Indentation] = function (request) { return _this.requiredResponse(_this.getIndentation(request.arguments)); }, - _a[server.CommandNames.NameOrDottedNameSpan] = function (request) { + _a[CommandNames.NameOrDottedNameSpan] = function (request) { return _this.requiredResponse(_this.getNameOrDottedNameSpan(request.arguments)); }, - _a[server.CommandNames.BreakpointStatement] = function (request) { + _a[CommandNames.BreakpointStatement] = function (request) { return _this.requiredResponse(_this.getBreakpointStatement(request.arguments)); }, - _a[server.CommandNames.BraceCompletion] = function (request) { + _a[CommandNames.BraceCompletion] = function (request) { return _this.requiredResponse(_this.isValidBraceCompletion(request.arguments)); }, - _a[server.CommandNames.DocCommentTemplate] = function (request) { + _a[CommandNames.DocCommentTemplate] = function (request) { return _this.requiredResponse(_this.getDocCommentTemplate(request.arguments)); }, - _a[server.CommandNames.Format] = function (request) { + _a[CommandNames.Format] = function (request) { return _this.requiredResponse(_this.getFormattingEditsForRange(request.arguments)); }, - _a[server.CommandNames.Formatonkey] = function (request) { + _a[CommandNames.Formatonkey] = function (request) { return _this.requiredResponse(_this.getFormattingEditsAfterKeystroke(request.arguments)); }, - _a[server.CommandNames.FormatFull] = function (request) { + _a[CommandNames.FormatFull] = function (request) { return _this.requiredResponse(_this.getFormattingEditsForDocumentFull(request.arguments)); }, - _a[server.CommandNames.FormatonkeyFull] = function (request) { + _a[CommandNames.FormatonkeyFull] = function (request) { return _this.requiredResponse(_this.getFormattingEditsAfterKeystrokeFull(request.arguments)); }, - _a[server.CommandNames.FormatRangeFull] = function (request) { + _a[CommandNames.FormatRangeFull] = function (request) { return _this.requiredResponse(_this.getFormattingEditsForRangeFull(request.arguments)); }, - _a[server.CommandNames.Completions] = function (request) { + _a[CommandNames.Completions] = function (request) { return _this.requiredResponse(_this.getCompletions(request.arguments, true)); }, - _a[server.CommandNames.CompletionsFull] = function (request) { + _a[CommandNames.CompletionsFull] = function (request) { return _this.requiredResponse(_this.getCompletions(request.arguments, false)); }, - _a[server.CommandNames.CompletionDetails] = function (request) { + _a[CommandNames.CompletionDetails] = function (request) { return _this.requiredResponse(_this.getCompletionEntryDetails(request.arguments)); }, - _a[server.CommandNames.CompileOnSaveAffectedFileList] = function (request) { + _a[CommandNames.CompileOnSaveAffectedFileList] = function (request) { return _this.requiredResponse(_this.getCompileOnSaveAffectedFileList(request.arguments)); }, - _a[server.CommandNames.CompileOnSaveEmitFile] = function (request) { + _a[CommandNames.CompileOnSaveEmitFile] = function (request) { return _this.requiredResponse(_this.emitFile(request.arguments)); }, - _a[server.CommandNames.SignatureHelp] = function (request) { + _a[CommandNames.SignatureHelp] = function (request) { return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, true)); }, - _a[server.CommandNames.SignatureHelpFull] = function (request) { + _a[CommandNames.SignatureHelpFull] = function (request) { return _this.requiredResponse(_this.getSignatureHelpItems(request.arguments, false)); }, - _a[server.CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { + _a[CommandNames.CompilerOptionsDiagnosticsFull] = function (request) { return _this.requiredResponse(_this.getCompilerOptionsDiagnostics(request.arguments)); }, - _a[server.CommandNames.EncodedSemanticClassificationsFull] = function (request) { + _a[CommandNames.EncodedSemanticClassificationsFull] = function (request) { return _this.requiredResponse(_this.getEncodedSemanticClassifications(request.arguments)); }, - _a[server.CommandNames.Cleanup] = function () { + _a[CommandNames.Cleanup] = function () { _this.cleanup(); return _this.requiredResponse(true); }, - _a[server.CommandNames.SemanticDiagnosticsSync] = function (request) { + _a[CommandNames.SemanticDiagnosticsSync] = function (request) { return _this.requiredResponse(_this.getSemanticDiagnosticsSync(request.arguments)); }, - _a[server.CommandNames.SyntacticDiagnosticsSync] = function (request) { + _a[CommandNames.SyntacticDiagnosticsSync] = function (request) { return _this.requiredResponse(_this.getSyntacticDiagnosticsSync(request.arguments)); }, - _a[server.CommandNames.Geterr] = function (request) { + _a[CommandNames.Geterr] = function (request) { _this.errorCheck.startNew(function (next) { return _this.getDiagnostics(next, request.arguments.delay, request.arguments.files); }); return _this.notRequired(); }, - _a[server.CommandNames.GeterrForProject] = function (request) { + _a[CommandNames.GeterrForProject] = function (request) { _this.errorCheck.startNew(function (next) { return _this.getDiagnosticsForProject(next, request.arguments.delay, request.arguments.file); }); return _this.notRequired(); }, - _a[server.CommandNames.Change] = function (request) { + _a[CommandNames.Change] = function (request) { _this.change(request.arguments); return _this.notRequired(); }, - _a[server.CommandNames.Configure] = function (request) { + _a[CommandNames.Configure] = function (request) { _this.projectService.setHostConfiguration(request.arguments); - _this.output(undefined, server.CommandNames.Configure, request.seq); + _this.output(undefined, CommandNames.Configure, request.seq); return _this.notRequired(); }, - _a[server.CommandNames.Reload] = function (request) { + _a[CommandNames.Reload] = function (request) { _this.reload(request.arguments, request.seq); return _this.requiredResponse({ reloadFinished: true }); }, - _a[server.CommandNames.Saveto] = function (request) { + _a[CommandNames.Saveto] = function (request) { var savetoArgs = request.arguments; _this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile); return _this.notRequired(); }, - _a[server.CommandNames.Close] = function (request) { + _a[CommandNames.Close] = function (request) { var closeArgs = request.arguments; _this.closeClientFile(closeArgs.file); return _this.notRequired(); }, - _a[server.CommandNames.Navto] = function (request) { + _a[CommandNames.Navto] = function (request) { return _this.requiredResponse(_this.getNavigateToItems(request.arguments, true)); }, - _a[server.CommandNames.NavtoFull] = function (request) { + _a[CommandNames.NavtoFull] = function (request) { return _this.requiredResponse(_this.getNavigateToItems(request.arguments, false)); }, - _a[server.CommandNames.Brace] = function (request) { + _a[CommandNames.Brace] = function (request) { return _this.requiredResponse(_this.getBraceMatching(request.arguments, true)); }, - _a[server.CommandNames.BraceFull] = function (request) { + _a[CommandNames.BraceFull] = function (request) { return _this.requiredResponse(_this.getBraceMatching(request.arguments, false)); }, - _a[server.CommandNames.NavBar] = function (request) { + _a[CommandNames.NavBar] = function (request) { return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, true)); }, - _a[server.CommandNames.NavBarFull] = function (request) { + _a[CommandNames.NavBarFull] = function (request) { return _this.requiredResponse(_this.getNavigationBarItems(request.arguments, false)); }, - _a[server.CommandNames.NavTree] = function (request) { + _a[CommandNames.NavTree] = function (request) { return _this.requiredResponse(_this.getNavigationTree(request.arguments, true)); }, - _a[server.CommandNames.NavTreeFull] = function (request) { + _a[CommandNames.NavTreeFull] = function (request) { return _this.requiredResponse(_this.getNavigationTree(request.arguments, false)); }, - _a[server.CommandNames.Occurrences] = function (request) { + _a[CommandNames.Occurrences] = function (request) { return _this.requiredResponse(_this.getOccurrences(request.arguments)); }, - _a[server.CommandNames.DocumentHighlights] = function (request) { + _a[CommandNames.DocumentHighlights] = function (request) { return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, true)); }, - _a[server.CommandNames.DocumentHighlightsFull] = function (request) { + _a[CommandNames.DocumentHighlightsFull] = function (request) { return _this.requiredResponse(_this.getDocumentHighlights(request.arguments, false)); }, - _a[server.CommandNames.CompilerOptionsForInferredProjects] = function (request) { + _a[CommandNames.CompilerOptionsForInferredProjects] = function (request) { _this.setCompilerOptionsForInferredProjects(request.arguments); return _this.requiredResponse(true); }, - _a[server.CommandNames.ProjectInfo] = function (request) { + _a[CommandNames.ProjectInfo] = function (request) { return _this.requiredResponse(_this.getProjectInfo(request.arguments)); }, - _a[server.CommandNames.ReloadProjects] = function () { + _a[CommandNames.ReloadProjects] = function () { _this.projectService.reloadProjects(); return _this.notRequired(); }, - _a[server.CommandNames.GetCodeFixes] = function (request) { + _a[CommandNames.GetCodeFixes] = function (request) { return _this.requiredResponse(_this.getCodeFixes(request.arguments, true)); }, - _a[server.CommandNames.GetCodeFixesFull] = function (request) { + _a[CommandNames.GetCodeFixesFull] = function (request) { return _this.requiredResponse(_this.getCodeFixes(request.arguments, false)); }, - _a[server.CommandNames.GetSupportedCodeFixes] = function () { + _a[CommandNames.GetSupportedCodeFixes] = function () { return _this.requiredResponse(_this.getSupportedCodeFixes()); }, - _a[server.CommandNames.GetApplicableRefactors] = function (request) { + _a[CommandNames.GetApplicableRefactors] = function (request) { return _this.requiredResponse(_this.getApplicableRefactors(request.arguments)); }, - _a[server.CommandNames.GetEditsForRefactor] = function (request) { + _a[CommandNames.GetEditsForRefactor] = function (request) { return _this.requiredResponse(_this.getEditsForRefactor(request.arguments, true)); }, - _a[server.CommandNames.GetEditsForRefactorFull] = function (request) { + _a[CommandNames.GetEditsForRefactorFull] = function (request) { return _this.requiredResponse(_this.getEditsForRefactor(request.arguments, false)); }, _a)); @@ -76560,7 +76530,7 @@ var ts; if (project) { this.changeSeq++; if (project.reloadScript(file, tempFileName)) { - this.output(undefined, server.CommandNames.Reload, reqSeq); + this.output(undefined, CommandNames.Reload, reqSeq); } } }; @@ -76901,7 +76871,7 @@ var ts; } else { this.logger.msg("Unrecognized JSON command: " + JSON.stringify(request), server.Msg.Err); - this.output(undefined, server.CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); + this.output(undefined, CommandNames.Unknown, request.seq, "Unrecognized JSON command: " + request.command); return { responseRequired: false }; } }; @@ -76940,7 +76910,7 @@ var ts; return; } this.logError(err, message); - this.output(undefined, request ? request.command : server.CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message + "\n" + err.stack); + this.output(undefined, request ? request.command : CommandNames.Unknown, request ? request.seq : 0, "Error processing request. " + err.message + "\n" + err.stack); } }; return Session; @@ -81408,7 +81378,7 @@ var ts; var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (result.resolvedModule && result.resolvedModule.extension !== ".ts" && result.resolvedModule.extension !== ".tsx" && result.resolvedModule.extension !== ".d.ts") { + if (result.resolvedModule && result.resolvedModule.extension !== ts.Extension.Ts && result.resolvedModule.extension !== ts.Extension.Tsx && result.resolvedModule.extension !== ts.Extension.Dts) { resolvedFileName = undefined; } return { diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index fb5346c28aa0c..9dc499c288230 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -2333,11 +2333,12 @@ declare namespace ts { extension: Extension; } enum Extension { - Ts = ".ts", - Tsx = ".tsx", - Dts = ".d.ts", - Js = ".js", - Jsx = ".jsx", + Ts = 0, + Tsx = 1, + Dts = 2, + Js = 3, + Jsx = 4, + LastTypeScriptExtension = 2, } interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; @@ -3756,7 +3757,7 @@ declare namespace ts { } interface ClassifiedSpan { textSpan: TextSpan; - classificationType: ClassificationTypeNames; + classificationType: string; } /** * Navigation bar interface designed for visual studio's dual-column layout. @@ -3766,7 +3767,7 @@ declare namespace ts { */ interface NavigationBarItem { text: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; spans: TextSpan[]; childItems: NavigationBarItem[]; @@ -3781,7 +3782,8 @@ declare namespace ts { interface NavigationTree { /** Name of the declaration, or a short description, e.g. "". */ text: string; - kind: ScriptElementKind; + /** A ScriptElementKind */ + kind: string; /** ScriptElementKindModifier separated by commas, e.g. "public,abstract" */ kindModifiers: string; /** @@ -3880,35 +3882,35 @@ declare namespace ts { isInString?: true; } interface ImplementationLocation extends DocumentSpan { - kind: ScriptElementKind; + kind: string; displayParts: SymbolDisplayPart[]; } interface DocumentHighlights { fileName: string; highlightSpans: HighlightSpan[]; } - enum HighlightSpanKind { - none = "none", - definition = "definition", - reference = "reference", - writtenReference = "writtenReference", + namespace HighlightSpanKind { + const none = "none"; + const definition = "definition"; + const reference = "reference"; + const writtenReference = "writtenReference"; } interface HighlightSpan { fileName?: string; isInString?: true; textSpan: TextSpan; - kind: HighlightSpanKind; + kind: string; } interface NavigateToItem { name: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; matchKind: string; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; containerName: string; - containerKind: ScriptElementKind; + containerKind: string; } enum IndentStyle { None = 0, @@ -3968,9 +3970,9 @@ declare namespace ts { interface DefinitionInfo { fileName: string; textSpan: TextSpan; - kind: ScriptElementKind; + kind: string; name: string; - containerKind: ScriptElementKind; + containerKind: string; containerName: string; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -4013,7 +4015,7 @@ declare namespace ts { text?: string; } interface QuickInfo { - kind: ScriptElementKind; + kind: string; kindModifiers: string; textSpan: TextSpan; displayParts: SymbolDisplayPart[]; @@ -4025,7 +4027,7 @@ declare namespace ts { localizedErrorMessage: string; displayName: string; fullDisplayName: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; triggerSpan: TextSpan; } @@ -4072,7 +4074,7 @@ declare namespace ts { } interface CompletionEntry { name: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; sortText: string; /** @@ -4084,7 +4086,7 @@ declare namespace ts { } interface CompletionEntryDetails { name: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; @@ -4169,107 +4171,107 @@ declare namespace ts { getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; } - enum ScriptElementKind { - unknown = "", - warning = "warning", + namespace ScriptElementKind { + const unknown = ""; + const warning = "warning"; /** predefined type (void) or keyword (class) */ - keyword = "keyword", + const keyword = "keyword"; /** top level script node */ - scriptElement = "script", + const scriptElement = "script"; /** module foo {} */ - moduleElement = "module", + const moduleElement = "module"; /** class X {} */ - classElement = "class", + const classElement = "class"; /** var x = class X {} */ - localClassElement = "local class", + const localClassElement = "local class"; /** interface Y {} */ - interfaceElement = "interface", + const interfaceElement = "interface"; /** type T = ... */ - typeElement = "type", + const typeElement = "type"; /** enum E */ - enumElement = "enum", - enumMemberElement = "enum member", + const enumElement = "enum"; + const enumMemberElement = "enum member"; /** * Inside module and script only * const v = .. */ - variableElement = "var", + const variableElement = "var"; /** Inside function */ - localVariableElement = "local var", + const localVariableElement = "local var"; /** * Inside module and script only * function f() { } */ - functionElement = "function", + const functionElement = "function"; /** Inside function */ - localFunctionElement = "local function", + const localFunctionElement = "local function"; /** class X { [public|private]* foo() {} } */ - memberFunctionElement = "method", + const memberFunctionElement = "method"; /** class X { [public|private]* [get|set] foo:number; } */ - memberGetAccessorElement = "getter", - memberSetAccessorElement = "setter", + const memberGetAccessorElement = "getter"; + const memberSetAccessorElement = "setter"; /** * class X { [public|private]* foo:number; } * interface Y { foo:number; } */ - memberVariableElement = "property", + const memberVariableElement = "property"; /** class X { constructor() { } } */ - constructorImplementationElement = "constructor", + const constructorImplementationElement = "constructor"; /** interface Y { ():number; } */ - callSignatureElement = "call", + const callSignatureElement = "call"; /** interface Y { []:number; } */ - indexSignatureElement = "index", + const indexSignatureElement = "index"; /** interface Y { new():Y; } */ - constructSignatureElement = "construct", + const constructSignatureElement = "construct"; /** function foo(*Y*: string) */ - parameterElement = "parameter", - typeParameterElement = "type parameter", - primitiveType = "primitive type", - label = "label", - alias = "alias", - constElement = "const", - letElement = "let", - directory = "directory", - externalModuleName = "external module name", + const parameterElement = "parameter"; + const typeParameterElement = "type parameter"; + const primitiveType = "primitive type"; + const label = "label"; + const alias = "alias"; + const constElement = "const"; + const letElement = "let"; + const directory = "directory"; + const externalModuleName = "external module name"; /** * */ - jsxAttribute = "JSX attribute", - } - enum ScriptElementKindModifier { - none = "", - publicMemberModifier = "public", - privateMemberModifier = "private", - protectedMemberModifier = "protected", - exportedModifier = "export", - ambientModifier = "declare", - staticModifier = "static", - abstractModifier = "abstract", - } - enum ClassificationTypeNames { - comment = "comment", - identifier = "identifier", - keyword = "keyword", - numericLiteral = "number", - operator = "operator", - stringLiteral = "string", - whiteSpace = "whitespace", - text = "text", - punctuation = "punctuation", - className = "class name", - enumName = "enum name", - interfaceName = "interface name", - moduleName = "module name", - typeParameterName = "type parameter name", - typeAliasName = "type alias name", - parameterName = "parameter name", - docCommentTagName = "doc comment tag name", - jsxOpenTagName = "jsx open tag name", - jsxCloseTagName = "jsx close tag name", - jsxSelfClosingTagName = "jsx self closing tag name", - jsxAttribute = "jsx attribute", - jsxText = "jsx text", - jsxAttributeStringLiteralValue = "jsx attribute string literal value", + const jsxAttribute = "JSX attribute"; + } + namespace ScriptElementKindModifier { + const none = ""; + const publicMemberModifier = "public"; + const privateMemberModifier = "private"; + const protectedMemberModifier = "protected"; + const exportedModifier = "export"; + const ambientModifier = "declare"; + const staticModifier = "static"; + const abstractModifier = "abstract"; + } + class ClassificationTypeNames { + static comment: string; + static identifier: string; + static keyword: string; + static numericLiteral: string; + static operator: string; + static stringLiteral: string; + static whiteSpace: string; + static text: string; + static punctuation: string; + static className: string; + static enumName: string; + static interfaceName: string; + static moduleName: string; + static typeParameterName: string; + static typeAliasName: string; + static parameterName: string; + static docCommentTagName: string; + static jsxOpenTagName: string; + static jsxCloseTagName: string; + static jsxSelfClosingTagName: string; + static jsxAttribute: string; + static jsxText: string; + static jsxAttributeStringLiteralValue: string; } enum ClassificationType { comment = 1, diff --git a/lib/typescript.js b/lib/typescript.js index 184425351e6b2..b7487aeaa4496 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -1064,11 +1064,12 @@ var ts; })(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {})); var Extension; (function (Extension) { - Extension["Ts"] = ".ts"; - Extension["Tsx"] = ".tsx"; - Extension["Dts"] = ".d.ts"; - Extension["Js"] = ".js"; - Extension["Jsx"] = ".jsx"; + Extension[Extension["Ts"] = 0] = "Ts"; + Extension[Extension["Tsx"] = 1] = "Tsx"; + Extension[Extension["Dts"] = 2] = "Dts"; + Extension[Extension["Js"] = 3] = "Js"; + Extension[Extension["Jsx"] = 4] = "Jsx"; + Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; })(Extension = ts.Extension || (ts.Extension = {})); /* @internal */ var TransformFlags; @@ -3291,13 +3292,13 @@ var ts; function getScriptKindFromFileName(fileName) { var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case ".js" /* Js */: + case ".js": return 1 /* JS */; - case ".jsx" /* Jsx */: + case ".jsx": return 2 /* JSX */; - case ".ts" /* Ts */: + case ".ts": return 3 /* TS */; - case ".tsx" /* Tsx */: + case ".tsx": return 4 /* TSX */; default: return 0 /* Unknown */; @@ -3307,10 +3308,10 @@ var ts; /** * List of supported extensions in order of file resolution precedence. */ - ts.supportedTypeScriptExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */]; + ts.supportedTypeScriptExtensions = [".ts", ".tsx", ".d.ts"]; /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - ts.supportedTypescriptExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; - ts.supportedJavascriptExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; + ts.supportedTypescriptExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"]; + ts.supportedJavascriptExtensions = [".js", ".jsx"]; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; @@ -3398,7 +3399,7 @@ var ts; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; - var extensionsToRemove = [".d.ts" /* Dts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */]; + var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -3635,7 +3636,7 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTypeScript(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */; + return ext <= ts.Extension.LastTypeScriptExtension; } ts.extensionIsTypeScript = extensionIsTypeScript; /** @@ -3651,7 +3652,21 @@ var ts; } ts.extensionFromPath = extensionFromPath; function tryGetExtensionFromPath(path) { - return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); }); + if (fileExtensionIs(path, ".d.ts")) { + return ts.Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return ts.Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return ts.Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return ts.Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return ts.Extension.Jsx; + } } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; function isCheckJsEnabledForFile(sourceFile, compilerOptions) { @@ -9122,7 +9137,7 @@ var ts; var path = outputDir ? getSourceFilePathInNewDir(sourceFile, host, outputDir) : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts" /* Dts */; + return ts.removeFileExtension(path) + ".d.ts"; } ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; /** @@ -9172,7 +9187,7 @@ var ts; if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : ""; + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : ""; action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); } } @@ -9196,16 +9211,16 @@ var ts; function getOutputExtension(sourceFile, options) { if (options.jsx === 1 /* Preserve */) { if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx" /* Jsx */)) { - return ".jsx" /* Jsx */; + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; } } else if (sourceFile.languageVariant === 1 /* JSX */) { // TypeScript source file preserving JSX syntax - return ".jsx" /* Jsx */; + return ".jsx"; } } - return ".js" /* Js */; + return ".js"; } function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); @@ -16629,7 +16644,7 @@ var ts; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); sourceFile.languageVariant = getLanguageVariant(scriptKind); - sourceFile.isDeclarationFile = ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + sourceFile.isDeclarationFile = ts.fileExtensionIs(sourceFile.fileName, ".d.ts"); sourceFile.scriptKind = scriptKind; return sourceFile; } @@ -26420,14 +26435,14 @@ var ts; } switch (extensions) { case Extensions.DtsOnly: - return tryExtension(".d.ts" /* Dts */); + return tryExtension(".d.ts", ts.Extension.Dts); case Extensions.TypeScript: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); case Extensions.JavaScript: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } - function tryExtension(extension) { - var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); return path && { path: path, extension: extension }; } } @@ -26503,11 +26518,11 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */; + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; case Extensions.TypeScript: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */; + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; case Extensions.DtsOnly: - return extension === ".d.ts" /* Dts */; + return extension === ts.Extension.Dts; } } function pathToPackageJson(directory) { @@ -70162,7 +70177,7 @@ var ts; } var sourceFileWithAddedExtension = ts.forEach(supportedExtensions, function (extension) { return getSourceFile(fileName + extension); }); if (fail && !sourceFileWithAddedExtension) - fail(ts.Diagnostics.File_0_not_found, fileName + ".ts" /* Ts */); + fail(ts.Diagnostics.File_0_not_found, fileName + ".ts"); return sourceFileWithAddedExtension; } } @@ -70595,15 +70610,15 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: + case ts.Extension.Ts: + case ts.Extension.Dts: // These are always allowed. return undefined; - case ".tsx" /* Tsx */: + case ts.Extension.Tsx: return needJsx(); - case ".jsx" /* Jsx */: + case ts.Extension.Jsx: return needJsx() || needAllowJs(); - case ".js" /* Js */: + case ts.Extension.Js: return needAllowJs(); } function needJsx() { @@ -72286,10 +72301,10 @@ var ts; ts.TextChange = TextChange; var HighlightSpanKind; (function (HighlightSpanKind) { - HighlightSpanKind["none"] = "none"; - HighlightSpanKind["definition"] = "definition"; - HighlightSpanKind["reference"] = "reference"; - HighlightSpanKind["writtenReference"] = "writtenReference"; + HighlightSpanKind.none = "none"; + HighlightSpanKind.definition = "definition"; + HighlightSpanKind.reference = "reference"; + HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); var IndentStyle; (function (IndentStyle) { @@ -72350,111 +72365,115 @@ var ts; TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; })(TokenClass = ts.TokenClass || (ts.TokenClass = {})); + // TODO: move these to enums var ScriptElementKind; (function (ScriptElementKind) { - ScriptElementKind["unknown"] = ""; - ScriptElementKind["warning"] = "warning"; + ScriptElementKind.unknown = ""; + ScriptElementKind.warning = "warning"; /** predefined type (void) or keyword (class) */ - ScriptElementKind["keyword"] = "keyword"; + ScriptElementKind.keyword = "keyword"; /** top level script node */ - ScriptElementKind["scriptElement"] = "script"; + ScriptElementKind.scriptElement = "script"; /** module foo {} */ - ScriptElementKind["moduleElement"] = "module"; + ScriptElementKind.moduleElement = "module"; /** class X {} */ - ScriptElementKind["classElement"] = "class"; + ScriptElementKind.classElement = "class"; /** var x = class X {} */ - ScriptElementKind["localClassElement"] = "local class"; + ScriptElementKind.localClassElement = "local class"; /** interface Y {} */ - ScriptElementKind["interfaceElement"] = "interface"; + ScriptElementKind.interfaceElement = "interface"; /** type T = ... */ - ScriptElementKind["typeElement"] = "type"; + ScriptElementKind.typeElement = "type"; /** enum E */ - ScriptElementKind["enumElement"] = "enum"; - ScriptElementKind["enumMemberElement"] = "enum member"; + ScriptElementKind.enumElement = "enum"; + ScriptElementKind.enumMemberElement = "enum member"; /** * Inside module and script only * const v = .. */ - ScriptElementKind["variableElement"] = "var"; + ScriptElementKind.variableElement = "var"; /** Inside function */ - ScriptElementKind["localVariableElement"] = "local var"; + ScriptElementKind.localVariableElement = "local var"; /** * Inside module and script only * function f() { } */ - ScriptElementKind["functionElement"] = "function"; + ScriptElementKind.functionElement = "function"; /** Inside function */ - ScriptElementKind["localFunctionElement"] = "local function"; + ScriptElementKind.localFunctionElement = "local function"; /** class X { [public|private]* foo() {} } */ - ScriptElementKind["memberFunctionElement"] = "method"; + ScriptElementKind.memberFunctionElement = "method"; /** class X { [public|private]* [get|set] foo:number; } */ - ScriptElementKind["memberGetAccessorElement"] = "getter"; - ScriptElementKind["memberSetAccessorElement"] = "setter"; + ScriptElementKind.memberGetAccessorElement = "getter"; + ScriptElementKind.memberSetAccessorElement = "setter"; /** * class X { [public|private]* foo:number; } * interface Y { foo:number; } */ - ScriptElementKind["memberVariableElement"] = "property"; + ScriptElementKind.memberVariableElement = "property"; /** class X { constructor() { } } */ - ScriptElementKind["constructorImplementationElement"] = "constructor"; + ScriptElementKind.constructorImplementationElement = "constructor"; /** interface Y { ():number; } */ - ScriptElementKind["callSignatureElement"] = "call"; + ScriptElementKind.callSignatureElement = "call"; /** interface Y { []:number; } */ - ScriptElementKind["indexSignatureElement"] = "index"; + ScriptElementKind.indexSignatureElement = "index"; /** interface Y { new():Y; } */ - ScriptElementKind["constructSignatureElement"] = "construct"; + ScriptElementKind.constructSignatureElement = "construct"; /** function foo(*Y*: string) */ - ScriptElementKind["parameterElement"] = "parameter"; - ScriptElementKind["typeParameterElement"] = "type parameter"; - ScriptElementKind["primitiveType"] = "primitive type"; - ScriptElementKind["label"] = "label"; - ScriptElementKind["alias"] = "alias"; - ScriptElementKind["constElement"] = "const"; - ScriptElementKind["letElement"] = "let"; - ScriptElementKind["directory"] = "directory"; - ScriptElementKind["externalModuleName"] = "external module name"; + ScriptElementKind.parameterElement = "parameter"; + ScriptElementKind.typeParameterElement = "type parameter"; + ScriptElementKind.primitiveType = "primitive type"; + ScriptElementKind.label = "label"; + ScriptElementKind.alias = "alias"; + ScriptElementKind.constElement = "const"; + ScriptElementKind.letElement = "let"; + ScriptElementKind.directory = "directory"; + ScriptElementKind.externalModuleName = "external module name"; /** * */ - ScriptElementKind["jsxAttribute"] = "JSX attribute"; + ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { - ScriptElementKindModifier["none"] = ""; - ScriptElementKindModifier["publicMemberModifier"] = "public"; - ScriptElementKindModifier["privateMemberModifier"] = "private"; - ScriptElementKindModifier["protectedMemberModifier"] = "protected"; - ScriptElementKindModifier["exportedModifier"] = "export"; - ScriptElementKindModifier["ambientModifier"] = "declare"; - ScriptElementKindModifier["staticModifier"] = "static"; - ScriptElementKindModifier["abstractModifier"] = "abstract"; + ScriptElementKindModifier.none = ""; + ScriptElementKindModifier.publicMemberModifier = "public"; + ScriptElementKindModifier.privateMemberModifier = "private"; + ScriptElementKindModifier.protectedMemberModifier = "protected"; + ScriptElementKindModifier.exportedModifier = "export"; + ScriptElementKindModifier.ambientModifier = "declare"; + ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); - var ClassificationTypeNames; - (function (ClassificationTypeNames) { - ClassificationTypeNames["comment"] = "comment"; - ClassificationTypeNames["identifier"] = "identifier"; - ClassificationTypeNames["keyword"] = "keyword"; - ClassificationTypeNames["numericLiteral"] = "number"; - ClassificationTypeNames["operator"] = "operator"; - ClassificationTypeNames["stringLiteral"] = "string"; - ClassificationTypeNames["whiteSpace"] = "whitespace"; - ClassificationTypeNames["text"] = "text"; - ClassificationTypeNames["punctuation"] = "punctuation"; - ClassificationTypeNames["className"] = "class name"; - ClassificationTypeNames["enumName"] = "enum name"; - ClassificationTypeNames["interfaceName"] = "interface name"; - ClassificationTypeNames["moduleName"] = "module name"; - ClassificationTypeNames["typeParameterName"] = "type parameter name"; - ClassificationTypeNames["typeAliasName"] = "type alias name"; - ClassificationTypeNames["parameterName"] = "parameter name"; - ClassificationTypeNames["docCommentTagName"] = "doc comment tag name"; - ClassificationTypeNames["jsxOpenTagName"] = "jsx open tag name"; - ClassificationTypeNames["jsxCloseTagName"] = "jsx close tag name"; - ClassificationTypeNames["jsxSelfClosingTagName"] = "jsx self closing tag name"; - ClassificationTypeNames["jsxAttribute"] = "jsx attribute"; - ClassificationTypeNames["jsxText"] = "jsx text"; - ClassificationTypeNames["jsxAttributeStringLiteralValue"] = "jsx attribute string literal value"; - })(ClassificationTypeNames = ts.ClassificationTypeNames || (ts.ClassificationTypeNames = {})); + var ClassificationTypeNames = (function () { + function ClassificationTypeNames() { + } + ClassificationTypeNames.comment = "comment"; + ClassificationTypeNames.identifier = "identifier"; + ClassificationTypeNames.keyword = "keyword"; + ClassificationTypeNames.numericLiteral = "number"; + ClassificationTypeNames.operator = "operator"; + ClassificationTypeNames.stringLiteral = "string"; + ClassificationTypeNames.whiteSpace = "whitespace"; + ClassificationTypeNames.text = "text"; + ClassificationTypeNames.punctuation = "punctuation"; + ClassificationTypeNames.className = "class name"; + ClassificationTypeNames.enumName = "enum name"; + ClassificationTypeNames.interfaceName = "interface name"; + ClassificationTypeNames.moduleName = "module name"; + ClassificationTypeNames.typeParameterName = "type parameter name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; + ClassificationTypeNames.docCommentTagName = "doc comment tag name"; + ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; + ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; + ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; + ClassificationTypeNames.jsxAttribute = "jsx attribute"; + ClassificationTypeNames.jsxText = "jsx text"; + ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; + return ClassificationTypeNames; + }()); + ts.ClassificationTypeNames = ClassificationTypeNames; var ClassificationType; (function (ClassificationType) { ClassificationType[ClassificationType["comment"] = 1] = "comment"; @@ -72760,15 +72779,15 @@ var ts; function getNodeKind(node) { switch (node.kind) { case 265 /* SourceFile */: - return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; + return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; case 233 /* ModuleDeclaration */: - return "module" /* moduleElement */; + return ts.ScriptElementKind.moduleElement; case 229 /* ClassDeclaration */: case 199 /* ClassExpression */: - return "class" /* classElement */; - case 230 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 231 /* TypeAliasDeclaration */: return "type" /* typeElement */; - case 232 /* EnumDeclaration */: return "enum" /* enumElement */; + return ts.ScriptElementKind.classElement; + case 230 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 231 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 232 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; case 226 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); case 176 /* BindingElement */: @@ -72776,39 +72795,39 @@ var ts; case 187 /* ArrowFunction */: case 228 /* FunctionDeclaration */: case 186 /* FunctionExpression */: - return "function" /* functionElement */; - case 153 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 154 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + return ts.ScriptElementKind.functionElement; + case 153 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 154 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; case 151 /* MethodDeclaration */: case 150 /* MethodSignature */: - return "method" /* memberFunctionElement */; + return ts.ScriptElementKind.memberFunctionElement; case 149 /* PropertyDeclaration */: case 148 /* PropertySignature */: - return "property" /* memberVariableElement */; - case 157 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 156 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 155 /* CallSignature */: return "call" /* callSignatureElement */; - case 152 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 145 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 264 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 146 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + return ts.ScriptElementKind.memberVariableElement; + case 157 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 156 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 155 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 152 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 145 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 264 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 146 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; case 237 /* ImportEqualsDeclaration */: case 242 /* ImportSpecifier */: case 239 /* ImportClause */: case 246 /* ExportSpecifier */: case 240 /* NamespaceImport */: - return "alias" /* alias */; + return ts.ScriptElementKind.alias; case 291 /* JSDocTypedefTag */: - return "type" /* typeElement */; + return ts.ScriptElementKind.typeElement; default: - return "" /* unknown */; + return ts.ScriptElementKind.unknown; } function getKindOfVariableDeclaration(v) { return ts.isConst(v) - ? "const" /* constElement */ + ? ts.ScriptElementKind.constElement : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? ts.ScriptElementKind.letElement + : ts.ScriptElementKind.variableElement; } } ts.getNodeKind = getNodeKind; @@ -73311,20 +73330,20 @@ var ts; var flags = ts.getCombinedModifierFlags(node); var result = []; if (flags & 8 /* Private */) - result.push("private" /* privateMemberModifier */); + result.push(ts.ScriptElementKindModifier.privateMemberModifier); if (flags & 16 /* Protected */) - result.push("protected" /* protectedMemberModifier */); + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); if (flags & 4 /* Public */) - result.push("public" /* publicMemberModifier */); + result.push(ts.ScriptElementKindModifier.publicMemberModifier); if (flags & 32 /* Static */) - result.push("static" /* staticModifier */); + result.push(ts.ScriptElementKindModifier.staticModifier); if (flags & 128 /* Abstract */) - result.push("abstract" /* abstractModifier */); + result.push(ts.ScriptElementKindModifier.abstractModifier); if (flags & 1 /* Export */) - result.push("export" /* exportedModifier */); + result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) - result.push("declare" /* ambientModifier */); - return result.length > 0 ? result.join(",") : "" /* none */; + result.push(ts.ScriptElementKindModifier.ambientModifier); + return result.length > 0 ? result.join(",") : ts.ScriptElementKindModifier.none; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { @@ -74281,29 +74300,29 @@ var ts; ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function getClassificationTypeName(type) { switch (type) { - case 1 /* comment */: return "comment" /* comment */; - case 2 /* identifier */: return "identifier" /* identifier */; - case 3 /* keyword */: return "keyword" /* keyword */; - case 4 /* numericLiteral */: return "number" /* numericLiteral */; - case 5 /* operator */: return "operator" /* operator */; - case 6 /* stringLiteral */: return "string" /* stringLiteral */; - case 8 /* whiteSpace */: return "whitespace" /* whiteSpace */; - case 9 /* text */: return "text" /* text */; - case 10 /* punctuation */: return "punctuation" /* punctuation */; - case 11 /* className */: return "class name" /* className */; - case 12 /* enumName */: return "enum name" /* enumName */; - case 13 /* interfaceName */: return "interface name" /* interfaceName */; - case 14 /* moduleName */: return "module name" /* moduleName */; - case 15 /* typeParameterName */: return "type parameter name" /* typeParameterName */; - case 16 /* typeAliasName */: return "type alias name" /* typeAliasName */; - case 17 /* parameterName */: return "parameter name" /* parameterName */; - case 18 /* docCommentTagName */: return "doc comment tag name" /* docCommentTagName */; - case 19 /* jsxOpenTagName */: return "jsx open tag name" /* jsxOpenTagName */; - case 20 /* jsxCloseTagName */: return "jsx close tag name" /* jsxCloseTagName */; - case 21 /* jsxSelfClosingTagName */: return "jsx self closing tag name" /* jsxSelfClosingTagName */; - case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; - case 23 /* jsxText */: return "jsx text" /* jsxText */; - case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + case 1 /* comment */: return ts.ClassificationTypeNames.comment; + case 2 /* identifier */: return ts.ClassificationTypeNames.identifier; + case 3 /* keyword */: return ts.ClassificationTypeNames.keyword; + case 4 /* numericLiteral */: return ts.ClassificationTypeNames.numericLiteral; + case 5 /* operator */: return ts.ClassificationTypeNames.operator; + case 6 /* stringLiteral */: return ts.ClassificationTypeNames.stringLiteral; + case 8 /* whiteSpace */: return ts.ClassificationTypeNames.whiteSpace; + case 9 /* text */: return ts.ClassificationTypeNames.text; + case 10 /* punctuation */: return ts.ClassificationTypeNames.punctuation; + case 11 /* className */: return ts.ClassificationTypeNames.className; + case 12 /* enumName */: return ts.ClassificationTypeNames.enumName; + case 13 /* interfaceName */: return ts.ClassificationTypeNames.interfaceName; + case 14 /* moduleName */: return ts.ClassificationTypeNames.moduleName; + case 15 /* typeParameterName */: return ts.ClassificationTypeNames.typeParameterName; + case 16 /* typeAliasName */: return ts.ClassificationTypeNames.typeAliasName; + case 17 /* parameterName */: return ts.ClassificationTypeNames.parameterName; + case 18 /* docCommentTagName */: return ts.ClassificationTypeNames.docCommentTagName; + case 19 /* jsxOpenTagName */: return ts.ClassificationTypeNames.jsxOpenTagName; + case 20 /* jsxCloseTagName */: return ts.ClassificationTypeNames.jsxCloseTagName; + case 21 /* jsxSelfClosingTagName */: return ts.ClassificationTypeNames.jsxSelfClosingTagName; + case 22 /* jsxAttribute */: return ts.ClassificationTypeNames.jsxAttribute; + case 23 /* jsxText */: return ts.ClassificationTypeNames.jsxText; + case 24 /* jsxAttributeStringLiteralValue */: return ts.ClassificationTypeNames.jsxAttributeStringLiteralValue; } } function convertClassifications(classifications) { @@ -74750,7 +74769,7 @@ var ts; } } ts.forEachKey(foundFiles, function (foundFile) { - result.push(createCompletionEntryForModule(foundFile, "script" /* scriptElement */, span)); + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); }); } // If possible, get folder completion as well @@ -74759,7 +74778,7 @@ var ts; for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { var directory = directories_2[_a]; var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, "directory" /* directory */, span)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); } } } @@ -74789,7 +74808,7 @@ var ts; var pattern = _a[_i]; for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { var match = _c[_b]; - result.push(createCompletionEntryForModule(match, "external module name" /* externalModuleName */, span)); + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); } } } @@ -74797,7 +74816,7 @@ var ts; else if (ts.startsWith(path, fragment)) { var entry = paths[path] && paths[path].length === 1 && paths[path][0]; if (entry) { - result.push(createCompletionEntryForModule(path, "external module name" /* externalModuleName */, span)); + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); } } } @@ -74810,7 +74829,7 @@ var ts; getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, "external module name" /* externalModuleName */, span)); + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); } return result; } @@ -74943,7 +74962,7 @@ var ts; if (options.types) { for (var _i = 0, _a = options.types; _i < _a.length; _i++) { var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, "external module name" /* externalModuleName */, span)); + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); } } else if (host.getDirectories) { @@ -74977,7 +74996,7 @@ var ts; for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { var typeDirectory = directories_3[_i]; typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), "external module name" /* externalModuleName */, span)); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); } } } @@ -75049,7 +75068,7 @@ var ts; } } function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: "" /* none */, sortText: name, replacementSpan: replacementSpan }; + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; } // Replace everything after the last directory seperator that appears function getDirectoryFragmentTextSpan(text, textStart) { @@ -75144,7 +75163,7 @@ var ts; return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, entries: [{ name: tagName.getFullText(), - kind: "class" /* classElement */, + kind: ts.ScriptElementKind.classElement, kindModifiers: undefined, sortText: "0", }] }; @@ -75193,7 +75212,7 @@ var ts; if (displayName) { var entry = { name: displayName, - kind: "warning" /* warning */, + kind: ts.ScriptElementKind.warning, kindModifiers: "", sortText: "1" }; @@ -75372,8 +75391,8 @@ var ts; uniques.set(name, true); result.push({ name: name, - kindModifiers: "" /* none */, - kind: "var" /* variableElement */, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, sortText: "0" }); } @@ -75406,8 +75425,8 @@ var ts; if (keywordCompletion) { return { name: entryName, - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], documentation: undefined, tags: undefined @@ -76492,8 +76511,8 @@ var ts; for (var i = 72 /* FirstKeyword */; i <= 142 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, sortText: "0" }); } @@ -76584,7 +76603,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node, sourceFile), - kind: "none" /* none */ + kind: ts.HighlightSpanKind.none }; } function getSemanticDocumentHighlights(node, program, cancellationToken, sourceFilesToSearch) { @@ -77065,7 +77084,7 @@ var ts; result.push({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: "reference" /* reference */ + kind: ts.HighlightSpanKind.reference }); i++; // skip the next keyword continue; @@ -77854,22 +77873,22 @@ var ts; } case "label": { var node_3 = def.node; - return { node: node_3, name: node_3.text, kind: "label" /* label */, displayParts: [ts.displayPart(node_3.text, ts.SymbolDisplayPartKind.text)] }; + return { node: node_3, name: node_3.text, kind: ts.ScriptElementKind.label, displayParts: [ts.displayPart(node_3.text, ts.SymbolDisplayPartKind.text)] }; } case "keyword": { var node_4 = def.node; var name_4 = ts.tokenToString(node_4.kind); - return { node: node_4, name: name_4, kind: "keyword" /* keyword */, displayParts: [{ text: name_4, kind: "keyword" /* keyword */ }] }; + return { node: node_4, name: name_4, kind: ts.ScriptElementKind.keyword, displayParts: [{ text: name_4, kind: ts.ScriptElementKind.keyword }] }; } case "this": { var node_5 = def.node; var symbol = checker.getSymbolAtLocation(node_5); var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node_5.getSourceFile(), ts.getContainerNode(node_5), node_5).displayParts; - return { node: node_5, name: "this", kind: "var" /* variableElement */, displayParts: displayParts_2 }; + return { node: node_5, name: "this", kind: ts.ScriptElementKind.variableElement, displayParts: displayParts_2 }; } case "string": { var node_6 = def.node; - return { node: node_6, name: node_6.text, kind: "var" /* variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node_6), ts.SymbolDisplayPartKind.stringLiteral)] }; + return { node: node_6, name: node_6.text, kind: ts.ScriptElementKind.variableElement, displayParts: [ts.displayPart(ts.getTextOfNode(node_6), ts.SymbolDisplayPartKind.stringLiteral)] }; } } })(); @@ -77879,7 +77898,7 @@ var ts; var node = info.node, name = info.name, kind = info.kind, displayParts = info.displayParts; var sourceFile = node.getSourceFile(); return { - containerKind: "" /* unknown */, + containerKind: "", containerName: "", fileName: sourceFile.fileName, kind: kind, @@ -77912,7 +77931,7 @@ var ts; } else { var textSpan = entry.textSpan, fileName = entry.fileName; - return { textSpan: textSpan, fileName: fileName, kind: "" /* unknown */, displayParts: [] }; + return { textSpan: textSpan, fileName: fileName, kind: ts.ScriptElementKind.unknown, displayParts: [] }; } } function implementationKindDisplayParts(node, checker) { @@ -77922,13 +77941,13 @@ var ts; } else if (node.kind === 178 /* ObjectLiteralExpression */) { return { - kind: "interface" /* interfaceElement */, + kind: ts.ScriptElementKind.interfaceElement, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] }; } else if (node.kind === 199 /* ClassExpression */) { return { - kind: "local class" /* localClassElement */, + kind: ts.ScriptElementKind.localClassElement, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] }; } @@ -77939,14 +77958,14 @@ var ts; function toHighlightSpan(entry) { if (entry.type === "span") { var fileName_1 = entry.fileName, textSpan = entry.textSpan; - return { fileName: fileName_1, span: { textSpan: textSpan, kind: "reference" /* reference */ } }; + return { fileName: fileName_1, span: { textSpan: textSpan, kind: ts.HighlightSpanKind.reference } }; } var node = entry.node, isInString = entry.isInString; var fileName = entry.node.getSourceFile().fileName; var writeAccess = isWriteAccess(node); var span = { textSpan: getTextSpan(node), - kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, + kind: writeAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference, isInString: isInString }; return { fileName: fileName, span: span }; @@ -79310,7 +79329,7 @@ var ts; if (ts.isJumpStatementTarget(node)) { var labelName = node.text; var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(label, "label" /* label */, labelName, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ts.ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -79439,7 +79458,8 @@ var ts; for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; if (ts.isClassLike(declaration)) { - return tryAddSignature(declaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); } } ts.Debug.fail("Expected declaration to have at least one class-like declaration"); @@ -79525,7 +79545,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: "script" /* scriptElement */, + kind: ts.ScriptElementKind.scriptElement, name: name, containerName: undefined, containerKind: undefined @@ -79674,7 +79694,7 @@ var ts; return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: "keyword" /* keyword */, + kind: ts.ScriptElementKind.keyword, kindModifiers: "", sortText: "0", }; @@ -79685,7 +79705,7 @@ var ts; return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: "@" + tagName, - kind: "keyword" /* keyword */, + kind: ts.ScriptElementKind.keyword, kindModifiers: "", sortText: "0" }; @@ -79706,7 +79726,7 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: "0" }; + return { name: name, kind: ts.ScriptElementKind.parameterElement, kindModifiers: "", sortText: "0" }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; @@ -80065,7 +80085,7 @@ var ts; var rawItems = []; var _loop_5 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); - if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) { + if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { return "continue"; } ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { @@ -80235,7 +80255,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ + containerKind: containerName ? ts.getNodeKind(container) : "" }; } } @@ -81933,7 +81953,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } var displayName = ts.stripQuotes(node.text); - return getRenameInfoSuccess(displayName, displayName, "var" /* variableElement */, "" /* none */, node, sourceFile); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); } } function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { @@ -82425,70 +82445,70 @@ var ts; var flags = symbol.flags; if (flags & 32 /* Class */) { return ts.getDeclarationOfKind(symbol, 199 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; + ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; } if (flags & 384 /* Enum */) - return "enum" /* enumElement */; + return ts.ScriptElementKind.enumElement; if (flags & 524288 /* TypeAlias */) - return "type" /* typeElement */; + return ts.ScriptElementKind.typeElement; if (flags & 64 /* Interface */) - return "interface" /* interfaceElement */; + return ts.ScriptElementKind.interfaceElement; if (flags & 262144 /* TypeParameter */) - return "type parameter" /* typeParameterElement */; + return ts.ScriptElementKind.typeParameterElement; var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - if (result === "" /* unknown */) { + if (result === ts.ScriptElementKind.unknown) { if (flags & 262144 /* TypeParameter */) - return "type parameter" /* typeParameterElement */; + return ts.ScriptElementKind.typeParameterElement; if (flags & 8 /* EnumMember */) - return "enum member" /* enumMemberElement */; + return ts.ScriptElementKind.enumMemberElement; if (flags & 8388608 /* Alias */) - return "alias" /* alias */; + return ts.ScriptElementKind.alias; if (flags & 1536 /* Module */) - return "module" /* moduleElement */; + return ts.ScriptElementKind.moduleElement; } return result; } SymbolDisplay.getSymbolKind = getSymbolKind; function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) { if (typeChecker.isUndefinedSymbol(symbol)) { - return "var" /* variableElement */; + return ts.ScriptElementKind.variableElement; } if (typeChecker.isArgumentsSymbol(symbol)) { - return "local var" /* localVariableElement */; + return ts.ScriptElementKind.localVariableElement; } if (location.kind === 99 /* ThisKeyword */ && ts.isExpression(location)) { - return "parameter" /* parameterElement */; + return ts.ScriptElementKind.parameterElement; } var flags = symbol.flags; if (flags & 3 /* Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return "parameter" /* parameterElement */; + return ts.ScriptElementKind.parameterElement; } else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { - return "const" /* constElement */; + return ts.ScriptElementKind.constElement; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return "let" /* letElement */; + return ts.ScriptElementKind.letElement; } - return isLocalVariableOrFunction(symbol) ? "local var" /* localVariableElement */ : "var" /* variableElement */; + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localVariableElement : ts.ScriptElementKind.variableElement; } if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */; + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localFunctionElement : ts.ScriptElementKind.functionElement; if (flags & 32768 /* GetAccessor */) - return "getter" /* memberGetAccessorElement */; + return ts.ScriptElementKind.memberGetAccessorElement; if (flags & 65536 /* SetAccessor */) - return "setter" /* memberSetAccessorElement */; + return ts.ScriptElementKind.memberSetAccessorElement; if (flags & 8192 /* Method */) - return "method" /* memberFunctionElement */; + return ts.ScriptElementKind.memberFunctionElement; if (flags & 16384 /* Constructor */) - return "constructor" /* constructorImplementationElement */; + return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { if (flags & 134217728 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return "property" /* memberVariableElement */; + return ts.ScriptElementKind.memberVariableElement; } ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); }); @@ -82497,23 +82517,23 @@ var ts; // make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return "method" /* memberFunctionElement */; + return ts.ScriptElementKind.memberFunctionElement; } - return "property" /* memberVariableElement */; + return ts.ScriptElementKind.memberVariableElement; } return unionPropertyKind; } if (location.parent && ts.isJsxAttribute(location.parent)) { - return "JSX attribute" /* jsxAttribute */; + return ts.ScriptElementKind.jsxAttribute; } - return "property" /* memberVariableElement */; + return ts.ScriptElementKind.memberVariableElement; } - return "" /* unknown */; + return ts.ScriptElementKind.unknown; } function getSymbolModifiers(symbol) { return symbol && symbol.declarations && symbol.declarations.length > 0 ? ts.getNodeModifiers(symbol.declarations[0]) - : "" /* none */; + : ts.ScriptElementKindModifier.none; } SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location @@ -82528,10 +82548,10 @@ var ts; var isThisExpression = location.kind === 99 /* ThisKeyword */ && ts.isExpression(location); var type; // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { + if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { // If it is accessor they are allowed only if location is at name of the accessor - if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) { - symbolKind = "property" /* memberVariableElement */; + if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { + symbolKind = ts.ScriptElementKind.memberVariableElement; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); @@ -82571,11 +82591,11 @@ var ts; if (signature) { if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { // Constructor - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else if (symbolFlags & 8388608 /* Alias */) { - symbolKind = "alias" /* alias */; + symbolKind = ts.ScriptElementKind.alias; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { @@ -82588,13 +82608,13 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case "JSX attribute" /* jsxAttribute */: - case "property" /* memberVariableElement */: - case "var" /* variableElement */: - case "const" /* constElement */: - case "let" /* letElement */: - case "parameter" /* parameterElement */: - case "local var" /* localVariableElement */: + case ts.ScriptElementKind.jsxAttribute: + case ts.ScriptElementKind.memberVariableElement: + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.parameterElement: + case ts.ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name displayParts.push(ts.punctuationPart(56 /* ColonToken */)); displayParts.push(ts.spacePart()); @@ -82632,7 +82652,7 @@ var ts; } if (functionDeclaration_1.kind === 152 /* Constructor */) { // show (constructor) Type(...) signature - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { @@ -82651,7 +82671,7 @@ var ts; // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class - pushTypePart("local class" /* localClassElement */); + pushTypePart(ts.ScriptElementKind.localClassElement); } else { // Class declaration has name which is not local. @@ -82742,7 +82762,7 @@ var ts; } } if (symbolFlags & 8 /* EnumMember */) { - symbolKind = "enum member" /* enumMemberElement */; + symbolKind = ts.ScriptElementKind.enumMemberElement; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; if (declaration.kind === 264 /* EnumMember */) { @@ -82793,7 +82813,7 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== "" /* unknown */) { + if (symbolKind !== ts.ScriptElementKind.unknown) { if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); @@ -82803,10 +82823,10 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } // For properties, variables and local vars: show the type - if (symbolKind === "property" /* memberVariableElement */ || - symbolKind === "JSX attribute" /* jsxAttribute */ || + if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolKind === ts.ScriptElementKind.jsxAttribute || symbolFlags & 3 /* Variable */ || - symbolKind === "local var" /* localVariableElement */ || + symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { displayParts.push(ts.punctuationPart(56 /* ColonToken */)); displayParts.push(ts.spacePart()); @@ -82826,7 +82846,7 @@ var ts; symbolFlags & 16384 /* Constructor */ || symbolFlags & 131072 /* Signature */ || symbolFlags & 98304 /* Accessor */ || - symbolKind === "method" /* memberFunctionElement */) { + symbolKind === ts.ScriptElementKind.memberFunctionElement) { var allSignatures = type.getNonNullableType().getCallSignatures(); addSignatureDisplayParts(allSignatures[0], allSignatures); } @@ -82887,11 +82907,11 @@ var ts; } function pushTypePart(symbolKind) { switch (symbolKind) { - case "var" /* variableElement */: - case "function" /* functionElement */: - case "let" /* letElement */: - case "const" /* constElement */: - case "constructor" /* constructorImplementationElement */: + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.functionElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.constructorImplementationElement: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: @@ -89314,8 +89334,8 @@ var ts; var type = typeChecker.getTypeAtLocation(node); if (type) { return { - kind: "" /* unknown */, - kindModifiers: "" /* none */, + kind: ts.ScriptElementKind.unknown, + kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined, @@ -89380,7 +89400,7 @@ var ts; result.push({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, - isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, + isWriteAccess: highlightSpan.kind === ts.HighlightSpanKind.writtenReference, isDefinition: false, isInString: highlightSpan.isInString, }); @@ -91217,7 +91237,7 @@ var ts; var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) { + if (result.resolvedModule && result.resolvedModule.extension !== ts.Extension.Ts && result.resolvedModule.extension !== ts.Extension.Tsx && result.resolvedModule.extension !== ts.Extension.Dts) { resolvedFileName = undefined; } return { diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 802f936d9de1d..1ea738fdcd923 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -2333,11 +2333,12 @@ declare namespace ts { extension: Extension; } enum Extension { - Ts = ".ts", - Tsx = ".tsx", - Dts = ".d.ts", - Js = ".js", - Jsx = ".jsx", + Ts = 0, + Tsx = 1, + Dts = 2, + Js = 3, + Jsx = 4, + LastTypeScriptExtension = 2, } interface ResolvedModuleWithFailedLookupLocations { resolvedModule: ResolvedModuleFull | undefined; @@ -3756,7 +3757,7 @@ declare namespace ts { } interface ClassifiedSpan { textSpan: TextSpan; - classificationType: ClassificationTypeNames; + classificationType: string; } /** * Navigation bar interface designed for visual studio's dual-column layout. @@ -3766,7 +3767,7 @@ declare namespace ts { */ interface NavigationBarItem { text: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; spans: TextSpan[]; childItems: NavigationBarItem[]; @@ -3781,7 +3782,8 @@ declare namespace ts { interface NavigationTree { /** Name of the declaration, or a short description, e.g. "". */ text: string; - kind: ScriptElementKind; + /** A ScriptElementKind */ + kind: string; /** ScriptElementKindModifier separated by commas, e.g. "public,abstract" */ kindModifiers: string; /** @@ -3880,35 +3882,35 @@ declare namespace ts { isInString?: true; } interface ImplementationLocation extends DocumentSpan { - kind: ScriptElementKind; + kind: string; displayParts: SymbolDisplayPart[]; } interface DocumentHighlights { fileName: string; highlightSpans: HighlightSpan[]; } - enum HighlightSpanKind { - none = "none", - definition = "definition", - reference = "reference", - writtenReference = "writtenReference", + namespace HighlightSpanKind { + const none = "none"; + const definition = "definition"; + const reference = "reference"; + const writtenReference = "writtenReference"; } interface HighlightSpan { fileName?: string; isInString?: true; textSpan: TextSpan; - kind: HighlightSpanKind; + kind: string; } interface NavigateToItem { name: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; matchKind: string; isCaseSensitive: boolean; fileName: string; textSpan: TextSpan; containerName: string; - containerKind: ScriptElementKind; + containerKind: string; } enum IndentStyle { None = 0, @@ -3968,9 +3970,9 @@ declare namespace ts { interface DefinitionInfo { fileName: string; textSpan: TextSpan; - kind: ScriptElementKind; + kind: string; name: string; - containerKind: ScriptElementKind; + containerKind: string; containerName: string; } interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { @@ -4013,7 +4015,7 @@ declare namespace ts { text?: string; } interface QuickInfo { - kind: ScriptElementKind; + kind: string; kindModifiers: string; textSpan: TextSpan; displayParts: SymbolDisplayPart[]; @@ -4025,7 +4027,7 @@ declare namespace ts { localizedErrorMessage: string; displayName: string; fullDisplayName: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; triggerSpan: TextSpan; } @@ -4072,7 +4074,7 @@ declare namespace ts { } interface CompletionEntry { name: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; sortText: string; /** @@ -4084,7 +4086,7 @@ declare namespace ts { } interface CompletionEntryDetails { name: string; - kind: ScriptElementKind; + kind: string; kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; @@ -4169,107 +4171,107 @@ declare namespace ts { getClassificationsForLine(text: string, lexState: EndOfLineState, syntacticClassifierAbsent: boolean): ClassificationResult; getEncodedLexicalClassifications(text: string, endOfLineState: EndOfLineState, syntacticClassifierAbsent: boolean): Classifications; } - enum ScriptElementKind { - unknown = "", - warning = "warning", + namespace ScriptElementKind { + const unknown = ""; + const warning = "warning"; /** predefined type (void) or keyword (class) */ - keyword = "keyword", + const keyword = "keyword"; /** top level script node */ - scriptElement = "script", + const scriptElement = "script"; /** module foo {} */ - moduleElement = "module", + const moduleElement = "module"; /** class X {} */ - classElement = "class", + const classElement = "class"; /** var x = class X {} */ - localClassElement = "local class", + const localClassElement = "local class"; /** interface Y {} */ - interfaceElement = "interface", + const interfaceElement = "interface"; /** type T = ... */ - typeElement = "type", + const typeElement = "type"; /** enum E */ - enumElement = "enum", - enumMemberElement = "enum member", + const enumElement = "enum"; + const enumMemberElement = "enum member"; /** * Inside module and script only * const v = .. */ - variableElement = "var", + const variableElement = "var"; /** Inside function */ - localVariableElement = "local var", + const localVariableElement = "local var"; /** * Inside module and script only * function f() { } */ - functionElement = "function", + const functionElement = "function"; /** Inside function */ - localFunctionElement = "local function", + const localFunctionElement = "local function"; /** class X { [public|private]* foo() {} } */ - memberFunctionElement = "method", + const memberFunctionElement = "method"; /** class X { [public|private]* [get|set] foo:number; } */ - memberGetAccessorElement = "getter", - memberSetAccessorElement = "setter", + const memberGetAccessorElement = "getter"; + const memberSetAccessorElement = "setter"; /** * class X { [public|private]* foo:number; } * interface Y { foo:number; } */ - memberVariableElement = "property", + const memberVariableElement = "property"; /** class X { constructor() { } } */ - constructorImplementationElement = "constructor", + const constructorImplementationElement = "constructor"; /** interface Y { ():number; } */ - callSignatureElement = "call", + const callSignatureElement = "call"; /** interface Y { []:number; } */ - indexSignatureElement = "index", + const indexSignatureElement = "index"; /** interface Y { new():Y; } */ - constructSignatureElement = "construct", + const constructSignatureElement = "construct"; /** function foo(*Y*: string) */ - parameterElement = "parameter", - typeParameterElement = "type parameter", - primitiveType = "primitive type", - label = "label", - alias = "alias", - constElement = "const", - letElement = "let", - directory = "directory", - externalModuleName = "external module name", + const parameterElement = "parameter"; + const typeParameterElement = "type parameter"; + const primitiveType = "primitive type"; + const label = "label"; + const alias = "alias"; + const constElement = "const"; + const letElement = "let"; + const directory = "directory"; + const externalModuleName = "external module name"; /** * */ - jsxAttribute = "JSX attribute", - } - enum ScriptElementKindModifier { - none = "", - publicMemberModifier = "public", - privateMemberModifier = "private", - protectedMemberModifier = "protected", - exportedModifier = "export", - ambientModifier = "declare", - staticModifier = "static", - abstractModifier = "abstract", - } - enum ClassificationTypeNames { - comment = "comment", - identifier = "identifier", - keyword = "keyword", - numericLiteral = "number", - operator = "operator", - stringLiteral = "string", - whiteSpace = "whitespace", - text = "text", - punctuation = "punctuation", - className = "class name", - enumName = "enum name", - interfaceName = "interface name", - moduleName = "module name", - typeParameterName = "type parameter name", - typeAliasName = "type alias name", - parameterName = "parameter name", - docCommentTagName = "doc comment tag name", - jsxOpenTagName = "jsx open tag name", - jsxCloseTagName = "jsx close tag name", - jsxSelfClosingTagName = "jsx self closing tag name", - jsxAttribute = "jsx attribute", - jsxText = "jsx text", - jsxAttributeStringLiteralValue = "jsx attribute string literal value", + const jsxAttribute = "JSX attribute"; + } + namespace ScriptElementKindModifier { + const none = ""; + const publicMemberModifier = "public"; + const privateMemberModifier = "private"; + const protectedMemberModifier = "protected"; + const exportedModifier = "export"; + const ambientModifier = "declare"; + const staticModifier = "static"; + const abstractModifier = "abstract"; + } + class ClassificationTypeNames { + static comment: string; + static identifier: string; + static keyword: string; + static numericLiteral: string; + static operator: string; + static stringLiteral: string; + static whiteSpace: string; + static text: string; + static punctuation: string; + static className: string; + static enumName: string; + static interfaceName: string; + static moduleName: string; + static typeParameterName: string; + static typeAliasName: string; + static parameterName: string; + static docCommentTagName: string; + static jsxOpenTagName: string; + static jsxCloseTagName: string; + static jsxSelfClosingTagName: string; + static jsxAttribute: string; + static jsxText: string; + static jsxAttributeStringLiteralValue: string; } enum ClassificationType { comment = 1, diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 184425351e6b2..b7487aeaa4496 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -1064,11 +1064,12 @@ var ts; })(CharacterCodes = ts.CharacterCodes || (ts.CharacterCodes = {})); var Extension; (function (Extension) { - Extension["Ts"] = ".ts"; - Extension["Tsx"] = ".tsx"; - Extension["Dts"] = ".d.ts"; - Extension["Js"] = ".js"; - Extension["Jsx"] = ".jsx"; + Extension[Extension["Ts"] = 0] = "Ts"; + Extension[Extension["Tsx"] = 1] = "Tsx"; + Extension[Extension["Dts"] = 2] = "Dts"; + Extension[Extension["Js"] = 3] = "Js"; + Extension[Extension["Jsx"] = 4] = "Jsx"; + Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; })(Extension = ts.Extension || (ts.Extension = {})); /* @internal */ var TransformFlags; @@ -3291,13 +3292,13 @@ var ts; function getScriptKindFromFileName(fileName) { var ext = fileName.substr(fileName.lastIndexOf(".")); switch (ext.toLowerCase()) { - case ".js" /* Js */: + case ".js": return 1 /* JS */; - case ".jsx" /* Jsx */: + case ".jsx": return 2 /* JSX */; - case ".ts" /* Ts */: + case ".ts": return 3 /* TS */; - case ".tsx" /* Tsx */: + case ".tsx": return 4 /* TSX */; default: return 0 /* Unknown */; @@ -3307,10 +3308,10 @@ var ts; /** * List of supported extensions in order of file resolution precedence. */ - ts.supportedTypeScriptExtensions = [".ts" /* Ts */, ".tsx" /* Tsx */, ".d.ts" /* Dts */]; + ts.supportedTypeScriptExtensions = [".ts", ".tsx", ".d.ts"]; /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - ts.supportedTypescriptExtensionsForExtractExtension = [".d.ts" /* Dts */, ".ts" /* Ts */, ".tsx" /* Tsx */]; - ts.supportedJavascriptExtensions = [".js" /* Js */, ".jsx" /* Jsx */]; + ts.supportedTypescriptExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"]; + ts.supportedJavascriptExtensions = [".js", ".jsx"]; var allSupportedExtensions = ts.supportedTypeScriptExtensions.concat(ts.supportedJavascriptExtensions); function getSupportedExtensions(options, extraFileExtensions) { var needAllExtensions = options && options.allowJs; @@ -3398,7 +3399,7 @@ var ts; } } ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority; - var extensionsToRemove = [".d.ts" /* Dts */, ".ts" /* Ts */, ".js" /* Js */, ".tsx" /* Tsx */, ".jsx" /* Jsx */]; + var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"]; function removeFileExtension(path) { for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) { var ext = extensionsToRemove_1[_i]; @@ -3635,7 +3636,7 @@ var ts; ts.positionIsSynthesized = positionIsSynthesized; /** True if an extension is one of the supported TypeScript extensions. */ function extensionIsTypeScript(ext) { - return ext === ".ts" /* Ts */ || ext === ".tsx" /* Tsx */ || ext === ".d.ts" /* Dts */; + return ext <= ts.Extension.LastTypeScriptExtension; } ts.extensionIsTypeScript = extensionIsTypeScript; /** @@ -3651,7 +3652,21 @@ var ts; } ts.extensionFromPath = extensionFromPath; function tryGetExtensionFromPath(path) { - return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); }); + if (fileExtensionIs(path, ".d.ts")) { + return ts.Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return ts.Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return ts.Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return ts.Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return ts.Extension.Jsx; + } } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; function isCheckJsEnabledForFile(sourceFile, compilerOptions) { @@ -9122,7 +9137,7 @@ var ts; var path = outputDir ? getSourceFilePathInNewDir(sourceFile, host, outputDir) : sourceFile.fileName; - return ts.removeFileExtension(path) + ".d.ts" /* Dts */; + return ts.removeFileExtension(path) + ".d.ts"; } ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath; /** @@ -9172,7 +9187,7 @@ var ts; if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" /* Dts */ : ""; + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : ""; action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); } } @@ -9196,16 +9211,16 @@ var ts; function getOutputExtension(sourceFile, options) { if (options.jsx === 1 /* Preserve */) { if (isSourceFileJavaScript(sourceFile)) { - if (ts.fileExtensionIs(sourceFile.fileName, ".jsx" /* Jsx */)) { - return ".jsx" /* Jsx */; + if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) { + return ".jsx"; } } else if (sourceFile.languageVariant === 1 /* JSX */) { // TypeScript source file preserving JSX syntax - return ".jsx" /* Jsx */; + return ".jsx"; } } - return ".js" /* Js */; + return ".js"; } function getSourceFilePathInNewDir(sourceFile, host, newDirPath) { var sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, host.getCurrentDirectory()); @@ -16629,7 +16644,7 @@ var ts; sourceFile.languageVersion = languageVersion; sourceFile.fileName = ts.normalizePath(fileName); sourceFile.languageVariant = getLanguageVariant(scriptKind); - sourceFile.isDeclarationFile = ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */); + sourceFile.isDeclarationFile = ts.fileExtensionIs(sourceFile.fileName, ".d.ts"); sourceFile.scriptKind = scriptKind; return sourceFile; } @@ -26420,14 +26435,14 @@ var ts; } switch (extensions) { case Extensions.DtsOnly: - return tryExtension(".d.ts" /* Dts */); + return tryExtension(".d.ts", ts.Extension.Dts); case Extensions.TypeScript: - return tryExtension(".ts" /* Ts */) || tryExtension(".tsx" /* Tsx */) || tryExtension(".d.ts" /* Dts */); + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); case Extensions.JavaScript: - return tryExtension(".js" /* Js */) || tryExtension(".jsx" /* Jsx */); + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } - function tryExtension(extension) { - var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); return path && { path: path, extension: extension }; } } @@ -26503,11 +26518,11 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" /* Js */ || extension === ".jsx" /* Jsx */; + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; case Extensions.TypeScript: - return extension === ".ts" /* Ts */ || extension === ".tsx" /* Tsx */ || extension === ".d.ts" /* Dts */; + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; case Extensions.DtsOnly: - return extension === ".d.ts" /* Dts */; + return extension === ts.Extension.Dts; } } function pathToPackageJson(directory) { @@ -70162,7 +70177,7 @@ var ts; } var sourceFileWithAddedExtension = ts.forEach(supportedExtensions, function (extension) { return getSourceFile(fileName + extension); }); if (fail && !sourceFileWithAddedExtension) - fail(ts.Diagnostics.File_0_not_found, fileName + ".ts" /* Ts */); + fail(ts.Diagnostics.File_0_not_found, fileName + ".ts"); return sourceFileWithAddedExtension; } } @@ -70595,15 +70610,15 @@ var ts; function getResolutionDiagnostic(options, _a) { var extension = _a.extension; switch (extension) { - case ".ts" /* Ts */: - case ".d.ts" /* Dts */: + case ts.Extension.Ts: + case ts.Extension.Dts: // These are always allowed. return undefined; - case ".tsx" /* Tsx */: + case ts.Extension.Tsx: return needJsx(); - case ".jsx" /* Jsx */: + case ts.Extension.Jsx: return needJsx() || needAllowJs(); - case ".js" /* Js */: + case ts.Extension.Js: return needAllowJs(); } function needJsx() { @@ -72286,10 +72301,10 @@ var ts; ts.TextChange = TextChange; var HighlightSpanKind; (function (HighlightSpanKind) { - HighlightSpanKind["none"] = "none"; - HighlightSpanKind["definition"] = "definition"; - HighlightSpanKind["reference"] = "reference"; - HighlightSpanKind["writtenReference"] = "writtenReference"; + HighlightSpanKind.none = "none"; + HighlightSpanKind.definition = "definition"; + HighlightSpanKind.reference = "reference"; + HighlightSpanKind.writtenReference = "writtenReference"; })(HighlightSpanKind = ts.HighlightSpanKind || (ts.HighlightSpanKind = {})); var IndentStyle; (function (IndentStyle) { @@ -72350,111 +72365,115 @@ var ts; TokenClass[TokenClass["StringLiteral"] = 7] = "StringLiteral"; TokenClass[TokenClass["RegExpLiteral"] = 8] = "RegExpLiteral"; })(TokenClass = ts.TokenClass || (ts.TokenClass = {})); + // TODO: move these to enums var ScriptElementKind; (function (ScriptElementKind) { - ScriptElementKind["unknown"] = ""; - ScriptElementKind["warning"] = "warning"; + ScriptElementKind.unknown = ""; + ScriptElementKind.warning = "warning"; /** predefined type (void) or keyword (class) */ - ScriptElementKind["keyword"] = "keyword"; + ScriptElementKind.keyword = "keyword"; /** top level script node */ - ScriptElementKind["scriptElement"] = "script"; + ScriptElementKind.scriptElement = "script"; /** module foo {} */ - ScriptElementKind["moduleElement"] = "module"; + ScriptElementKind.moduleElement = "module"; /** class X {} */ - ScriptElementKind["classElement"] = "class"; + ScriptElementKind.classElement = "class"; /** var x = class X {} */ - ScriptElementKind["localClassElement"] = "local class"; + ScriptElementKind.localClassElement = "local class"; /** interface Y {} */ - ScriptElementKind["interfaceElement"] = "interface"; + ScriptElementKind.interfaceElement = "interface"; /** type T = ... */ - ScriptElementKind["typeElement"] = "type"; + ScriptElementKind.typeElement = "type"; /** enum E */ - ScriptElementKind["enumElement"] = "enum"; - ScriptElementKind["enumMemberElement"] = "enum member"; + ScriptElementKind.enumElement = "enum"; + ScriptElementKind.enumMemberElement = "enum member"; /** * Inside module and script only * const v = .. */ - ScriptElementKind["variableElement"] = "var"; + ScriptElementKind.variableElement = "var"; /** Inside function */ - ScriptElementKind["localVariableElement"] = "local var"; + ScriptElementKind.localVariableElement = "local var"; /** * Inside module and script only * function f() { } */ - ScriptElementKind["functionElement"] = "function"; + ScriptElementKind.functionElement = "function"; /** Inside function */ - ScriptElementKind["localFunctionElement"] = "local function"; + ScriptElementKind.localFunctionElement = "local function"; /** class X { [public|private]* foo() {} } */ - ScriptElementKind["memberFunctionElement"] = "method"; + ScriptElementKind.memberFunctionElement = "method"; /** class X { [public|private]* [get|set] foo:number; } */ - ScriptElementKind["memberGetAccessorElement"] = "getter"; - ScriptElementKind["memberSetAccessorElement"] = "setter"; + ScriptElementKind.memberGetAccessorElement = "getter"; + ScriptElementKind.memberSetAccessorElement = "setter"; /** * class X { [public|private]* foo:number; } * interface Y { foo:number; } */ - ScriptElementKind["memberVariableElement"] = "property"; + ScriptElementKind.memberVariableElement = "property"; /** class X { constructor() { } } */ - ScriptElementKind["constructorImplementationElement"] = "constructor"; + ScriptElementKind.constructorImplementationElement = "constructor"; /** interface Y { ():number; } */ - ScriptElementKind["callSignatureElement"] = "call"; + ScriptElementKind.callSignatureElement = "call"; /** interface Y { []:number; } */ - ScriptElementKind["indexSignatureElement"] = "index"; + ScriptElementKind.indexSignatureElement = "index"; /** interface Y { new():Y; } */ - ScriptElementKind["constructSignatureElement"] = "construct"; + ScriptElementKind.constructSignatureElement = "construct"; /** function foo(*Y*: string) */ - ScriptElementKind["parameterElement"] = "parameter"; - ScriptElementKind["typeParameterElement"] = "type parameter"; - ScriptElementKind["primitiveType"] = "primitive type"; - ScriptElementKind["label"] = "label"; - ScriptElementKind["alias"] = "alias"; - ScriptElementKind["constElement"] = "const"; - ScriptElementKind["letElement"] = "let"; - ScriptElementKind["directory"] = "directory"; - ScriptElementKind["externalModuleName"] = "external module name"; + ScriptElementKind.parameterElement = "parameter"; + ScriptElementKind.typeParameterElement = "type parameter"; + ScriptElementKind.primitiveType = "primitive type"; + ScriptElementKind.label = "label"; + ScriptElementKind.alias = "alias"; + ScriptElementKind.constElement = "const"; + ScriptElementKind.letElement = "let"; + ScriptElementKind.directory = "directory"; + ScriptElementKind.externalModuleName = "external module name"; /** * */ - ScriptElementKind["jsxAttribute"] = "JSX attribute"; + ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; (function (ScriptElementKindModifier) { - ScriptElementKindModifier["none"] = ""; - ScriptElementKindModifier["publicMemberModifier"] = "public"; - ScriptElementKindModifier["privateMemberModifier"] = "private"; - ScriptElementKindModifier["protectedMemberModifier"] = "protected"; - ScriptElementKindModifier["exportedModifier"] = "export"; - ScriptElementKindModifier["ambientModifier"] = "declare"; - ScriptElementKindModifier["staticModifier"] = "static"; - ScriptElementKindModifier["abstractModifier"] = "abstract"; + ScriptElementKindModifier.none = ""; + ScriptElementKindModifier.publicMemberModifier = "public"; + ScriptElementKindModifier.privateMemberModifier = "private"; + ScriptElementKindModifier.protectedMemberModifier = "protected"; + ScriptElementKindModifier.exportedModifier = "export"; + ScriptElementKindModifier.ambientModifier = "declare"; + ScriptElementKindModifier.staticModifier = "static"; + ScriptElementKindModifier.abstractModifier = "abstract"; })(ScriptElementKindModifier = ts.ScriptElementKindModifier || (ts.ScriptElementKindModifier = {})); - var ClassificationTypeNames; - (function (ClassificationTypeNames) { - ClassificationTypeNames["comment"] = "comment"; - ClassificationTypeNames["identifier"] = "identifier"; - ClassificationTypeNames["keyword"] = "keyword"; - ClassificationTypeNames["numericLiteral"] = "number"; - ClassificationTypeNames["operator"] = "operator"; - ClassificationTypeNames["stringLiteral"] = "string"; - ClassificationTypeNames["whiteSpace"] = "whitespace"; - ClassificationTypeNames["text"] = "text"; - ClassificationTypeNames["punctuation"] = "punctuation"; - ClassificationTypeNames["className"] = "class name"; - ClassificationTypeNames["enumName"] = "enum name"; - ClassificationTypeNames["interfaceName"] = "interface name"; - ClassificationTypeNames["moduleName"] = "module name"; - ClassificationTypeNames["typeParameterName"] = "type parameter name"; - ClassificationTypeNames["typeAliasName"] = "type alias name"; - ClassificationTypeNames["parameterName"] = "parameter name"; - ClassificationTypeNames["docCommentTagName"] = "doc comment tag name"; - ClassificationTypeNames["jsxOpenTagName"] = "jsx open tag name"; - ClassificationTypeNames["jsxCloseTagName"] = "jsx close tag name"; - ClassificationTypeNames["jsxSelfClosingTagName"] = "jsx self closing tag name"; - ClassificationTypeNames["jsxAttribute"] = "jsx attribute"; - ClassificationTypeNames["jsxText"] = "jsx text"; - ClassificationTypeNames["jsxAttributeStringLiteralValue"] = "jsx attribute string literal value"; - })(ClassificationTypeNames = ts.ClassificationTypeNames || (ts.ClassificationTypeNames = {})); + var ClassificationTypeNames = (function () { + function ClassificationTypeNames() { + } + ClassificationTypeNames.comment = "comment"; + ClassificationTypeNames.identifier = "identifier"; + ClassificationTypeNames.keyword = "keyword"; + ClassificationTypeNames.numericLiteral = "number"; + ClassificationTypeNames.operator = "operator"; + ClassificationTypeNames.stringLiteral = "string"; + ClassificationTypeNames.whiteSpace = "whitespace"; + ClassificationTypeNames.text = "text"; + ClassificationTypeNames.punctuation = "punctuation"; + ClassificationTypeNames.className = "class name"; + ClassificationTypeNames.enumName = "enum name"; + ClassificationTypeNames.interfaceName = "interface name"; + ClassificationTypeNames.moduleName = "module name"; + ClassificationTypeNames.typeParameterName = "type parameter name"; + ClassificationTypeNames.typeAliasName = "type alias name"; + ClassificationTypeNames.parameterName = "parameter name"; + ClassificationTypeNames.docCommentTagName = "doc comment tag name"; + ClassificationTypeNames.jsxOpenTagName = "jsx open tag name"; + ClassificationTypeNames.jsxCloseTagName = "jsx close tag name"; + ClassificationTypeNames.jsxSelfClosingTagName = "jsx self closing tag name"; + ClassificationTypeNames.jsxAttribute = "jsx attribute"; + ClassificationTypeNames.jsxText = "jsx text"; + ClassificationTypeNames.jsxAttributeStringLiteralValue = "jsx attribute string literal value"; + return ClassificationTypeNames; + }()); + ts.ClassificationTypeNames = ClassificationTypeNames; var ClassificationType; (function (ClassificationType) { ClassificationType[ClassificationType["comment"] = 1] = "comment"; @@ -72760,15 +72779,15 @@ var ts; function getNodeKind(node) { switch (node.kind) { case 265 /* SourceFile */: - return ts.isExternalModule(node) ? "module" /* moduleElement */ : "script" /* scriptElement */; + return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; case 233 /* ModuleDeclaration */: - return "module" /* moduleElement */; + return ts.ScriptElementKind.moduleElement; case 229 /* ClassDeclaration */: case 199 /* ClassExpression */: - return "class" /* classElement */; - case 230 /* InterfaceDeclaration */: return "interface" /* interfaceElement */; - case 231 /* TypeAliasDeclaration */: return "type" /* typeElement */; - case 232 /* EnumDeclaration */: return "enum" /* enumElement */; + return ts.ScriptElementKind.classElement; + case 230 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 231 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 232 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; case 226 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); case 176 /* BindingElement */: @@ -72776,39 +72795,39 @@ var ts; case 187 /* ArrowFunction */: case 228 /* FunctionDeclaration */: case 186 /* FunctionExpression */: - return "function" /* functionElement */; - case 153 /* GetAccessor */: return "getter" /* memberGetAccessorElement */; - case 154 /* SetAccessor */: return "setter" /* memberSetAccessorElement */; + return ts.ScriptElementKind.functionElement; + case 153 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 154 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; case 151 /* MethodDeclaration */: case 150 /* MethodSignature */: - return "method" /* memberFunctionElement */; + return ts.ScriptElementKind.memberFunctionElement; case 149 /* PropertyDeclaration */: case 148 /* PropertySignature */: - return "property" /* memberVariableElement */; - case 157 /* IndexSignature */: return "index" /* indexSignatureElement */; - case 156 /* ConstructSignature */: return "construct" /* constructSignatureElement */; - case 155 /* CallSignature */: return "call" /* callSignatureElement */; - case 152 /* Constructor */: return "constructor" /* constructorImplementationElement */; - case 145 /* TypeParameter */: return "type parameter" /* typeParameterElement */; - case 264 /* EnumMember */: return "enum member" /* enumMemberElement */; - case 146 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? "property" /* memberVariableElement */ : "parameter" /* parameterElement */; + return ts.ScriptElementKind.memberVariableElement; + case 157 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 156 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 155 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 152 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 145 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 264 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 146 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; case 237 /* ImportEqualsDeclaration */: case 242 /* ImportSpecifier */: case 239 /* ImportClause */: case 246 /* ExportSpecifier */: case 240 /* NamespaceImport */: - return "alias" /* alias */; + return ts.ScriptElementKind.alias; case 291 /* JSDocTypedefTag */: - return "type" /* typeElement */; + return ts.ScriptElementKind.typeElement; default: - return "" /* unknown */; + return ts.ScriptElementKind.unknown; } function getKindOfVariableDeclaration(v) { return ts.isConst(v) - ? "const" /* constElement */ + ? ts.ScriptElementKind.constElement : ts.isLet(v) - ? "let" /* letElement */ - : "var" /* variableElement */; + ? ts.ScriptElementKind.letElement + : ts.ScriptElementKind.variableElement; } } ts.getNodeKind = getNodeKind; @@ -73311,20 +73330,20 @@ var ts; var flags = ts.getCombinedModifierFlags(node); var result = []; if (flags & 8 /* Private */) - result.push("private" /* privateMemberModifier */); + result.push(ts.ScriptElementKindModifier.privateMemberModifier); if (flags & 16 /* Protected */) - result.push("protected" /* protectedMemberModifier */); + result.push(ts.ScriptElementKindModifier.protectedMemberModifier); if (flags & 4 /* Public */) - result.push("public" /* publicMemberModifier */); + result.push(ts.ScriptElementKindModifier.publicMemberModifier); if (flags & 32 /* Static */) - result.push("static" /* staticModifier */); + result.push(ts.ScriptElementKindModifier.staticModifier); if (flags & 128 /* Abstract */) - result.push("abstract" /* abstractModifier */); + result.push(ts.ScriptElementKindModifier.abstractModifier); if (flags & 1 /* Export */) - result.push("export" /* exportedModifier */); + result.push(ts.ScriptElementKindModifier.exportedModifier); if (ts.isInAmbientContext(node)) - result.push("declare" /* ambientModifier */); - return result.length > 0 ? result.join(",") : "" /* none */; + result.push(ts.ScriptElementKindModifier.ambientModifier); + return result.length > 0 ? result.join(",") : ts.ScriptElementKindModifier.none; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { @@ -74281,29 +74300,29 @@ var ts; ts.getEncodedSemanticClassifications = getEncodedSemanticClassifications; function getClassificationTypeName(type) { switch (type) { - case 1 /* comment */: return "comment" /* comment */; - case 2 /* identifier */: return "identifier" /* identifier */; - case 3 /* keyword */: return "keyword" /* keyword */; - case 4 /* numericLiteral */: return "number" /* numericLiteral */; - case 5 /* operator */: return "operator" /* operator */; - case 6 /* stringLiteral */: return "string" /* stringLiteral */; - case 8 /* whiteSpace */: return "whitespace" /* whiteSpace */; - case 9 /* text */: return "text" /* text */; - case 10 /* punctuation */: return "punctuation" /* punctuation */; - case 11 /* className */: return "class name" /* className */; - case 12 /* enumName */: return "enum name" /* enumName */; - case 13 /* interfaceName */: return "interface name" /* interfaceName */; - case 14 /* moduleName */: return "module name" /* moduleName */; - case 15 /* typeParameterName */: return "type parameter name" /* typeParameterName */; - case 16 /* typeAliasName */: return "type alias name" /* typeAliasName */; - case 17 /* parameterName */: return "parameter name" /* parameterName */; - case 18 /* docCommentTagName */: return "doc comment tag name" /* docCommentTagName */; - case 19 /* jsxOpenTagName */: return "jsx open tag name" /* jsxOpenTagName */; - case 20 /* jsxCloseTagName */: return "jsx close tag name" /* jsxCloseTagName */; - case 21 /* jsxSelfClosingTagName */: return "jsx self closing tag name" /* jsxSelfClosingTagName */; - case 22 /* jsxAttribute */: return "jsx attribute" /* jsxAttribute */; - case 23 /* jsxText */: return "jsx text" /* jsxText */; - case 24 /* jsxAttributeStringLiteralValue */: return "jsx attribute string literal value" /* jsxAttributeStringLiteralValue */; + case 1 /* comment */: return ts.ClassificationTypeNames.comment; + case 2 /* identifier */: return ts.ClassificationTypeNames.identifier; + case 3 /* keyword */: return ts.ClassificationTypeNames.keyword; + case 4 /* numericLiteral */: return ts.ClassificationTypeNames.numericLiteral; + case 5 /* operator */: return ts.ClassificationTypeNames.operator; + case 6 /* stringLiteral */: return ts.ClassificationTypeNames.stringLiteral; + case 8 /* whiteSpace */: return ts.ClassificationTypeNames.whiteSpace; + case 9 /* text */: return ts.ClassificationTypeNames.text; + case 10 /* punctuation */: return ts.ClassificationTypeNames.punctuation; + case 11 /* className */: return ts.ClassificationTypeNames.className; + case 12 /* enumName */: return ts.ClassificationTypeNames.enumName; + case 13 /* interfaceName */: return ts.ClassificationTypeNames.interfaceName; + case 14 /* moduleName */: return ts.ClassificationTypeNames.moduleName; + case 15 /* typeParameterName */: return ts.ClassificationTypeNames.typeParameterName; + case 16 /* typeAliasName */: return ts.ClassificationTypeNames.typeAliasName; + case 17 /* parameterName */: return ts.ClassificationTypeNames.parameterName; + case 18 /* docCommentTagName */: return ts.ClassificationTypeNames.docCommentTagName; + case 19 /* jsxOpenTagName */: return ts.ClassificationTypeNames.jsxOpenTagName; + case 20 /* jsxCloseTagName */: return ts.ClassificationTypeNames.jsxCloseTagName; + case 21 /* jsxSelfClosingTagName */: return ts.ClassificationTypeNames.jsxSelfClosingTagName; + case 22 /* jsxAttribute */: return ts.ClassificationTypeNames.jsxAttribute; + case 23 /* jsxText */: return ts.ClassificationTypeNames.jsxText; + case 24 /* jsxAttributeStringLiteralValue */: return ts.ClassificationTypeNames.jsxAttributeStringLiteralValue; } } function convertClassifications(classifications) { @@ -74750,7 +74769,7 @@ var ts; } } ts.forEachKey(foundFiles, function (foundFile) { - result.push(createCompletionEntryForModule(foundFile, "script" /* scriptElement */, span)); + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); }); } // If possible, get folder completion as well @@ -74759,7 +74778,7 @@ var ts; for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { var directory = directories_2[_a]; var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, "directory" /* directory */, span)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); } } } @@ -74789,7 +74808,7 @@ var ts; var pattern = _a[_i]; for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { var match = _c[_b]; - result.push(createCompletionEntryForModule(match, "external module name" /* externalModuleName */, span)); + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); } } } @@ -74797,7 +74816,7 @@ var ts; else if (ts.startsWith(path, fragment)) { var entry = paths[path] && paths[path].length === 1 && paths[path][0]; if (entry) { - result.push(createCompletionEntryForModule(path, "external module name" /* externalModuleName */, span)); + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); } } } @@ -74810,7 +74829,7 @@ var ts; getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, "external module name" /* externalModuleName */, span)); + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); } return result; } @@ -74943,7 +74962,7 @@ var ts; if (options.types) { for (var _i = 0, _a = options.types; _i < _a.length; _i++) { var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, "external module name" /* externalModuleName */, span)); + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); } } else if (host.getDirectories) { @@ -74977,7 +74996,7 @@ var ts; for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { var typeDirectory = directories_3[_i]; typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), "external module name" /* externalModuleName */, span)); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); } } } @@ -75049,7 +75068,7 @@ var ts; } } function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: "" /* none */, sortText: name, replacementSpan: replacementSpan }; + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; } // Replace everything after the last directory seperator that appears function getDirectoryFragmentTextSpan(text, textStart) { @@ -75144,7 +75163,7 @@ var ts; return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false, entries: [{ name: tagName.getFullText(), - kind: "class" /* classElement */, + kind: ts.ScriptElementKind.classElement, kindModifiers: undefined, sortText: "0", }] }; @@ -75193,7 +75212,7 @@ var ts; if (displayName) { var entry = { name: displayName, - kind: "warning" /* warning */, + kind: ts.ScriptElementKind.warning, kindModifiers: "", sortText: "1" }; @@ -75372,8 +75391,8 @@ var ts; uniques.set(name, true); result.push({ name: name, - kindModifiers: "" /* none */, - kind: "var" /* variableElement */, + kindModifiers: ts.ScriptElementKindModifier.none, + kind: ts.ScriptElementKind.variableElement, sortText: "0" }); } @@ -75406,8 +75425,8 @@ var ts; if (keywordCompletion) { return { name: entryName, - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], documentation: undefined, tags: undefined @@ -76492,8 +76511,8 @@ var ts; for (var i = 72 /* FirstKeyword */; i <= 142 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), - kind: "keyword" /* keyword */, - kindModifiers: "" /* none */, + kind: ts.ScriptElementKind.keyword, + kindModifiers: ts.ScriptElementKindModifier.none, sortText: "0" }); } @@ -76584,7 +76603,7 @@ var ts; return { fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromNode(node, sourceFile), - kind: "none" /* none */ + kind: ts.HighlightSpanKind.none }; } function getSemanticDocumentHighlights(node, program, cancellationToken, sourceFilesToSearch) { @@ -77065,7 +77084,7 @@ var ts; result.push({ fileName: sourceFile.fileName, textSpan: ts.createTextSpanFromBounds(elseKeyword.getStart(), ifKeyword.end), - kind: "reference" /* reference */ + kind: ts.HighlightSpanKind.reference }); i++; // skip the next keyword continue; @@ -77854,22 +77873,22 @@ var ts; } case "label": { var node_3 = def.node; - return { node: node_3, name: node_3.text, kind: "label" /* label */, displayParts: [ts.displayPart(node_3.text, ts.SymbolDisplayPartKind.text)] }; + return { node: node_3, name: node_3.text, kind: ts.ScriptElementKind.label, displayParts: [ts.displayPart(node_3.text, ts.SymbolDisplayPartKind.text)] }; } case "keyword": { var node_4 = def.node; var name_4 = ts.tokenToString(node_4.kind); - return { node: node_4, name: name_4, kind: "keyword" /* keyword */, displayParts: [{ text: name_4, kind: "keyword" /* keyword */ }] }; + return { node: node_4, name: name_4, kind: ts.ScriptElementKind.keyword, displayParts: [{ text: name_4, kind: ts.ScriptElementKind.keyword }] }; } case "this": { var node_5 = def.node; var symbol = checker.getSymbolAtLocation(node_5); var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node_5.getSourceFile(), ts.getContainerNode(node_5), node_5).displayParts; - return { node: node_5, name: "this", kind: "var" /* variableElement */, displayParts: displayParts_2 }; + return { node: node_5, name: "this", kind: ts.ScriptElementKind.variableElement, displayParts: displayParts_2 }; } case "string": { var node_6 = def.node; - return { node: node_6, name: node_6.text, kind: "var" /* variableElement */, displayParts: [ts.displayPart(ts.getTextOfNode(node_6), ts.SymbolDisplayPartKind.stringLiteral)] }; + return { node: node_6, name: node_6.text, kind: ts.ScriptElementKind.variableElement, displayParts: [ts.displayPart(ts.getTextOfNode(node_6), ts.SymbolDisplayPartKind.stringLiteral)] }; } } })(); @@ -77879,7 +77898,7 @@ var ts; var node = info.node, name = info.name, kind = info.kind, displayParts = info.displayParts; var sourceFile = node.getSourceFile(); return { - containerKind: "" /* unknown */, + containerKind: "", containerName: "", fileName: sourceFile.fileName, kind: kind, @@ -77912,7 +77931,7 @@ var ts; } else { var textSpan = entry.textSpan, fileName = entry.fileName; - return { textSpan: textSpan, fileName: fileName, kind: "" /* unknown */, displayParts: [] }; + return { textSpan: textSpan, fileName: fileName, kind: ts.ScriptElementKind.unknown, displayParts: [] }; } } function implementationKindDisplayParts(node, checker) { @@ -77922,13 +77941,13 @@ var ts; } else if (node.kind === 178 /* ObjectLiteralExpression */) { return { - kind: "interface" /* interfaceElement */, + kind: ts.ScriptElementKind.interfaceElement, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] }; } else if (node.kind === 199 /* ClassExpression */) { return { - kind: "local class" /* localClassElement */, + kind: ts.ScriptElementKind.localClassElement, displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] }; } @@ -77939,14 +77958,14 @@ var ts; function toHighlightSpan(entry) { if (entry.type === "span") { var fileName_1 = entry.fileName, textSpan = entry.textSpan; - return { fileName: fileName_1, span: { textSpan: textSpan, kind: "reference" /* reference */ } }; + return { fileName: fileName_1, span: { textSpan: textSpan, kind: ts.HighlightSpanKind.reference } }; } var node = entry.node, isInString = entry.isInString; var fileName = entry.node.getSourceFile().fileName; var writeAccess = isWriteAccess(node); var span = { textSpan: getTextSpan(node), - kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, + kind: writeAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference, isInString: isInString }; return { fileName: fileName, span: span }; @@ -79310,7 +79329,7 @@ var ts; if (ts.isJumpStatementTarget(node)) { var labelName = node.text; var label = ts.getTargetLabel(node.parent, node.text); - return label ? [createDefinitionInfoFromName(label, "label" /* label */, labelName, /*containerName*/ undefined)] : undefined; + return label ? [createDefinitionInfoFromName(label, ts.ScriptElementKind.label, labelName, /*containerName*/ undefined)] : undefined; } var typeChecker = program.getTypeChecker(); var calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); @@ -79439,7 +79458,8 @@ var ts; for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; if (ts.isClassLike(declaration)) { - return tryAddSignature(declaration.members, /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); + return tryAddSignature(declaration.members, + /*selectConstructors*/ true, symbolKind, symbolName, containerName, result); } } ts.Debug.fail("Expected declaration to have at least one class-like declaration"); @@ -79525,7 +79545,7 @@ var ts; return { fileName: targetFileName, textSpan: ts.createTextSpanFromBounds(0, 0), - kind: "script" /* scriptElement */, + kind: ts.ScriptElementKind.scriptElement, name: name, containerName: undefined, containerKind: undefined @@ -79674,7 +79694,7 @@ var ts; return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, - kind: "keyword" /* keyword */, + kind: ts.ScriptElementKind.keyword, kindModifiers: "", sortText: "0", }; @@ -79685,7 +79705,7 @@ var ts; return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: "@" + tagName, - kind: "keyword" /* keyword */, + kind: ts.ScriptElementKind.keyword, kindModifiers: "", sortText: "0" }; @@ -79706,7 +79726,7 @@ var ts; || nameThusFar !== undefined && !ts.startsWith(name, nameThusFar)) { return undefined; } - return { name: name, kind: "parameter" /* parameterElement */, kindModifiers: "", sortText: "0" }; + return { name: name, kind: ts.ScriptElementKind.parameterElement, kindModifiers: "", sortText: "0" }; }); } JsDoc.getJSDocParameterNameCompletions = getJSDocParameterNameCompletions; @@ -80065,7 +80085,7 @@ var ts; var rawItems = []; var _loop_5 = function (sourceFile) { cancellationToken.throwIfCancellationRequested(); - if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */)) { + if (excludeDtsFiles && ts.fileExtensionIs(sourceFile.fileName, ".d.ts")) { return "continue"; } ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { @@ -80235,7 +80255,7 @@ var ts; textSpan: ts.createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ + containerKind: containerName ? ts.getNodeKind(container) : "" }; } } @@ -81933,7 +81953,7 @@ var ts; return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } var displayName = ts.stripQuotes(node.text); - return getRenameInfoSuccess(displayName, displayName, "var" /* variableElement */, "" /* none */, node, sourceFile); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); } } function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { @@ -82425,70 +82445,70 @@ var ts; var flags = symbol.flags; if (flags & 32 /* Class */) { return ts.getDeclarationOfKind(symbol, 199 /* ClassExpression */) ? - "local class" /* localClassElement */ : "class" /* classElement */; + ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; } if (flags & 384 /* Enum */) - return "enum" /* enumElement */; + return ts.ScriptElementKind.enumElement; if (flags & 524288 /* TypeAlias */) - return "type" /* typeElement */; + return ts.ScriptElementKind.typeElement; if (flags & 64 /* Interface */) - return "interface" /* interfaceElement */; + return ts.ScriptElementKind.interfaceElement; if (flags & 262144 /* TypeParameter */) - return "type parameter" /* typeParameterElement */; + return ts.ScriptElementKind.typeParameterElement; var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); - if (result === "" /* unknown */) { + if (result === ts.ScriptElementKind.unknown) { if (flags & 262144 /* TypeParameter */) - return "type parameter" /* typeParameterElement */; + return ts.ScriptElementKind.typeParameterElement; if (flags & 8 /* EnumMember */) - return "enum member" /* enumMemberElement */; + return ts.ScriptElementKind.enumMemberElement; if (flags & 8388608 /* Alias */) - return "alias" /* alias */; + return ts.ScriptElementKind.alias; if (flags & 1536 /* Module */) - return "module" /* moduleElement */; + return ts.ScriptElementKind.moduleElement; } return result; } SymbolDisplay.getSymbolKind = getSymbolKind; function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) { if (typeChecker.isUndefinedSymbol(symbol)) { - return "var" /* variableElement */; + return ts.ScriptElementKind.variableElement; } if (typeChecker.isArgumentsSymbol(symbol)) { - return "local var" /* localVariableElement */; + return ts.ScriptElementKind.localVariableElement; } if (location.kind === 99 /* ThisKeyword */ && ts.isExpression(location)) { - return "parameter" /* parameterElement */; + return ts.ScriptElementKind.parameterElement; } var flags = symbol.flags; if (flags & 3 /* Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { - return "parameter" /* parameterElement */; + return ts.ScriptElementKind.parameterElement; } else if (symbol.valueDeclaration && ts.isConst(symbol.valueDeclaration)) { - return "const" /* constElement */; + return ts.ScriptElementKind.constElement; } else if (ts.forEach(symbol.declarations, ts.isLet)) { - return "let" /* letElement */; + return ts.ScriptElementKind.letElement; } - return isLocalVariableOrFunction(symbol) ? "local var" /* localVariableElement */ : "var" /* variableElement */; + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localVariableElement : ts.ScriptElementKind.variableElement; } if (flags & 16 /* Function */) - return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */; + return isLocalVariableOrFunction(symbol) ? ts.ScriptElementKind.localFunctionElement : ts.ScriptElementKind.functionElement; if (flags & 32768 /* GetAccessor */) - return "getter" /* memberGetAccessorElement */; + return ts.ScriptElementKind.memberGetAccessorElement; if (flags & 65536 /* SetAccessor */) - return "setter" /* memberSetAccessorElement */; + return ts.ScriptElementKind.memberSetAccessorElement; if (flags & 8192 /* Method */) - return "method" /* memberFunctionElement */; + return ts.ScriptElementKind.memberFunctionElement; if (flags & 16384 /* Constructor */) - return "constructor" /* constructorImplementationElement */; + return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { if (flags & 134217728 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { - return "property" /* memberVariableElement */; + return ts.ScriptElementKind.memberVariableElement; } ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); }); @@ -82497,23 +82517,23 @@ var ts; // make sure it has call signatures before we can label it as method var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (typeOfUnionProperty.getCallSignatures().length) { - return "method" /* memberFunctionElement */; + return ts.ScriptElementKind.memberFunctionElement; } - return "property" /* memberVariableElement */; + return ts.ScriptElementKind.memberVariableElement; } return unionPropertyKind; } if (location.parent && ts.isJsxAttribute(location.parent)) { - return "JSX attribute" /* jsxAttribute */; + return ts.ScriptElementKind.jsxAttribute; } - return "property" /* memberVariableElement */; + return ts.ScriptElementKind.memberVariableElement; } - return "" /* unknown */; + return ts.ScriptElementKind.unknown; } function getSymbolModifiers(symbol) { return symbol && symbol.declarations && symbol.declarations.length > 0 ? ts.getNodeModifiers(symbol.declarations[0]) - : "" /* none */; + : ts.ScriptElementKindModifier.none; } SymbolDisplay.getSymbolModifiers = getSymbolModifiers; // TODO(drosen): Currently completion entry details passes the SemanticMeaning.All instead of using semanticMeaning of location @@ -82528,10 +82548,10 @@ var ts; var isThisExpression = location.kind === 99 /* ThisKeyword */ && ts.isExpression(location); var type; // Class at constructor site need to be shown as constructor apart from property,method, vars - if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { + if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { // If it is accessor they are allowed only if location is at name of the accessor - if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) { - symbolKind = "property" /* memberVariableElement */; + if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { + symbolKind = ts.ScriptElementKind.memberVariableElement; } var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); @@ -82571,11 +82591,11 @@ var ts; if (signature) { if (useConstructSignatures && (symbolFlags & 32 /* Class */)) { // Constructor - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else if (symbolFlags & 8388608 /* Alias */) { - symbolKind = "alias" /* alias */; + symbolKind = ts.ScriptElementKind.alias; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { @@ -82588,13 +82608,13 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } switch (symbolKind) { - case "JSX attribute" /* jsxAttribute */: - case "property" /* memberVariableElement */: - case "var" /* variableElement */: - case "const" /* constElement */: - case "let" /* letElement */: - case "parameter" /* parameterElement */: - case "local var" /* localVariableElement */: + case ts.ScriptElementKind.jsxAttribute: + case ts.ScriptElementKind.memberVariableElement: + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.parameterElement: + case ts.ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name displayParts.push(ts.punctuationPart(56 /* ColonToken */)); displayParts.push(ts.spacePart()); @@ -82632,7 +82652,7 @@ var ts; } if (functionDeclaration_1.kind === 152 /* Constructor */) { // show (constructor) Type(...) signature - symbolKind = "constructor" /* constructorImplementationElement */; + symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { @@ -82651,7 +82671,7 @@ var ts; // Special case for class expressions because we would like to indicate that // the class name is local to the class body (similar to function expression) // (local class) class - pushTypePart("local class" /* localClassElement */); + pushTypePart(ts.ScriptElementKind.localClassElement); } else { // Class declaration has name which is not local. @@ -82742,7 +82762,7 @@ var ts; } } if (symbolFlags & 8 /* EnumMember */) { - symbolKind = "enum member" /* enumMemberElement */; + symbolKind = ts.ScriptElementKind.enumMemberElement; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; if (declaration.kind === 264 /* EnumMember */) { @@ -82793,7 +82813,7 @@ var ts; }); } if (!hasAddedSymbolInfo) { - if (symbolKind !== "" /* unknown */) { + if (symbolKind !== ts.ScriptElementKind.unknown) { if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); @@ -82803,10 +82823,10 @@ var ts; addPrefixForAnyFunctionOrVar(symbol, symbolKind); } // For properties, variables and local vars: show the type - if (symbolKind === "property" /* memberVariableElement */ || - symbolKind === "JSX attribute" /* jsxAttribute */ || + if (symbolKind === ts.ScriptElementKind.memberVariableElement || + symbolKind === ts.ScriptElementKind.jsxAttribute || symbolFlags & 3 /* Variable */ || - symbolKind === "local var" /* localVariableElement */ || + symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { displayParts.push(ts.punctuationPart(56 /* ColonToken */)); displayParts.push(ts.spacePart()); @@ -82826,7 +82846,7 @@ var ts; symbolFlags & 16384 /* Constructor */ || symbolFlags & 131072 /* Signature */ || symbolFlags & 98304 /* Accessor */ || - symbolKind === "method" /* memberFunctionElement */) { + symbolKind === ts.ScriptElementKind.memberFunctionElement) { var allSignatures = type.getNonNullableType().getCallSignatures(); addSignatureDisplayParts(allSignatures[0], allSignatures); } @@ -82887,11 +82907,11 @@ var ts; } function pushTypePart(symbolKind) { switch (symbolKind) { - case "var" /* variableElement */: - case "function" /* functionElement */: - case "let" /* letElement */: - case "const" /* constElement */: - case "constructor" /* constructorImplementationElement */: + case ts.ScriptElementKind.variableElement: + case ts.ScriptElementKind.functionElement: + case ts.ScriptElementKind.letElement: + case ts.ScriptElementKind.constElement: + case ts.ScriptElementKind.constructorImplementationElement: displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: @@ -89314,8 +89334,8 @@ var ts; var type = typeChecker.getTypeAtLocation(node); if (type) { return { - kind: "" /* unknown */, - kindModifiers: "" /* none */, + kind: ts.ScriptElementKind.unknown, + kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined, @@ -89380,7 +89400,7 @@ var ts; result.push({ fileName: entry.fileName, textSpan: highlightSpan.textSpan, - isWriteAccess: highlightSpan.kind === "writtenReference" /* writtenReference */, + isWriteAccess: highlightSpan.kind === ts.HighlightSpanKind.writtenReference, isDefinition: false, isInString: highlightSpan.isInString, }); @@ -91217,7 +91237,7 @@ var ts; var compilerOptions = JSON.parse(compilerOptionsJson); var result = ts.resolveModuleName(moduleName, ts.normalizeSlashes(fileName), compilerOptions, _this.host); var resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; - if (result.resolvedModule && result.resolvedModule.extension !== ".ts" /* Ts */ && result.resolvedModule.extension !== ".tsx" /* Tsx */ && result.resolvedModule.extension !== ".d.ts" /* Dts */) { + if (result.resolvedModule && result.resolvedModule.extension !== ts.Extension.Ts && result.resolvedModule.extension !== ts.Extension.Tsx && result.resolvedModule.extension !== ts.Extension.Dts) { resolvedFileName = undefined; } return { diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index f84faeca8479a..c83cde71b53ea 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -90,6 +90,15 @@ var ts; ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015"; ModuleKind[ModuleKind["ESNext"] = 6] = "ESNext"; })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {})); + var Extension; + (function (Extension) { + Extension[Extension["Ts"] = 0] = "Ts"; + Extension[Extension["Tsx"] = 1] = "Tsx"; + Extension[Extension["Dts"] = 2] = "Dts"; + Extension[Extension["Js"] = 3] = "Js"; + Extension[Extension["Jsx"] = 4] = "Jsx"; + Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension"; + })(Extension = ts.Extension || (ts.Extension = {})); })(ts || (ts = {})); var ts; (function (ts) { @@ -2133,7 +2142,7 @@ var ts; } ts.positionIsSynthesized = positionIsSynthesized; function extensionIsTypeScript(ext) { - return ext === ".ts" || ext === ".tsx" || ext === ".d.ts"; + return ext <= ts.Extension.LastTypeScriptExtension; } ts.extensionIsTypeScript = extensionIsTypeScript; function extensionFromPath(path) { @@ -2145,7 +2154,21 @@ var ts; } ts.extensionFromPath = extensionFromPath; function tryGetExtensionFromPath(path) { - return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); }); + if (fileExtensionIs(path, ".d.ts")) { + return ts.Extension.Dts; + } + if (fileExtensionIs(path, ".ts")) { + return ts.Extension.Ts; + } + if (fileExtensionIs(path, ".tsx")) { + return ts.Extension.Tsx; + } + if (fileExtensionIs(path, ".js")) { + return ts.Extension.Js; + } + if (fileExtensionIs(path, ".jsx")) { + return ts.Extension.Jsx; + } } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; function isCheckJsEnabledForFile(sourceFile, compilerOptions) { @@ -7174,14 +7197,14 @@ var ts; } switch (extensions) { case Extensions.DtsOnly: - return tryExtension(".d.ts"); + return tryExtension(".d.ts", ts.Extension.Dts); case Extensions.TypeScript: - return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts"); + return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts); case Extensions.JavaScript: - return tryExtension(".js") || tryExtension(".jsx"); + return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx); } - function tryExtension(extension) { - var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state); + function tryExtension(ext, extension) { + var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state); return path && { path: path, extension: extension }; } } @@ -7251,11 +7274,11 @@ var ts; function extensionIsOk(extensions, extension) { switch (extensions) { case Extensions.JavaScript: - return extension === ".js" || extension === ".jsx"; + return extension === ts.Extension.Js || extension === ts.Extension.Jsx; case Extensions.TypeScript: - return extension === ".ts" || extension === ".tsx" || extension === ".d.ts"; + return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts; case Extensions.DtsOnly: - return extension === ".d.ts"; + return extension === ts.Extension.Dts; } } function pathToPackageJson(directory) { From dd3d485e967f1940f306f21d16ad32991aba13f4 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 15 Jun 2017 14:03:11 -0700 Subject: [PATCH 6/6] Revert "Make CommandTypes a const enum and use `allCommandTypes` for unit test" This reverts commit f6240cb6f91fb202c8c0b8fc21d965fd83ea62b7. --- src/harness/unittests/session.ts | 77 ++------------------------------ src/server/session.ts | 2 +- 2 files changed, 5 insertions(+), 74 deletions(-) diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 407f9f70aaaa0..f86913504a563 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -172,81 +172,12 @@ namespace ts.server { }); describe("onMessage", () => { - const allCommandNames: CommandNames[] = [ - CommandNames.Brace, - CommandNames.BraceFull, - CommandNames.BraceCompletion, - CommandNames.Change, - CommandNames.Close, - CommandNames.Completions, - CommandNames.CompletionsFull, - CommandNames.CompletionDetails, - CommandNames.CompileOnSaveAffectedFileList, - CommandNames.Configure, - CommandNames.Definition, - CommandNames.DefinitionFull, - CommandNames.Implementation, - CommandNames.ImplementationFull, - CommandNames.Exit, - CommandNames.Format, - CommandNames.Formatonkey, - CommandNames.FormatFull, - CommandNames.FormatonkeyFull, - CommandNames.FormatRangeFull, - CommandNames.Geterr, - CommandNames.GeterrForProject, - CommandNames.SemanticDiagnosticsSync, - CommandNames.SyntacticDiagnosticsSync, - CommandNames.NavBar, - CommandNames.NavBarFull, - CommandNames.Navto, - CommandNames.NavtoFull, - CommandNames.NavTree, - CommandNames.NavTreeFull, - CommandNames.Occurrences, - CommandNames.DocumentHighlights, - CommandNames.DocumentHighlightsFull, - CommandNames.Open, - CommandNames.Quickinfo, - CommandNames.QuickinfoFull, - CommandNames.References, - CommandNames.ReferencesFull, - CommandNames.Reload, - CommandNames.Rename, - CommandNames.RenameInfoFull, - CommandNames.RenameLocationsFull, - CommandNames.Saveto, - CommandNames.SignatureHelp, - CommandNames.SignatureHelpFull, - CommandNames.TypeDefinition, - CommandNames.ProjectInfo, - CommandNames.ReloadProjects, - CommandNames.Unknown, - CommandNames.OpenExternalProject, - CommandNames.CloseExternalProject, - CommandNames.SynchronizeProjectList, - CommandNames.ApplyChangedToOpenFiles, - CommandNames.EncodedSemanticClassificationsFull, - CommandNames.Cleanup, - CommandNames.OutliningSpans, - CommandNames.TodoComments, - CommandNames.Indentation, - CommandNames.DocCommentTemplate, - CommandNames.CompilerOptionsDiagnosticsFull, - CommandNames.NameOrDottedNameSpan, - CommandNames.BreakpointStatement, - CommandNames.CompilerOptionsForInferredProjects, - CommandNames.GetCodeFixes, - CommandNames.GetCodeFixesFull, - CommandNames.GetSupportedCodeFixes, - CommandNames.GetApplicableRefactors, - CommandNames.GetEditsForRefactor, - CommandNames.GetEditsForRefactorFull, - ]; - it("should not throw when commands are executed with invalid arguments", () => { let i = 0; - for (const name of allCommandNames) { + for (const name in CommandNames) { + if (!Object.prototype.hasOwnProperty.call(CommandNames, name)) { + continue; + } const req: protocol.Request = { command: name, seq: i, diff --git a/src/server/session.ts b/src/server/session.ts index d09f2f3dd2711..ff5ef6a285a99 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -213,7 +213,7 @@ namespace ts.server { export const GetEditsForRefactor: protocol.CommandTypes.GetEditsForRefactor = "getEditsForRefactor"; /* @internal */ - export const GetEditsForRefactorFull: protocol.CommandTypes.GetEditsForRefactorFull = "getEditsForRefactor-full" + export const GetEditsForRefactorFull: protocol.CommandTypes.GetEditsForRefactorFull = "getEditsForRefactor-full"; } export function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string {