From 64dad30ca0c2d2870bf58d7b189ab671689e992c Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Wed, 7 Dec 2016 15:31:46 -0800 Subject: [PATCH] Reduced version from CR comments --- src/compiler/program.ts | 4 ++-- src/server/lsHost.ts | 9 --------- src/server/project.ts | 1 - src/services/completions.ts | 11 ++++------- src/services/services.ts | 9 +-------- src/services/types.ts | 1 - 6 files changed, 7 insertions(+), 28 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 2d92561ad93..73976d5d02e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -285,7 +285,7 @@ namespace ts { return resolutions; } - export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, fileExtensionMap?: FileExtensionMap): Program { + export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program { let program: Program; let files: SourceFile[] = []; let commonSourceDirectory: string; @@ -320,7 +320,7 @@ namespace ts { let skipDefaultLib = options.noLib; const programDiagnostics = createDiagnosticCollection(); const currentDirectory = host.getCurrentDirectory(); - const supportedExtensions = getSupportedExtensions(options, fileExtensionMap); + const supportedExtensions = getSupportedExtensions(options); // Map storing if there is emit blocking diagnostics for given input const hasEmitBlockingDiagnostics = createFileMap(getCanonicalFileName); diff --git a/src/server/lsHost.ts b/src/server/lsHost.ts index f8b4d28af84..8f57cbf4074 100644 --- a/src/server/lsHost.ts +++ b/src/server/lsHost.ts @@ -5,7 +5,6 @@ namespace ts.server { export class LSHost implements ts.LanguageServiceHost, ModuleResolutionHost { private compilationSettings: ts.CompilerOptions; - private fileExtensionMap: FileExtensionMap; private readonly resolvedModuleNames = createFileMap>(); private readonly resolvedTypeReferenceDirectives = createFileMap>(); private readonly getCanonicalFileName: (fileName: string) => string; @@ -144,10 +143,6 @@ namespace ts.server { return this.compilationSettings; } - getFileExtensionMap() { - return this.fileExtensionMap; - } - useCaseSensitiveFileNames() { return this.host.useCaseSensitiveFileNames; } @@ -236,9 +231,5 @@ namespace ts.server { } this.compilationSettings = opt; } - - setFileExtensionMap(fileExtensionMap: FileExtensionMap) { - this.fileExtensionMap = fileExtensionMap || {}; - } } } \ No newline at end of file diff --git a/src/server/project.ts b/src/server/project.ts index 31c651e7cc3..f17494149e5 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -254,7 +254,6 @@ namespace ts.server { this.lsHost = new LSHost(this.projectService.host, this, this.projectService.cancellationToken); this.lsHost.setCompilationSettings(this.compilerOptions); - this.lsHost.setFileExtensionMap(this.projectService.hostConfiguration.fileExtensionMap); this.languageService = ts.createLanguageService(this.lsHost, this.documentRegistry); this.noSemanticFeaturesLanguageService = createNoSemanticFeaturesWrapper(this.languageService); diff --git a/src/services/completions.ts b/src/services/completions.ts index 8820f4fee54..b710aa8cd78 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -271,14 +271,13 @@ namespace ts.Completions { const span = getDirectoryFragmentTextSpan((node).text, node.getStart() + 1); let entries: CompletionEntry[]; if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) { - const fileExtensionMap = host.getFileExtensionMap ? host.getFileExtensionMap() : {}; if (compilerOptions.rootDirs) { entries = getCompletionEntriesForDirectoryFragmentWithRootDirs( - compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(compilerOptions, fileExtensionMap), /*includeExtensions*/false, span, scriptPath); + compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(compilerOptions), /*includeExtensions*/false, span, scriptPath); } else { entries = getCompletionEntriesForDirectoryFragment( - literalValue, scriptDirectory, getSupportedExtensions(compilerOptions, fileExtensionMap), /*includeExtensions*/false, span, scriptPath); + literalValue, scriptDirectory, getSupportedExtensions(compilerOptions), /*includeExtensions*/false, span, scriptPath); } } else { @@ -412,8 +411,7 @@ namespace ts.Completions { let result: CompletionEntry[]; if (baseUrl) { - const fileExtensionMap = host.getFileExtensionMap ? host.getFileExtensionMap() : {}; - const fileExtensions = getSupportedExtensions(compilerOptions, fileExtensionMap); + const fileExtensions = getSupportedExtensions(compilerOptions); const projectDir = compilerOptions.project || host.getCurrentDirectory(); const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(projectDir, baseUrl); result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false, span); @@ -590,8 +588,7 @@ namespace ts.Completions { if (kind === "path") { // Give completions for a relative path const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - const fileExtensionMap = host.getFileExtensionMap ? host.getFileExtensionMap() : {}; - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(compilerOptions, fileExtensionMap), /*includeExtensions*/true, span, sourceFile.path); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(compilerOptions), /*includeExtensions*/true, span, sourceFile.path); } else { // Give completions based on the typings available diff --git a/src/services/services.ts b/src/services/services.ts index 66b0b10a090..ef50f4b5a2f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -757,7 +757,6 @@ namespace ts { class HostCache { private fileNameToEntry: FileMap; private _compilationSettings: CompilerOptions; - private _fileExtensionMap: FileExtensionMap; private currentDirectory: string; constructor(private host: LanguageServiceHost, private getCanonicalFileName: (fileName: string) => string) { @@ -773,18 +772,12 @@ namespace ts { // store the compilation settings this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions(); - - this._fileExtensionMap = host.getFileExtensionMap ? host.getFileExtensionMap() : {}; } public compilationSettings() { return this._compilationSettings; } - public fileExtensionMap() { - return this._fileExtensionMap; - } - private createEntry(fileName: string, path: Path) { let entry: HostFileInformation; const scriptSnapshot = this.host.getScriptSnapshot(fileName); @@ -1107,7 +1100,7 @@ namespace ts { } const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings); - const newProgram = createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program, hostCache.fileExtensionMap()); + const newProgram = createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program); // Release any files we have acquired in the old program but are // not part of the new program. diff --git a/src/services/types.ts b/src/services/types.ts index 6e688e409af..6a0e6e886b5 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -126,7 +126,6 @@ namespace ts { // export interface LanguageServiceHost { getCompilationSettings(): CompilerOptions; - getFileExtensionMap?(): FileExtensionMap; getNewLine?(): string; getProjectVersion?(): string; getScriptFileNames(): string[];