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