"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ Object.defineProperty(exports, "__esModule", { value: true }); exports.StaticLanguageServiceHost = void 0; const ts = require("typescript"); const path = require("path"); class StaticLanguageServiceHost { projectPath; _cmdLine; _scriptSnapshots = new Map(); constructor(projectPath) { this.projectPath = projectPath; const existingOptions = {}; const parsed = ts.readConfigFile(projectPath, ts.sys.readFile); if (parsed.error) { throw parsed.error; } this._cmdLine = ts.parseJsonConfigFileContent(parsed.config, ts.sys, path.dirname(projectPath), existingOptions); 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) { const content = ts.sys.readFile(fileName); if (content === undefined) { return undefined; } result = ts.ScriptSnapshot.fromString(content); this._scriptSnapshots.set(fileName, result); } return result; } getCurrentDirectory() { return path.dirname(this.projectPath); } getDefaultLibFileName(options) { return ts.getDefaultLibFilePath(options); } directoryExists = ts.sys.directoryExists; getDirectories = ts.sys.getDirectories; fileExists = ts.sys.fileExists; readFile = ts.sys.readFile; readDirectory = ts.sys.readDirectory; // this is necessary to make source references work. realpath = ts.sys.realpath; } exports.StaticLanguageServiceHost = StaticLanguageServiceHost; //# sourceMappingURL=staticLanguageServiceHost.js.map