added children modules

This commit is contained in:
geetanshjuneja 2025-03-10 18:05:10 +05:30
parent c5882732e6
commit 1f7c3e8b92
10 changed files with 196 additions and 0 deletions

View file

@ -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,

View file

@ -157,6 +157,7 @@ pub fn server_capabilities(config: &Config) -> ServerCapabilities {
"onEnter": true,
"openCargoToml": true,
"parentModule": true,
"childrenModules": true,
"runnables": {
"kinds": [ "cargo" ],
},

View file

@ -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 {

View file

@ -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)