summaryrefslogtreecommitdiff
path: root/deps/v8/tools/torque/vscode-torque/out/extension.js
blob: 8cfae5dea4cfbcfe8b030db801e8a7b70ceb472f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"use strict";
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
// The file out/extension.js gets automatically created from
// src/extension.ts. out/extension.js should not be modified manually.
const path = require("path");
const vscode_1 = require("vscode");
const vscode_languageclient_1 = require("vscode-languageclient");
const vscode_languageclient_2 = require("vscode-languageclient");
let client;
let outputChannel;
class TorqueErrorHandler {
    constructor(config) {
        this.config = config;
    }
    error(error, message, count) {
        outputChannel.appendLine("TorqueErrorHandler: ");
        outputChannel.append(error.toString());
        outputChannel.append(message.toString());
        return vscode_languageclient_1.ErrorAction.Continue;
    }
    closed() {
        return vscode_languageclient_1.CloseAction.DoNotRestart;
    }
}
function activate(context) {
    return __awaiter(this, void 0, void 0, function* () {
        // Create a status bar item that displays the current status of the language server.
        const statusBarItem = vscode_1.window.createStatusBarItem(vscode_1.StatusBarAlignment.Left, 0);
        statusBarItem.text = "torque-ls: <unknown>";
        statusBarItem.show();
        const torqueConfiguration = vscode_1.workspace.getConfiguration("torque.ls");
        let serverExecutable = torqueConfiguration.get("executable");
        if (serverExecutable == null) {
            serverExecutable = path.join(vscode_1.workspace.rootPath, "out", "x64.release", "torque-language-server");
        }
        let serverArguments = [];
        const loggingEnabled = torqueConfiguration.get("logging");
        if (loggingEnabled) {
            const logfile = torqueConfiguration.get("logfile");
            serverArguments = ["-l", logfile];
        }
        const serverOptions = { command: serverExecutable, args: serverArguments };
        outputChannel = vscode_1.window.createOutputChannel("Torque Language Server");
        const clientOptions = {
            diagnosticCollectionName: "torque",
            documentSelector: [{ scheme: "file", language: "torque" }],
            errorHandler: new TorqueErrorHandler(vscode_1.workspace.getConfiguration("torque")),
            initializationFailedHandler: (e) => {
                outputChannel.appendLine(e);
                return false;
            },
            outputChannel,
            revealOutputChannelOn: vscode_languageclient_1.RevealOutputChannelOn.Info,
        };
        // Create the language client and start the client.
        client = new vscode_languageclient_2.LanguageClient("torque", "Torque Language Server", serverOptions, clientOptions);
        client.trace = vscode_languageclient_1.Trace.Verbose;
        // Update the status bar according to the client state.
        client.onDidChangeState((event) => {
            if (event.newState === vscode_languageclient_1.State.Running) {
                statusBarItem.text = "torque-ls: Running";
            }
            else if (event.newState === vscode_languageclient_1.State.Starting) {
                statusBarItem.text = "torque-ls: Starting";
            }
            else {
                statusBarItem.text = "torque-ls: Stopped";
            }
        });
        // This will start client and server.
        client.start();
        yield client.onReady();
        // The server needs an initial list of all the Torque files
        // in the workspace, send them over.
        vscode_1.workspace.findFiles("**/*.tq").then((urls) => {
            client.sendNotification("torque/fileList", { files: urls.map((url) => url.toString()) });
        });
    });
}
exports.activate = activate;
function deactivate() {
    if (!client) {
        return undefined;
    }
    return client.stop();
}
exports.deactivate = deactivate;
//# sourceMappingURL=extension.js.map