@@ -18,7 +18,7 @@ let analyzer: Analyzer
18
18
const CURRENT_URI = 'dummy-uri.sh'
19
19
20
20
// if you add a .sh file to testing/fixtures, update this value
21
- const FIXTURE_FILES_MATCHING_GLOB = 16
21
+ const FIXTURE_FILES_MATCHING_GLOB = 17
22
22
23
23
const defaultConfig = getDefaultConfiguration ( )
24
24
@@ -28,12 +28,33 @@ jest.spyOn(Logger.prototype, 'log').mockImplementation(() => {
28
28
const loggerInfo = jest . spyOn ( Logger . prototype , 'info' )
29
29
const loggerWarn = jest . spyOn ( Logger . prototype , 'warn' )
30
30
31
- beforeAll ( async ( ) => {
31
+ async function getAnalyzer ( {
32
+ includeAllWorkspaceSymbols = false ,
33
+ workspaceFolder = FIXTURE_FOLDER ,
34
+ runBackgroundAnalysis = false ,
35
+ } : {
36
+ includeAllWorkspaceSymbols ?: boolean
37
+ workspaceFolder ?: string
38
+ runBackgroundAnalysis ?: boolean
39
+ } ) {
32
40
const parser = await initializeParser ( )
33
- analyzer = new Analyzer ( {
41
+
42
+ const analyzer = new Analyzer ( {
34
43
parser,
35
- workspaceFolder : FIXTURE_FOLDER ,
44
+ includeAllWorkspaceSymbols,
45
+ workspaceFolder,
36
46
} )
47
+ if ( runBackgroundAnalysis ) {
48
+ await analyzer . initiateBackgroundAnalysis ( {
49
+ backgroundAnalysisMaxFiles : defaultConfig . backgroundAnalysisMaxFiles ,
50
+ globPattern : defaultConfig . globPattern ,
51
+ } )
52
+ }
53
+ return analyzer
54
+ }
55
+
56
+ beforeAll ( async ( ) => {
57
+ analyzer = await getAnalyzer ( { } )
37
58
} )
38
59
39
60
describe ( 'analyze' , ( ) => {
@@ -355,7 +376,6 @@ describe('findAllSourcedUris', () => {
355
376
new Set ( [
356
377
`file://${ FIXTURE_FOLDER } extension.inc` ,
357
378
`file://${ FIXTURE_FOLDER } issue101.sh` ,
358
- `file://${ FIXTURE_FOLDER } sourcing.sh` ,
359
379
] ) ,
360
380
)
361
381
} )
@@ -578,6 +598,27 @@ describe('findDeclarationsMatchingWord', () => {
578
598
` )
579
599
} )
580
600
601
+ it ( 'resolves sourced file not covered by the background analysis glob' , async ( ) => {
602
+ async function expectThatSourcingWorksWhenIncludeAllWorkspaceSymbolsIs ( v : boolean ) {
603
+ const analyzer = await getAnalyzer ( {
604
+ runBackgroundAnalysis : true ,
605
+ includeAllWorkspaceSymbols : v ,
606
+ } )
607
+
608
+ expect (
609
+ analyzer . findDeclarationsMatchingWord ( {
610
+ word : 'XXX' ,
611
+ uri : FIXTURE_URI . SOURCING2 ,
612
+ exactMatch : true ,
613
+ position : { line : 2 , character : 21 } , // XXX
614
+ } ) ,
615
+ ) . toHaveLength ( 1 )
616
+ }
617
+
618
+ await expectThatSourcingWorksWhenIncludeAllWorkspaceSymbolsIs ( false )
619
+ await expectThatSourcingWorksWhenIncludeAllWorkspaceSymbolsIs ( true )
620
+ } )
621
+
581
622
it ( 'returns symbols depending on the scope' , async ( ) => {
582
623
const parser = await initializeParser ( )
583
624
0 commit comments