mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Fix prettier error
This commit is contained in:
parent
6971c7f118
commit
c894a3e19b
@ -2,7 +2,7 @@ import * as child_process from 'child_process';
|
|||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as timers from 'timers';
|
import * as timers from 'timers';
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import {StatusDisplay} from './watch_status';
|
import { StatusDisplay } from './watch_status';
|
||||||
|
|
||||||
export class CargoWatchProvider {
|
export class CargoWatchProvider {
|
||||||
private diagnosticCollection?: vscode.DiagnosticCollection;
|
private diagnosticCollection?: vscode.DiagnosticCollection;
|
||||||
@ -12,19 +12,22 @@ export class CargoWatchProvider {
|
|||||||
|
|
||||||
public activate(subscriptions: vscode.Disposable[]) {
|
public activate(subscriptions: vscode.Disposable[]) {
|
||||||
subscriptions.push(this);
|
subscriptions.push(this);
|
||||||
this.diagnosticCollection = vscode.languages.createDiagnosticCollection('rustc');
|
this.diagnosticCollection = vscode.languages.createDiagnosticCollection(
|
||||||
|
'rustc'
|
||||||
|
);
|
||||||
|
|
||||||
this.statusDisplay = new StatusDisplay(subscriptions);
|
this.statusDisplay = new StatusDisplay(subscriptions);
|
||||||
|
|
||||||
// Start the cargo watch with json message
|
// Start the cargo watch with json message
|
||||||
this.cargoProcess = child_process.spawn('cargo',
|
this.cargoProcess = child_process.spawn(
|
||||||
['watch', '-x', '\"check --message-format json\"'],
|
'cargo',
|
||||||
|
['watch', '-x', '"check --message-format json"'],
|
||||||
{
|
{
|
||||||
// stdio: ['ignore', 'pipe', 'ignore'],
|
// stdio: ['ignore', 'pipe', 'ignore'],
|
||||||
shell: true,
|
shell: true,
|
||||||
cwd: vscode.workspace.rootPath,
|
cwd: vscode.workspace.rootPath
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
this.cargoProcess.stdout.on('data', (s: string) => {
|
this.cargoProcess.stdout.on('data', (s: string) => {
|
||||||
this.processOutput(s);
|
this.processOutput(s);
|
||||||
@ -109,7 +112,9 @@ export class CargoWatchProvider {
|
|||||||
|
|
||||||
const fileUrl = vscode.Uri.file(fileName!);
|
const fileUrl = vscode.Uri.file(fileName!);
|
||||||
|
|
||||||
const diagnostics: vscode.Diagnostic[] = [...(this.diagnosticCollection!.get(fileUrl) || [])];
|
const diagnostics: vscode.Diagnostic[] = [
|
||||||
|
...(this.diagnosticCollection!.get(fileUrl) || [])
|
||||||
|
];
|
||||||
diagnostics.push(diagnostic);
|
diagnostics.push(diagnostic);
|
||||||
|
|
||||||
this.diagnosticCollection!.set(fileUrl, diagnostics);
|
this.diagnosticCollection!.set(fileUrl, diagnostics);
|
||||||
@ -129,5 +134,4 @@ export class CargoWatchProvider {
|
|||||||
eolIndex = this.outBuffer.indexOf('\n');
|
eolIndex = this.outBuffer.indexOf('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -134,8 +134,9 @@ export async function handleSingle(runnable: Runnable) {
|
|||||||
* provide inline diagnostics; the user is met with a series of dialog boxes
|
* provide inline diagnostics; the user is met with a series of dialog boxes
|
||||||
* that, when accepted, allow us to `cargo install cargo-watch` and then run it.
|
* that, when accepted, allow us to `cargo install cargo-watch` and then run it.
|
||||||
*/
|
*/
|
||||||
export async function interactivelyStartCargoWatch(context: vscode.ExtensionContext) {
|
export async function interactivelyStartCargoWatch(
|
||||||
|
context: vscode.ExtensionContext
|
||||||
|
) {
|
||||||
if (Server.config.enableCargoWatchOnStartup === 'disabled') {
|
if (Server.config.enableCargoWatchOnStartup === 'disabled') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -195,7 +196,6 @@ export async function interactivelyStartCargoWatch(context: vscode.ExtensionCont
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const validater = new CargoWatchProvider();
|
const validater = new CargoWatchProvider();
|
||||||
validater.activate(context.subscriptions);
|
validater.activate(context.subscriptions);
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,20 @@ export class StatusDisplay {
|
|||||||
private timer?: NodeJS.Timeout;
|
private timer?: NodeJS.Timeout;
|
||||||
|
|
||||||
constructor(subscriptions: vscode.Disposable[]) {
|
constructor(subscriptions: vscode.Disposable[]) {
|
||||||
this.statusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 10);
|
this.statusBarItem = vscode.window.createStatusBarItem(
|
||||||
|
vscode.StatusBarAlignment.Left,
|
||||||
|
10
|
||||||
|
);
|
||||||
subscriptions.push(this.statusBarItem);
|
subscriptions.push(this.statusBarItem);
|
||||||
this.statusBarItem.hide();
|
this.statusBarItem.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
public show() {
|
public show() {
|
||||||
this.timer = this.timer || setInterval(() => {
|
this.timer =
|
||||||
this.statusBarItem!.text = 'cargo check ' + this.frame();
|
this.timer ||
|
||||||
}, 300);
|
setInterval(() => {
|
||||||
|
this.statusBarItem!.text = 'cargo check ' + this.frame();
|
||||||
|
}, 300);
|
||||||
|
|
||||||
this.statusBarItem!.show();
|
this.statusBarItem!.show();
|
||||||
}
|
}
|
||||||
@ -32,6 +37,6 @@ export class StatusDisplay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private frame() {
|
private frame() {
|
||||||
return spinnerFrames[this.i = ++this.i % spinnerFrames.length];
|
return spinnerFrames[(this.i = ++this.i % spinnerFrames.length)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import * as vscode from 'vscode';
|
|||||||
import * as lc from 'vscode-languageclient';
|
import * as lc from 'vscode-languageclient';
|
||||||
|
|
||||||
import * as commands from './commands';
|
import * as commands from './commands';
|
||||||
import { interactivelyStartCargoWatch} from './commands/runnables';
|
import { interactivelyStartCargoWatch } from './commands/runnables';
|
||||||
import { SyntaxTreeContentProvider } from './commands/syntaxTree';
|
import { SyntaxTreeContentProvider } from './commands/syntaxTree';
|
||||||
import * as events from './events';
|
import * as events from './events';
|
||||||
import * as notifications from './notifications';
|
import * as notifications from './notifications';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user