Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #19554 from davidbarsky/davidbarsky/rename-children-modules-to-child-modules
internal: rename `children_modules` to `child_modules`
Laurențiu Nicola 2025-04-09
parent a055643 · parent 99a2b67 · commit a556f72
-rw-r--r--crates/ide/src/child_modules.rs (renamed from crates/ide/src/children_modules.rs)30
-rw-r--r--crates/ide/src/lib.rs6
-rw-r--r--crates/rust-analyzer/src/handlers/request.rs8
-rw-r--r--crates/rust-analyzer/src/lsp/capabilities.rs2
-rw-r--r--crates/rust-analyzer/src/lsp/ext.rs6
-rw-r--r--crates/rust-analyzer/src/main_loop.rs2
-rw-r--r--docs/book/src/contributing/lsp-extensions.md2
-rw-r--r--editors/code/package.json6
-rw-r--r--editors/code/src/commands.ts4
-rw-r--r--editors/code/src/lsp_ext.ts4
-rw-r--r--editors/code/src/main.ts14
11 files changed, 45 insertions, 39 deletions
diff --git a/crates/ide/src/children_modules.rs b/crates/ide/src/child_modules.rs
index 4bb7cb8424..b781596187 100644
--- a/crates/ide/src/children_modules.rs
+++ b/crates/ide/src/child_modules.rs
@@ -7,16 +7,16 @@ use syntax::{
use crate::NavigationTarget;
-// Feature: Children Modules
+// Feature: Child Modules
//
-// Navigates to the children modules of the current module.
+// Navigates to the child modules of the current module.
//
// | Editor | Action Name |
// |---------|-------------|
-// | VS Code | **rust-analyzer: Locate children modules** |
+// | VS Code | **rust-analyzer: Locate child modules** |
/// This returns `Vec` because a module may be included from several places.
-pub(crate) fn children_modules(db: &RootDatabase, position: FilePosition) -> Vec<NavigationTarget> {
+pub(crate) fn child_modules(db: &RootDatabase, position: FilePosition) -> Vec<NavigationTarget> {
let sema = Semantics::new(db);
let source_file = sema.parse_guess_edition(position.file_id);
// First go to the parent module which contains the cursor
@@ -24,7 +24,7 @@ pub(crate) fn children_modules(db: &RootDatabase, position: FilePosition) -> Vec
match module {
Some(module) => {
- // Return all the children module inside the ItemList of the parent module
+ // Return all child modules inside the ItemList of the parent module
sema.to_def(&module)
.into_iter()
.flat_map(|module| module.children(db))
@@ -32,7 +32,7 @@ pub(crate) fn children_modules(db: &RootDatabase, position: FilePosition) -> Vec
.collect()
}
None => {
- // Return all the children module inside the source file
+ // Return all the child modules inside the source file
sema.file_to_module_defs(position.file_id)
.flat_map(|module| module.children(db))
.map(|module| NavigationTarget::from_module_to_decl(db, module).call_site())
@@ -47,9 +47,9 @@ mod tests {
use crate::fixture;
- fn check_children_module(#[rust_analyzer::rust_fixture] ra_fixture: &str) {
+ fn check_child_module(#[rust_analyzer::rust_fixture] ra_fixture: &str) {
let (analysis, position, expected) = fixture::annotations(ra_fixture);
- let navs = analysis.children_modules(position).unwrap();
+ let navs = analysis.child_modules(position).unwrap();
let navs = navs
.iter()
.map(|nav| FileRange { file_id: nav.file_id, range: nav.focus_or_full_range() })
@@ -58,8 +58,8 @@ mod tests {
}
#[test]
- fn test_resolve_children_module() {
- check_children_module(
+ fn test_resolve_child_module() {
+ check_child_module(
r#"
//- /lib.rs
$0
@@ -73,8 +73,8 @@ mod foo;
}
#[test]
- fn test_resolve_children_module_on_module_decl() {
- check_children_module(
+ fn test_resolve_child_module_on_module_decl() {
+ check_child_module(
r#"
//- /lib.rs
mod $0foo;
@@ -89,8 +89,8 @@ mod bar;
}
#[test]
- fn test_resolve_children_module_for_inline() {
- check_children_module(
+ fn test_resolve_child_module_for_inline() {
+ check_child_module(
r#"
//- /lib.rs
mod foo {
@@ -104,7 +104,7 @@ mod foo {
#[test]
fn test_resolve_multi_child_module() {
- check_children_module(
+ check_child_module(
r#"
//- /main.rs
$0
diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs
index a517dd0381..4b22f7c6c2 100644
--- a/crates/ide/src/lib.rs
+++ b/crates/ide/src/lib.rs
@@ -20,7 +20,7 @@ mod navigation_target;
mod annotations;
mod call_hierarchy;
-mod children_modules;
+mod child_modules;
mod doc_links;
mod expand_macro;
mod extend_selection;
@@ -607,8 +607,8 @@ impl Analysis {
}
/// Returns vec of `mod name;` declaration which are created by the current module.
- pub fn children_modules(&self, position: FilePosition) -> Cancellable<Vec<NavigationTarget>> {
- self.with_db(|db| children_modules::children_modules(db, position))
+ pub fn child_modules(&self, position: FilePosition) -> Cancellable<Vec<NavigationTarget>> {
+ self.with_db(|db| child_modules::child_modules(db, position))
}
/// Returns crates that this file belongs to.
diff --git a/crates/rust-analyzer/src/handlers/request.rs b/crates/rust-analyzer/src/handlers/request.rs
index 0444a0ebf6..7427a3bbaa 100644
--- a/crates/rust-analyzer/src/handlers/request.rs
+++ b/crates/rust-analyzer/src/handlers/request.rs
@@ -943,14 +943,14 @@ pub(crate) fn handle_parent_module(
Ok(Some(res))
}
-pub(crate) fn handle_children_modules(
+pub(crate) fn handle_child_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 _p = tracing::info_span!("handle_child_modules").entered();
+ // locate child module by semantics
let position = try_default!(from_proto::file_position(&snap, params)?);
- let navs = snap.analysis.children_modules(position)?;
+ let navs = snap.analysis.child_modules(position)?;
let res = to_proto::goto_definition_response(&snap, None, navs)?;
Ok(Some(res))
}
diff --git a/crates/rust-analyzer/src/lsp/capabilities.rs b/crates/rust-analyzer/src/lsp/capabilities.rs
index e751e7da70..418fe95759 100644
--- a/crates/rust-analyzer/src/lsp/capabilities.rs
+++ b/crates/rust-analyzer/src/lsp/capabilities.rs
@@ -157,7 +157,7 @@ pub fn server_capabilities(config: &Config) -> ServerCapabilities {
"onEnter": true,
"openCargoToml": true,
"parentModule": true,
- "childrenModules": true,
+ "childModules": true,
"runnables": {
"kinds": [ "cargo" ],
},
diff --git a/crates/rust-analyzer/src/lsp/ext.rs b/crates/rust-analyzer/src/lsp/ext.rs
index ae4a9dbe19..b132323bec 100644
--- a/crates/rust-analyzer/src/lsp/ext.rs
+++ b/crates/rust-analyzer/src/lsp/ext.rs
@@ -399,12 +399,12 @@ impl Request for ParentModule {
const METHOD: &'static str = "experimental/parentModule";
}
-pub enum ChildrenModules {}
+pub enum ChildModules {}
-impl Request for ChildrenModules {
+impl Request for ChildModules {
type Params = lsp_types::TextDocumentPositionParams;
type Result = Option<lsp_types::GotoDefinitionResponse>;
- const METHOD: &'static str = "experimental/childrenModule";
+ const METHOD: &'static str = "experimental/childModules";
}
pub enum JoinLines {}
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 0b5d040df2..930c499c5f 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -1172,7 +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::ChildModules>(handlers::handle_child_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)
diff --git a/docs/book/src/contributing/lsp-extensions.md b/docs/book/src/contributing/lsp-extensions.md
index 8854f580ea..1ada1cb24c 100644
--- a/docs/book/src/contributing/lsp-extensions.md
+++ b/docs/book/src/contributing/lsp-extensions.md
@@ -1,5 +1,5 @@
<!---
-lsp/ext.rs hash: 300b4be5841cee6f
+lsp/ext.rs hash: 78e87a78de8f288e
If you need to change the above hash to make the test pass, please check if you
need to adjust this doc as well and ping this issue:
diff --git a/editors/code/package.json b/editors/code/package.json
index daabab49ec..ae05992321 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -171,8 +171,8 @@
"category": "rust-analyzer"
},
{
- "command": "rust-analyzer.childrenModules",
- "title": "Locate children modules",
+ "command": "rust-analyzer.childModules",
+ "title": "Locate child modules",
"category": "rust-analyzer"
},
{
@@ -3379,7 +3379,7 @@
"when": "inRustProject"
},
{
- "command": "rust-analyzer.childrenModule",
+ "command": "rust-analyzer.childModules",
"when": "inRustProject"
},
{
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index a78e935152..3ac1a933d9 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -266,7 +266,7 @@ export function parentModule(ctx: CtxInit): Cmd {
};
}
-export function childrenModules(ctx: CtxInit): Cmd {
+export function childModules(ctx: CtxInit): Cmd {
return async () => {
const editor = vscode.window.activeTextEditor;
if (!editor) return;
@@ -274,7 +274,7 @@ export function childrenModules(ctx: CtxInit): Cmd {
const client = ctx.client;
- const locations = await client.sendRequest(ra.childrenModules, {
+ const locations = await client.sendRequest(ra.childModules, {
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document),
position: client.code2ProtocolConverter.asPosition(editor.selection.active),
});
diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts
index 1cf55f6613..20952e93cc 100644
--- a/editors/code/src/lsp_ext.ts
+++ b/editors/code/src/lsp_ext.ts
@@ -194,11 +194,11 @@ export const parentModule = new lc.RequestType<
lc.LocationLink[] | null,
void
>("experimental/parentModule");
-export const childrenModules = new lc.RequestType<
+export const childModules = new lc.RequestType<
lc.TextDocumentPositionParams,
lc.LocationLink[] | null,
void
->("experimental/childrenModule");
+>("experimental/childModules");
export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>(
"experimental/runnables",
);
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 95a52d710c..5e50073069 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -158,7 +158,7 @@ function createCommands(): Record<string, CommandFactory> {
matchingBrace: { enabled: commands.matchingBrace },
joinLines: { enabled: commands.joinLines },
parentModule: { enabled: commands.parentModule },
- childrenModules: { enabled: commands.childrenModules },
+ childModules: { enabled: commands.childModules },
viewHir: { enabled: commands.viewHir },
viewMir: { enabled: commands.viewMir },
interpretFunction: { enabled: commands.interpretFunction },
@@ -188,7 +188,9 @@ function createCommands(): Record<string, CommandFactory> {
openWalkthrough: { enabled: commands.openWalkthrough },
// Internal commands which are invoked by the server.
applyActionGroup: { enabled: commands.applyActionGroup },
- applySnippetWorkspaceEdit: { enabled: commands.applySnippetWorkspaceEditCommand },
+ applySnippetWorkspaceEdit: {
+ enabled: commands.applySnippetWorkspaceEditCommand,
+ },
debugSingle: { enabled: commands.debugSingle },
gotoLocation: { enabled: commands.gotoLocation },
hoverRefCommandProxy: { enabled: commands.hoverRefCommandProxy },
@@ -201,8 +203,12 @@ function createCommands(): Record<string, CommandFactory> {
revealDependency: { enabled: commands.revealDependency },
syntaxTreeReveal: { enabled: commands.syntaxTreeReveal },
syntaxTreeCopy: { enabled: commands.syntaxTreeCopy },
- syntaxTreeHideWhitespace: { enabled: commands.syntaxTreeHideWhitespace },
- syntaxTreeShowWhitespace: { enabled: commands.syntaxTreeShowWhitespace },
+ syntaxTreeHideWhitespace: {
+ enabled: commands.syntaxTreeHideWhitespace,
+ },
+ syntaxTreeShowWhitespace: {
+ enabled: commands.syntaxTreeShowWhitespace,
+ },
};
}