From 64958669e1a0b25a9c0f02dd246c0beb7a40b995 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 24 Dec 2015 17:18:10 +0900 Subject: [PATCH 1/6] remove "this should be removed ..." codes --- src/services/shims.ts | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index 6b656ea2738..c12c52fa201 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -333,11 +333,6 @@ namespace ts { } public getScriptSnapshot(fileName: string): IScriptSnapshot { - // Shim the API changes for 1.5 release. This should be removed once - // TypeScript 1.5 has shipped. - if (this.files && this.files.indexOf(fileName) < 0) { - return undefined; - } var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); } @@ -371,14 +366,7 @@ namespace ts { } public getDefaultLibFileName(options: CompilerOptions): string { - // Wrap the API changes for 1.5 release. This try/catch - // should be removed once TypeScript 1.5 has shipped. - try { - return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); - } - catch (e) { - return ""; - } + return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); } } @@ -411,17 +399,9 @@ namespace ts { } public readDirectory(rootDir: string, extension: string, exclude: string[]): string[] { - // Wrap the API changes for 1.5 release. This try/catch - // should be removed once TypeScript 1.5 has shipped. - // Also consider removing the optional designation for + // Consider removing the optional designation for // the exclude param at this time. - var encoded: string; - try { - encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); - } - catch (e) { - encoded = this.shimHost.readDirectory(rootDir, extension); - } + var encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); return JSON.parse(encoded); } @@ -889,9 +869,6 @@ namespace ts { "getEmitOutput('" + fileName + "')", () => { var output = this.languageService.getEmitOutput(fileName); - // Shim the API changes for 1.5 release. This should be removed once - // TypeScript 1.5 has shipped. - (output).emitOutputStatus = output.emitSkipped ? 1 : 0; return output; }); } From 6373cfff64dda36dcf23906e5726790ba29b15dd Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 24 Dec 2015 17:21:03 +0900 Subject: [PATCH 2/6] lets and template strings --- src/services/shims.ts | 202 +++++++++++++++++++++--------------------- 1 file changed, 101 insertions(+), 101 deletions(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index c12c52fa201..86bf15539bf 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -60,7 +60,7 @@ namespace ts { getNewLine?(): string; getProjectVersion?(): string; useCaseSensitiveFileNames?(): boolean; - + getModuleResolutionsForFile?(fileName: string): string; } @@ -247,14 +247,14 @@ namespace ts { } public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange { - var oldSnapshotShim = oldSnapshot; - var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + let oldSnapshotShim = oldSnapshot; + let encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); // TODO: should this be '==='? if (encoded == null) { return null; } - var decoded: { span: { start: number; length: number; }; newLength: number; } = JSON.parse(encoded); + let decoded: { span: { start: number; length: number; }; newLength: number; } = JSON.parse(encoded); return createTextChangeRange( createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); } @@ -272,9 +272,9 @@ namespace ts { private files: string[]; private loggingEnabled = false; private tracingEnabled = false; - + public resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModule[]; - + constructor(private shimHost: LanguageServiceShimHost) { // if shimHost is a COM object then property check will become method call with no arguments. // 'in' does not have this effect. @@ -319,7 +319,7 @@ namespace ts { } public getCompilationSettings(): CompilerOptions { - var settingsJson = this.shimHost.getCompilationSettings(); + let settingsJson = this.shimHost.getCompilationSettings(); // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); @@ -328,12 +328,12 @@ namespace ts { } public getScriptFileNames(): string[] { - var encoded = this.shimHost.getScriptFileNames(); + let encoded = this.shimHost.getScriptFileNames(); return this.files = JSON.parse(encoded); } public getScriptSnapshot(fileName: string): IScriptSnapshot { - var scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + let scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); } @@ -342,7 +342,7 @@ namespace ts { } public getLocalizedDiagnosticMessages(): any { - var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); + let diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { return null; } @@ -357,7 +357,7 @@ namespace ts { } public getCancellationToken(): HostCancellationToken { - var hostCancellationToken = this.shimHost.getCancellationToken(); + let hostCancellationToken = this.shimHost.getCancellationToken(); return new ThrottledCancellationToken(hostCancellationToken); } @@ -381,8 +381,8 @@ namespace ts { } public isCancellationRequested(): boolean { - var time = Date.now(); - var duration = Math.abs(time - this.lastCancellationCheckTime); + let time = Date.now(); + let duration = Math.abs(time - this.lastCancellationCheckTime); if (duration > 10) { // Check no more than once every 10 ms. this.lastCancellationCheckTime = time; @@ -401,36 +401,37 @@ namespace ts { public readDirectory(rootDir: string, extension: string, exclude: string[]): string[] { // Consider removing the optional designation for // the exclude param at this time. - var encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + let encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); return JSON.parse(encoded); } - + public fileExists(fileName: string): boolean { return this.shimHost.fileExists(fileName); } - + public readFile(fileName: string): string { return this.shimHost.readFile(fileName); } } function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): any { + let start: number; if (logPerformance) { logger.log(actionDescription); - var start = Date.now(); + start = Date.now(); } - var result = action(); + let result = action(); if (logPerformance) { - var end = Date.now(); - logger.log(actionDescription + " completed in " + (end - start) + " msec"); - if (typeof (result) === "string") { - var str = result; + let end = Date.now(); + logger.log(`${actionDescription} completed in ${end - start} msec`); + if (typeof result === "string") { + let str = result; if (str.length > 128) { str = str.substring(0, 128) + "..."; } - logger.log(" result.length=" + str.length + ", result='" + JSON.stringify(str) + "'"); + logger.log(` result.length=${str.length}, result='${JSON.stringify(str)}'`); } } @@ -439,7 +440,7 @@ namespace ts { function forwardJSONCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): string { try { - var result = simpleForwardCall(logger, actionDescription, action, logPerformance); + let result = simpleForwardCall(logger, actionDescription, action, logPerformance); return JSON.stringify({ result: result }); } catch (err) { @@ -461,7 +462,7 @@ namespace ts { } } - export function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { message: string; start: number; length: number; category: string; code: number; } []{ + export function realizeDiagnostics(diagnostics: Diagnostic[], newLine: string): { message: string; start: number; length: number; category: string; code: number; }[] { return diagnostics.map(d => realizeDiagnostic(d, newLine)); } @@ -520,7 +521,7 @@ namespace ts { */ public refresh(throwOnError: boolean): void { this.forwardJSONCall( - "refresh(" + throwOnError + ")", + `refresh(${throwOnError})`, () => { return null; }); @@ -535,32 +536,32 @@ namespace ts { }); } - private realizeDiagnostics(diagnostics: Diagnostic[]): { message: string; start: number; length: number; category: string; }[]{ - var newLine = getNewLineOrDefaultFromHost(this.host); + private realizeDiagnostics(diagnostics: Diagnostic[]): { message: string; start: number; length: number; category: string; }[] { + let newLine = getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); } public getSyntacticClassifications(fileName: string, start: number, length: number): string { return this.forwardJSONCall( - "getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", + `getSyntacticClassifications('${fileName}', ${start}, ${length})`, () => { - var classifications = this.languageService.getSyntacticClassifications(fileName, createTextSpan(start, length)); + let classifications = this.languageService.getSyntacticClassifications(fileName, createTextSpan(start, length)); return classifications; }); } public getSemanticClassifications(fileName: string, start: number, length: number): string { return this.forwardJSONCall( - "getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", + `getSemanticClassifications('${fileName}', ${start}, ${length})`, () => { - var classifications = this.languageService.getSemanticClassifications(fileName, createTextSpan(start, length)); + let classifications = this.languageService.getSemanticClassifications(fileName, createTextSpan(start, length)); return classifications; }); } public getEncodedSyntacticClassifications(fileName: string, start: number, length: number): string { return this.forwardJSONCall( - "getEncodedSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")", + `getEncodedSyntacticClassifications('${fileName}', ${start}, ${length})`, () => { // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. @@ -570,7 +571,7 @@ namespace ts { public getEncodedSemanticClassifications(fileName: string, start: number, length: number): string { return this.forwardJSONCall( - "getEncodedSemanticClassifications('" + fileName + "', " + start + ", " + length + ")", + `getEncodedSemanticClassifications('${fileName}', ${start}, ${length})`, () => { // directly serialize the spans out to a string. This is much faster to decode // on the managed side versus a full JSON array. @@ -580,18 +581,18 @@ namespace ts { public getSyntacticDiagnostics(fileName: string): string { return this.forwardJSONCall( - "getSyntacticDiagnostics('" + fileName + "')", + `getSyntacticDiagnostics('${fileName}')`, () => { - var diagnostics = this.languageService.getSyntacticDiagnostics(fileName); + let diagnostics = this.languageService.getSyntacticDiagnostics(fileName); return this.realizeDiagnostics(diagnostics); }); } public getSemanticDiagnostics(fileName: string): string { return this.forwardJSONCall( - "getSemanticDiagnostics('" + fileName + "')", + `getSemanticDiagnostics('${fileName}')`, () => { - var diagnostics = this.languageService.getSemanticDiagnostics(fileName); + let diagnostics = this.languageService.getSemanticDiagnostics(fileName); return this.realizeDiagnostics(diagnostics); }); } @@ -600,7 +601,7 @@ namespace ts { return this.forwardJSONCall( "getCompilerOptionsDiagnostics()", () => { - var diagnostics = this.languageService.getCompilerOptionsDiagnostics(); + let diagnostics = this.languageService.getCompilerOptionsDiagnostics(); return this.realizeDiagnostics(diagnostics); }); } @@ -613,9 +614,9 @@ namespace ts { */ public getQuickInfoAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( - "getQuickInfoAtPosition('" + fileName + "', " + position + ")", + `getQuickInfoAtPosition('${fileName}', ${position})`, () => { - var quickInfo = this.languageService.getQuickInfoAtPosition(fileName, position); + let quickInfo = this.languageService.getQuickInfoAtPosition(fileName, position); return quickInfo; }); } @@ -629,9 +630,9 @@ namespace ts { */ public getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): string { return this.forwardJSONCall( - "getNameOrDottedNameSpan('" + fileName + "', " + startPos + ", " + endPos + ")", + `getNameOrDottedNameSpan('${fileName}', ${startPos}, ${endPos})`, () => { - var spanInfo = this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); + let spanInfo = this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); return spanInfo; }); } @@ -642,9 +643,9 @@ namespace ts { */ public getBreakpointStatementAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( - "getBreakpointStatementAtPosition('" + fileName + "', " + position + ")", + `getBreakpointStatementAtPosition('${fileName}', ${position})`, () => { - var spanInfo = this.languageService.getBreakpointStatementAtPosition(fileName, position); + let spanInfo = this.languageService.getBreakpointStatementAtPosition(fileName, position); return spanInfo; }); } @@ -653,9 +654,9 @@ namespace ts { public getSignatureHelpItems(fileName: string, position: number): string { return this.forwardJSONCall( - "getSignatureHelpItems('" + fileName + "', " + position + ")", + `getSignatureHelpItems('${fileName}', ${position})`, () => { - var signatureInfo = this.languageService.getSignatureHelpItems(fileName, position); + let signatureInfo = this.languageService.getSignatureHelpItems(fileName, position); return signatureInfo; }); } @@ -668,7 +669,7 @@ namespace ts { */ public getDefinitionAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( - "getDefinitionAtPosition('" + fileName + "', " + position + ")", + `getDefinitionAtPosition('${fileName}', ${position})`, () => { return this.languageService.getDefinitionAtPosition(fileName, position); }); @@ -682,7 +683,7 @@ namespace ts { */ public getTypeDefinitionAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( - "getTypeDefinitionAtPosition('" + fileName + "', " + position + ")", + `getTypeDefinitionAtPosition('${fileName}', ${position})`, () => { return this.languageService.getTypeDefinitionAtPosition(fileName, position); }); @@ -690,7 +691,7 @@ namespace ts { public getRenameInfo(fileName: string, position: number): string { return this.forwardJSONCall( - "getRenameInfo('" + fileName + "', " + position + ")", + `getRenameInfo('${fileName}', ${position})`, () => { return this.languageService.getRenameInfo(fileName, position); }); @@ -698,7 +699,7 @@ namespace ts { public findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): string { return this.forwardJSONCall( - "findRenameLocations('" + fileName + "', " + position + ", " + findInStrings + ", " + findInComments + ")", + `findRenameLocations('${fileName}', ${position}, ${findInStrings}, ${findInComments})`, () => { return this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); }); @@ -707,9 +708,9 @@ namespace ts { /// GET BRACE MATCHING public getBraceMatchingAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( - "getBraceMatchingAtPosition('" + fileName + "', " + position + ")", + `getBraceMatchingAtPosition('${fileName}', ${position})`, () => { - var textRanges = this.languageService.getBraceMatchingAtPosition(fileName, position); + let textRanges = this.languageService.getBraceMatchingAtPosition(fileName, position); return textRanges; }); } @@ -717,9 +718,9 @@ namespace ts { /// GET SMART INDENT public getIndentationAtPosition(fileName: string, position: number, options: string /*Services.EditorOptions*/): string { return this.forwardJSONCall( - "getIndentationAtPosition('" + fileName + "', " + position + ")", + `getIndentationAtPosition('${fileName}', ${position})`, () => { - var localOptions: EditorOptions = JSON.parse(options); + let localOptions: EditorOptions = JSON.parse(options); return this.languageService.getIndentationAtPosition(fileName, position, localOptions); }); } @@ -728,7 +729,7 @@ namespace ts { public getReferencesAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( - "getReferencesAtPosition('" + fileName + "', " + position + ")", + `getReferencesAtPosition('${fileName}', ${position})`, () => { return this.languageService.getReferencesAtPosition(fileName, position); }); @@ -736,7 +737,7 @@ namespace ts { public findReferences(fileName: string, position: number): string { return this.forwardJSONCall( - "findReferences('" + fileName + "', " + position + ")", + `findReferences('${fileName}', ${position})`, () => { return this.languageService.findReferences(fileName, position); }); @@ -744,7 +745,7 @@ namespace ts { public getOccurrencesAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( - "getOccurrencesAtPosition('" + fileName + "', " + position + ")", + `getOccurrencesAtPosition('${fileName}', ${position})`, () => { return this.languageService.getOccurrencesAtPosition(fileName, position); }); @@ -752,9 +753,9 @@ namespace ts { public getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string { return this.forwardJSONCall( - "getDocumentHighlights('" + fileName + "', " + position + ")", + `getDocumentHighlights('${fileName}', ${position})`, () => { - var results = this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + let results = this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); // workaround for VS document higlighting issue - keep only items from the initial file let normalizedName = normalizeSlashes(fileName).toLowerCase(); return filter(results, r => normalizeSlashes(r.fileName).toLowerCase() === normalizedName); @@ -770,9 +771,9 @@ namespace ts { */ public getCompletionsAtPosition(fileName: string, position: number) { return this.forwardJSONCall( - "getCompletionsAtPosition('" + fileName + "', " + position + ")", + `getCompletionsAtPosition('${fileName}', ${position})`, () => { - var completion = this.languageService.getCompletionsAtPosition(fileName, position); + let completion = this.languageService.getCompletionsAtPosition(fileName, position); return completion; }); } @@ -780,46 +781,46 @@ namespace ts { /** Get a string based representation of a completion list entry details */ public getCompletionEntryDetails(fileName: string, position: number, entryName: string) { return this.forwardJSONCall( - "getCompletionEntryDetails('" + fileName + "', " + position + ", " + entryName + ")", + `getCompletionEntryDetails('${fileName}', ${position}, ${entryName})`, () => { - var details = this.languageService.getCompletionEntryDetails(fileName, position, entryName); + let details = this.languageService.getCompletionEntryDetails(fileName, position, entryName); return details; }); } public getFormattingEditsForRange(fileName: string, start: number, end: number, options: string/*Services.FormatCodeOptions*/): string { return this.forwardJSONCall( - "getFormattingEditsForRange('" + fileName + "', " + start + ", " + end + ")", + `getFormattingEditsForRange('${fileName}', ${start}, ${end})`, () => { - var localOptions: ts.FormatCodeOptions = JSON.parse(options); - var edits = this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); + let localOptions: ts.FormatCodeOptions = JSON.parse(options); + let edits = this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); return edits; }); } public getFormattingEditsForDocument(fileName: string, options: string/*Services.FormatCodeOptions*/): string { return this.forwardJSONCall( - "getFormattingEditsForDocument('" + fileName + "')", + `getFormattingEditsForDocument('${fileName}')`, () => { - var localOptions: ts.FormatCodeOptions = JSON.parse(options); - var edits = this.languageService.getFormattingEditsForDocument(fileName, localOptions); + let localOptions: ts.FormatCodeOptions = JSON.parse(options); + let edits = this.languageService.getFormattingEditsForDocument(fileName, localOptions); return edits; }); } public getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: string/*Services.FormatCodeOptions*/): string { return this.forwardJSONCall( - "getFormattingEditsAfterKeystroke('" + fileName + "', " + position + ", '" + key + "')", + `getFormattingEditsAfterKeystroke('${fileName}', ${position}, '${key}')`, () => { - var localOptions: ts.FormatCodeOptions = JSON.parse(options); - var edits = this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); + let localOptions: ts.FormatCodeOptions = JSON.parse(options); + let edits = this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); return edits; }); } public getDocCommentTemplateAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( - "getDocCommentTemplateAtPosition('" + fileName + "', " + position + ")", + `getDocCommentTemplateAtPosition('${fileName}', ${position})`, () => this.languageService.getDocCommentTemplateAtPosition(fileName, position) ); } @@ -829,36 +830,36 @@ namespace ts { /** Return a list of symbols that are interesting to navigate to */ public getNavigateToItems(searchValue: string, maxResultCount?: number): string { return this.forwardJSONCall( - "getNavigateToItems('" + searchValue + "', " + maxResultCount+ ")", + `getNavigateToItems('${searchValue}', ${maxResultCount})`, () => { - var items = this.languageService.getNavigateToItems(searchValue, maxResultCount); + let items = this.languageService.getNavigateToItems(searchValue, maxResultCount); return items; }); } public getNavigationBarItems(fileName: string): string { return this.forwardJSONCall( - "getNavigationBarItems('" + fileName + "')", + `getNavigationBarItems('${fileName}')`, () => { - var items = this.languageService.getNavigationBarItems(fileName); + let items = this.languageService.getNavigationBarItems(fileName); return items; }); } public getOutliningSpans(fileName: string): string { return this.forwardJSONCall( - "getOutliningSpans('" + fileName + "')", + `getOutliningSpans('${fileName}')`, () => { - var items = this.languageService.getOutliningSpans(fileName); + let items = this.languageService.getOutliningSpans(fileName); return items; }); } public getTodoComments(fileName: string, descriptors: string): string { return this.forwardJSONCall( - "getTodoComments('" + fileName + "')", + `getTodoComments('${fileName}')`, () => { - var items = this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); + let items = this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); return items; }); } @@ -866,9 +867,9 @@ namespace ts { /// Emit public getEmitOutput(fileName: string): string { return this.forwardJSONCall( - "getEmitOutput('" + fileName + "')", + `getEmitOutput('${fileName}')`, () => { - var output = this.languageService.getEmitOutput(fileName); + let output = this.languageService.getEmitOutput(fileName); return output; }); } @@ -895,12 +896,11 @@ namespace ts { /// COLORIZATION public getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): string { - var classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); - var items = classification.entries; - var result = ""; - for (var i = 0; i < items.length; i++) { - result += items[i].length + "\n"; - result += items[i].classification + "\n"; + let classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); + let result = ""; + for (let item of classification.entries) { + result += item.length + "\n"; + result += item.classification + "\n"; } result += classification.finalLexState; return result; @@ -917,16 +917,16 @@ namespace ts { private forwardJSONCall(actionDescription: string, action: () => any): any { return forwardJSONCall(this.logger, actionDescription, action, this.logPerformance); } - + public resolveModuleName(fileName: string, moduleName: string, compilerOptionsJson: string): string { return this.forwardJSONCall(`resolveModuleName('${fileName}')`, () => { let compilerOptions = JSON.parse(compilerOptionsJson); const result = resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host); return { - resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName: undefined, + resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, failedLookupLocations: result.failedLookupLocations }; - }); + }); } public getPreProcessedFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string { @@ -934,8 +934,8 @@ namespace ts { "getPreProcessedFileInfo('" + fileName + "')", () => { // for now treat files as JavaScript - var result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true); - var convertResult = { + let result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true); + let convertResult = { referencedFiles: [], importedFiles: [], ambientExternalModules: result.ambientExternalModules, @@ -963,7 +963,7 @@ namespace ts { public getTSConfigFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string { return this.forwardJSONCall( - "getTSConfigFileInfo('" + fileName + "')", + `getTSConfigFileInfo('${fileName}')`, () => { let text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); @@ -977,7 +977,7 @@ namespace ts { }; } - var configFile = parseJsonConfigFileContent(result.config, this.host, getDirectoryPath(normalizeSlashes(fileName))); + let configFile = parseJsonConfigFileContent(result.config, this.host, getDirectoryPath(normalizeSlashes(fileName))); return { options: configFile.options, @@ -1012,8 +1012,8 @@ namespace ts { if (this.documentRegistry === undefined) { this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } - var hostAdapter = new LanguageServiceShimHostAdapter(host); - var languageService = createLanguageService(hostAdapter, this.documentRegistry); + let hostAdapter = new LanguageServiceShimHostAdapter(host); + let languageService = createLanguageService(hostAdapter, this.documentRegistry); return new LanguageServiceShimObject(this, host, languageService); } catch (err) { @@ -1034,7 +1034,7 @@ namespace ts { public createCoreServicesShim(host: CoreServicesShimHost): CoreServicesShim { try { - var adapter = new CoreServicesShimHostAdapter(host); + let adapter = new CoreServicesShimHostAdapter(host); return new CoreServicesShimObject(this, host, adapter); } catch (err) { @@ -1054,7 +1054,7 @@ namespace ts { } public unregisterShim(shim: Shim): void { - for (var i = 0, n = this._shims.length; i < n; i++) { + for (let i = 0, n = this._shims.length; i < n; i++) { if (this._shims[i] === shim) { delete this._shims[i]; return; From f0a4d6fd0be706950b58ceb5e88be7b8e7f0ef06 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Fri, 8 Jan 2016 02:00:20 +0900 Subject: [PATCH 3/6] enclose entryName --- src/services/shims.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index 31171ba2f98..0a48d5c2523 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -791,7 +791,7 @@ namespace ts { /** Get a string based representation of a completion list entry details */ public getCompletionEntryDetails(fileName: string, position: number, entryName: string) { return this.forwardJSONCall( - `getCompletionEntryDetails('${fileName}', ${position}, ${entryName})`, + `getCompletionEntryDetails('${fileName}', ${position}, '${entryName}')`, () => { let details = this.languageService.getCompletionEntryDetails(fileName, position, entryName); return details; From 5144603b3bcce421cd3dea08bdd75767b54800e5 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Fri, 8 Jan 2016 02:16:14 +0900 Subject: [PATCH 4/6] const everywhere --- src/services/shims.ts | 77 +++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 40 deletions(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index 0a48d5c2523..88042d0e821 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -248,14 +248,14 @@ namespace ts { } public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange { - let oldSnapshotShim = oldSnapshot; - let encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + const oldSnapshotShim = oldSnapshot; + const encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); // TODO: should this be '==='? if (encoded == null) { return null; } - let decoded: { span: { start: number; length: number; }; newLength: number; } = JSON.parse(encoded); + const decoded: { span: { start: number; length: number; }; newLength: number; } = JSON.parse(encoded); return createTextChangeRange( createTextSpan(decoded.span.start, decoded.span.length), decoded.newLength); } @@ -282,7 +282,7 @@ namespace ts { // 'in' does not have this effect. if ("getModuleResolutionsForFile" in this.shimHost) { this.resolveModuleNames = (moduleNames: string[], containingFile: string) => { - let resolutionsInFile = >JSON.parse(this.shimHost.getModuleResolutionsForFile(containingFile)); + const resolutionsInFile = >JSON.parse(this.shimHost.getModuleResolutionsForFile(containingFile)); return map(moduleNames, name => { const result = lookUp(resolutionsInFile, name); return result ? { resolvedFileName: result } : undefined; @@ -324,7 +324,7 @@ namespace ts { } public getCompilationSettings(): CompilerOptions { - let settingsJson = this.shimHost.getCompilationSettings(); + const settingsJson = this.shimHost.getCompilationSettings(); // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); @@ -333,12 +333,12 @@ namespace ts { } public getScriptFileNames(): string[] { - let encoded = this.shimHost.getScriptFileNames(); + const encoded = this.shimHost.getScriptFileNames(); return this.files = JSON.parse(encoded); } public getScriptSnapshot(fileName: string): IScriptSnapshot { - let scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); + const scriptSnapshot = this.shimHost.getScriptSnapshot(fileName); return scriptSnapshot && new ScriptSnapshotShimAdapter(scriptSnapshot); } @@ -347,7 +347,7 @@ namespace ts { } public getLocalizedDiagnosticMessages(): any { - let diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); + const diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { return null; } @@ -362,7 +362,7 @@ namespace ts { } public getCancellationToken(): HostCancellationToken { - let hostCancellationToken = this.shimHost.getCancellationToken(); + const hostCancellationToken = this.shimHost.getCancellationToken(); return new ThrottledCancellationToken(hostCancellationToken); } @@ -386,8 +386,8 @@ namespace ts { } public isCancellationRequested(): boolean { - let time = Date.now(); - let duration = Math.abs(time - this.lastCancellationCheckTime); + const time = Date.now(); + const duration = Math.abs(time - this.lastCancellationCheckTime); if (duration > 10) { // Check no more than once every 10 ms. this.lastCancellationCheckTime = time; @@ -411,7 +411,7 @@ namespace ts { public readDirectory(rootDir: string, extension: string, exclude: string[]): string[] { // Consider removing the optional designation for // the exclude param at this time. - let encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); + const encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); return JSON.parse(encoded); } @@ -431,10 +431,10 @@ namespace ts { start = Date.now(); } - let result = action(); + const result = action(); if (logPerformance) { - let end = Date.now(); + const end = Date.now(); logger.log(`${actionDescription} completed in ${end - start} msec`); if (typeof result === "string") { let str = result; @@ -450,8 +450,8 @@ namespace ts { function forwardJSONCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): string { try { - let result = simpleForwardCall(logger, actionDescription, action, logPerformance); - return JSON.stringify({ result: result }); + const result = simpleForwardCall(logger, actionDescription, action, logPerformance); + return JSON.stringify({ result }); } catch (err) { if (err instanceof OperationCanceledException) { @@ -547,7 +547,7 @@ namespace ts { } private realizeDiagnostics(diagnostics: Diagnostic[]): { message: string; start: number; length: number; category: string; }[] { - let newLine = getNewLineOrDefaultFromHost(this.host); + const newLine = getNewLineOrDefaultFromHost(this.host); return ts.realizeDiagnostics(diagnostics, newLine); } @@ -730,7 +730,7 @@ namespace ts { return this.forwardJSONCall( `getIndentationAtPosition('${fileName}', ${position})`, () => { - let localOptions: EditorOptions = JSON.parse(options); + const localOptions: EditorOptions = JSON.parse(options); return this.languageService.getIndentationAtPosition(fileName, position, localOptions); }); } @@ -765,9 +765,9 @@ namespace ts { return this.forwardJSONCall( `getDocumentHighlights('${fileName}', ${position})`, () => { - let results = this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); + const results = this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch)); // workaround for VS document higlighting issue - keep only items from the initial file - let normalizedName = normalizeSlashes(fileName).toLowerCase(); + const normalizedName = normalizeSlashes(fileName).toLowerCase(); return filter(results, r => normalizeSlashes(r.fileName).toLowerCase() === normalizedName); }); } @@ -802,9 +802,8 @@ namespace ts { return this.forwardJSONCall( `getFormattingEditsForRange('${fileName}', ${start}, ${end})`, () => { - let localOptions: ts.FormatCodeOptions = JSON.parse(options); - let edits = this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); - return edits; + const localOptions: ts.FormatCodeOptions = JSON.parse(options); + return this.languageService.getFormattingEditsForRange(fileName, start, end, localOptions); }); } @@ -812,9 +811,8 @@ namespace ts { return this.forwardJSONCall( `getFormattingEditsForDocument('${fileName}')`, () => { - let localOptions: ts.FormatCodeOptions = JSON.parse(options); - let edits = this.languageService.getFormattingEditsForDocument(fileName, localOptions); - return edits; + const localOptions: ts.FormatCodeOptions = JSON.parse(options); + return this.languageService.getFormattingEditsForDocument(fileName, localOptions); }); } @@ -822,9 +820,8 @@ namespace ts { return this.forwardJSONCall( `getFormattingEditsAfterKeystroke('${fileName}', ${position}, '${key}')`, () => { - let localOptions: ts.FormatCodeOptions = JSON.parse(options); - let edits = this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); - return edits; + const localOptions: ts.FormatCodeOptions = JSON.parse(options); + return this.languageService.getFormattingEditsAfterKeystroke(fileName, position, key, localOptions); }); } @@ -906,9 +903,9 @@ namespace ts { /// COLORIZATION public getClassificationsForLine(text: string, lexState: EndOfLineState, classifyKeywordsInGenerics?: boolean): string { - let classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); + const classification = this.classifier.getClassificationsForLine(text, lexState, classifyKeywordsInGenerics); let result = ""; - for (let item of classification.entries) { + for (const item of classification.entries) { result += item.length + "\n"; result += item.classification + "\n"; } @@ -930,7 +927,7 @@ namespace ts { public resolveModuleName(fileName: string, moduleName: string, compilerOptionsJson: string): string { return this.forwardJSONCall(`resolveModuleName('${fileName}')`, () => { - let compilerOptions = JSON.parse(compilerOptionsJson); + const compilerOptions = JSON.parse(compilerOptionsJson); const result = resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host); return { resolvedFileName: result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined, @@ -944,8 +941,8 @@ namespace ts { "getPreProcessedFileInfo('" + fileName + "')", () => { // for now treat files as JavaScript - let result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true); - let convertResult = { + const result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true); + const convertResult = { referencedFiles: [], importedFiles: [], ambientExternalModules: result.ambientExternalModules, @@ -975,9 +972,9 @@ namespace ts { return this.forwardJSONCall( `getTSConfigFileInfo('${fileName}')`, () => { - let text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); + const text = sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()); - let result = parseConfigFileTextToJson(fileName, text); + const result = parseConfigFileTextToJson(fileName, text); if (result.error) { return { @@ -987,7 +984,7 @@ namespace ts { }; } - let configFile = parseJsonConfigFileContent(result.config, this.host, getDirectoryPath(normalizeSlashes(fileName))); + const configFile = parseJsonConfigFileContent(result.config, this.host, getDirectoryPath(normalizeSlashes(fileName))); return { options: configFile.options, @@ -1022,8 +1019,8 @@ namespace ts { if (this.documentRegistry === undefined) { this.documentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } - let hostAdapter = new LanguageServiceShimHostAdapter(host); - let languageService = createLanguageService(hostAdapter, this.documentRegistry); + const hostAdapter = new LanguageServiceShimHostAdapter(host); + const languageService = createLanguageService(hostAdapter, this.documentRegistry); return new LanguageServiceShimObject(this, host, languageService); } catch (err) { @@ -1044,7 +1041,7 @@ namespace ts { public createCoreServicesShim(host: CoreServicesShimHost): CoreServicesShim { try { - let adapter = new CoreServicesShimHostAdapter(host); + const adapter = new CoreServicesShimHostAdapter(host); return new CoreServicesShimObject(this, host, adapter); } catch (err) { From 5cafd962e9c489a2a6aa9720932889e2eb2feb15 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Fri, 8 Jan 2016 02:24:32 +0900 Subject: [PATCH 5/6] thinner arrows --- src/services/shims.ts | 157 ++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 98 deletions(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index 88042d0e821..4551013ff8d 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -276,7 +276,7 @@ namespace ts { public resolveModuleNames: (moduleName: string[], containingFile: string) => ResolvedModule[]; public directoryExists: (directoryName: string) => boolean; - + constructor(private shimHost: LanguageServiceShimHost) { // if shimHost is a COM object then property check will become method call with no arguments. // 'in' does not have this effect. @@ -401,7 +401,7 @@ namespace ts { export class CoreServicesShimHostAdapter implements ParseConfigHost, ModuleResolutionHost { public directoryExists: (directoryName: string) => boolean; - + constructor(private shimHost: CoreServicesShimHost) { if ("directoryExists" in this.shimHost) { this.directoryExists = directoryName => this.shimHost.directoryExists(directoryName); @@ -532,9 +532,8 @@ namespace ts { public refresh(throwOnError: boolean): void { this.forwardJSONCall( `refresh(${throwOnError})`, - () => { - return null; - }); + () => null + ); } public cleanupSemanticCache(): void { @@ -554,46 +553,40 @@ namespace ts { public getSyntacticClassifications(fileName: string, start: number, length: number): string { return this.forwardJSONCall( `getSyntacticClassifications('${fileName}', ${start}, ${length})`, - () => { - let classifications = this.languageService.getSyntacticClassifications(fileName, createTextSpan(start, length)); - return classifications; - }); + () => this.languageService.getSyntacticClassifications(fileName, createTextSpan(start, length)) + ); } public getSemanticClassifications(fileName: string, start: number, length: number): string { return this.forwardJSONCall( `getSemanticClassifications('${fileName}', ${start}, ${length})`, - () => { - let classifications = this.languageService.getSemanticClassifications(fileName, createTextSpan(start, length)); - return classifications; - }); + () => this.languageService.getSemanticClassifications(fileName, createTextSpan(start, length)) + ); } public getEncodedSyntacticClassifications(fileName: string, start: number, length: number): string { return this.forwardJSONCall( `getEncodedSyntacticClassifications('${fileName}', ${start}, ${length})`, - () => { - // directly serialize the spans out to a string. This is much faster to decode - // on the managed side versus a full JSON array. - return convertClassifications(this.languageService.getEncodedSyntacticClassifications(fileName, createTextSpan(start, length))); - }); + // directly serialize the spans out to a string. This is much faster to decode + // on the managed side versus a full JSON array. + () => convertClassifications(this.languageService.getEncodedSyntacticClassifications(fileName, createTextSpan(start, length))) + ); } public getEncodedSemanticClassifications(fileName: string, start: number, length: number): string { return this.forwardJSONCall( `getEncodedSemanticClassifications('${fileName}', ${start}, ${length})`, - () => { - // directly serialize the spans out to a string. This is much faster to decode - // on the managed side versus a full JSON array. - return convertClassifications(this.languageService.getEncodedSemanticClassifications(fileName, createTextSpan(start, length))); - }); + // directly serialize the spans out to a string. This is much faster to decode + // on the managed side versus a full JSON array. + () => convertClassifications(this.languageService.getEncodedSemanticClassifications(fileName, createTextSpan(start, length))) + ); } public getSyntacticDiagnostics(fileName: string): string { return this.forwardJSONCall( `getSyntacticDiagnostics('${fileName}')`, () => { - let diagnostics = this.languageService.getSyntacticDiagnostics(fileName); + const diagnostics = this.languageService.getSyntacticDiagnostics(fileName); return this.realizeDiagnostics(diagnostics); }); } @@ -602,7 +595,7 @@ namespace ts { return this.forwardJSONCall( `getSemanticDiagnostics('${fileName}')`, () => { - let diagnostics = this.languageService.getSemanticDiagnostics(fileName); + const diagnostics = this.languageService.getSemanticDiagnostics(fileName); return this.realizeDiagnostics(diagnostics); }); } @@ -611,7 +604,7 @@ namespace ts { return this.forwardJSONCall( "getCompilerOptionsDiagnostics()", () => { - let diagnostics = this.languageService.getCompilerOptionsDiagnostics(); + const diagnostics = this.languageService.getCompilerOptionsDiagnostics(); return this.realizeDiagnostics(diagnostics); }); } @@ -625,10 +618,8 @@ namespace ts { public getQuickInfoAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( `getQuickInfoAtPosition('${fileName}', ${position})`, - () => { - let quickInfo = this.languageService.getQuickInfoAtPosition(fileName, position); - return quickInfo; - }); + () => this.languageService.getQuickInfoAtPosition(fileName, position) + ); } @@ -641,10 +632,8 @@ namespace ts { public getNameOrDottedNameSpan(fileName: string, startPos: number, endPos: number): string { return this.forwardJSONCall( `getNameOrDottedNameSpan('${fileName}', ${startPos}, ${endPos})`, - () => { - let spanInfo = this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos); - return spanInfo; - }); + () => this.languageService.getNameOrDottedNameSpan(fileName, startPos, endPos) + ); } /** @@ -654,10 +643,8 @@ namespace ts { public getBreakpointStatementAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( `getBreakpointStatementAtPosition('${fileName}', ${position})`, - () => { - let spanInfo = this.languageService.getBreakpointStatementAtPosition(fileName, position); - return spanInfo; - }); + () => this.languageService.getBreakpointStatementAtPosition(fileName, position) + ); } /// SIGNATUREHELP @@ -665,10 +652,8 @@ namespace ts { public getSignatureHelpItems(fileName: string, position: number): string { return this.forwardJSONCall( `getSignatureHelpItems('${fileName}', ${position})`, - () => { - let signatureInfo = this.languageService.getSignatureHelpItems(fileName, position); - return signatureInfo; - }); + () => this.languageService.getSignatureHelpItems(fileName, position) + ); } /// GOTO DEFINITION @@ -680,9 +665,8 @@ namespace ts { public getDefinitionAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( `getDefinitionAtPosition('${fileName}', ${position})`, - () => { - return this.languageService.getDefinitionAtPosition(fileName, position); - }); + () => this.languageService.getDefinitionAtPosition(fileName, position) + ); } /// GOTO Type @@ -694,35 +678,30 @@ namespace ts { public getTypeDefinitionAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( `getTypeDefinitionAtPosition('${fileName}', ${position})`, - () => { - return this.languageService.getTypeDefinitionAtPosition(fileName, position); - }); + () => this.languageService.getTypeDefinitionAtPosition(fileName, position) + ); } public getRenameInfo(fileName: string, position: number): string { return this.forwardJSONCall( `getRenameInfo('${fileName}', ${position})`, - () => { - return this.languageService.getRenameInfo(fileName, position); - }); + () => this.languageService.getRenameInfo(fileName, position) + ); } public findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): string { return this.forwardJSONCall( `findRenameLocations('${fileName}', ${position}, ${findInStrings}, ${findInComments})`, - () => { - return this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments); - }); + () => this.languageService.findRenameLocations(fileName, position, findInStrings, findInComments) + ); } /// GET BRACE MATCHING public getBraceMatchingAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( `getBraceMatchingAtPosition('${fileName}', ${position})`, - () => { - let textRanges = this.languageService.getBraceMatchingAtPosition(fileName, position); - return textRanges; - }); + () => this.languageService.getBraceMatchingAtPosition(fileName, position) + ); } /// GET SMART INDENT @@ -740,25 +719,22 @@ namespace ts { public getReferencesAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( `getReferencesAtPosition('${fileName}', ${position})`, - () => { - return this.languageService.getReferencesAtPosition(fileName, position); - }); + () => this.languageService.getReferencesAtPosition(fileName, position) + ); } public findReferences(fileName: string, position: number): string { return this.forwardJSONCall( `findReferences('${fileName}', ${position})`, - () => { - return this.languageService.findReferences(fileName, position); - }); + () => this.languageService.findReferences(fileName, position) + ); } public getOccurrencesAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( `getOccurrencesAtPosition('${fileName}', ${position})`, - () => { - return this.languageService.getOccurrencesAtPosition(fileName, position); - }); + () => this.languageService.getOccurrencesAtPosition(fileName, position) + ); } public getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string { @@ -782,20 +758,16 @@ namespace ts { public getCompletionsAtPosition(fileName: string, position: number) { return this.forwardJSONCall( `getCompletionsAtPosition('${fileName}', ${position})`, - () => { - let completion = this.languageService.getCompletionsAtPosition(fileName, position); - return completion; - }); + () => this.languageService.getCompletionsAtPosition(fileName, position) + ); } /** Get a string based representation of a completion list entry details */ public getCompletionEntryDetails(fileName: string, position: number, entryName: string) { return this.forwardJSONCall( `getCompletionEntryDetails('${fileName}', ${position}, '${entryName}')`, - () => { - let details = this.languageService.getCompletionEntryDetails(fileName, position, entryName); - return details; - }); + () => this.languageService.getCompletionEntryDetails(fileName, position, entryName) + ); } public getFormattingEditsForRange(fileName: string, start: number, end: number, options: string/*Services.FormatCodeOptions*/): string { @@ -838,47 +810,37 @@ namespace ts { public getNavigateToItems(searchValue: string, maxResultCount?: number): string { return this.forwardJSONCall( `getNavigateToItems('${searchValue}', ${maxResultCount})`, - () => { - let items = this.languageService.getNavigateToItems(searchValue, maxResultCount); - return items; - }); + () => this.languageService.getNavigateToItems(searchValue, maxResultCount) + ); } public getNavigationBarItems(fileName: string): string { return this.forwardJSONCall( `getNavigationBarItems('${fileName}')`, - () => { - let items = this.languageService.getNavigationBarItems(fileName); - return items; - }); + () => this.languageService.getNavigationBarItems(fileName) + ); } public getOutliningSpans(fileName: string): string { return this.forwardJSONCall( `getOutliningSpans('${fileName}')`, - () => { - let items = this.languageService.getOutliningSpans(fileName); - return items; - }); + () => this.languageService.getOutliningSpans(fileName) + ); } public getTodoComments(fileName: string, descriptors: string): string { return this.forwardJSONCall( `getTodoComments('${fileName}')`, - () => { - let items = this.languageService.getTodoComments(fileName, JSON.parse(descriptors)); - return items; - }); + () => this.languageService.getTodoComments(fileName, JSON.parse(descriptors)) + ); } /// Emit public getEmitOutput(fileName: string): string { return this.forwardJSONCall( `getEmitOutput('${fileName}')`, - () => { - let output = this.languageService.getEmitOutput(fileName); - return output; - }); + () => this.languageService.getEmitOutput(fileName) + ); } } @@ -997,9 +959,8 @@ namespace ts { public getDefaultCompilationSettings(): string { return this.forwardJSONCall( "getDefaultCompilationSettings()", - () => { - return getDefaultCompilerOptions(); - }); + () => getDefaultCompilerOptions() + ); } } From 4ef8e0bb734dd1041578aa155dae01787aa97828 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Fri, 8 Jan 2016 02:25:29 +0900 Subject: [PATCH 6/6] remove unneeded comment --- src/services/shims.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index 4551013ff8d..90a015240f0 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -409,8 +409,6 @@ namespace ts { } public readDirectory(rootDir: string, extension: string, exclude: string[]): string[] { - // Consider removing the optional designation for - // the exclude param at this time. const encoded = this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude)); return JSON.parse(encoded); }