mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-15 22:54:00 +00:00
removing unused code
This commit is contained in:
parent
299382dacd
commit
fc57339fdf
1 changed files with 6 additions and 13 deletions
|
@ -3,9 +3,7 @@ import * as os from "os";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as readline from "readline";
|
import * as readline from "readline";
|
||||||
import * as vscode from "vscode";
|
import * as vscode from "vscode";
|
||||||
import { execute, log, memoizeAsync } from "./util";
|
import {execute, log, memoizeAsync} from "./util";
|
||||||
|
|
||||||
const TOOLCHAIN_PATTERN = new RegExp(/(.*)\s\(.*\)/);
|
|
||||||
|
|
||||||
interface CompilationArtifact {
|
interface CompilationArtifact {
|
||||||
fileName: string;
|
fileName: string;
|
||||||
|
@ -24,7 +22,7 @@ export class Cargo {
|
||||||
readonly rootFolder: string,
|
readonly rootFolder: string,
|
||||||
readonly output: vscode.OutputChannel,
|
readonly output: vscode.OutputChannel,
|
||||||
readonly env: Record<string, string>
|
readonly env: Record<string, string>
|
||||||
) { }
|
) {}
|
||||||
|
|
||||||
// Made public for testing purposes
|
// Made public for testing purposes
|
||||||
static artifactSpec(args: readonly string[]): ArtifactSpec {
|
static artifactSpec(args: readonly string[]): ArtifactSpec {
|
||||||
|
@ -44,7 +42,7 @@ export class Cargo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const result: ArtifactSpec = { cargoArgs: cargoArgs };
|
const result: ArtifactSpec = {cargoArgs: cargoArgs};
|
||||||
if (cargoArgs[0] === "test" || cargoArgs[0] === "bench") {
|
if (cargoArgs[0] === "test" || cargoArgs[0] === "bench") {
|
||||||
// for instance, `crates\rust-analyzer\tests\heavy_tests\main.rs` tests
|
// for instance, `crates\rust-analyzer\tests\heavy_tests\main.rs` tests
|
||||||
// produce 2 artifacts: {"kind": "bin"} and {"kind": "test"}
|
// produce 2 artifacts: {"kind": "bin"} and {"kind": "test"}
|
||||||
|
@ -149,7 +147,7 @@ export class Cargo {
|
||||||
|
|
||||||
cargo.stderr.on("data", (chunk) => onStderrString(chunk.toString()));
|
cargo.stderr.on("data", (chunk) => onStderrString(chunk.toString()));
|
||||||
|
|
||||||
const rl = readline.createInterface({ input: cargo.stdout });
|
const rl = readline.createInterface({input: cargo.stdout});
|
||||||
rl.on("line", (line) => {
|
rl.on("line", (line) => {
|
||||||
const message = JSON.parse(line);
|
const message = JSON.parse(line);
|
||||||
onStdoutJson(message);
|
onStdoutJson(message);
|
||||||
|
@ -191,14 +189,14 @@ export async function getSysroot(dir: string): Promise<string> {
|
||||||
const rustcPath = await getPathForExecutable("rustc");
|
const rustcPath = await getPathForExecutable("rustc");
|
||||||
|
|
||||||
// do not memoize the result because the toolchain may change between runs
|
// do not memoize the result because the toolchain may change between runs
|
||||||
return await execute(`${rustcPath} --print sysroot`, { cwd: dir });
|
return await execute(`${rustcPath} --print sysroot`, {cwd: dir});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getRustcId(dir: string): Promise<string> {
|
export async function getRustcId(dir: string): Promise<string> {
|
||||||
const rustcPath = await getPathForExecutable("rustc");
|
const rustcPath = await getPathForExecutable("rustc");
|
||||||
|
|
||||||
// do not memoize the result because the toolchain may change between runs
|
// do not memoize the result because the toolchain may change between runs
|
||||||
const data = await execute(`${rustcPath} -V -v`, { cwd: dir });
|
const data = await execute(`${rustcPath} -V -v`, {cwd: dir});
|
||||||
const rx = /commit-hash:\s(.*)$/m;
|
const rx = /commit-hash:\s(.*)$/m;
|
||||||
|
|
||||||
return rx.exec(data)![1];
|
return rx.exec(data)![1];
|
||||||
|
@ -219,11 +217,6 @@ export function cargoPath(): Promise<string> {
|
||||||
return getPathForExecutable("cargo");
|
return getPathForExecutable("cargo");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mirrors `toolchain::cargo()` implementation */
|
|
||||||
export function rustupPath(): Promise<string> {
|
|
||||||
return getPathForExecutable("rustup");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Mirrors `toolchain::get_path_for_executable()` implementation */
|
/** Mirrors `toolchain::get_path_for_executable()` implementation */
|
||||||
export const getPathForExecutable = memoizeAsync(
|
export const getPathForExecutable = memoizeAsync(
|
||||||
// We apply caching to decrease file-system interactions
|
// We apply caching to decrease file-system interactions
|
||||||
|
|
Loading…
Reference in a new issue