File tree Expand file tree Collapse file tree 2 files changed +12
-19
lines changed Expand file tree Collapse file tree 2 files changed +12
-19
lines changed Original file line number Diff line number Diff line change @@ -578,6 +578,7 @@ export default class Analyzer {
578
578
579
579
const localDeclarations = getLocalDeclarations ( {
580
580
node,
581
+ rootNode : analyzedDocument . tree . rootNode ,
581
582
uri,
582
583
} )
583
584
Original file line number Diff line number Diff line change @@ -94,9 +94,11 @@ export function getAllDeclarationsInTree({
94
94
*/
95
95
export function getLocalDeclarations ( {
96
96
node,
97
+ rootNode,
97
98
uri,
98
99
} : {
99
100
node : Parser . SyntaxNode | null
101
+ rootNode : Parser . SyntaxNode
100
102
uri : string
101
103
} ) : Declarations {
102
104
const declarations : Declarations = { }
@@ -149,26 +151,16 @@ export function getLocalDeclarations({
149
151
walk ( node )
150
152
151
153
// Top down traversal to add missing global variables from within functions
152
- if ( node ) {
153
- const rootNode =
154
- node . type === 'program'
155
- ? node
156
- : TreeSitterUtil . findParent ( node , ( p ) => p . type === 'program' )
157
-
158
- if ( rootNode ) {
159
- // In case of parsing errors, the root node might not be found
160
- Object . entries (
161
- getAllGlobalVariableDeclarations ( {
162
- rootNode,
163
- uri,
164
- } ) ,
165
- ) . map ( ( [ name , symbols ] ) => {
166
- if ( ! declarations [ name ] ) {
167
- declarations [ name ] = symbols
168
- }
169
- } )
154
+ Object . entries (
155
+ getAllGlobalVariableDeclarations ( {
156
+ rootNode,
157
+ uri,
158
+ } ) ,
159
+ ) . map ( ( [ name , symbols ] ) => {
160
+ if ( ! declarations [ name ] ) {
161
+ declarations [ name ] = symbols
170
162
}
171
- }
163
+ } )
172
164
173
165
return declarations
174
166
}
You can’t perform that action at this time.
0 commit comments