Fix proc-macro server spawning behavior when the server is r-a itself
This commit is contained in:
parent
0522503f14
commit
af0d548b66
@ -376,18 +376,23 @@ pub(crate) fn switch_workspaces(&mut self, cause: Cause) {
|
|||||||
.workspaces
|
.workspaces
|
||||||
.iter()
|
.iter()
|
||||||
.map(|ws| {
|
.map(|ws| {
|
||||||
let (path, args): (_, &[_]) = if path_manually_set {
|
let path = if path_manually_set {
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
"Pro-macro server path explicitly set: {}",
|
"Pro-macro server path explicitly set: {}",
|
||||||
path.display()
|
path.display()
|
||||||
);
|
);
|
||||||
(path.clone(), &[])
|
path.clone()
|
||||||
} else {
|
} else {
|
||||||
match ws.find_sysroot_proc_macro_srv() {
|
match ws.find_sysroot_proc_macro_srv() {
|
||||||
Some(server_path) => (server_path, &[]),
|
Some(server_path) => server_path,
|
||||||
None => (path.clone(), &["proc-macro"]),
|
None => path.clone(),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
let args: &[_] = if path.file_stem() == Some("rust-analyzer".as_ref()) {
|
||||||
|
&["proc-macro"]
|
||||||
|
} else {
|
||||||
|
&[]
|
||||||
|
};
|
||||||
|
|
||||||
tracing::info!(?args, "Using proc-macro server at {}", path.display(),);
|
tracing::info!(?args, "Using proc-macro server at {}", path.display(),);
|
||||||
ProcMacroServer::spawn(path.clone(), args).map_err(|err| {
|
ProcMacroServer::spawn(path.clone(), args).map_err(|err| {
|
||||||
|
@ -59,7 +59,10 @@ fn completes_items_from_standard_library() {
|
|||||||
"#,
|
"#,
|
||||||
)
|
)
|
||||||
.with_config(serde_json::json!({
|
.with_config(serde_json::json!({
|
||||||
"cargo": { "sysroot": "discover" }
|
"cargo": { "sysroot": "discover" },
|
||||||
|
"procMacro": {
|
||||||
|
"enable": false,
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
.server()
|
.server()
|
||||||
.wait_until_workspace_is_loaded();
|
.wait_until_workspace_is_loaded();
|
||||||
@ -508,7 +511,7 @@ fn main() {}
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_missing_module_code_action_in_json_project() {
|
fn test_missing_module_code_action_in_json_project() {
|
||||||
if skip_slow_tests() {
|
if skip_slow_tests() {
|
||||||
// return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let tmp_dir = TestDir::new();
|
let tmp_dir = TestDir::new();
|
||||||
@ -612,7 +615,10 @@ fn main() {{}}
|
|||||||
"#
|
"#
|
||||||
))
|
))
|
||||||
.with_config(serde_json::json!({
|
.with_config(serde_json::json!({
|
||||||
"cargo": { "sysroot": "discover" }
|
"cargo": { "sysroot": "discover" },
|
||||||
|
"procMacro": {
|
||||||
|
"enable": false,
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
.server()
|
.server()
|
||||||
.wait_until_workspace_is_loaded();
|
.wait_until_workspace_is_loaded();
|
||||||
@ -685,7 +691,7 @@ fn preserves_dos_line_endings() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn out_dirs_check() {
|
fn out_dirs_check() {
|
||||||
if skip_slow_tests() {
|
if skip_slow_tests() {
|
||||||
// return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let server = Project::with_fixture(
|
let server = Project::with_fixture(
|
||||||
@ -711,10 +717,20 @@ fn main() {
|
|||||||
println!("cargo:rerun-if-changed=build.rs");
|
println!("cargo:rerun-if-changed=build.rs");
|
||||||
}
|
}
|
||||||
//- /src/main.rs
|
//- /src/main.rs
|
||||||
#[rustc_builtin_macro] macro_rules! include {}
|
#![feature(rustc_attrs)]
|
||||||
#[rustc_builtin_macro] macro_rules! include_str {}
|
#[rustc_builtin_macro] macro_rules! include {
|
||||||
#[rustc_builtin_macro] macro_rules! concat {}
|
($file:expr $(,)?) => {{ /* compiler built-in */ }};
|
||||||
#[rustc_builtin_macro] macro_rules! env {}
|
}
|
||||||
|
#[rustc_builtin_macro] macro_rules! include_str {
|
||||||
|
($file:expr $(,)?) => {{ /* compiler built-in */ }};
|
||||||
|
}
|
||||||
|
#[rustc_builtin_macro] macro_rules! concat {
|
||||||
|
($($e:ident),+ $(,)?) => {{ /* compiler built-in */ }};
|
||||||
|
}
|
||||||
|
#[rustc_builtin_macro] macro_rules! env {
|
||||||
|
($name:expr $(,)?) => {{ /* compiler built-in */ }};
|
||||||
|
($name:expr, $error_msg:expr $(,)?) => {{ /* compiler built-in */ }};
|
||||||
|
}
|
||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/hello.rs"));
|
include!(concat!(env!("OUT_DIR"), "/hello.rs"));
|
||||||
|
|
||||||
@ -749,7 +765,7 @@ fn main() {
|
|||||||
let res = server.send_request::<HoverRequest>(HoverParams {
|
let res = server.send_request::<HoverRequest>(HoverParams {
|
||||||
text_document_position_params: TextDocumentPositionParams::new(
|
text_document_position_params: TextDocumentPositionParams::new(
|
||||||
server.doc_id("src/main.rs"),
|
server.doc_id("src/main.rs"),
|
||||||
Position::new(19, 10),
|
Position::new(29, 10),
|
||||||
),
|
),
|
||||||
work_done_progress_params: Default::default(),
|
work_done_progress_params: Default::default(),
|
||||||
});
|
});
|
||||||
@ -758,7 +774,7 @@ fn main() {
|
|||||||
let res = server.send_request::<HoverRequest>(HoverParams {
|
let res = server.send_request::<HoverRequest>(HoverParams {
|
||||||
text_document_position_params: TextDocumentPositionParams::new(
|
text_document_position_params: TextDocumentPositionParams::new(
|
||||||
server.doc_id("src/main.rs"),
|
server.doc_id("src/main.rs"),
|
||||||
Position::new(20, 10),
|
Position::new(30, 10),
|
||||||
),
|
),
|
||||||
work_done_progress_params: Default::default(),
|
work_done_progress_params: Default::default(),
|
||||||
});
|
});
|
||||||
@ -768,23 +784,23 @@ fn main() {
|
|||||||
GotoDefinitionParams {
|
GotoDefinitionParams {
|
||||||
text_document_position_params: TextDocumentPositionParams::new(
|
text_document_position_params: TextDocumentPositionParams::new(
|
||||||
server.doc_id("src/main.rs"),
|
server.doc_id("src/main.rs"),
|
||||||
Position::new(17, 9),
|
Position::new(27, 9),
|
||||||
),
|
),
|
||||||
work_done_progress_params: Default::default(),
|
work_done_progress_params: Default::default(),
|
||||||
partial_result_params: Default::default(),
|
partial_result_params: Default::default(),
|
||||||
},
|
},
|
||||||
json!([{
|
json!([{
|
||||||
"originSelectionRange": {
|
"originSelectionRange": {
|
||||||
"end": { "character": 10, "line": 17 },
|
"end": { "character": 10, "line": 27 },
|
||||||
"start": { "character": 8, "line": 17 }
|
"start": { "character": 8, "line": 27 }
|
||||||
},
|
},
|
||||||
"targetRange": {
|
"targetRange": {
|
||||||
"end": { "character": 9, "line": 8 },
|
"end": { "character": 9, "line": 18 },
|
||||||
"start": { "character": 0, "line": 7 }
|
"start": { "character": 0, "line": 17 }
|
||||||
},
|
},
|
||||||
"targetSelectionRange": {
|
"targetSelectionRange": {
|
||||||
"end": { "character": 8, "line": 8 },
|
"end": { "character": 8, "line": 18 },
|
||||||
"start": { "character": 7, "line": 8 }
|
"start": { "character": 7, "line": 18 }
|
||||||
},
|
},
|
||||||
"targetUri": "file:///[..]src/main.rs"
|
"targetUri": "file:///[..]src/main.rs"
|
||||||
}]),
|
}]),
|
||||||
@ -794,23 +810,23 @@ fn main() {
|
|||||||
GotoDefinitionParams {
|
GotoDefinitionParams {
|
||||||
text_document_position_params: TextDocumentPositionParams::new(
|
text_document_position_params: TextDocumentPositionParams::new(
|
||||||
server.doc_id("src/main.rs"),
|
server.doc_id("src/main.rs"),
|
||||||
Position::new(18, 9),
|
Position::new(28, 9),
|
||||||
),
|
),
|
||||||
work_done_progress_params: Default::default(),
|
work_done_progress_params: Default::default(),
|
||||||
partial_result_params: Default::default(),
|
partial_result_params: Default::default(),
|
||||||
},
|
},
|
||||||
json!([{
|
json!([{
|
||||||
"originSelectionRange": {
|
"originSelectionRange": {
|
||||||
"end": { "character": 10, "line": 18 },
|
"end": { "character": 10, "line": 28 },
|
||||||
"start": { "character": 8, "line": 18 }
|
"start": { "character": 8, "line": 28 }
|
||||||
},
|
},
|
||||||
"targetRange": {
|
"targetRange": {
|
||||||
"end": { "character": 9, "line": 12 },
|
"end": { "character": 9, "line": 22 },
|
||||||
"start": { "character": 0, "line":11 }
|
"start": { "character": 0, "line": 21 }
|
||||||
},
|
},
|
||||||
"targetSelectionRange": {
|
"targetSelectionRange": {
|
||||||
"end": { "character": 8, "line": 12 },
|
"end": { "character": 8, "line": 22 },
|
||||||
"start": { "character": 7, "line": 12 }
|
"start": { "character": 7, "line": 22 }
|
||||||
},
|
},
|
||||||
"targetUri": "file:///[..]src/main.rs"
|
"targetUri": "file:///[..]src/main.rs"
|
||||||
}]),
|
}]),
|
||||||
@ -836,6 +852,7 @@ fn resolve_proc_macro() {
|
|||||||
bar = {path = "../bar"}
|
bar = {path = "../bar"}
|
||||||
|
|
||||||
//- /foo/src/main.rs
|
//- /foo/src/main.rs
|
||||||
|
#![feature(rustc_attrs, decl_macro)]
|
||||||
use bar::Bar;
|
use bar::Bar;
|
||||||
|
|
||||||
#[rustc_builtin_macro]
|
#[rustc_builtin_macro]
|
||||||
@ -912,7 +929,7 @@ pub fn foo(_input: TokenStream) -> TokenStream {
|
|||||||
let res = server.send_request::<HoverRequest>(HoverParams {
|
let res = server.send_request::<HoverRequest>(HoverParams {
|
||||||
text_document_position_params: TextDocumentPositionParams::new(
|
text_document_position_params: TextDocumentPositionParams::new(
|
||||||
server.doc_id("foo/src/main.rs"),
|
server.doc_id("foo/src/main.rs"),
|
||||||
Position::new(10, 9),
|
Position::new(11, 9),
|
||||||
),
|
),
|
||||||
work_done_progress_params: Default::default(),
|
work_done_progress_params: Default::default(),
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user