mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
you better run
This commit is contained in:
parent
5751815314
commit
422efe59af
9
code/.gitignore
vendored
9
code/.gitignore
vendored
@ -1,7 +1,4 @@
|
||||
target
|
||||
index.node
|
||||
artifacts.json
|
||||
out
|
||||
node_modules
|
||||
.vscode-test/
|
||||
*.vsix
|
||||
out/*
|
||||
node_modules/*
|
||||
log/*
|
||||
|
@ -1,4 +0,0 @@
|
||||
runtime = electron
|
||||
target = 1.7.9
|
||||
target_arch = x64
|
||||
disturl = https://atom.io/download/atom-shell
|
40
code/.vscode/launch.json
vendored
40
code/.vscode/launch.json
vendored
@ -1,22 +1,36 @@
|
||||
// A launch configuration that compiles the extension and then opens it inside a new window
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch Extension",
|
||||
"name": "Extension",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": ["--extensionDevelopmentPath='./'"],
|
||||
"env": {
|
||||
"RUST_LOG": "m=trace"
|
||||
},
|
||||
"stopOnEntry": false,
|
||||
"sourceMaps": true,
|
||||
"outFiles": [ "./out/src/**/*.js" ],
|
||||
"preLaunchTask": "npm"
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceFolder}"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/**/*.js"
|
||||
],
|
||||
"preLaunchTask": "npm: watch"
|
||||
},
|
||||
{
|
||||
"name": "Extension Tests",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceFolder}",
|
||||
"--extensionTestsPath=${workspaceFolder}/out/test"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/test/**/*.js"
|
||||
],
|
||||
"preLaunchTask": "npm: watch"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
9
code/.vscode/settings.json
vendored
9
code/.vscode/settings.json
vendored
@ -1,10 +1,11 @@
|
||||
// Place your settings in this file to overwrite default and user settings.
|
||||
{
|
||||
"files.exclude": {
|
||||
"out": true
|
||||
// "node_modules": true
|
||||
"out": false // set this to true to hide the "out" folder with the compiled JS files
|
||||
},
|
||||
"search.exclude": {
|
||||
"out": true // set this to false to include "out" folder in search results
|
||||
}
|
||||
}
|
||||
},
|
||||
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
|
||||
"typescript.tsc.autoDetect": "off"
|
||||
}
|
49
code/.vscode/tasks.json
vendored
49
code/.vscode/tasks.json
vendored
@ -1,31 +1,20 @@
|
||||
|
||||
// Available variables which can be used inside of strings.
|
||||
// ${workspaceRoot}: the root folder of the team
|
||||
// ${file}: the current opened file
|
||||
// ${fileBasename}: the current opened file's basename
|
||||
// ${fileDirname}: the current opened file's dirname
|
||||
// ${fileExtname}: the current opened file's extension
|
||||
// ${cwd}: the current working directory of the spawned process
|
||||
|
||||
// A task runner that calls a custom npm script that compiles the extension.
|
||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
// for the documentation about the tasks.json format
|
||||
{
|
||||
"version": "0.2.0",
|
||||
|
||||
// we want to run npm
|
||||
"command": "npm",
|
||||
|
||||
// the command is a shell script
|
||||
"isShellCommand": true,
|
||||
|
||||
// show the output window only if unrecognized errors occur.
|
||||
"showOutput": "silent",
|
||||
|
||||
// we run the custom script "compile" as defined in package.json
|
||||
"args": ["run", "compile",],
|
||||
|
||||
// The tsc compiler is started in watching mode
|
||||
"isBackground": true,
|
||||
|
||||
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
|
||||
"problemMatcher": "$tsc-watch"
|
||||
}
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "watch",
|
||||
"problemMatcher": "$tsc-watch",
|
||||
"isBackground": true,
|
||||
"presentation": {
|
||||
"reveal": "never"
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
9
code/.vscodeignore
Normal file
9
code/.vscodeignore
Normal file
@ -0,0 +1,9 @@
|
||||
.vscode/**
|
||||
.vscode-test/**
|
||||
out/test/**
|
||||
out/**/*.map
|
||||
src/**
|
||||
.gitignore
|
||||
tsconfig.json
|
||||
vsc-extension-quickstart.md
|
||||
tslint.json
|
4728
code/package-lock.json
generated
4728
code/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,138 +1,149 @@
|
||||
{
|
||||
"name": "libsyntax-rust",
|
||||
"displayName": "libsyntax-rust",
|
||||
"description": "An experimental Rust plugin for VS Code based on libsyntax2",
|
||||
"license": "MIT",
|
||||
"repository": "http://github.com/matklad/libsyntax2/",
|
||||
"version": "0.0.1",
|
||||
"publisher": "matklad",
|
||||
"engines": {
|
||||
"vscode": "^1.26.0"
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "tsc -p ./",
|
||||
"compile": "tsc -watch -p ./",
|
||||
"postinstall": "node ./node_modules/vscode/bin/install"
|
||||
},
|
||||
"dependencies": {
|
||||
"vscode-languageclient": "^4.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^7.0.56",
|
||||
"typescript": "^2.9.1",
|
||||
"vsce": "^1.42.0",
|
||||
"vscode": "^1.1.18"
|
||||
},
|
||||
"main": "./out/src/extension",
|
||||
"activationEvents": [
|
||||
"onLanguage:rust"
|
||||
],
|
||||
"contributes": {
|
||||
"taskDefinitions": [
|
||||
{
|
||||
"type": "cargo",
|
||||
"required": [
|
||||
"command"
|
||||
"name": "rcf-lsp",
|
||||
"displayName": "rcf-lsp",
|
||||
"description": "",
|
||||
"version": "0.0.1",
|
||||
"publisher": "matklad",
|
||||
"repository": {
|
||||
"url": "https://github.com/matklad/libsyntax2/"
|
||||
},
|
||||
"categories": [
|
||||
"Other"
|
||||
],
|
||||
"engines": {
|
||||
"vscode": "^1.26.0"
|
||||
},
|
||||
"scripts": {
|
||||
"vscode:prepublish": "npm run compile",
|
||||
"compile": "tsc -p ./",
|
||||
"watch": "tsc -watch -p ./",
|
||||
"postinstall": "node ./node_modules/vscode/bin/install"
|
||||
},
|
||||
"dependencies": {
|
||||
"vscode-languageclient": "^4.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^2.6.1",
|
||||
"vscode": "^1.1.21",
|
||||
"vsce": "^1.42.0",
|
||||
"@types/node": "^8.10.25",
|
||||
"@types/mocha": "^2.2.42"
|
||||
},
|
||||
"activationEvents": [
|
||||
"onLanguage:rust"
|
||||
],
|
||||
"main": "./out/extension",
|
||||
"contributes": {
|
||||
"taskDefinitions": [
|
||||
{
|
||||
"type": "cargo",
|
||||
"required": [
|
||||
"command"
|
||||
],
|
||||
"properties": {
|
||||
"label": {
|
||||
"type": "string"
|
||||
},
|
||||
"command": {
|
||||
"type": "string"
|
||||
},
|
||||
"args": {
|
||||
"type": "array"
|
||||
},
|
||||
"env": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"label": {
|
||||
"type": "string"
|
||||
},
|
||||
"command": {
|
||||
"type": "string"
|
||||
},
|
||||
"args": {
|
||||
"type": "array"
|
||||
},
|
||||
"env": {
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
{
|
||||
"command": "libsyntax-rust.createFile",
|
||||
"title": "Show Rust syntax tree"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.syntaxTree",
|
||||
"title": "Show Rust syntax tree"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.extendSelection",
|
||||
"title": "Rust Extend Selection"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.matchingBrace",
|
||||
"title": "Rust Matching Brace"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.parentModule",
|
||||
"title": "Rust Parent Module"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.joinLines",
|
||||
"title": "Rust Join Lines"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.run",
|
||||
"title": "Rust Run"
|
||||
}
|
||||
],
|
||||
"keybindings": [
|
||||
{
|
||||
"command": "libsyntax-rust.parentModule",
|
||||
"key": "ctrl+u",
|
||||
"when": "editorTextFocus && editorLangId == rust"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.matchingBrace",
|
||||
"key": "ctrl+shift+m",
|
||||
"when": "editorTextFocus && editorLangId == rust"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.extendSelection",
|
||||
"key": "ctrl+w",
|
||||
"when": "editorTextFocus && editorLangId == rust"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.joinLines",
|
||||
"key": "ctrl+shift+j",
|
||||
"when": "editorTextFocus && editorLangId == rust"
|
||||
}
|
||||
],
|
||||
"problemMatchers": [
|
||||
{
|
||||
"name": "rustc",
|
||||
"fileLocation": [
|
||||
"relative",
|
||||
"${workspaceRoot}"
|
||||
"commands": [
|
||||
{
|
||||
"command": "libsyntax-rust.createFile",
|
||||
"title": "Show Rust syntax tree"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.syntaxTree",
|
||||
"title": "Show Rust syntax tree"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.extendSelection",
|
||||
"title": "Rust Extend Selection"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.matchingBrace",
|
||||
"title": "Rust Matching Brace"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.parentModule",
|
||||
"title": "Rust Parent Module"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.joinLines",
|
||||
"title": "Rust Join Lines"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.run",
|
||||
"title": "Rust Run"
|
||||
}
|
||||
],
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(warning|warn|error)(\\[(.*)\\])?: (.*)$",
|
||||
"severity": 1,
|
||||
"message": 4,
|
||||
"code": 3
|
||||
},
|
||||
{
|
||||
"regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
|
||||
"file": 2,
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
{
|
||||
"regexp": "^.*$"
|
||||
},
|
||||
{
|
||||
"regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
|
||||
"file": 2,
|
||||
"line": 3,
|
||||
"column": 4
|
||||
}
|
||||
"keybindings": [
|
||||
{
|
||||
"command": "libsyntax-rust.parentModule",
|
||||
"key": "ctrl+u",
|
||||
"when": "editorTextFocus && editorLangId == rust"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.matchingBrace",
|
||||
"key": "ctrl+shift+m",
|
||||
"when": "editorTextFocus && editorLangId == rust"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.extendSelection",
|
||||
"key": "ctrl+w",
|
||||
"when": "editorTextFocus && editorLangId == rust"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.joinLines",
|
||||
"key": "ctrl+shift+j",
|
||||
"when": "editorTextFocus && editorLangId == rust"
|
||||
},
|
||||
{
|
||||
"command": "libsyntax-rust.run",
|
||||
"key": "ctrl+r",
|
||||
"when": "editorTextFocus && editorLangId == rust"
|
||||
}
|
||||
],
|
||||
"problemMatchers": [
|
||||
{
|
||||
"name": "rustc",
|
||||
"fileLocation": [
|
||||
"relative",
|
||||
"${workspaceRoot}"
|
||||
],
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(warning|warn|error)(\\[(.*)\\])?: (.*)$",
|
||||
"severity": 1,
|
||||
"message": 4,
|
||||
"code": 3
|
||||
},
|
||||
{
|
||||
"regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
|
||||
"file": 2,
|
||||
"line": 3,
|
||||
"column": 4
|
||||
},
|
||||
{
|
||||
"regexp": "^.*$"
|
||||
},
|
||||
{
|
||||
"regexp": "^([\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
|
||||
"file": 2,
|
||||
"line": 3,
|
||||
"column": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
import * as vscode from 'vscode';
|
||||
import * as lc from 'vscode-languageclient'
|
||||
import { DH_UNABLE_TO_CHECK_GENERATOR } from 'constants';
|
||||
|
||||
|
||||
let client: lc.LanguageClient;
|
||||
@ -12,10 +13,10 @@ let uris = {
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
let textDocumentContentProvider = new TextDocumentContentProvider()
|
||||
let dispose = (disposable) => {
|
||||
let dispose = (disposable: vscode.Disposable) => {
|
||||
context.subscriptions.push(disposable);
|
||||
}
|
||||
let registerCommand = (name, f) => {
|
||||
let registerCommand = (name: string, f: any) => {
|
||||
dispose(vscode.commands.registerCommand(name, f))
|
||||
}
|
||||
|
||||
@ -42,7 +43,7 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
textDocument: { uri: editor.document.uri.toString() },
|
||||
offsets: editor.selections.map((s) => {
|
||||
return client.code2ProtocolConverter.asPosition(s.active)
|
||||
})
|
||||
})
|
||||
}
|
||||
let response = await client.sendRequest<lc.Position[]>("m/findMatchingBrace", request)
|
||||
editor.selections = editor.selections.map((sel, idx) => {
|
||||
@ -71,8 +72,8 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
let request: lc.TextDocumentIdentifier = {
|
||||
uri: editor.document.uri.toString()
|
||||
}
|
||||
let response = await client.sendRequest<lc.TextDocumentIdentifier>("m/parentModule", request)
|
||||
let loc: lc.Location = response[0]
|
||||
let response = await client.sendRequest<lc.Location[]>("m/parentModule", request)
|
||||
let loc = response[0]
|
||||
if (loc == null) return
|
||||
let uri = client.protocol2CodeConverter.asUri(loc.uri)
|
||||
let range = client.protocol2CodeConverter.asRange(loc.range)
|
||||
@ -82,19 +83,40 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
e.revealRange(range, vscode.TextEditorRevealType.InCenter)
|
||||
})
|
||||
|
||||
registerCommand('libsyntax-rust.run', async (cmd: ProcessSpec) => {
|
||||
let task = createTask(cmd)
|
||||
await vscode.tasks.executeTask(task)
|
||||
let prevRunnable: RunnableQuickPick | undefined = undefined
|
||||
registerCommand('libsyntax-rust.run', async () => {
|
||||
let editor = vscode.window.activeTextEditor
|
||||
if (editor == null || editor.document.languageId != "rust") return
|
||||
let textDocument: lc.TextDocumentIdentifier = {
|
||||
uri: editor.document.uri.toString()
|
||||
}
|
||||
let params: RunnablesParams = {
|
||||
textDocument,
|
||||
position: client.code2ProtocolConverter.asPosition(editor.selection.active)
|
||||
}
|
||||
let runnables = await client.sendRequest<Runnable[]>('m/runnables', params)
|
||||
let items: RunnableQuickPick[] = []
|
||||
if (prevRunnable) {
|
||||
items.push(prevRunnable)
|
||||
}
|
||||
for (let r of runnables) {
|
||||
items.push(new RunnableQuickPick(r))
|
||||
}
|
||||
let item = await vscode.window.showQuickPick(items)
|
||||
if (item) {
|
||||
item.detail = "last"
|
||||
prevRunnable = item
|
||||
let task = createTask(item.runnable)
|
||||
return await vscode.tasks.executeTask(task)
|
||||
}
|
||||
})
|
||||
registerCommand('libsyntax-rust.createFile', async (uri_: string) => {
|
||||
console.log(`uri: ${uri_}`)
|
||||
let uri = vscode.Uri.parse(uri_)
|
||||
let edit = new vscode.WorkspaceEdit()
|
||||
edit.createFile(uri)
|
||||
await vscode.workspace.applyEdit(edit)
|
||||
let doc = await vscode.workspace.openTextDocument(uri)
|
||||
await vscode.window.showTextDocument(doc)
|
||||
console.log("Done")
|
||||
})
|
||||
|
||||
dispose(vscode.workspace.registerTextDocumentContentProvider(
|
||||
@ -113,13 +135,13 @@ export function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
// We need to order this after LS updates, but there's no API for that.
|
||||
// Hence, good old setTimeout.
|
||||
function afterLs(f) {
|
||||
function afterLs(f: () => any) {
|
||||
setTimeout(f, 10)
|
||||
}
|
||||
|
||||
export function deactivate(): Thenable<void> {
|
||||
if (!client) {
|
||||
return undefined;
|
||||
return Promise.resolve();
|
||||
}
|
||||
return client.stop();
|
||||
}
|
||||
@ -148,7 +170,7 @@ function startServer() {
|
||||
);
|
||||
client.onReady().then(() => {
|
||||
client.onNotification(
|
||||
new lc.NotificationType("m/publishDecorations"),
|
||||
"m/publishDecorations",
|
||||
(params: PublishDecorationsParams) => {
|
||||
let editor = vscode.window.visibleTextEditors.find(
|
||||
(editor) => editor.document.uri.toString() == params.uri
|
||||
@ -164,11 +186,11 @@ function startServer() {
|
||||
new lc.RequestType<lc.Position, void, any, any>("m/moveCursor"),
|
||||
(params: lc.Position, token: lc.CancellationToken) => {
|
||||
let editor = vscode.window.activeTextEditor;
|
||||
if (editor == null) return
|
||||
if (!editor) return
|
||||
if (!editor.selection.isEmpty) return
|
||||
let position = client.protocol2CodeConverter.asPosition(params)
|
||||
afterLs(() => {
|
||||
editor.selection = new vscode.Selection(position, position)
|
||||
editor!.selection = new vscode.Selection(position, position)
|
||||
})
|
||||
}
|
||||
)
|
||||
@ -200,8 +222,8 @@ class TextDocumentContentProvider implements vscode.TextDocumentContentProvider
|
||||
}
|
||||
|
||||
|
||||
const decorations = (() => {
|
||||
const decor = (obj) => vscode.window.createTextEditorDecorationType({ color: obj })
|
||||
const decorations: { [index: string]: vscode.TextEditorDecorationType } = (() => {
|
||||
const decor = (obj: any) => vscode.window.createTextEditorDecorationType({ color: obj })
|
||||
return {
|
||||
background: decor("#3F3F3F"),
|
||||
error: vscode.window.createTextEditorDecorationType({
|
||||
@ -224,24 +246,24 @@ function setHighlights(
|
||||
editor: vscode.TextEditor,
|
||||
highlihgs: Array<Decoration>
|
||||
) {
|
||||
let byTag = {}
|
||||
let byTag: Map<string, vscode.Range[]> = new Map()
|
||||
for (let tag in decorations) {
|
||||
byTag[tag] = []
|
||||
byTag.set(tag, [])
|
||||
}
|
||||
|
||||
for (let d of highlihgs) {
|
||||
if (!byTag[d.tag]) {
|
||||
if (!byTag.get(d.tag)) {
|
||||
console.log(`unknown tag ${d.tag}`)
|
||||
continue
|
||||
}
|
||||
byTag[d.tag].push(
|
||||
byTag.get(d.tag)!.push(
|
||||
client.protocol2CodeConverter.asRange(d.range)
|
||||
)
|
||||
}
|
||||
|
||||
for (let tag in byTag) {
|
||||
let dec = decorations[tag]
|
||||
let ranges = byTag[tag]
|
||||
for (let tag of byTag.keys()) {
|
||||
let dec: vscode.TextEditorDecorationType = decorations[tag]
|
||||
let ranges = byTag.get(tag)!
|
||||
editor.setDecorations(dec, ranges)
|
||||
}
|
||||
}
|
||||
@ -276,16 +298,35 @@ interface PublishDecorationsParams {
|
||||
decorations: Decoration[],
|
||||
}
|
||||
|
||||
interface RunnablesParams {
|
||||
textDocument: lc.TextDocumentIdentifier,
|
||||
position?: lc.Position,
|
||||
}
|
||||
|
||||
interface Runnable {
|
||||
range: lc.Range;
|
||||
label: string;
|
||||
bin: string;
|
||||
args: string[];
|
||||
env: { [index: string]: string },
|
||||
}
|
||||
|
||||
class RunnableQuickPick implements vscode.QuickPickItem {
|
||||
label: string;
|
||||
description?: string | undefined;
|
||||
detail?: string | undefined;
|
||||
picked?: boolean | undefined;
|
||||
|
||||
constructor(public runnable: Runnable) {
|
||||
this.label = runnable.label
|
||||
}
|
||||
}
|
||||
|
||||
interface Decoration {
|
||||
range: lc.Range,
|
||||
tag: string,
|
||||
}
|
||||
|
||||
interface ProcessSpec {
|
||||
bin: string;
|
||||
args: string[];
|
||||
env: { [key: string]: string };
|
||||
}
|
||||
|
||||
interface CargoTaskDefinition extends vscode.TaskDefinition {
|
||||
type: 'cargo';
|
||||
@ -295,8 +336,7 @@ interface CargoTaskDefinition extends vscode.TaskDefinition {
|
||||
env?: { [key: string]: string };
|
||||
}
|
||||
|
||||
|
||||
function createTask(spec: ProcessSpec): vscode.Task {
|
||||
function createTask(spec: Runnable): vscode.Task {
|
||||
const TASK_SOURCE = 'Rust';
|
||||
let definition: CargoTaskDefinition = {
|
||||
type: 'cargo',
|
||||
@ -313,7 +353,7 @@ function createTask(spec: ProcessSpec): vscode.Task {
|
||||
};
|
||||
let exec = new vscode.ShellExecution(execCmd, execOption);
|
||||
|
||||
let f = vscode.workspace.workspaceFolders[0]
|
||||
let f = vscode.workspace.workspaceFolders![0]
|
||||
let t = new vscode.Task(definition, f, definition.label, TASK_SOURCE, exec, ['$rustc']);
|
||||
return t;
|
||||
}
|
||||
|
@ -3,9 +3,15 @@
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"outDir": "out",
|
||||
"lib": [ "es6" ],
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"rootDir": "."
|
||||
"rootDir": "src",
|
||||
"strict": true
|
||||
},
|
||||
"include": [ "src/*.ts" ],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".vscode-test"
|
||||
]
|
||||
}
|
||||
|
@ -135,48 +135,6 @@ pub fn handle_code_action(
|
||||
res.push(cmd);
|
||||
}
|
||||
}
|
||||
for runnable in libeditor::runnables(&file) {
|
||||
if !contains_offset_nonstrict(runnable.range, offset) {
|
||||
continue;
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct ProcessSpec {
|
||||
bin: String,
|
||||
args: Vec<String>,
|
||||
env: HashMap<String, String>,
|
||||
}
|
||||
|
||||
let spec = ProcessSpec {
|
||||
bin: "cargo".to_string(),
|
||||
args: match runnable.kind {
|
||||
libeditor::RunnableKind::Test { name } => {
|
||||
vec![
|
||||
"test".to_string(),
|
||||
"--".to_string(),
|
||||
name,
|
||||
"--nocapture".to_string(),
|
||||
]
|
||||
}
|
||||
libeditor::RunnableKind::Bin => vec!["run".to_string()]
|
||||
},
|
||||
env: {
|
||||
let mut m = HashMap::new();
|
||||
m.insert(
|
||||
"RUST_BACKTRACE".to_string(),
|
||||
"short".to_string(),
|
||||
);
|
||||
m
|
||||
}
|
||||
};
|
||||
|
||||
let cmd = Command {
|
||||
title: "Run ...".to_string(),
|
||||
command: "libsyntax-rust.run".to_string(),
|
||||
arguments: Some(vec![to_value(spec).unwrap()]),
|
||||
};
|
||||
res.push(cmd);
|
||||
}
|
||||
|
||||
for (diag, quick_fix) in world.analysis().diagnostics(file_id)? {
|
||||
let quick_fix = match quick_fix {
|
||||
|
@ -142,7 +142,7 @@ pub enum Runnables {}
|
||||
impl Request for Runnables {
|
||||
type Params = RunnablesParams;
|
||||
type Result = Vec<Runnable>;
|
||||
const METHOD: &'static str = "m/joinLines";
|
||||
const METHOD: &'static str = "m/runnables";
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
|
@ -204,7 +204,7 @@ cd code
|
||||
execute!(
|
||||
r"
|
||||
cd code
|
||||
code --install-extension ./libsyntax-rust-0.0.1.vsix
|
||||
code --install-extension ./rcf-lsp-0.0.1.vsix
|
||||
"
|
||||
)?;
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user