From 4176c03d1254a462da1c84a3a1185c8f2161e8a8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 23 Apr 2020 16:33:01 +0200 Subject: Remove SyntaxPtr::range from more places --- crates/ra_hir_def/src/body/scope.rs | 7 +++++-- crates/ra_ide/src/display/navigation_target.rs | 2 +- crates/ra_ide_db/src/symbol_index.rs | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir_def/src/body/scope.rs b/crates/ra_hir_def/src/body/scope.rs index fe4137176..5b36a7cc1 100644 --- a/crates/ra_hir_def/src/body/scope.rs +++ b/crates/ra_hir_def/src/body/scope.rs @@ -325,8 +325,11 @@ mod tests { let resolved = scopes.resolve_name_in_scope(expr_scope, &name_ref.as_name()).unwrap(); let pat_src = source_map.pat_syntax(resolved.pat()).unwrap(); - let local_name = pat_src.value.either(|it| it.syntax_node_ptr(), |it| it.syntax_node_ptr()); - assert_eq!(local_name.range(), expected_name.syntax().text_range()); + let local_name = pat_src.value.either( + |it| it.syntax_node_ptr().to_node(file.syntax()), + |it| it.syntax_node_ptr().to_node(file.syntax()), + ); + assert_eq!(local_name.text_range(), expected_name.syntax().text_range()); } #[test] diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 6289f53f3..67bc9c31b 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -176,7 +176,7 @@ impl ToNav for FileSymbol { file_id: self.file_id, name: self.name.clone(), kind: self.kind, - full_range: self.ptr.range(), + full_range: self.range, focus_range: self.name_range, container_name: self.container_name.clone(), description: description_from_symbol(db, self), diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs index 937abb433..95be11134 100644 --- a/crates/ra_ide_db/src/symbol_index.rs +++ b/crates/ra_ide_db/src/symbol_index.rs @@ -313,6 +313,7 @@ pub struct FileSymbol { pub file_id: FileId, pub name: SmolStr, pub kind: SyntaxKind, + pub range: TextRange, pub ptr: SyntaxNodePtr, pub name_range: Option, pub container_name: Option, @@ -379,6 +380,7 @@ fn to_file_symbol(node: &SyntaxNode, file_id: FileId) -> Option { to_symbol(node).map(move |(name, ptr, name_range)| FileSymbol { name, kind: node.kind(), + range: node.text_range(), ptr, file_id, name_range: Some(name_range), -- cgit v1.2.3