Skip to content

Commit 64dad30

Browse files
committed
Reduced version from CR comments
1 parent 12971d2 commit 64dad30

File tree

6 files changed

+7
-28
lines changed

6 files changed

+7
-28
lines changed

src/compiler/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ namespace ts {
285285
return resolutions;
286286
}
287287

288-
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, fileExtensionMap?: FileExtensionMap): Program {
288+
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program {
289289
let program: Program;
290290
let files: SourceFile[] = [];
291291
let commonSourceDirectory: string;
@@ -320,7 +320,7 @@ namespace ts {
320320
let skipDefaultLib = options.noLib;
321321
const programDiagnostics = createDiagnosticCollection();
322322
const currentDirectory = host.getCurrentDirectory();
323-
const supportedExtensions = getSupportedExtensions(options, fileExtensionMap);
323+
const supportedExtensions = getSupportedExtensions(options);
324324

325325
// Map storing if there is emit blocking diagnostics for given input
326326
const hasEmitBlockingDiagnostics = createFileMap<boolean>(getCanonicalFileName);

src/server/lsHost.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace ts.server {
66
export class LSHost implements ts.LanguageServiceHost, ModuleResolutionHost {
77
private compilationSettings: ts.CompilerOptions;
8-
private fileExtensionMap: FileExtensionMap;
98
private readonly resolvedModuleNames = createFileMap<Map<ResolvedModuleWithFailedLookupLocations>>();
109
private readonly resolvedTypeReferenceDirectives = createFileMap<Map<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>>();
1110
private readonly getCanonicalFileName: (fileName: string) => string;
@@ -144,10 +143,6 @@ namespace ts.server {
144143
return this.compilationSettings;
145144
}
146145

147-
getFileExtensionMap() {
148-
return this.fileExtensionMap;
149-
}
150-
151146
useCaseSensitiveFileNames() {
152147
return this.host.useCaseSensitiveFileNames;
153148
}
@@ -236,9 +231,5 @@ namespace ts.server {
236231
}
237232
this.compilationSettings = opt;
238233
}
239-
240-
setFileExtensionMap(fileExtensionMap: FileExtensionMap) {
241-
this.fileExtensionMap = fileExtensionMap || {};
242-
}
243234
}
244235
}

src/server/project.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ namespace ts.server {
254254

255255
this.lsHost = new LSHost(this.projectService.host, this, this.projectService.cancellationToken);
256256
this.lsHost.setCompilationSettings(this.compilerOptions);
257-
this.lsHost.setFileExtensionMap(this.projectService.hostConfiguration.fileExtensionMap);
258257

259258
this.languageService = ts.createLanguageService(this.lsHost, this.documentRegistry);
260259
this.noSemanticFeaturesLanguageService = createNoSemanticFeaturesWrapper(this.languageService);

src/services/completions.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,14 +271,13 @@ namespace ts.Completions {
271271
const span = getDirectoryFragmentTextSpan((<StringLiteral>node).text, node.getStart() + 1);
272272
let entries: CompletionEntry[];
273273
if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) {
274-
const fileExtensionMap = host.getFileExtensionMap ? host.getFileExtensionMap() : {};
275274
if (compilerOptions.rootDirs) {
276275
entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(
277-
compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(compilerOptions, fileExtensionMap), /*includeExtensions*/false, span, scriptPath);
276+
compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(compilerOptions), /*includeExtensions*/false, span, scriptPath);
278277
}
279278
else {
280279
entries = getCompletionEntriesForDirectoryFragment(
281-
literalValue, scriptDirectory, getSupportedExtensions(compilerOptions, fileExtensionMap), /*includeExtensions*/false, span, scriptPath);
280+
literalValue, scriptDirectory, getSupportedExtensions(compilerOptions), /*includeExtensions*/false, span, scriptPath);
282281
}
283282
}
284283
else {
@@ -412,8 +411,7 @@ namespace ts.Completions {
412411
let result: CompletionEntry[];
413412

414413
if (baseUrl) {
415-
const fileExtensionMap = host.getFileExtensionMap ? host.getFileExtensionMap() : {};
416-
const fileExtensions = getSupportedExtensions(compilerOptions, fileExtensionMap);
414+
const fileExtensions = getSupportedExtensions(compilerOptions);
417415
const projectDir = compilerOptions.project || host.getCurrentDirectory();
418416
const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(projectDir, baseUrl);
419417
result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false, span);
@@ -590,8 +588,7 @@ namespace ts.Completions {
590588
if (kind === "path") {
591589
// Give completions for a relative path
592590
const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length);
593-
const fileExtensionMap = host.getFileExtensionMap ? host.getFileExtensionMap() : {};
594-
completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(compilerOptions, fileExtensionMap), /*includeExtensions*/true, span, sourceFile.path);
591+
completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(compilerOptions), /*includeExtensions*/true, span, sourceFile.path);
595592
}
596593
else {
597594
// Give completions based on the typings available

src/services/services.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,6 @@ namespace ts {
757757
class HostCache {
758758
private fileNameToEntry: FileMap<HostFileInformation>;
759759
private _compilationSettings: CompilerOptions;
760-
private _fileExtensionMap: FileExtensionMap;
761760
private currentDirectory: string;
762761

763762
constructor(private host: LanguageServiceHost, private getCanonicalFileName: (fileName: string) => string) {
@@ -773,18 +772,12 @@ namespace ts {
773772

774773
// store the compilation settings
775774
this._compilationSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
776-
777-
this._fileExtensionMap = host.getFileExtensionMap ? host.getFileExtensionMap() : {};
778775
}
779776

780777
public compilationSettings() {
781778
return this._compilationSettings;
782779
}
783780

784-
public fileExtensionMap() {
785-
return this._fileExtensionMap;
786-
}
787-
788781
private createEntry(fileName: string, path: Path) {
789782
let entry: HostFileInformation;
790783
const scriptSnapshot = this.host.getScriptSnapshot(fileName);
@@ -1107,7 +1100,7 @@ namespace ts {
11071100
}
11081101

11091102
const documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
1110-
const newProgram = createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program, hostCache.fileExtensionMap());
1103+
const newProgram = createProgram(hostCache.getRootFileNames(), newSettings, compilerHost, program);
11111104

11121105
// Release any files we have acquired in the old program but are
11131106
// not part of the new program.

src/services/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ namespace ts {
126126
//
127127
export interface LanguageServiceHost {
128128
getCompilationSettings(): CompilerOptions;
129-
getFileExtensionMap?(): FileExtensionMap;
130129
getNewLine?(): string;
131130
getProjectVersion?(): string;
132131
getScriptFileNames(): string[];

0 commit comments

Comments
 (0)