void/build/lib/mangle/staticLanguageServiceHost.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
2.7 KiB
JavaScript
Raw Permalink Normal View History

2024-09-11 02:37:36 +00:00
"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
2025-03-01 02:01:53 +00:00
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
2024-09-11 02:37:36 +00:00
Object.defineProperty(exports, "__esModule", { value: true });
exports.StaticLanguageServiceHost = void 0;
2025-03-01 02:01:53 +00:00
const typescript_1 = __importDefault(require("typescript"));
const path_1 = __importDefault(require("path"));
2024-09-11 02:37:36 +00:00
class StaticLanguageServiceHost {
projectPath;
_cmdLine;
_scriptSnapshots = new Map();
constructor(projectPath) {
this.projectPath = projectPath;
const existingOptions = {};
2025-03-01 02:01:53 +00:00
const parsed = typescript_1.default.readConfigFile(projectPath, typescript_1.default.sys.readFile);
2024-09-11 02:37:36 +00:00
if (parsed.error) {
throw parsed.error;
}
2025-03-01 02:01:53 +00:00
this._cmdLine = typescript_1.default.parseJsonConfigFileContent(parsed.config, typescript_1.default.sys, path_1.default.dirname(projectPath), existingOptions);
2024-09-11 02:37:36 +00:00
if (this._cmdLine.errors.length > 0) {
throw parsed.error;
}
}
getCompilationSettings() {
return this._cmdLine.options;
}
getScriptFileNames() {
return this._cmdLine.fileNames;
}
getScriptVersion(_fileName) {
return '1';
}
getProjectVersion() {
return '1';
}
getScriptSnapshot(fileName) {
let result = this._scriptSnapshots.get(fileName);
if (result === undefined) {
2025-03-01 02:01:53 +00:00
const content = typescript_1.default.sys.readFile(fileName);
2024-09-11 02:37:36 +00:00
if (content === undefined) {
return undefined;
}
2025-03-01 02:01:53 +00:00
result = typescript_1.default.ScriptSnapshot.fromString(content);
2024-09-11 02:37:36 +00:00
this._scriptSnapshots.set(fileName, result);
}
return result;
}
getCurrentDirectory() {
2025-03-01 02:01:53 +00:00
return path_1.default.dirname(this.projectPath);
2024-09-11 02:37:36 +00:00
}
getDefaultLibFileName(options) {
2025-03-01 02:01:53 +00:00
return typescript_1.default.getDefaultLibFilePath(options);
2024-09-11 02:37:36 +00:00
}
2025-03-01 02:01:53 +00:00
directoryExists = typescript_1.default.sys.directoryExists;
getDirectories = typescript_1.default.sys.getDirectories;
fileExists = typescript_1.default.sys.fileExists;
readFile = typescript_1.default.sys.readFile;
readDirectory = typescript_1.default.sys.readDirectory;
2024-09-11 02:37:36 +00:00
// this is necessary to make source references work.
2025-03-01 02:01:53 +00:00
realpath = typescript_1.default.sys.realpath;
2024-09-11 02:37:36 +00:00
}
exports.StaticLanguageServiceHost = StaticLanguageServiceHost;
//# sourceMappingURL=staticLanguageServiceHost.js.map