@@ -604,40 +604,42 @@ func registerMultiProjectReferenceRequestHandler[Req lsproto.HasTextDocumentPosi
604604 params = req .Params .(Req )
605605 }
606606 // !!! sheetal: multiple projects that contain the file through symlinks
607- defaultProject , defaultLs , allProjects , err := s .session .GetProjectsForFile (ctx , params .TextDocumentURI ())
607+ defaultProject , defaultLs , allProjects , err := s .session .GetLanguageServiceAndProjectsForFile (ctx , params .TextDocumentURI ())
608608 if err != nil {
609609 return err
610610 }
611611 defer s .recover (req )
612612
613613 var queue []projectAndTextDocumentPosition
614614 results := make (map [tspath.Path ]Resp )
615- defaultDefinitions := make ([] * ls. SymbolAndEntries , 0 ) // Single location
615+ var defaultDefinition lsproto. HasTextDocumentPosition
616616
617617 searchPosition := func (project * project.Project , ls * ls.LanguageService , uri lsproto.DocumentUri , position lsproto.Position ) (Resp , error ) {
618618 originalNode , symbolsAndEntries , ok := ls .ProvideSymbolsAndEntries (ctx , uri , position , info .Method == lsproto .MethodTextDocumentRename )
619619 if ok {
620620 for _ , entry := range symbolsAndEntries {
621- if project == defaultProject {
622- // !!! TODO sheetal
623- // store default definition if it can be visible in other projects
624- // Use this to determine if we should load the projects from solution to find references
625-
626- // definitionKindSymbol Possible
627- // definitionKindThis Possible
628- // definitionKindTripleSlashReference Yes - look for file names
629- defaultDefinitions = append (defaultDefinitions , entry )
621+ // Find the default definition that can be in another project
622+ // Later we will use this load ancestor tree that references this location and expand search
623+ if project == defaultProject && defaultDefinition == nil {
624+ defaultDefinition = ls .GetNonLocalDefinition (ctx , entry )
630625 }
631-
632- // TODOS: sheetal
633-
634- // Original location:
635- // If file included was dts -> try toi see if we can use source map and find ts file
636- // If its ts file - if this is ts file for "d.ts" of referenced project use this location
637- // Get default configured project for this file
638-
639- // Also get all the projects - existing for this file and add to queue this definition location
640- // including its symlinks
626+ ls .ForEachOriginalDefinitionLocation (ctx , entry , func (uri lsproto.DocumentUri , position lsproto.Position ) {
627+ // Get default configured project for this file
628+ defProjects , errProjects := s .session .GetProjectsForFile (ctx , uri )
629+ if errProjects != nil {
630+ return
631+ }
632+ for _ , defProject := range defProjects {
633+ // Optimization: don't enqueue if will be discarded
634+ if _ , alreadyDone := results [defProject .Id ()]; ! alreadyDone {
635+ queue = append (queue , projectAndTextDocumentPosition {
636+ project : defProject ,
637+ Uri : uri ,
638+ Position : position ,
639+ })
640+ }
641+ }
642+ })
641643 }
642644 }
643645 return fn (s , ctx , ls , params , originalNode , symbolsAndEntries )
@@ -692,7 +694,7 @@ func registerMultiProjectReferenceRequestHandler[Req lsproto.HasTextDocumentPosi
692694 }
693695 }
694696
695- if defaultDefinitions != nil {
697+ if defaultDefinition != nil {
696698 // !!! TODO: sheetal
697699 // load ancestor projects for all the projects that can reference the ones already seen
698700 // for all projects
@@ -1102,7 +1104,7 @@ func combineRenameResponse(defaultProject *project.Project, results map[tspath.P
11021104 // ChangeAnnotations *map[string]*ChangeAnnotation `json:"changeAnnotations,omitzero"`
11031105
11041106 if resp , ok := results [defaultProject .Id ()]; ok {
1105- if resp .WorkspaceEdit != nil {
1107+ if resp .WorkspaceEdit != nil && resp . WorkspaceEdit . Changes != nil {
11061108 for doc , changes := range * resp .WorkspaceEdit .Changes {
11071109 seenSet := collections.Set [lsproto.TextEdit ]{}
11081110 seenChanges [doc ] = & seenSet
@@ -1117,7 +1119,7 @@ func combineRenameResponse(defaultProject *project.Project, results map[tspath.P
11171119 }
11181120 for projectID , resp := range results {
11191121 if projectID != defaultProject .Id () {
1120- if resp .WorkspaceEdit != nil {
1122+ if resp .WorkspaceEdit != nil && resp . WorkspaceEdit . Changes != nil {
11211123 for doc , changes := range * resp .WorkspaceEdit .Changes {
11221124 seenSet , ok := seenChanges [doc ]
11231125 if ! ok {
0 commit comments