@@ -283,12 +283,12 @@ export default class Analyzer {
283
283
position,
284
284
uri,
285
285
word,
286
- type ,
286
+ kind ,
287
287
} : {
288
288
position : LSP . Position
289
289
uri : string
290
290
word : string
291
- type : 'variable' | 'function'
291
+ kind : LSP . SymbolKind
292
292
} ) : { declaration : LSP . Location | null ; parent : LSP . Location | null } {
293
293
const node = this . nodeAtPoint ( uri , position . line , position . character )
294
294
@@ -303,7 +303,7 @@ export default class Analyzer {
303
303
let boundary = position . line
304
304
while ( parent ) {
305
305
if (
306
- type === 'variable' &&
306
+ kind === LSP . SymbolKind . Variable &&
307
307
parent . type === 'function_definition' &&
308
308
parent . lastChild
309
309
) {
@@ -357,7 +357,7 @@ export default class Analyzer {
357
357
let definedVariableInExpression = false
358
358
359
359
if (
360
- type === 'variable' &&
360
+ kind === LSP . SymbolKind . Variable &&
361
361
( [ 'declaration_command' , 'variable_assignment' , 'for_statement' ] . includes (
362
362
n . type ,
363
363
) ||
@@ -370,7 +370,10 @@ export default class Analyzer {
370
370
! ! definedSymbol &&
371
371
( definedSymbol . endPosition . column < position . character ||
372
372
definedSymbol . endPosition . row < position . line )
373
- } else if ( type === 'function' && n . type === 'function_definition' ) {
373
+ } else if (
374
+ kind === LSP . SymbolKind . Function &&
375
+ n . type === 'function_definition'
376
+ ) {
374
377
definedSymbol = n . firstNamedChild
375
378
}
376
379
@@ -468,13 +471,13 @@ export default class Analyzer {
468
471
public findOccurrencesWithin ( {
469
472
uri,
470
473
word,
471
- type ,
474
+ kind ,
472
475
start,
473
476
scope,
474
477
} : {
475
478
uri : string
476
479
word : string
477
- type : 'variable' | 'function'
480
+ kind : LSP . SymbolKind
478
481
start ?: LSP . Position
479
482
scope ?: LSP . Range
480
483
} ) : LSP . Range [ ] {
@@ -486,7 +489,7 @@ export default class Analyzer {
486
489
)
487
490
: null
488
491
const baseNode =
489
- scopeNode && ( type === 'variable' || scopeNode . type === 'subshell' )
492
+ scopeNode && ( kind === LSP . SymbolKind . Variable || scopeNode . type === 'subshell' )
490
493
? scopeNode
491
494
: this . uriToAnalyzedDocument [ uri ] ?. tree . rootNode
492
495
@@ -495,14 +498,16 @@ export default class Analyzer {
495
498
}
496
499
497
500
const typeOfDescendants =
498
- type === 'variable' ? 'variable_name' : [ 'function_definition' , 'command_name' ]
501
+ kind === LSP . SymbolKind . Variable
502
+ ? 'variable_name'
503
+ : [ 'function_definition' , 'command_name' ]
499
504
const startPosition = start
500
505
? { row : start . line , column : start . character }
501
506
: baseNode . startPosition
502
507
503
508
const ignoredRanges : LSP . Range [ ] = [ ]
504
509
const filter =
505
- type === 'variable'
510
+ kind === LSP . SymbolKind . Variable
506
511
? ( n : Parser . SyntaxNode ) => {
507
512
if ( n . text !== word ) {
508
513
return false
@@ -800,7 +805,7 @@ export default class Analyzer {
800
805
801
806
public symbolAtPointFromTextPosition (
802
807
params : LSP . TextDocumentPositionParams ,
803
- ) : { word : string ; range : LSP . Range ; type : 'variable' | 'function' } | null {
808
+ ) : { word : string ; range : LSP . Range ; kind : LSP . SymbolKind } | null {
804
809
const node = this . nodeAtPoint (
805
810
params . textDocument . uri ,
806
811
params . position . line ,
@@ -819,7 +824,10 @@ export default class Analyzer {
819
824
return {
820
825
word : node . text ,
821
826
range : TreeSitterUtil . range ( node ) ,
822
- type : node . type === 'variable_name' ? 'variable' : 'function' ,
827
+ kind :
828
+ node . type === 'variable_name'
829
+ ? LSP . SymbolKind . Variable
830
+ : LSP . SymbolKind . Function ,
823
831
}
824
832
}
825
833
0 commit comments