@@ -29,7 +29,7 @@ pub fn goto_definition(db: &dyn Db, file: File, offset: TextSize) -> SmallVec<[L
2929 if let Some ( case_expr) = ast:: CaseExpr :: cast ( parent)
3030 && let Some ( case_token) = case_expr. case_token ( )
3131 {
32- return smallvec ! [ Location :: current (
32+ return smallvec ! [ Location :: new (
3333 file,
3434 case_token. text_range( ) ,
3535 LocationKind :: CaseExpr
@@ -42,50 +42,33 @@ pub fn goto_definition(db: &dyn Db, file: File, offset: TextSize) -> SmallVec<[L
4242 if ast:: Commit :: can_cast ( parent. kind ( ) )
4343 && let Some ( begin_range) = find_preceding_begin ( db, file, offset)
4444 {
45- return smallvec ! [ Location :: current(
46- file,
47- begin_range,
48- LocationKind :: CommitBegin
49- ) ] ;
45+ return smallvec ! [ Location :: new( file, begin_range, LocationKind :: CommitBegin ) ] ;
5046 }
5147
5248 // goto def on ROLLBACK -> BEGIN/START TRANSACTION
5349 if ast:: Rollback :: can_cast ( parent. kind ( ) )
5450 && let Some ( begin_range) = find_preceding_begin ( db, file, offset)
5551 {
56- return smallvec ! [ Location :: current(
57- file,
58- begin_range,
59- LocationKind :: CommitBegin
60- ) ] ;
52+ return smallvec ! [ Location :: new( file, begin_range, LocationKind :: CommitBegin ) ] ;
6153 }
6254
6355 // goto def on BEGIN/START TRANSACTION -> COMMIT or ROLLBACK
6456 if ast:: Begin :: can_cast ( parent. kind ( ) )
6557 && let Some ( end_range) = find_following_commit_or_rollback ( db, file, offset)
6658 {
67- return smallvec ! [ Location :: current ( file, end_range, LocationKind :: CommitEnd ) ] ;
59+ return smallvec ! [ Location :: new ( file, end_range, LocationKind :: CommitEnd ) ] ;
6860 }
6961
7062 if let Some ( name) = ast:: Name :: cast ( parent. clone ( ) )
71- && let Some ( kind ) = LocationKind :: from_node ( name. syntax ( ) )
63+ && let Some ( location ) = Location :: from_node ( file , name. syntax ( ) )
7264 {
73- return smallvec ! [ Location :: current ( file , name . syntax ( ) . text_range ( ) , kind ) ] ;
65+ return smallvec ! [ location ] ;
7466 }
7567
7668 if let Some ( name_ref) = ast:: NameRef :: cast ( parent. clone ( ) ) {
7769 for definition_file in [ file, builtins_file ( db) ] {
78- if let Some ( ( ptrs, kind) ) = resolve:: resolve_name_ref ( db, definition_file, & name_ref) {
79- let ranges = ptrs
80- . iter ( )
81- . map ( |ptr| ptr. text_range ( ) )
82- . map ( |range| Location {
83- file : definition_file,
84- range,
85- kind,
86- } )
87- . collect ( ) ;
88- return ranges;
70+ if let Some ( locations) = resolve:: resolve_name_ref ( db, definition_file, & name_ref) {
71+ return locations;
8972 }
9073 }
9174 }
@@ -5786,6 +5769,20 @@ select t$0 from t;
57865769 " ) ;
57875770 }
57885771
5772+ #[ test]
5773+ fn goto_select_view_name_from_view ( ) {
5774+ assert_snapshot ! ( goto( "
5775+ create view boop as select 1 a;
5776+ select boop$0 from boop;
5777+ " ) , @"
5778+ ββΈ
5779+ 2 β create view boop as select 1 a;
5780+ β ββββ 2. destination
5781+ 3 β select boop from boop;
5782+ β°β΄ β 1. source
5783+ " ) ;
5784+ }
5785+
57895786 #[ test]
57905787 fn goto_drop_schema ( ) {
57915788 assert_snapshot ! ( goto( "
0 commit comments