@@ -864,23 +864,41 @@ export default class Analyzer {
864
864
this . includeAllWorkspaceSymbols = includeAllWorkspaceSymbols
865
865
}
866
866
867
- // TODO: Handle cases where sourcing files gets sourced.
868
- public findAllSourcingUris ( uri : string ) : string [ ] {
867
+ /**
868
+ * If `includeAllWorkspaceSymbols` is true, this returns all URIs from the
869
+ * background analysis. Else, it returns the URIs of the files that are
870
+ * connected to `uri` via sourcing.
871
+ */
872
+ public findAllConnectedUris ( uri : string ) : string [ ] {
869
873
if ( this . includeAllWorkspaceSymbols ) {
870
874
return Object . keys ( this . uriToAnalyzedDocument )
871
875
}
872
876
873
- const uris = [ ]
874
- for ( const [ u , ad ] of Object . entries ( this . uriToAnalyzedDocument ) ) {
875
- if ( ad ?. sourcedUris ) {
876
- for ( const v of ad . sourcedUris . values ( ) ) {
877
- if ( v === uri ) {
878
- uris . push ( u )
877
+ const uriToAnalyzedDocument = Object . entries ( this . uriToAnalyzedDocument )
878
+ const uris : string [ ] = [ ]
879
+ let continueSearching = true
880
+
881
+ while ( continueSearching ) {
882
+ continueSearching = false
883
+
884
+ for ( const [ analyzedUri , analyzedDocument ] of uriToAnalyzedDocument ) {
885
+ if ( ! analyzedDocument ) {
886
+ continue
887
+ }
888
+
889
+ for ( const sourcedUri of analyzedDocument . sourcedUris . values ( ) ) {
890
+ if (
891
+ ( sourcedUri === uri || uris . includes ( sourcedUri ) ) &&
892
+ ! uris . includes ( analyzedUri )
893
+ ) {
894
+ uris . push ( analyzedUri )
895
+ continueSearching = true
879
896
break
880
897
}
881
898
}
882
899
}
883
900
}
901
+
884
902
return uris
885
903
}
886
904
0 commit comments