mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-22 03:09:13 +00:00
For #270408 There are currently duplicated `LanguageServiceHost` definitions in our build folder. As far as I can tell they are the same except for the default lib name As part of #270408 I'll have to touch the service hosts and having a single definition will make this easier
67 lines
1.9 KiB
JavaScript
67 lines
1.9 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.TypeScriptLanguageServiceHost = void 0;
|
|
/**
|
|
* A TypeScript language service host
|
|
*/
|
|
class TypeScriptLanguageServiceHost {
|
|
ts;
|
|
libs;
|
|
files;
|
|
compilerOptions;
|
|
defaultLibName;
|
|
constructor(ts, libs, files, compilerOptions, defaultLibName) {
|
|
this.ts = ts;
|
|
this.libs = libs;
|
|
this.files = files;
|
|
this.compilerOptions = compilerOptions;
|
|
this.defaultLibName = defaultLibName;
|
|
}
|
|
// --- language service host ---------------
|
|
getCompilationSettings() {
|
|
return this.compilerOptions;
|
|
}
|
|
getScriptFileNames() {
|
|
return [
|
|
...this.libs.keys(),
|
|
...this.files.keys(),
|
|
];
|
|
}
|
|
getScriptVersion(_fileName) {
|
|
return '1';
|
|
}
|
|
getProjectVersion() {
|
|
return '1';
|
|
}
|
|
getScriptSnapshot(fileName) {
|
|
if (this.files.has(fileName)) {
|
|
return this.ts.ScriptSnapshot.fromString(this.files.get(fileName));
|
|
}
|
|
else if (this.libs.has(fileName)) {
|
|
return this.ts.ScriptSnapshot.fromString(this.libs.get(fileName));
|
|
}
|
|
else {
|
|
return this.ts.ScriptSnapshot.fromString('');
|
|
}
|
|
}
|
|
getScriptKind(_fileName) {
|
|
return this.ts.ScriptKind.TS;
|
|
}
|
|
getCurrentDirectory() {
|
|
return '';
|
|
}
|
|
getDefaultLibFileName(_options) {
|
|
return this.defaultLibName;
|
|
}
|
|
isDefaultLibFileName(fileName) {
|
|
return fileName === this.getDefaultLibFileName(this.compilerOptions);
|
|
}
|
|
readFile(path, _encoding) {
|
|
return this.files.get(path) || this.libs.get(path);
|
|
}
|
|
fileExists(path) {
|
|
return this.files.has(path) || this.libs.has(path);
|
|
}
|
|
}
|
|
exports.TypeScriptLanguageServiceHost = TypeScriptLanguageServiceHost;
|
|
//# sourceMappingURL=typeScriptLanguageServiceHost.js.map
|