Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add children modules feature #19255

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

geetanshjuneja
Copy link

Links to #17401

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 1, 2025
@geetanshjuneja geetanshjuneja changed the title Added child module feature Added children module feature Mar 1, 2025
@geetanshjuneja
Copy link
Author

@Veykril I have implemented whatever was stated in issue. Looks like I also need need to add childrenModule function in commands.ts and children_module handler in request.rs similar to parentModule.

Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this plural, that is all children_module occurences should be children_modules

Comment on lines 40 to 52
// Return all the children module inside the ItemList of the parent module
module
.syntax()
.children()
.filter_map(ast::ItemList::cast)
.flat_map(|it| it.syntax().children())
.filter_map(ast::Module::cast)
.flat_map(|m| {
sema.to_def(&m)
.into_iter()
.flat_map(|module| NavigationTarget::from_module_to_decl(db, module))
})
.collect()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Return all the children module inside the ItemList of the parent module
module
.syntax()
.children()
.filter_map(ast::ItemList::cast)
.flat_map(|it| it.syntax().children())
.filter_map(ast::Module::cast)
.flat_map(|m| {
sema.to_def(&m)
.into_iter()
.flat_map(|module| NavigationTarget::from_module_to_decl(db, module))
})
.collect()
sema
.to_def(&module)
.into_iter()
.flat_map(|module| module.children(db))
.map(|module| NavigationTarget::from_module_to_decl(db, module))
.collect(),

Comment on lines 55 to 65
// Return all the children module inside the source file
source_file
.syntax()
.children()
.filter_map(ast::Module::cast)
.flat_map(|m| {
sema.to_def(&m)
.into_iter()
.flat_map(|module| NavigationTarget::from_module_to_decl(db, module))
})
.collect()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Return all the children module inside the source file
source_file
.syntax()
.children()
.filter_map(ast::Module::cast)
.flat_map(|m| {
sema.to_def(&m)
.into_iter()
.flat_map(|module| NavigationTarget::from_module_to_decl(db, module))
})
.collect()
sema
.file_to_module_defs(position.file_id)
.flat_map(|module| module.children(db))
.map(|module| NavigationTarget::from_module_to_decl(db, module))
.collect(),

@geetanshjuneja geetanshjuneja changed the title Added children module feature Add children modules feature Mar 10, 2025
@geetanshjuneja geetanshjuneja requested a review from Veykril March 10, 2025 12:42
Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril
Copy link
Member

Veykril commented Apr 7, 2025

Will need a rebase + updating the hash in docs/dev/lsp-extensions.md.

@davidbarsky
Copy link
Contributor

Let's make this plural, that is all children_module occurences should be children_modules

This might be autocorrect, but I think this should be called child_modules?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants