mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 21:25:25 +00:00
added children modules
This commit is contained in:
parent
c5882732e6
commit
1f7c3e8b92
10 changed files with 196 additions and 0 deletions
|
|
@ -943,6 +943,18 @@ pub(crate) fn handle_parent_module(
|
|||
Ok(Some(res))
|
||||
}
|
||||
|
||||
pub(crate) fn handle_children_modules(
|
||||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::TextDocumentPositionParams,
|
||||
) -> anyhow::Result<Option<lsp_types::GotoDefinitionResponse>> {
|
||||
let _p = tracing::info_span!("handle_children_module").entered();
|
||||
// locate children module by semantics
|
||||
let position = try_default!(from_proto::file_position(&snap, params)?);
|
||||
let navs = snap.analysis.children_modules(position)?;
|
||||
let res = to_proto::goto_definition_response(&snap, None, navs)?;
|
||||
Ok(Some(res))
|
||||
}
|
||||
|
||||
pub(crate) fn handle_runnables(
|
||||
snap: GlobalStateSnapshot,
|
||||
params: lsp_ext::RunnablesParams,
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@ pub fn server_capabilities(config: &Config) -> ServerCapabilities {
|
|||
"onEnter": true,
|
||||
"openCargoToml": true,
|
||||
"parentModule": true,
|
||||
"childrenModules": true,
|
||||
"runnables": {
|
||||
"kinds": [ "cargo" ],
|
||||
},
|
||||
|
|
|
|||
|
|
@ -399,6 +399,14 @@ impl Request for ParentModule {
|
|||
const METHOD: &'static str = "experimental/parentModule";
|
||||
}
|
||||
|
||||
pub enum ChildrenModules {}
|
||||
|
||||
impl Request for ChildrenModules {
|
||||
type Params = lsp_types::TextDocumentPositionParams;
|
||||
type Result = Option<lsp_types::GotoDefinitionResponse>;
|
||||
const METHOD: &'static str = "experimental/childrenModule";
|
||||
}
|
||||
|
||||
pub enum JoinLines {}
|
||||
|
||||
impl Request for JoinLines {
|
||||
|
|
|
|||
|
|
@ -1172,6 +1172,7 @@ impl GlobalState {
|
|||
.on::<NO_RETRY, lsp_ext::InterpretFunction>(handlers::handle_interpret_function)
|
||||
.on::<NO_RETRY, lsp_ext::ExpandMacro>(handlers::handle_expand_macro)
|
||||
.on::<NO_RETRY, lsp_ext::ParentModule>(handlers::handle_parent_module)
|
||||
.on::<NO_RETRY, lsp_ext::ChildrenModules>(handlers::handle_children_modules)
|
||||
.on::<NO_RETRY, lsp_ext::Runnables>(handlers::handle_runnables)
|
||||
.on::<NO_RETRY, lsp_ext::RelatedTests>(handlers::handle_related_tests)
|
||||
.on::<NO_RETRY, lsp_ext::CodeActionRequest>(handlers::handle_code_action)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue