Skip to content

Commit

Permalink
fix symbol table's locate always returning root symbol location
Browse files Browse the repository at this point in the history
  • Loading branch information
SpontanCombust committed May 8, 2024
1 parent 0b3b1b3 commit acc0c4e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions crates/analysis/src/model/collections/symbol_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,21 @@ impl SymbolTable {
}

pub fn locate(&self, path: &SymbolPath) -> Option<SymbolLocation> {
path.root()
let local_source_path = path.root()
.and_then(|root| self.symbols.get(root))
.and_then(|v| {
if let (Some(file_path), Some(range)) = (v.local_source_path(), v.label_range()) {
Some(SymbolLocation {
local_source_path: file_path.to_owned(),
label_range: range
})
} else {
None
}
.and_then(|v| v.local_source_path());

let label_range = self.symbols.get(path)
.and_then(|v| v.label_range());

if let (Some(local_source_path), Some(label_range)) = (local_source_path, label_range) {
Some(SymbolLocation {
local_source_path: local_source_path.to_owned(),
label_range
})
} else {
None
}
}

pub fn remove_for_source(&mut self, local_source_path: &Path) {
Expand Down

0 comments on commit acc0c4e

Please sign in to comment.