mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Runnig tests somehow
This commit is contained in:
parent
89e56c364f
commit
6cade3f6d8
10 changed files with 149 additions and 32 deletions
|
@ -81,6 +81,11 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
let e = await vscode.window.showTextDocument(doc)
|
||||
e.revealRange(range, vscode.TextEditorRevealType.InCenter)
|
||||
})
|
||||
console.log("ping")
|
||||
registerCommand('libsyntax-rust.run', async (cmd: ProcessSpec) => {
|
||||
let task = createTask(cmd)
|
||||
await vscode.tasks.executeTask(task)
|
||||
})
|
||||
|
||||
dispose(vscode.workspace.registerTextDocumentContentProvider(
|
||||
'libsyntax-rust',
|
||||
|
@ -265,3 +270,40 @@ interface Decoration {
|
|||
range: lc.Range,
|
||||
tag: string,
|
||||
}
|
||||
|
||||
interface ProcessSpec {
|
||||
bin: string;
|
||||
args: string[];
|
||||
env: { [key: string]: string };
|
||||
}
|
||||
|
||||
interface CargoTaskDefinition extends vscode.TaskDefinition {
|
||||
type: 'cargo';
|
||||
label: string;
|
||||
command: string;
|
||||
args: Array<string>;
|
||||
env?: { [key: string]: string };
|
||||
}
|
||||
|
||||
|
||||
function createTask(spec: ProcessSpec): vscode.Task {
|
||||
const TASK_SOURCE = 'Rust';
|
||||
let definition: CargoTaskDefinition = {
|
||||
type: 'cargo',
|
||||
label: 'cargo',
|
||||
command: spec.bin,
|
||||
args: spec.args,
|
||||
env: spec.env
|
||||
}
|
||||
|
||||
let execCmd = `${definition.command} ${definition.args.join(' ')}`;
|
||||
let execOption: vscode.ShellExecutionOptions = {
|
||||
cwd: '.',
|
||||
env: definition.env,
|
||||
};
|
||||
let exec = new vscode.ShellExecution(execCmd, execOption);
|
||||
|
||||
let f = vscode.workspace.workspaceFolders[0]
|
||||
let t = new vscode.Task(definition, f, definition.label, TASK_SOURCE, exec, ['$rustc']);
|
||||
return t;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue