@@ -222,17 +222,59 @@ describe('commandNameAtPoint', () => {
222
222
} )
223
223
224
224
describe ( 'findSymbolsMatchingWord' , ( ) => {
225
- it ( 'return a list of symbols across the workspace' , ( ) => {
226
- analyzer . analyze ( 'install.sh' , FIXTURES . INSTALL )
227
- analyzer . analyze ( 'sourcing-sh' , FIXTURES . SOURCING )
225
+ it ( 'return a list of symbols across the workspace (with default config)' , async ( ) => {
226
+ const parser = await initializeParser ( )
227
+ const connection = getMockConnection ( )
228
+
229
+ const analyzer = new Analyzer ( { console : connection . console , parser } )
230
+ await analyzer . initiateBackgroundAnalysis ( {
231
+ rootPath : FIXTURE_FOLDER ,
232
+ } )
228
233
229
234
expect (
230
235
analyzer . findSymbolsMatchingWord ( {
231
236
word : 'npm_config_logl' ,
232
237
uri : FIXTURE_URI . INSTALL ,
233
238
exactMatch : false ,
234
239
} ) ,
235
- ) . toMatchInlineSnapshot ( `Array []` )
240
+ ) . toMatchInlineSnapshot ( `
241
+ Array [
242
+ Object {
243
+ "kind": 13,
244
+ "location": Object {
245
+ "range": Object {
246
+ "end": Object {
247
+ "character": 27,
248
+ "line": 40,
249
+ },
250
+ "start": Object {
251
+ "character": 0,
252
+ "line": 40,
253
+ },
254
+ },
255
+ "uri": "file://${ FIXTURE_FOLDER } install.sh",
256
+ },
257
+ "name": "npm_config_loglevel",
258
+ },
259
+ Object {
260
+ "kind": 13,
261
+ "location": Object {
262
+ "range": Object {
263
+ "end": Object {
264
+ "character": 31,
265
+ "line": 48,
266
+ },
267
+ "start": Object {
268
+ "character": 2,
269
+ "line": 48,
270
+ },
271
+ },
272
+ "uri": "file://${ FIXTURE_FOLDER } install.sh",
273
+ },
274
+ "name": "npm_config_loglevel",
275
+ },
276
+ ]
277
+ ` )
236
278
237
279
expect (
238
280
analyzer . findSymbolsMatchingWord ( {
@@ -248,15 +290,105 @@ describe('findSymbolsMatchingWord', () => {
248
290
uri : FIXTURE_URI . INSTALL ,
249
291
exactMatch : false ,
250
292
} ) ,
251
- ) . toMatchInlineSnapshot ( `Array []` )
293
+ ) . toMatchInlineSnapshot ( `
294
+ Array [
295
+ Object {
296
+ "kind": 13,
297
+ "location": Object {
298
+ "range": Object {
299
+ "end": Object {
300
+ "character": 19,
301
+ "line": 6,
302
+ },
303
+ "start": Object {
304
+ "character": 0,
305
+ "line": 6,
306
+ },
307
+ },
308
+ "uri": "file://${ FIXTURE_FOLDER } extension.inc",
309
+ },
310
+ "name": "BLUE",
311
+ },
312
+ ]
313
+ ` )
252
314
253
315
expect (
254
316
analyzer . findSymbolsMatchingWord ( {
255
317
word : 'BLU' ,
256
318
uri : FIXTURE_URI . SOURCING ,
257
319
exactMatch : false ,
258
320
} ) ,
321
+ ) . toMatchInlineSnapshot ( `
322
+ Array [
323
+ Object {
324
+ "kind": 13,
325
+ "location": Object {
326
+ "range": Object {
327
+ "end": Object {
328
+ "character": 19,
329
+ "line": 6,
330
+ },
331
+ "start": Object {
332
+ "character": 0,
333
+ "line": 6,
334
+ },
335
+ },
336
+ "uri": "file://${ FIXTURE_FOLDER } extension.inc",
337
+ },
338
+ "name": "BLUE",
339
+ },
340
+ ]
341
+ ` )
342
+ } )
343
+
344
+ it ( 'return a list of symbols accessible to the uri (when config.COMPLETION_BASED_ON_IMPORTS is true)' , async ( ) => {
345
+ process . env = {
346
+ COMPLETION_BASED_ON_IMPORTS : '1' ,
347
+ }
348
+
349
+ const parser = await initializeParser ( )
350
+ const connection = getMockConnection ( )
351
+
352
+ const analyzer = new Analyzer ( { console : connection . console , parser } )
353
+ await analyzer . initiateBackgroundAnalysis ( {
354
+ rootPath : FIXTURE_FOLDER ,
355
+ } )
356
+
357
+ expect (
358
+ analyzer . findSymbolsMatchingWord ( {
359
+ word : 'BLU' ,
360
+ uri : FIXTURE_URI . INSTALL ,
361
+ exactMatch : false ,
362
+ } ) ,
259
363
) . toMatchInlineSnapshot ( `Array []` )
364
+
365
+ expect (
366
+ analyzer . findSymbolsMatchingWord ( {
367
+ word : 'BLU' ,
368
+ uri : FIXTURE_URI . SOURCING ,
369
+ exactMatch : false ,
370
+ } ) ,
371
+ ) . toMatchInlineSnapshot ( `
372
+ Array [
373
+ Object {
374
+ "kind": 13,
375
+ "location": Object {
376
+ "range": Object {
377
+ "end": Object {
378
+ "character": 19,
379
+ "line": 6,
380
+ },
381
+ "start": Object {
382
+ "character": 0,
383
+ "line": 6,
384
+ },
385
+ },
386
+ "uri": "file://${ FIXTURE_FOLDER } extension.inc",
387
+ },
388
+ "name": "BLUE",
389
+ },
390
+ ]
391
+ ` )
260
392
} )
261
393
} )
262
394
0 commit comments