mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Reduced version from CR comments
This commit is contained in:
parent
12971d2c65
commit
64dad30ca0
@ -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<boolean>(getCanonicalFileName);
|
||||
|
||||
@ -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<Map<ResolvedModuleWithFailedLookupLocations>>();
|
||||
private readonly resolvedTypeReferenceDirectives = createFileMap<Map<ResolvedTypeReferenceDirectiveWithFailedLookupLocations>>();
|
||||
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 || {};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
|
||||
@ -271,14 +271,13 @@ namespace ts.Completions {
|
||||
const span = getDirectoryFragmentTextSpan((<StringLiteral>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
|
||||
|
||||
@ -757,7 +757,6 @@ namespace ts {
|
||||
class HostCache {
|
||||
private fileNameToEntry: FileMap<HostFileInformation>;
|
||||
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.
|
||||
|
||||
@ -126,7 +126,6 @@ namespace ts {
|
||||
//
|
||||
export interface LanguageServiceHost {
|
||||
getCompilationSettings(): CompilerOptions;
|
||||
getFileExtensionMap?(): FileExtensionMap;
|
||||
getNewLine?(): string;
|
||||
getProjectVersion?(): string;
|
||||
getScriptFileNames(): string[];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user