@@ -2330,6 +2330,86 @@ func (f *FourslashTest) VerifyBaselineFindAllReferences(
23302330 }
23312331}
23322332
2333+ func (f * FourslashTest ) VerifyBaselineVsFindAllReferences (
2334+ t * testing.T ,
2335+ markers ... string ,
2336+ ) {
2337+ referenceLocations := f .lookupMarkersOrGetRanges (t , markers )
2338+
2339+ for _ , markerOrRange := range referenceLocations {
2340+ f .GoToMarkerOrRange (t , markerOrRange )
2341+
2342+ params := & lsproto.ReferenceParams {
2343+ TextDocument : lsproto.TextDocumentIdentifier {
2344+ Uri : lsconv .FileNameToDocumentURI (f .activeFilename ),
2345+ },
2346+ Position : f .currentCaretPosition ,
2347+ Context : & lsproto.ReferenceContext {
2348+ IncludeDeclaration : true ,
2349+ },
2350+ }
2351+ result := sendRequest (t , f , lsproto .TextDocumentVSReferencesInfo , params )
2352+ // Sort cross-project results for deterministic baselines
2353+ if result .VsReferenceItems != nil && len (* result .VsReferenceItems ) > 0 {
2354+ items := * result .VsReferenceItems
2355+ slices .SortStableFunc (items , func (a , b * lsproto.VsReferenceItem ) int {
2356+ ap , bp := "" , ""
2357+ if a .VSProjectName != nil {
2358+ ap = * a .VSProjectName
2359+ }
2360+ if b .VSProjectName != nil {
2361+ bp = * b .VSProjectName
2362+ }
2363+ if ap != bp {
2364+ if ap < bp {
2365+ return - 1
2366+ }
2367+ return 1
2368+ }
2369+ if a .VSLocation .Uri != b .VSLocation .Uri {
2370+ if string (a .VSLocation .Uri ) < string (b .VSLocation .Uri ) {
2371+ return - 1
2372+ }
2373+ return 1
2374+ }
2375+ if a .VSLocation .Range .Start .Line != b .VSLocation .Range .Start .Line {
2376+ return int (a .VSLocation .Range .Start .Line ) - int (b .VSLocation .Range .Start .Line )
2377+ }
2378+ return int (a .VSLocation .Range .Start .Character ) - int (b .VSLocation .Range .Start .Character )
2379+ })
2380+ // Re-number IDs sequentially after sort
2381+ idRemap := make (map [int32 ]int32 , len (items ))
2382+ for i , item := range items {
2383+ idRemap [item .VSId ] = int32 (i )
2384+ item .VSId = int32 (i )
2385+ }
2386+ for _ , item := range items {
2387+ if item .VSDefinitionId != nil {
2388+ newDefId := idRemap [* item .VSDefinitionId ]
2389+ item .VSDefinitionId = & newDefId
2390+ }
2391+ }
2392+ }
2393+ // Include file contents with markers
2394+ var locations []lsproto.Location
2395+ if result .VsReferenceItems != nil {
2396+ for _ , item := range * result .VsReferenceItems {
2397+ locations = append (locations , item .VSLocation )
2398+ }
2399+ }
2400+ fileContents := f .getBaselineForLocationsWithFileContents (locations , baselineFourslashLocationsOptions {
2401+ marker : markerOrRange ,
2402+ markerName : "/*FIND ALL REFS*/" ,
2403+ })
2404+
2405+ if jsonStr , err := core .StringifyJson (result , "" , " " ); err == nil {
2406+ f .addResultToBaseline (t , vsFindAllReferencesCmd , fileContents + "\n \n " + jsonStr )
2407+ } else {
2408+ t .Fatalf ("Failed to stringify VS references result for baseline: %v" , err )
2409+ }
2410+ }
2411+ }
2412+
23332413func (f * FourslashTest ) VerifyBaselineCodeLens (t * testing.T , preferences * lsutil.UserPreferences ) {
23342414 if preferences != nil {
23352415 reset := f .ConfigureWithReset (t , * preferences )
0 commit comments