@@ -205,17 +205,60 @@ describe('wordAtPoint', () => {
205
205
} )
206
206
207
207
describe ( 'findSymbolsMatchingWord' , ( ) => {
208
- it ( 'return a list of symbols across the workspace' , ( ) => {
209
- analyzer . analyze ( 'install.sh' , FIXTURES . INSTALL )
210
- analyzer . analyze ( 'sourcing-sh' , FIXTURES . SOURCING )
208
+ it ( 'return a list of symbols across the workspace (with default config)' , async ( ) => {
209
+ const parser = await initializeParser ( )
210
+ const connection = getMockConnection ( )
211
+
212
+ const analyzer = await Analyzer . fromRoot ( {
213
+ connection,
214
+ rootPath : FIXTURE_FOLDER ,
215
+ parser,
216
+ } )
211
217
212
218
expect (
213
219
analyzer . findSymbolsMatchingWord ( {
214
220
word : 'npm_config_logl' ,
215
221
uri : FIXTURE_URI . INSTALL ,
216
222
exactMatch : false ,
217
223
} ) ,
218
- ) . toMatchInlineSnapshot ( `Array []` )
224
+ ) . toMatchInlineSnapshot ( `
225
+ Array [
226
+ Object {
227
+ "kind": 13,
228
+ "location": Object {
229
+ "range": Object {
230
+ "end": Object {
231
+ "character": 27,
232
+ "line": 40,
233
+ },
234
+ "start": Object {
235
+ "character": 0,
236
+ "line": 40,
237
+ },
238
+ },
239
+ "uri": "file://${ FIXTURE_FOLDER } install.sh",
240
+ },
241
+ "name": "npm_config_loglevel",
242
+ },
243
+ Object {
244
+ "kind": 13,
245
+ "location": Object {
246
+ "range": Object {
247
+ "end": Object {
248
+ "character": 31,
249
+ "line": 48,
250
+ },
251
+ "start": Object {
252
+ "character": 2,
253
+ "line": 48,
254
+ },
255
+ },
256
+ "uri": "file://${ FIXTURE_FOLDER } install.sh",
257
+ },
258
+ "name": "npm_config_loglevel",
259
+ },
260
+ ]
261
+ ` )
219
262
220
263
expect (
221
264
analyzer . findSymbolsMatchingWord ( {
@@ -231,15 +274,106 @@ describe('findSymbolsMatchingWord', () => {
231
274
uri : FIXTURE_URI . INSTALL ,
232
275
exactMatch : false ,
233
276
} ) ,
234
- ) . toMatchInlineSnapshot ( `Array []` )
277
+ ) . toMatchInlineSnapshot ( `
278
+ Array [
279
+ Object {
280
+ "kind": 13,
281
+ "location": Object {
282
+ "range": Object {
283
+ "end": Object {
284
+ "character": 19,
285
+ "line": 6,
286
+ },
287
+ "start": Object {
288
+ "character": 0,
289
+ "line": 6,
290
+ },
291
+ },
292
+ "uri": "file://${ FIXTURE_FOLDER } extension.inc",
293
+ },
294
+ "name": "BLUE",
295
+ },
296
+ ]
297
+ ` )
235
298
236
299
expect (
237
300
analyzer . findSymbolsMatchingWord ( {
238
301
word : 'BLU' ,
239
302
uri : FIXTURE_URI . SOURCING ,
240
303
exactMatch : false ,
241
304
} ) ,
305
+ ) . toMatchInlineSnapshot ( `
306
+ Array [
307
+ Object {
308
+ "kind": 13,
309
+ "location": Object {
310
+ "range": Object {
311
+ "end": Object {
312
+ "character": 19,
313
+ "line": 6,
314
+ },
315
+ "start": Object {
316
+ "character": 0,
317
+ "line": 6,
318
+ },
319
+ },
320
+ "uri": "file://${ FIXTURE_FOLDER } extension.inc",
321
+ },
322
+ "name": "BLUE",
323
+ },
324
+ ]
325
+ ` )
326
+ } )
327
+
328
+ it ( 'return a list of symbols accessible to the uri (when config.COMPLETION_BASED_ON_IMPORTS is true)' , async ( ) => {
329
+ process . env = {
330
+ COMPLETION_BASED_ON_IMPORTS : '1' ,
331
+ }
332
+
333
+ const parser = await initializeParser ( )
334
+ const connection = getMockConnection ( )
335
+
336
+ const analyzer = await Analyzer . fromRoot ( {
337
+ connection,
338
+ rootPath : FIXTURE_FOLDER ,
339
+ parser,
340
+ } )
341
+
342
+ expect (
343
+ analyzer . findSymbolsMatchingWord ( {
344
+ word : 'BLU' ,
345
+ uri : FIXTURE_URI . INSTALL ,
346
+ exactMatch : false ,
347
+ } ) ,
242
348
) . toMatchInlineSnapshot ( `Array []` )
349
+
350
+ expect (
351
+ analyzer . findSymbolsMatchingWord ( {
352
+ word : 'BLU' ,
353
+ uri : FIXTURE_URI . SOURCING ,
354
+ exactMatch : false ,
355
+ } ) ,
356
+ ) . toMatchInlineSnapshot ( `
357
+ Array [
358
+ Object {
359
+ "kind": 13,
360
+ "location": Object {
361
+ "range": Object {
362
+ "end": Object {
363
+ "character": 19,
364
+ "line": 6,
365
+ },
366
+ "start": Object {
367
+ "character": 0,
368
+ "line": 6,
369
+ },
370
+ },
371
+ "uri": "file://${ FIXTURE_FOLDER } extension.inc",
372
+ },
373
+ "name": "BLUE",
374
+ },
375
+ ]
376
+ ` )
243
377
} )
244
378
} )
245
379
0 commit comments