mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 13:48:50 +00:00
Fixed tsfmt and eslint errors.
This commit is contained in:
parent
eb6f9c23e1
commit
10836543d6
2 changed files with 19 additions and 19 deletions
|
@ -21,24 +21,24 @@ export class Cargo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async artifactsFromArgs(cargoArgs: string[]): Promise<CompilationArtifact[]> {
|
public async artifactsFromArgs(cargoArgs: string[]): Promise<CompilationArtifact[]> {
|
||||||
let artifacts: CompilationArtifact[] = [];
|
const artifacts: CompilationArtifact[] = [];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.runCargo(cargoArgs,
|
await this.runCargo(cargoArgs,
|
||||||
message => {
|
message => {
|
||||||
if (message.reason == 'compiler-artifact' && message.executable) {
|
if (message.reason === 'compiler-artifact' && message.executable) {
|
||||||
let isBinary = message.target.crate_types.includes('bin');
|
const isBinary = message.target.crate_types.includes('bin');
|
||||||
let isBuildScript = message.target.kind.includes('custom-build');
|
const isBuildScript = message.target.kind.includes('custom-build');
|
||||||
if ((isBinary && !isBuildScript) || message.profile.test) {
|
if ((isBinary && !isBuildScript) || message.profile.test) {
|
||||||
artifacts.push({
|
artifacts.push({
|
||||||
fileName: message.executable,
|
fileName: message.executable,
|
||||||
name: message.target.name,
|
name: message.target.name,
|
||||||
kind: message.target.kind[0],
|
kind: message.target.kind[0],
|
||||||
isTest: message.profile.test
|
isTest: message.profile.test
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( message.reason == 'compiler-message') {
|
else if (message.reason === 'compiler-message') {
|
||||||
this.output.append(message.message.rendered);
|
this.output.append(message.message.rendered);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -62,9 +62,9 @@ export class Cargo {
|
||||||
cargoArgs.push(...extraArgs);
|
cargoArgs.push(...extraArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
let artifacts = await this.artifactsFromArgs(cargoArgs);
|
const artifacts = await this.artifactsFromArgs(cargoArgs);
|
||||||
|
|
||||||
if (artifacts.length == 0 ) {
|
if (artifacts.length === 0) {
|
||||||
throw new Error('No compilation artifacts');
|
throw new Error('No compilation artifacts');
|
||||||
} else if (artifacts.length > 1) {
|
} else if (artifacts.length > 1) {
|
||||||
throw new Error('Multiple compilation artifacts are not supported.');
|
throw new Error('Multiple compilation artifacts are not supported.');
|
||||||
|
@ -79,7 +79,7 @@ export class Cargo {
|
||||||
onStderrString: (data: string) => void
|
onStderrString: (data: string) => void
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
return new Promise<number>((resolve, reject) => {
|
return new Promise<number>((resolve, reject) => {
|
||||||
let cargo = cp.spawn('cargo', cargoArgs, {
|
const cargo = cp.spawn('cargo', cargoArgs, {
|
||||||
stdio: ['ignore', 'pipe', 'pipe'],
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
cwd: this.rootFolder,
|
cwd: this.rootFolder,
|
||||||
env: this.env,
|
env: this.env,
|
||||||
|
@ -92,14 +92,14 @@ export class Cargo {
|
||||||
onStderrString(chunk.toString());
|
onStderrString(chunk.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
let rl = readline.createInterface({ input: cargo.stdout });
|
const rl = readline.createInterface({ input: cargo.stdout });
|
||||||
rl.on('line', line => {
|
rl.on('line', line => {
|
||||||
let message = JSON.parse(line);
|
const message = JSON.parse(line);
|
||||||
onStdoutJson(message);
|
onStdoutJson(message);
|
||||||
});
|
});
|
||||||
|
|
||||||
cargo.on('exit', (exitCode, _) => {
|
cargo.on('exit', (exitCode, _) => {
|
||||||
if (exitCode == 0)
|
if (exitCode === 0)
|
||||||
resolve(exitCode);
|
resolve(exitCode);
|
||||||
else
|
else
|
||||||
reject(new Error(`exit code: ${exitCode}.`));
|
reject(new Error(`exit code: ${exitCode}.`));
|
||||||
|
|
|
@ -82,9 +82,9 @@ const debugOutput = vscode.window.createOutputChannel("Debug");
|
||||||
|
|
||||||
async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, string>): Promise<vscode.DebugConfiguration> {
|
async function getCppvsDebugConfig(config: ra.Runnable, sourceFileMap: Record<string, string>): Promise<vscode.DebugConfiguration> {
|
||||||
debugOutput.clear();
|
debugOutput.clear();
|
||||||
|
|
||||||
let cargo = new Cargo(config.cwd || '.', debugOutput);
|
const cargo = new Cargo(config.cwd || '.', debugOutput);
|
||||||
let executable = await cargo.executableFromArgs(config.args, config.extraArgs);
|
const executable = await cargo.executableFromArgs(config.args, config.extraArgs);
|
||||||
|
|
||||||
// if we are here, there were no compilation errors.
|
// if we are here, there were no compilation errors.
|
||||||
return {
|
return {
|
||||||
|
@ -106,9 +106,9 @@ export function debugSingle(ctx: Ctx): Cmd {
|
||||||
const lldbId = "vadimcn.vscode-lldb";
|
const lldbId = "vadimcn.vscode-lldb";
|
||||||
const cpptoolsId = "ms-vscode.cpptools";
|
const cpptoolsId = "ms-vscode.cpptools";
|
||||||
|
|
||||||
let debugEngineId = ctx.config.debug.engine;
|
const debugEngineId = ctx.config.debug.engine;
|
||||||
let debugEngine = null;
|
let debugEngine = null;
|
||||||
if ( debugEngineId === "auto" ) {
|
if (debugEngineId === "auto") {
|
||||||
debugEngine = vscode.extensions.getExtension(lldbId);
|
debugEngine = vscode.extensions.getExtension(lldbId);
|
||||||
if (!debugEngine) {
|
if (!debugEngine) {
|
||||||
debugEngine = vscode.extensions.getExtension(cpptoolsId);
|
debugEngine = vscode.extensions.getExtension(cpptoolsId);
|
||||||
|
@ -120,11 +120,11 @@ export function debugSingle(ctx: Ctx): Cmd {
|
||||||
|
|
||||||
if (!debugEngine) {
|
if (!debugEngine) {
|
||||||
vscode.window.showErrorMessage(`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=${lldbId})`
|
vscode.window.showErrorMessage(`Install [CodeLLDB](https://marketplace.visualstudio.com/items?itemName=${lldbId})`
|
||||||
+ ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=${cpptoolsId}) extension for debugging.`);
|
+ ` or [MS C++ tools](https://marketplace.visualstudio.com/items?itemName=${cpptoolsId}) extension for debugging.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const debugConfig = lldbId == debugEngine.id
|
const debugConfig = lldbId === debugEngine.id
|
||||||
? getLldbDebugConfig(config, ctx.config.debug.sourceFileMap)
|
? getLldbDebugConfig(config, ctx.config.debug.sourceFileMap)
|
||||||
: await getCppvsDebugConfig(config, ctx.config.debug.sourceFileMap);
|
: await getCppvsDebugConfig(config, ctx.config.debug.sourceFileMap);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue