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

extend goto/implementation to find architectures of entities #230

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions vhdl_lang/src/analysis/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,14 +459,22 @@ impl DesignRoot {
return vec![design.into()];
}
}
// Find all components with same name as entity in the library
// Find components and architectures to entity
AnyEntKind::Design(Design::Entity(..)) => {
let mut searcher = FindAllEnt::new(self, |ent| {
matches!(ent.kind(), AnyEntKind::Component(_))
&& matches!(
let ent_id = ent.id;
let mut searcher = FindAllEnt::new(self, |ent| match ent.kind() {
// Find all components with same name as entity in the library
AnyEntKind::Component(_) => {
matches!(
ent.designator(),
Designator::Identifier(comp_ident) if comp_ident == ident
)
}
// Find all architectures which implement the entity
AnyEntKind::Design(Design::Architecture(ent_of_arch)) => {
ent_of_arch.id == ent_id
}
_ => false,
});

let _ = self.search_library(library_name, &mut searcher);
Expand Down
5 changes: 4 additions & 1 deletion vhdl_lang/src/analysis/tests/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,14 @@ end architecture;
let ent = root
.search_reference(code.source(), code.s1("ent0").start())
.unwrap();
let arch = root
.search_reference(code.source(), code.s1("a ").start())
.unwrap();
let comp = root
.search_reference(code.source(), code.sa("component ", "ent0").start())
.unwrap();

assert_eq!(root.find_implementation(ent), vec![comp]);
assert_eq!(root.find_implementation(ent), vec![arch, comp]);
assert_eq!(root.find_implementation(comp), vec![ent]);
}

Expand Down
Loading