File tree Expand file tree Collapse file tree 4 files changed +33
-21
lines changed Expand file tree Collapse file tree 4 files changed +33
-21
lines changed Original file line number Diff line number Diff line change @@ -164,11 +164,11 @@ describe('findDeclarationLocations', () => {
164
164
"range": Object {
165
165
"end": Object {
166
166
"character": 17,
167
- "line": 11 ,
167
+ "line": 12 ,
168
168
},
169
169
"start": Object {
170
170
"character": 10,
171
- "line": 11 ,
171
+ "line": 12 ,
172
172
},
173
173
},
174
174
"uri": "file://${ FIXTURE_FOLDER } scope.sh",
@@ -540,11 +540,11 @@ describe('findDeclarationsMatchingWord', () => {
540
540
"range": Object {
541
541
"end": Object {
542
542
"character": 17,
543
- "line": 11 ,
543
+ "line": 12 ,
544
544
},
545
545
"start": Object {
546
546
"character": 10,
547
- "line": 11 ,
547
+ "line": 12 ,
548
548
},
549
549
},
550
550
"uri": "file://${ FIXTURE_FOLDER } scope.sh",
@@ -555,7 +555,7 @@ describe('findDeclarationsMatchingWord', () => {
555
555
` )
556
556
557
557
// Local function definition
558
- expect ( findWordFromLine ( 'f' , 20 ) ) . toMatchInlineSnapshot ( `
558
+ expect ( findWordFromLine ( 'f' , 23 ) ) . toMatchInlineSnapshot ( `
559
559
Array [
560
560
Object {
561
561
"containerName": "g",
@@ -564,11 +564,11 @@ describe('findDeclarationsMatchingWord', () => {
564
564
"range": Object {
565
565
"end": Object {
566
566
"character": 5,
567
- "line": 18 ,
567
+ "line": 21 ,
568
568
},
569
569
"start": Object {
570
570
"character": 4,
571
- "line": 15 ,
571
+ "line": 18 ,
572
572
},
573
573
},
574
574
"uri": "file://${ FIXTURE_FOLDER } scope.sh",
@@ -609,7 +609,7 @@ describe('findDeclarationsMatchingWord', () => {
609
609
"range": Object {
610
610
"end": Object {
611
611
"character": 1,
612
- "line": 26 ,
612
+ "line": 30 ,
613
613
},
614
614
"start": Object {
615
615
"character": 0,
@@ -622,6 +622,9 @@ describe('findDeclarationsMatchingWord', () => {
622
622
},
623
623
]
624
624
` )
625
+
626
+ // FIXME: this should return the a reference to the function
627
+ expect ( findWordFromLine ( 'GLOBAL_1' , 1000 ) ) . toHaveLength ( 1 )
625
628
} )
626
629
} )
627
630
Original file line number Diff line number Diff line change @@ -274,7 +274,7 @@ describe('server', () => {
274
274
} ,
275
275
position : {
276
276
// X
277
- line : 28 ,
277
+ line : 32 ,
278
278
character : 8 ,
279
279
} ,
280
280
} ,
@@ -324,71 +324,71 @@ describe('server', () => {
324
324
"range": Object {
325
325
"end": Object {
326
326
"character": 11,
327
- "line": 11 ,
327
+ "line": 12 ,
328
328
},
329
329
"start": Object {
330
330
"character": 10,
331
- "line": 11 ,
331
+ "line": 12 ,
332
332
},
333
333
},
334
334
},
335
335
Object {
336
336
"range": Object {
337
337
"end": Object {
338
338
"character": 13,
339
- "line": 12 ,
339
+ "line": 15 ,
340
340
},
341
341
"start": Object {
342
342
"character": 12,
343
- "line": 12 ,
343
+ "line": 15 ,
344
344
},
345
345
},
346
346
},
347
347
Object {
348
348
"range": Object {
349
349
"end": Object {
350
350
"character": 13,
351
- "line": 16 ,
351
+ "line": 19 ,
352
352
},
353
353
"start": Object {
354
354
"character": 12,
355
- "line": 16 ,
355
+ "line": 19 ,
356
356
},
357
357
},
358
358
},
359
359
Object {
360
360
"range": Object {
361
361
"end": Object {
362
362
"character": 15,
363
- "line": 17 ,
363
+ "line": 20 ,
364
364
},
365
365
"start": Object {
366
366
"character": 14,
367
- "line": 17 ,
367
+ "line": 20 ,
368
368
},
369
369
},
370
370
},
371
371
Object {
372
372
"range": Object {
373
373
"end": Object {
374
374
"character": 11,
375
- "line": 25 ,
375
+ "line": 29 ,
376
376
},
377
377
"start": Object {
378
378
"character": 10,
379
- "line": 25 ,
379
+ "line": 29 ,
380
380
},
381
381
},
382
382
},
383
383
Object {
384
384
"range": Object {
385
385
"end": Object {
386
386
"character": 9,
387
- "line": 28 ,
387
+ "line": 32 ,
388
388
},
389
389
"start": Object {
390
390
"character": 8,
391
- "line": 28 ,
391
+ "line": 32 ,
392
392
},
393
393
},
394
394
},
Original file line number Diff line number Diff line change @@ -94,6 +94,9 @@ export function getAllDeclarationsInTree({
94
94
* Done by traversing the tree upwards (which is a simplification for
95
95
* actual bash behaviour but deemed good enough, compared to the complexity of flow tracing).
96
96
* Filters out duplicate definitions. Used when getting declarations for the current scope.
97
+ *
98
+ * FIXME: unfortunately this doesn't capture all global variables defined inside functions.
99
+ * Wondering if getGlobalDeclarations should return this or we should make that a custom feature of this function.
97
100
*/
98
101
export function getLocalDeclarations ( {
99
102
node,
Original file line number Diff line number Diff line change @@ -7,9 +7,12 @@ X="Mouse"
7
7
# some function
8
8
f () (
9
9
local X=" Dog"
10
+ GLOBAL_1=" Global 1"
10
11
11
12
g () {
12
13
local X=" Cat"
14
+ GLOBAL_1=" Global 1"
15
+ GLOBAL_2=" Global 1"
13
16
echo " ${X} "
14
17
15
18
# another function function
23
26
24
27
g
25
28
29
+ echo " ${GLOBAL_1} "
26
30
echo " ${X} "
27
31
)
28
32
29
33
echo " ${X} "
30
34
f
35
+
36
+ echo " ${GLOBAL_2} "
You can’t perform that action at this time.
0 commit comments