@@ -100,7 +100,7 @@ User::query()->active();
100100 }
101101
102102 let builder_uri = Url :: from_file_path ( dir. path ( ) . join ( "src/Models/UserBuilder.php" ) ) . unwrap ( ) ;
103-
103+
104104 // Find references for UserBuilder::active() declaration (line 5, col 21)
105105 let params = ReferenceParams {
106106 text_document_position : TextDocumentPositionParams {
@@ -113,18 +113,39 @@ User::query()->active();
113113 include_declaration : true ,
114114 } ,
115115 } ;
116-
117- let locations = backend. references ( params) . await . unwrap ( ) . unwrap_or_default ( ) ;
118-
116+
117+ let locations = backend
118+ . references ( params)
119+ . await
120+ . unwrap ( )
121+ . unwrap_or_default ( ) ;
122+
119123 let usage_uri = Url :: from_file_path ( dir. path ( ) . join ( "usage.php" ) ) . unwrap ( ) ;
120124 let usage_locs: Vec < _ > = locations. iter ( ) . filter ( |l| l. uri == usage_uri) . collect ( ) ;
121-
125+
122126 let lines: Vec < _ > = usage_locs. iter ( ) . map ( |l| l. range . start . line ) . collect ( ) ;
123-
124- assert ! ( lines. contains( & 4 ) , "Should find User::active(). Found at lines: {:?}" , lines) ;
125- assert ! ( lines. contains( & 6 ) , "Should find User::query()->active(). Found at lines: {:?}" , lines) ;
126- assert ! ( !lines. contains( & 5 ) , "Should NOT find Post::active(). Found at lines: {:?}" , lines) ;
127- assert_eq ! ( usage_locs. len( ) , 2 , "Should find exactly 2 references in usage.php, but found: {:?}" , lines) ;
127+
128+ assert ! (
129+ lines. contains( & 4 ) ,
130+ "Should find User::active(). Found at lines: {:?}" ,
131+ lines
132+ ) ;
133+ assert ! (
134+ lines. contains( & 6 ) ,
135+ "Should find User::query()->active(). Found at lines: {:?}" ,
136+ lines
137+ ) ;
138+ assert ! (
139+ !lines. contains( & 5 ) ,
140+ "Should NOT find Post::active(). Found at lines: {:?}" ,
141+ lines
142+ ) ;
143+ assert_eq ! (
144+ usage_locs. len( ) ,
145+ 2 ,
146+ "Should find exactly 2 references in usage.php, but found: {:?}" ,
147+ lines
148+ ) ;
128149}
129150
130151#[ tokio:: test]
@@ -225,7 +246,7 @@ User::query()->active();
225246 }
226247
227248 let usage_uri = Url :: from_file_path ( dir. path ( ) . join ( "usage.php" ) ) . unwrap ( ) ;
228-
249+
229250 // Find references for User::active() usage (line 4, col 6)
230251 let params = ReferenceParams {
231252 text_document_position : TextDocumentPositionParams {
@@ -238,20 +259,48 @@ User::query()->active();
238259 include_declaration : true ,
239260 } ,
240261 } ;
241-
242- let locations = backend. references ( params) . await . unwrap ( ) . unwrap_or_default ( ) ;
243-
262+
263+ let locations = backend
264+ . references ( params)
265+ . await
266+ . unwrap ( )
267+ . unwrap_or_default ( ) ;
268+
244269 let usage_locs: Vec < _ > = locations. iter ( ) . filter ( |l| l. uri == usage_uri) . collect ( ) ;
245270 let lines: Vec < _ > = usage_locs. iter ( ) . map ( |l| l. range . start . line ) . collect ( ) ;
246-
247- assert ! ( lines. contains( & 4 ) , "Should find User::active(). Found at lines: {:?}" , lines) ;
248- assert ! ( lines. contains( & 6 ) , "Should find User::query()->active(). Found at lines: {:?}" , lines) ;
249- assert ! ( !lines. contains( & 5 ) , "Should NOT find Post::active(). Found at lines: {:?}" , lines) ;
250- assert_eq ! ( usage_locs. len( ) , 2 , "Should find exactly 2 references in usage.php, but found: {:?}" , lines) ;
271+
272+ assert ! (
273+ lines. contains( & 4 ) ,
274+ "Should find User::active(). Found at lines: {:?}" ,
275+ lines
276+ ) ;
277+ assert ! (
278+ lines. contains( & 6 ) ,
279+ "Should find User::query()->active(). Found at lines: {:?}" ,
280+ lines
281+ ) ;
282+ assert ! (
283+ !lines. contains( & 5 ) ,
284+ "Should NOT find Post::active(). Found at lines: {:?}" ,
285+ lines
286+ ) ;
287+ assert_eq ! (
288+ usage_locs. len( ) ,
289+ 2 ,
290+ "Should find exactly 2 references in usage.php, but found: {:?}" ,
291+ lines
292+ ) ;
251293
252294 // Also should find the declaration in UserBuilder.php
253- let builder_locs: Vec < _ > = locations. iter ( ) . filter ( |l| l. uri . to_string ( ) . contains ( "UserBuilder.php" ) ) . collect ( ) ;
254- assert_eq ! ( builder_locs. len( ) , 1 , "Should find declaration in UserBuilder.php" ) ;
295+ let builder_locs: Vec < _ > = locations
296+ . iter ( )
297+ . filter ( |l| l. uri . to_string ( ) . contains ( "UserBuilder.php" ) )
298+ . collect ( ) ;
299+ assert_eq ! (
300+ builder_locs. len( ) ,
301+ 1 ,
302+ "Should find declaration in UserBuilder.php"
303+ ) ;
255304}
256305
257306#[ tokio:: test]
@@ -335,7 +384,7 @@ Member::query()->active();
335384 }
336385
337386 let builder_uri = Url :: from_file_path ( dir. path ( ) . join ( "src/Models/UserBuilder.php" ) ) . unwrap ( ) ;
338-
387+
339388 // Find references for UserBuilder::active() declaration (line 5, col 21)
340389 let params = ReferenceParams {
341390 text_document_position : TextDocumentPositionParams {
@@ -348,14 +397,30 @@ Member::query()->active();
348397 include_declaration : true ,
349398 } ,
350399 } ;
351-
352- let locations = backend. references ( params) . await . unwrap ( ) . unwrap_or_default ( ) ;
353-
400+
401+ let locations = backend
402+ . references ( params)
403+ . await
404+ . unwrap ( )
405+ . unwrap_or_default ( ) ;
406+
354407 let usage_uri = Url :: from_file_path ( dir. path ( ) . join ( "usage.php" ) ) . unwrap ( ) ;
355408 let usage_locs: Vec < _ > = locations. iter ( ) . filter ( |l| l. uri == usage_uri) . collect ( ) ;
356409 let lines: Vec < _ > = usage_locs. iter ( ) . map ( |l| l. range . start . line ) . collect ( ) ;
357-
358- assert ! ( lines. contains( & 3 ) , "Should find Member::active(). Found at lines: {:?}" , lines) ;
359- assert ! ( lines. contains( & 4 ) , "Should find Member::query()->active(). Found at lines: {:?}" , lines) ;
360- assert_eq ! ( usage_locs. len( ) , 2 , "Should find exactly 2 references in usage.php" ) ;
410+
411+ assert ! (
412+ lines. contains( & 3 ) ,
413+ "Should find Member::active(). Found at lines: {:?}" ,
414+ lines
415+ ) ;
416+ assert ! (
417+ lines. contains( & 4 ) ,
418+ "Should find Member::query()->active(). Found at lines: {:?}" ,
419+ lines
420+ ) ;
421+ assert_eq ! (
422+ usage_locs. len( ) ,
423+ 2 ,
424+ "Should find exactly 2 references in usage.php"
425+ ) ;
361426}
0 commit comments