Commit 8dcf591f authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[torque] Remove VSCode Torque extension from tools/

The extension moved to a separate Github repository found at:
https://github.com/v8/vscode-torque

The extension is best installed via the VSCode Marketplace:
https://marketplace.visualstudio.com/items?itemName=v8-torque.vscode-torque

R=tebbi@chromium.org

Bug: v8:8880
Change-Id: I38e1bc7c912002b37d367beac10fb57c58763844
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1640198
Auto-Submit: Simon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarTamer Tas <tmrts@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61972}
parent f953ee1a
{
"version": "0.2.0",
"configurations": [
{
"type": "extensionHost",
"request": "launch",
"name": "test:client",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/lib/test/**/*.js"],
"preLaunchTask": "watch:client"
}
]
}
{
"version": "2.0.0",
"tasks": [
{
"label": "watch:client",
"type": "shell",
"command": "npm run watch",
"group": "build",
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"isBackground": true,
"problemMatcher": [
"$tsc-watch"
]
}
]
}
\ No newline at end of file
# Torque support
This extension adds language support for [the Torque language used in V8](https://v8.dev/docs/torque).
## Installation
Since the extension is currently not published to the marketplace, the easiest way to
install the extension is to symlink it to your local extension directory:
```
ln -s $V8/tools/torque/vscode-torque $HOME/.vscode/extensions/vscode-torque
```
Additionally, for advanced language server features, the extension needs to be built
locally (the syntax highlighting does not require this step). The following needs to be run
everytime the extension is updated:
```
cd $V8/tools/torque/vscode-torque
npm install
```
### Language server
The language server is not built by default. To build the language server manually:
```
autoninja -C <output dir> torque-language-server
```
The default directory where the extension looks for the executable is "out/x64.release",
but the absolute path to the executable can be configured with the `torque.ls.executable`
setting.
{
"comments": {
"lineComment": "//",
"blockComment": [ "/*", "*/" ]
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""],
["'", "'"]
]
}
\ No newline at end of file
"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
\ No newline at end of file
{
"name": "vscode-torque",
"displayName": "Torque language support",
"description": "Syntax highlighting and language server for the V8 Torque programming language",
"version": "0.0.1",
"publisher": "szuend",
"engines": {
"vscode": "^1.31.0"
},
"categories": [
"Programming Languages"
],
"activationEvents": [
"onLanguage:torque",
"workspaceContains:**/*.tq"
],
"main": "./out/extension",
"contributes": {
"configuration": {
"type": "object",
"title": "Torque",
"properties": {
"torque.ls.executable": {
"type": [
"string",
null
],
"default": null,
"description": "Path to the torque language server executable (absolute)"
},
"torque.ls.logging": {
"type": "boolean",
"default": false,
"description": "Enable language server diagnostics output to log file"
},
"torque.ls.logfile": {
"type": "string",
"default": "torque-log.txt",
"description": "Target file for language server logging output"
},
"torque.trace.server": {
"type": "string",
"enum": [
"off",
"messages",
"verbose"
],
"default": "off",
"description": "Trace the communication with the Torque language server from VSCode."
}
}
},
"languages": [
{
"id": "torque",
"aliases": [
"Torque",
"torque"
],
"extensions": [
".tq"
],
"configuration": "./language-configuration.json"
}
],
"grammars": [
{
"language": "torque",
"scopeName": "source.torque",
"path": "./syntaxes/torque.tmLanguage.json"
}
]
},
"dependencies": {
"vscode-languageclient": "^5.2.1"
},
"devDependencies": {
"@types/node": "^8.0.0",
"vscode": "^1.1.21",
"tslint": "^5.11.0",
"typescript": "^3.1.3"
},
"scripts": {
"update-vscode": "vscode-install",
"postinstall": "vscode-install",
"vscode:prepublish": "npm run update-vscode && npm run compile",
"compile": "tsc -b",
"watch": "tsc -b -w"
}
}
// 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.
// The file out/extension.js gets automatically created from
// src/extension.ts. out/extension.js should not be modified manually.
import * as path from "path";
import { ExtensionContext, OutputChannel, StatusBarAlignment,
window, workspace, WorkspaceConfiguration } from "vscode";
import { CloseAction, ErrorAction, ErrorHandler, Message,
RevealOutputChannelOn, State, Trace } from "vscode-languageclient";
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
} from "vscode-languageclient";
let client: LanguageClient;
let outputChannel: OutputChannel;
class TorqueErrorHandler implements ErrorHandler {
constructor(readonly config: WorkspaceConfiguration) {}
public error(error: Error, message: Message, count: number): ErrorAction {
outputChannel.appendLine("TorqueErrorHandler: ");
outputChannel.append(error.toString());
outputChannel.append(message.toString());
return ErrorAction.Continue;
}
public closed(): CloseAction {
return CloseAction.DoNotRestart;
}
}
export async function activate(context: ExtensionContext) {
// Create a status bar item that displays the current status of the language server.
const statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left, 0);
statusBarItem.text = "torque-ls: <unknown>";
statusBarItem.show();
const torqueConfiguration = workspace.getConfiguration("torque.ls");
let serverExecutable: string | null = torqueConfiguration.get("executable");
if (serverExecutable == null) {
serverExecutable = path.join(workspace.rootPath, "out", "x64.release", "torque-language-server");
}
let serverArguments = [];
const loggingEnabled: boolean = torqueConfiguration.get("logging");
if (loggingEnabled) {
const logfile = torqueConfiguration.get("logfile");
serverArguments = ["-l", logfile];
}
const serverOptions: ServerOptions = { command: serverExecutable, args: serverArguments };
outputChannel = window.createOutputChannel("Torque Language Server");
const clientOptions: LanguageClientOptions = {
diagnosticCollectionName: "torque",
documentSelector: [{ scheme: "file", language: "torque" }],
errorHandler: new TorqueErrorHandler(workspace.getConfiguration("torque")),
initializationFailedHandler: (e) => {
outputChannel.appendLine(e);
return false;
},
outputChannel,
revealOutputChannelOn: RevealOutputChannelOn.Info,
};
// Create the language client and start the client.
client = new LanguageClient("torque", "Torque Language Server", serverOptions, clientOptions);
client.trace = Trace.Verbose;
// Update the status bar according to the client state.
client.onDidChangeState((event) => {
if (event.newState === State.Running) {
statusBarItem.text = "torque-ls: Running";
} else if (event.newState === State.Starting) {
statusBarItem.text = "torque-ls: Starting";
} else {
statusBarItem.text = "torque-ls: Stopped";
}
});
// This will start client and server.
client.start();
await client.onReady();
// The server needs an initial list of all the Torque files
// in the workspace, send them over.
workspace.findFiles("**/*.tq").then((urls) => {
client.sendNotification("torque/fileList",
{ files: urls.map((url) => url.toString())});
});
}
export function deactivate(): Thenable<void> | undefined {
if (!client) { return undefined; }
return client.stop();
}
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "Torque",
"patterns": [
{
"name": "comment.line.double-slash.torque",
"begin": "//",
"end": "$"
},
{
"name": "comment.block.torque",
"begin": "/\\*",
"end": "\\*/"
},
{
"name": "support.function.torque",
"match": "\\b(assert|check|debug|unreachable|Cast|Convert|FromConstexpr|UnsafeCast)\\b"
},
{
"name": "constant.other.torque",
"match": "\\b(true|True|false|False|Undefined|Hole|Null|k[A-Z][A-Za-z0-9]+)\\b"
},
{
"begin": "\\b<(?=[A-Za-z][0-9A-Za-z_|, ]*>)",
"end": ">",
"patterns": [
{
"include": "#common"
},
{
"name": "support.type.torque",
"match": "([A-Za-z][0-9A-Za-z_]*)"
}
]
},
{
"begin": "\\b(?=(macro|runtime|builtin)\\b)",
"end": ";|\\{",
"patterns": [
{
"begin": "\\(",
"end": "\\)",
"patterns": [
{
"include": "#common"
},
{
"match": "(([A-Za-z][0-9A-Za-z_]*):\\s*)?([A-Za-z][0-9A-Za-z_]*)",
"captures":{
"3": {"name": "support.type.torque"}
}
}
]
},
{
"include": "#common"
}
]
},
{
"begin": "\\b(type)\\b",
"end": ";",
"captures": {
"1": {
"name": "keyword.other.torque"
}
},
"patterns": [
{
"include": "#common"
},
{
"name": "support.type.torque",
"match": "\\b([A-Za-z][0-9A-Za-z_]*)\\b"
}
]
},
{
"name": "keyword.control.torque",
"match": "#include"
},
{
"include": "#common"
}
],
"repository": {
"common": {
"patterns": [
{
"match": "\\b(extends)\\s+([A-Za-z0-9]+)",
"captures": {
"1": {
"name": "keyword.other.torque"
},
"2": {
"name": "support.type.torque"
}
}
},
{
"name": "keyword.control.torque",
"match": "\\b(if|else|while|for|return|continue|break|goto|otherwise|try|label|catch)\\b"
},
{
"name": "keyword.other.torque",
"match": "\\b(constexpr|macro|builtin|runtime|intrinsic|javascript|implicit|deferred|label|labels|tail|let|generates|weak|extern|const|typeswitch|case|transient|transitioning|operator|namespace|export)\\b"
},
{
"name": "keyword.operator.torque",
"match": "\\b(=|\\*=)\\b"
},
{
"match": "\\b(class|new)\\s+([A-Za-z0-9]+)",
"captures": {
"1": {
"name": "keyword.other.torque"
},
"2": {
"name": "support.type.torque"
}
}
},
{
"match": "\\b(struct)\\s+([A-Za-z0-9]+)",
"captures": {
"1": {
"name": "keyword.other.torque"
},
"2": {
"name": "support.type.torque"
}
}
},
{
"name": "string.quoted.double.torque",
"begin": "\"",
"end": "\"",
"patterns": [
{
"name": "constant.character.escape.torque",
"match": "\\\\."
}
]
},
{
"name": "string.quoted.single.torque",
"begin": "'",
"end": "'",
"patterns": [
{
"name": "constant.character.escape.torque",
"match": "\\\\."
}
]
},
{
"begin": ":(\\s*)?",
"end": "(?=(generates|[^0-9A-Za-z_| ]))",
"patterns": [
{
"include": "#common"
},
{
"name": "support.type.torque",
"match": "([A-Za-z][0-9A-Za-z_]*)"
}
]
},
{
"name": "support.function.torque",
"match": "\\b[A-Za-z0-9_]+\\b(?=(<[ ,:A-Za-z0-9_]+>)?\\()"
}
]
}
},
"scopeName": "source.torque"
}
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "out",
"rootDir": "src",
"lib": [ "es6" ],
"sourceMap": true
},
"include": [
"src"
],
"exclude": [
"node_modules",
".vscode-test"
]
}
\ No newline at end of file
{
"defaultSeverity": "error",
"extends": [
"tslint:recommended"
],
"jsRules": {},
"rules": {
"indent": [true, "spaces", 2]
},
"rulesDirectory": []
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment