Skip to content

Commit 99a2b67

Browse files
committed
internal: rename children_modules to child_modules
1 parent a055643 commit 99a2b67

File tree

11 files changed

+45
-39
lines changed

11 files changed

+45
-39
lines changed

crates/ide/src/children_modules.rs renamed to crates/ide/src/child_modules.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,32 @@ use syntax::{
77

88
use crate::NavigationTarget;
99

10-
// Feature: Children Modules
10+
// Feature: Child Modules
1111
//
12-
// Navigates to the children modules of the current module.
12+
// Navigates to the child modules of the current module.
1313
//
1414
// | Editor | Action Name |
1515
// |---------|-------------|
16-
// | VS Code | **rust-analyzer: Locate children modules** |
16+
// | VS Code | **rust-analyzer: Locate child modules** |
1717

1818
/// This returns `Vec` because a module may be included from several places.
19-
pub(crate) fn children_modules(db: &RootDatabase, position: FilePosition) -> Vec<NavigationTarget> {
19+
pub(crate) fn child_modules(db: &RootDatabase, position: FilePosition) -> Vec<NavigationTarget> {
2020
let sema = Semantics::new(db);
2121
let source_file = sema.parse_guess_edition(position.file_id);
2222
// First go to the parent module which contains the cursor
2323
let module = find_node_at_offset::<ast::Module>(source_file.syntax(), position.offset);
2424

2525
match module {
2626
Some(module) => {
27-
// Return all the children module inside the ItemList of the parent module
27+
// Return all child modules inside the ItemList of the parent module
2828
sema.to_def(&module)
2929
.into_iter()
3030
.flat_map(|module| module.children(db))
3131
.map(|module| NavigationTarget::from_module_to_decl(db, module).call_site())
3232
.collect()
3333
}
3434
None => {
35-
// Return all the children module inside the source file
35+
// Return all the child modules inside the source file
3636
sema.file_to_module_defs(position.file_id)
3737
.flat_map(|module| module.children(db))
3838
.map(|module| NavigationTarget::from_module_to_decl(db, module).call_site())
@@ -47,9 +47,9 @@ mod tests {
4747

4848
use crate::fixture;
4949

50-
fn check_children_module(#[rust_analyzer::rust_fixture] ra_fixture: &str) {
50+
fn check_child_module(#[rust_analyzer::rust_fixture] ra_fixture: &str) {
5151
let (analysis, position, expected) = fixture::annotations(ra_fixture);
52-
let navs = analysis.children_modules(position).unwrap();
52+
let navs = analysis.child_modules(position).unwrap();
5353
let navs = navs
5454
.iter()
5555
.map(|nav| FileRange { file_id: nav.file_id, range: nav.focus_or_full_range() })
@@ -58,8 +58,8 @@ mod tests {
5858
}
5959

6060
#[test]
61-
fn test_resolve_children_module() {
62-
check_children_module(
61+
fn test_resolve_child_module() {
62+
check_child_module(
6363
r#"
6464
//- /lib.rs
6565
$0
@@ -73,8 +73,8 @@ mod foo;
7373
}
7474

7575
#[test]
76-
fn test_resolve_children_module_on_module_decl() {
77-
check_children_module(
76+
fn test_resolve_child_module_on_module_decl() {
77+
check_child_module(
7878
r#"
7979
//- /lib.rs
8080
mod $0foo;
@@ -89,8 +89,8 @@ mod bar;
8989
}
9090

9191
#[test]
92-
fn test_resolve_children_module_for_inline() {
93-
check_children_module(
92+
fn test_resolve_child_module_for_inline() {
93+
check_child_module(
9494
r#"
9595
//- /lib.rs
9696
mod foo {
@@ -104,7 +104,7 @@ mod foo {
104104

105105
#[test]
106106
fn test_resolve_multi_child_module() {
107-
check_children_module(
107+
check_child_module(
108108
r#"
109109
//- /main.rs
110110
$0

crates/ide/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod navigation_target;
2020

2121
mod annotations;
2222
mod call_hierarchy;
23-
mod children_modules;
23+
mod child_modules;
2424
mod doc_links;
2525
mod expand_macro;
2626
mod extend_selection;
@@ -607,8 +607,8 @@ impl Analysis {
607607
}
608608

609609
/// Returns vec of `mod name;` declaration which are created by the current module.
610-
pub fn children_modules(&self, position: FilePosition) -> Cancellable<Vec<NavigationTarget>> {
611-
self.with_db(|db| children_modules::children_modules(db, position))
610+
pub fn child_modules(&self, position: FilePosition) -> Cancellable<Vec<NavigationTarget>> {
611+
self.with_db(|db| child_modules::child_modules(db, position))
612612
}
613613

614614
/// Returns crates that this file belongs to.

crates/rust-analyzer/src/handlers/request.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -943,14 +943,14 @@ pub(crate) fn handle_parent_module(
943943
Ok(Some(res))
944944
}
945945

946-
pub(crate) fn handle_children_modules(
946+
pub(crate) fn handle_child_modules(
947947
snap: GlobalStateSnapshot,
948948
params: lsp_types::TextDocumentPositionParams,
949949
) -> anyhow::Result<Option<lsp_types::GotoDefinitionResponse>> {
950-
let _p = tracing::info_span!("handle_children_module").entered();
951-
// locate children module by semantics
950+
let _p = tracing::info_span!("handle_child_modules").entered();
951+
// locate child module by semantics
952952
let position = try_default!(from_proto::file_position(&snap, params)?);
953-
let navs = snap.analysis.children_modules(position)?;
953+
let navs = snap.analysis.child_modules(position)?;
954954
let res = to_proto::goto_definition_response(&snap, None, navs)?;
955955
Ok(Some(res))
956956
}

crates/rust-analyzer/src/lsp/capabilities.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub fn server_capabilities(config: &Config) -> ServerCapabilities {
157157
"onEnter": true,
158158
"openCargoToml": true,
159159
"parentModule": true,
160-
"childrenModules": true,
160+
"childModules": true,
161161
"runnables": {
162162
"kinds": [ "cargo" ],
163163
},

crates/rust-analyzer/src/lsp/ext.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,12 @@ impl Request for ParentModule {
399399
const METHOD: &'static str = "experimental/parentModule";
400400
}
401401

402-
pub enum ChildrenModules {}
402+
pub enum ChildModules {}
403403

404-
impl Request for ChildrenModules {
404+
impl Request for ChildModules {
405405
type Params = lsp_types::TextDocumentPositionParams;
406406
type Result = Option<lsp_types::GotoDefinitionResponse>;
407-
const METHOD: &'static str = "experimental/childrenModule";
407+
const METHOD: &'static str = "experimental/childModules";
408408
}
409409

410410
pub enum JoinLines {}

crates/rust-analyzer/src/main_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ impl GlobalState {
11721172
.on::<NO_RETRY, lsp_ext::InterpretFunction>(handlers::handle_interpret_function)
11731173
.on::<NO_RETRY, lsp_ext::ExpandMacro>(handlers::handle_expand_macro)
11741174
.on::<NO_RETRY, lsp_ext::ParentModule>(handlers::handle_parent_module)
1175-
.on::<NO_RETRY, lsp_ext::ChildrenModules>(handlers::handle_children_modules)
1175+
.on::<NO_RETRY, lsp_ext::ChildModules>(handlers::handle_child_modules)
11761176
.on::<NO_RETRY, lsp_ext::Runnables>(handlers::handle_runnables)
11771177
.on::<NO_RETRY, lsp_ext::RelatedTests>(handlers::handle_related_tests)
11781178
.on::<NO_RETRY, lsp_ext::CodeActionRequest>(handlers::handle_code_action)

docs/book/src/contributing/lsp-extensions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!---
2-
lsp/ext.rs hash: 300b4be5841cee6f
2+
lsp/ext.rs hash: 78e87a78de8f288e
33
44
If you need to change the above hash to make the test pass, please check if you
55
need to adjust this doc as well and ping this issue:

editors/code/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@
171171
"category": "rust-analyzer"
172172
},
173173
{
174-
"command": "rust-analyzer.childrenModules",
175-
"title": "Locate children modules",
174+
"command": "rust-analyzer.childModules",
175+
"title": "Locate child modules",
176176
"category": "rust-analyzer"
177177
},
178178
{
@@ -3379,7 +3379,7 @@
33793379
"when": "inRustProject"
33803380
},
33813381
{
3382-
"command": "rust-analyzer.childrenModule",
3382+
"command": "rust-analyzer.childModules",
33833383
"when": "inRustProject"
33843384
},
33853385
{

editors/code/src/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,15 @@ export function parentModule(ctx: CtxInit): Cmd {
266266
};
267267
}
268268

269-
export function childrenModules(ctx: CtxInit): Cmd {
269+
export function childModules(ctx: CtxInit): Cmd {
270270
return async () => {
271271
const editor = vscode.window.activeTextEditor;
272272
if (!editor) return;
273273
if (!(isRustDocument(editor.document) || isCargoTomlDocument(editor.document))) return;
274274

275275
const client = ctx.client;
276276

277-
const locations = await client.sendRequest(ra.childrenModules, {
277+
const locations = await client.sendRequest(ra.childModules, {
278278
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document),
279279
position: client.code2ProtocolConverter.asPosition(editor.selection.active),
280280
});

editors/code/src/lsp_ext.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ export const parentModule = new lc.RequestType<
194194
lc.LocationLink[] | null,
195195
void
196196
>("experimental/parentModule");
197-
export const childrenModules = new lc.RequestType<
197+
export const childModules = new lc.RequestType<
198198
lc.TextDocumentPositionParams,
199199
lc.LocationLink[] | null,
200200
void
201-
>("experimental/childrenModule");
201+
>("experimental/childModules");
202202
export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>(
203203
"experimental/runnables",
204204
);

0 commit comments

Comments
 (0)