Fix to cache correct PathToNode in artifact graph (#6632)

* Add NodePath to artifact graph

Since this is cached, this should make PathToNode computation correct
even when code is formatted, whitespace changes, and source ranges
are different.

* Remove dead code

* Add unit tests

* Add tests for PathToNode conversion

* Remove unused parameter

* Add missing PathToNode cases

* Fix to handle unlabeled arg

* Cherry pick unlabeled arg fix

* Change PathToNode comment to match TS implementation
This commit is contained in:
Jonathan Tran
2025-05-01 23:55:12 -04:00
committed by GitHub
parent 02a37e207f
commit 819ee23565
12 changed files with 767 additions and 67 deletions

View File

@ -99,6 +99,11 @@ impl SourceRange {
pos >= self.start() && pos <= self.end()
}
/// Check if the range contains another range. Modules must match.
pub(crate) fn contains_range(&self, other: &Self) -> bool {
self.module_id() == other.module_id() && self.start() <= other.start() && self.end() >= other.end()
}
pub fn start_to_lsp_position(&self, code: &str) -> LspPosition {
// Calculate the line and column of the error from the source range.
// Lines are zero indexed in vscode so we need to subtract 1.