Skip to content

Commit

Permalink
Search for references only in the current file
Browse files Browse the repository at this point in the history
  • Loading branch information
rapgenic committed Jun 4, 2024
1 parent e073ac0 commit 1268dab
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
6 changes: 6 additions & 0 deletions vhdl_lang/src/analysis/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,12 @@ impl DesignRoot {
searcher.references
}

pub fn find_all_references_in_source(&self, source: &Source, ent: EntRef) -> Vec<SrcPos> {
let mut searcher = FindAllReferences::new(self, ent);
let _ = self.search_source(source, &mut searcher);
searcher.references
}

pub fn public_symbols<'a>(&'a self) -> Box<dyn Iterator<Item = EntRef<'a>> + 'a> {
Box::new(self.libraries.values().flat_map(|library| {
std::iter::once(self.arenas.get(library.id)).chain(library.units.values().flat_map(
Expand Down
4 changes: 4 additions & 0 deletions vhdl_lang/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ impl Project {
self.root.find_all_references(ent)
}

pub fn find_all_references_in_source(&self, source: &Source, ent: &AnyEnt) -> Vec<SrcPos> {
self.root.find_all_references_in_source(source, ent)
}

/// Get source positions that are not resolved to a declaration
/// This is used for development to test where the language server is blind
pub fn find_all_unresolved(&self) -> (usize, Vec<SrcPos>) {
Expand Down
14 changes: 4 additions & 10 deletions vhdl_ls/src/vhdl_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,17 +696,11 @@ impl VHDLServer {

Some(
self.project
.find_all_references(ent)
.find_all_references_in_source(&source, ent)
.iter()
.filter_map(|pos| {
if pos.source == source {
Some(DocumentHighlight {
range: to_lsp_range(pos.range()),
kind: Some(DocumentHighlightKind::TEXT),
})
} else {
None
}
.map(|pos| DocumentHighlight {
range: to_lsp_range(pos.range()),
kind: Some(DocumentHighlightKind::TEXT),
})
.collect(),
)
Expand Down

0 comments on commit 1268dab

Please sign in to comment.