File tree Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Expand file tree Collapse file tree 3 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -785,13 +785,7 @@ export default class Analyzer {
785785 }
786786 }
787787
788- if (
789- node . type === 'word' &&
790- node . parent ?. type === 'command' &&
791- node . parent . firstChild ?. text === 'read' &&
792- ! node . text . startsWith ( '-' ) &&
793- ! / ^ - .* [ d i n N p t u ] $ / . test ( node . previousSibling ?. text ?? '' )
794- ) {
788+ if ( TreeSitterUtil . isVariableInReadCommand ( node ) ) {
795789 return {
796790 word : node . text ,
797791 range : TreeSitterUtil . range ( node ) ,
Original file line number Diff line number Diff line change @@ -361,6 +361,16 @@ export function findDeclarationUsingGlobalSemantics({
361361 return true
362362 }
363363
364+ if (
365+ kind === LSP . SymbolKind . Variable &&
366+ TreeSitterUtil . isVariableInReadCommand ( n ) &&
367+ n . text === word
368+ ) {
369+ declaration = n
370+ continueSearching = false
371+ return false
372+ }
373+
364374 if (
365375 kind === LSP . SymbolKind . Function &&
366376 n . type === 'function_definition' &&
Original file line number Diff line number Diff line change @@ -43,6 +43,20 @@ export function isReference(n: SyntaxNode): boolean {
4343 }
4444}
4545
46+ export function isVariableInReadCommand ( n : SyntaxNode ) : boolean {
47+ if (
48+ n . type === 'word' &&
49+ n . parent ?. type === 'command' &&
50+ n . parent . firstChild ?. text === 'read' &&
51+ ! n . text . startsWith ( '-' ) &&
52+ ! / ^ - .* [ d i n N p t u ] $ / . test ( n . previousSibling ?. text ?? '' )
53+ ) {
54+ return true
55+ }
56+
57+ return false
58+ }
59+
4660export function findParent (
4761 start : SyntaxNode ,
4862 predicate : ( n : SyntaxNode ) => boolean ,
You can’t perform that action at this time.
0 commit comments