mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-15 22:15:05 -05:00
Dont create script snapshots for files that arent source files
This commit is contained in:
@@ -815,7 +815,7 @@ namespace ts {
|
||||
private _compilationSettings: CompilerOptions;
|
||||
private currentDirectory: string;
|
||||
|
||||
constructor(private host: LanguageServiceHost, private getCanonicalFileName: (fileName: string) => string) {
|
||||
constructor(private host: LanguageServiceHost, getCanonicalFileName: (fileName: string) => string) {
|
||||
// script id => script index
|
||||
this.currentDirectory = host.getCurrentDirectory();
|
||||
this.fileNameToEntry = createFileMap<HostFileInformation>();
|
||||
@@ -850,22 +850,17 @@ namespace ts {
|
||||
return entry;
|
||||
}
|
||||
|
||||
private getEntry(path: Path): HostFileInformation {
|
||||
public getEntryByPath(path: Path): HostFileInformation {
|
||||
return this.fileNameToEntry.get(path);
|
||||
}
|
||||
|
||||
private contains(path: Path): boolean {
|
||||
public containsEntryByPath(path: Path): boolean {
|
||||
return this.fileNameToEntry.contains(path);
|
||||
}
|
||||
|
||||
public getOrCreateEntry(fileName: string): HostFileInformation {
|
||||
const path = toPath(fileName, this.currentDirectory, this.getCanonicalFileName);
|
||||
return this.getOrCreateEntryByPath(fileName, path);
|
||||
}
|
||||
|
||||
public getOrCreateEntryByPath(fileName: string, path: Path): HostFileInformation {
|
||||
return this.contains(path)
|
||||
? this.getEntry(path)
|
||||
return this.containsEntryByPath(path)
|
||||
? this.getEntryByPath(path)
|
||||
: this.createEntry(fileName, path);
|
||||
}
|
||||
|
||||
@@ -882,12 +877,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
public getVersion(path: Path): string {
|
||||
const file = this.getEntry(path);
|
||||
const file = this.getEntryByPath(path);
|
||||
return file && file.version;
|
||||
}
|
||||
|
||||
public getScriptSnapshot(path: Path): IScriptSnapshot {
|
||||
const file = this.getEntry(path);
|
||||
const file = this.getEntryByPath(path);
|
||||
return file && file.scriptSnapshot;
|
||||
}
|
||||
}
|
||||
@@ -1152,12 +1147,19 @@ namespace ts {
|
||||
getCurrentDirectory: () => currentDirectory,
|
||||
fileExists: (fileName): boolean => {
|
||||
// stub missing host functionality
|
||||
return hostCache.getOrCreateEntry(fileName) !== undefined;
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
return hostCache.containsEntryByPath(path) ?
|
||||
!!hostCache.getEntryByPath(path) :
|
||||
(host.fileExists && host.fileExists(fileName));
|
||||
},
|
||||
readFile: (fileName): string => {
|
||||
// stub missing host functionality
|
||||
const entry = hostCache.getOrCreateEntry(fileName);
|
||||
return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength());
|
||||
const path = toPath(fileName, currentDirectory, getCanonicalFileName);
|
||||
if (hostCache.containsEntryByPath(path)) {
|
||||
const entry = hostCache.getEntryByPath(path);
|
||||
return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength());
|
||||
}
|
||||
return host.readFile && host.readFile(fileName);
|
||||
},
|
||||
directoryExists: directoryName => {
|
||||
return directoryProbablyExists(directoryName, host);
|
||||
|
||||
Reference in New Issue
Block a user