Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/build/lib/mangle/staticLanguageServiceHost.js
3520 views
1
"use strict";
2
var __importDefault = (this && this.__importDefault) || function (mod) {
3
return (mod && mod.__esModule) ? mod : { "default": mod };
4
};
5
Object.defineProperty(exports, "__esModule", { value: true });
6
exports.StaticLanguageServiceHost = void 0;
7
/*---------------------------------------------------------------------------------------------
8
* Copyright (c) Microsoft Corporation. All rights reserved.
9
* Licensed under the MIT License. See License.txt in the project root for license information.
10
*--------------------------------------------------------------------------------------------*/
11
const typescript_1 = __importDefault(require("typescript"));
12
const path_1 = __importDefault(require("path"));
13
class StaticLanguageServiceHost {
14
projectPath;
15
_cmdLine;
16
_scriptSnapshots = new Map();
17
constructor(projectPath) {
18
this.projectPath = projectPath;
19
const existingOptions = {};
20
const parsed = typescript_1.default.readConfigFile(projectPath, typescript_1.default.sys.readFile);
21
if (parsed.error) {
22
throw parsed.error;
23
}
24
this._cmdLine = typescript_1.default.parseJsonConfigFileContent(parsed.config, typescript_1.default.sys, path_1.default.dirname(projectPath), existingOptions);
25
if (this._cmdLine.errors.length > 0) {
26
throw parsed.error;
27
}
28
}
29
getCompilationSettings() {
30
return this._cmdLine.options;
31
}
32
getScriptFileNames() {
33
return this._cmdLine.fileNames;
34
}
35
getScriptVersion(_fileName) {
36
return '1';
37
}
38
getProjectVersion() {
39
return '1';
40
}
41
getScriptSnapshot(fileName) {
42
let result = this._scriptSnapshots.get(fileName);
43
if (result === undefined) {
44
const content = typescript_1.default.sys.readFile(fileName);
45
if (content === undefined) {
46
return undefined;
47
}
48
result = typescript_1.default.ScriptSnapshot.fromString(content);
49
this._scriptSnapshots.set(fileName, result);
50
}
51
return result;
52
}
53
getCurrentDirectory() {
54
return path_1.default.dirname(this.projectPath);
55
}
56
getDefaultLibFileName(options) {
57
return typescript_1.default.getDefaultLibFilePath(options);
58
}
59
directoryExists = typescript_1.default.sys.directoryExists;
60
getDirectories = typescript_1.default.sys.getDirectories;
61
fileExists = typescript_1.default.sys.fileExists;
62
readFile = typescript_1.default.sys.readFile;
63
readDirectory = typescript_1.default.sys.readDirectory;
64
// this is necessary to make source references work.
65
realpath = typescript_1.default.sys.realpath;
66
}
67
exports.StaticLanguageServiceHost = StaticLanguageServiceHost;
68
//# sourceMappingURL=staticLanguageServiceHost.js.map
69