mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
you better run
This commit is contained in:
parent
5751815314
commit
422efe59af
13 changed files with 2654 additions and 2633 deletions
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue