"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServerHost = void 0;
const ts = require("typescript/lib/tsserverlibrary");
class ServerHost {
    constructor(host) {
        this.host = host;
        this.args = ts.sys.args;
        this.newLine = ts.sys.newLine;
        this.useCaseSensitiveFileNames = ts.sys.useCaseSensitiveFileNames;
    }
    readFile(path, encoding) {
        let content;
        try {
            content = this.host.read(path).toString(encoding);
        }
        finally {
            // eslint-disable-next-line no-unsafe-finally
            return content || ts.sys.readFile(path, encoding);
        }
    }
    getFileSize(path) {
        return ts.sys.getFileSize(path);
    }
    watchFile(path, callback, pollingInterval) {
        return ts.sys.watchFile(path, callback, pollingInterval);
    }
    watchDirectory(path, callback, recursive) {
        return ts.sys.watchDirectory(path, callback, recursive);
    }
    resolvePath(path) {
        return ts.sys.resolvePath(path);
    }
    fileExists(path) {
        return this.host.exists(path);
    }
    directoryExists(path) {
        let exists;
        try {
            exists = this.host.getDir(path) !== void 0;
        }
        finally {
            // eslint-disable-next-line no-unsafe-finally
            return exists || this.fileExists(path);
        }
    }
    getExecutingFilePath() {
        return ts.sys.getExecutingFilePath();
    }
    getCurrentDirectory() {
        return this.host.root.path;
    }
    getDirectories(path) {
        return this.host.getDir(path).subdirs;
    }
    readDirectory(path) {
        return this.host.getDir(path).subfiles;
    }
    require(initialPath, moduleName) {
        try {
            const modulePath = require.resolve(moduleName, {
                paths: [initialPath],
            });
            return {
                module: require(modulePath),
                error: undefined,
            };
        }
        catch (e) {
            return {
                module: undefined,
                error: e,
            };
        }
    }
    getModifiedTime(path) {
        return ts.sys.getModifiedTime(path);
    }
    realpath(path) {
        return ts.sys.realpath(path);
    }
    createSHA256Hash(data) {
        return ts.sys.createSHA256Hash(data);
    }
    //#region Not implemented methods
    write(data) {
        throw new Error('Method "write" not implemented.');
        // ts.sys.write(data);
    }
    writeOutputIsTTY() {
        throw new Error('Method "writeOutputIsTTY" not implemented.');
        // return ts.sys.writeOutputIsTTY();
    }
    writeFile(path, data, writeByteOrderMark) {
        throw new Error('Method "writeFile" not implemented.');
        // return ts.sys.writeFile(path, data, writeByteOrderMark);
    }
    createDirectory(path) {
        throw new Error('Method "createDirectory" not implemented.');
        // return ts.sys.createDirectory(path);
    }
    setModifiedTime(path, time) {
        throw new Error('Method "setModifiedTime" not implemented.');
        // return ts.sys.setModifiedTime(path, time);
    }
    deleteFile(path) {
        throw new Error('Method "deleteFile" not implemented.');
        // return ts.sys.deleteFile(path);
    }
    createHash(data) {
        throw new Error('Method "createHash" not implemented.');
        // return ts.sys.createHash(data);
    }
    getMemoryUsage() {
        throw new Error('Method "getMemoryUsage" not implemented.');
        // return ts.sys.getMemoryUsage();
    }
    exit(exitCode) {
        throw new Error('Method "exit" not implemented.');
        // return ts.sys.exit(exitCode);
    }
    setTimeout(callback, ms, ...args) {
        throw new Error('Method "setTimeout" not implemented.');
        // return ts.sys.setTimeout(callback, ms, ...args);
    }
    clearTimeout(timeoutId) {
        throw new Error('Method "clearTimeout" not implemented.');
        // return ts.sys.clearTimeout(timeoutId);
    }
    clearScreen() {
        throw new Error('Method "clearScreen" not implemented.');
        // return ts.sys.clearScreen();
    }
    base64decode(input) {
        throw new Error('Method "base64decode" not implemented.');
        // return ts.sys.base64decode(input);
    }
    base64encode(input) {
        throw new Error('Method "base64encode" not implemented.');
        // return ts.sys.base64encode(input);
    }
    setImmediate(callback, ...args) {
        throw new Error('Method "setImmediate" not implemented.');
        // return setImmediate(callback, ...args);
    }
    clearImmediate(timeoutId) {
        throw new Error('Method "clearImmediate" not implemented.');
        // return clearImmediate(timeoutId);
    }
}
exports.ServerHost = ServerHost;
