@@ -581,6 +581,126 @@ testCompositeFunction('why hello there', 42);`
581
581
baselineTsserverLogs ( "projectReferences" , `finding local reference doesnt load ancestor/sibling projects` , session ) ;
582
582
} ) ;
583
583
584
+ it ( "when finding references in overlapping projects" , ( ) => {
585
+ const solutionLocation = "/user/username/projects/solution" ;
586
+ const solutionConfig : File = {
587
+ path : `${ solutionLocation } /tsconfig.json` ,
588
+ content : JSON . stringify ( {
589
+ files : [ ] ,
590
+ include : [ ] ,
591
+ references : [
592
+ { path : "./a" } ,
593
+ { path : "./b" } ,
594
+ { path : "./c" } ,
595
+ { path : "./d" } ,
596
+ ]
597
+ } )
598
+ } ;
599
+ const aConfig : File = {
600
+ path : `${ solutionLocation } /a/tsconfig.json` ,
601
+ content : JSON . stringify ( {
602
+ compilerOptions : {
603
+ composite : true ,
604
+ module : "none"
605
+ } ,
606
+ files : [ "./index.ts" ]
607
+ } )
608
+ } ;
609
+ const aFile : File = {
610
+ path : `${ solutionLocation } /a/index.ts` ,
611
+ content : `
612
+ export interface I {
613
+ M(): void;
614
+ }`
615
+ } ;
616
+
617
+ const bConfig : File = {
618
+ path : `${ solutionLocation } /b/tsconfig.json` ,
619
+ content : JSON . stringify ( {
620
+ compilerOptions : {
621
+ composite : true
622
+ } ,
623
+ files : [ "./index.ts" ] ,
624
+ references : [
625
+ { path : "../a" }
626
+ ]
627
+ } )
628
+ } ;
629
+ const bFile : File = {
630
+ path : `${ solutionLocation } /b/index.ts` ,
631
+ content : `
632
+ import { I } from "../a";
633
+
634
+ export class B implements I {
635
+ M() {}
636
+ }`
637
+ } ;
638
+
639
+ const cConfig : File = {
640
+ path : `${ solutionLocation } /c/tsconfig.json` ,
641
+ content : JSON . stringify ( {
642
+ compilerOptions : {
643
+ composite : true
644
+ } ,
645
+ files : [ "./index.ts" ] ,
646
+ references : [
647
+ { path : "../b" }
648
+ ]
649
+ } )
650
+ } ;
651
+ const cFile : File = {
652
+ path : `${ solutionLocation } /c/index.ts` ,
653
+ content : `
654
+ import { I } from "../a";
655
+ import { B } from "../b";
656
+
657
+ export const C: I = new B();
658
+ `
659
+ } ;
660
+
661
+ const dConfig : File = {
662
+ path : `${ solutionLocation } /d/tsconfig.json` ,
663
+ content : JSON . stringify ( {
664
+ compilerOptions : {
665
+ composite : true
666
+ } ,
667
+ files : [ "./index.ts" ] ,
668
+ references : [
669
+ { path : "../c" }
670
+ ]
671
+ } )
672
+ } ;
673
+ const dFile : File = {
674
+ path : `${ solutionLocation } /d/index.ts` ,
675
+ content : `
676
+ import { I } from "../a";
677
+ import { C } from "../c";
678
+
679
+ export const D: I = C;
680
+ `
681
+ } ;
682
+
683
+ const files = [ libFile , solutionConfig , aConfig , aFile , bConfig , bFile , cConfig , cFile , dConfig , dFile , libFile ] ;
684
+ const host = createServerHost ( files ) ;
685
+ const session = createSession ( host , { logger : createLoggerWithInMemoryLogs ( ) } ) ;
686
+ openFilesForSession ( [ bFile ] , session ) ;
687
+
688
+ // The first search will trigger project loads
689
+ session . executeCommandSeq < protocol . ReferencesRequest > ( {
690
+ command : protocol . CommandTypes . References ,
691
+ arguments : protocolFileLocationFromSubstring ( bFile , "I" , { index : 1 } )
692
+ } ) ;
693
+
694
+ // The second search starts with the projects already loaded
695
+ // Formerly, this would search some projects multiple times
696
+ session . executeCommandSeq < protocol . ReferencesRequest > ( {
697
+ command : protocol . CommandTypes . References ,
698
+ arguments : protocolFileLocationFromSubstring ( bFile , "I" , { index : 1 } )
699
+ } ) ;
700
+
701
+ baselineTsserverLogs ( "projectReferences" , `finding references in overlapping projects` , session ) ;
702
+ } ) ;
703
+
584
704
describe ( "special handling of localness of the definitions for findAllRefs" , ( ) => {
585
705
function verify ( scenario : string , definition : string , usage : string , referenceTerm : string ) {
586
706
it ( scenario , ( ) => {
0 commit comments