Skip to content

Commit 6ed1f59

Browse files
refactor: rename generic walk to language-specific names in all extractors
Each extractor's internal AST traversal function was identically named `walk`, making codegraph search results ambiguous across languages. Renamed to walkPythonNode, walkJavaScriptNode, walkGoNode, etc. so symbol searches return unique, language-specific hits.
1 parent 02b931d commit 6ed1f59

9 files changed

Lines changed: 28 additions & 28 deletions

File tree

src/extractors/csharp.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function extractCSharpSymbols(tree, _filePath) {
2828
return null;
2929
}
3030

31-
function walk(node) {
31+
function walkCSharpNode(node) {
3232
switch (node.type) {
3333
case 'class_declaration': {
3434
const nameNode = node.childForFieldName('name');
@@ -208,10 +208,10 @@ export function extractCSharpSymbols(tree, _filePath) {
208208
}
209209
}
210210

211-
for (let i = 0; i < node.childCount; i++) walk(node.child(i));
211+
for (let i = 0; i < node.childCount; i++) walkCSharpNode(node.child(i));
212212
}
213213

214-
walk(tree.rootNode);
214+
walkCSharpNode(tree.rootNode);
215215
return { definitions, calls, imports, classes, exports };
216216
}
217217

src/extractors/go.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function extractGoSymbols(tree, _filePath) {
1010
const classes = [];
1111
const exports = [];
1212

13-
function walk(node) {
13+
function walkGoNode(node) {
1414
switch (node.type) {
1515
case 'function_declaration': {
1616
const nameNode = node.childForFieldName('name');
@@ -159,9 +159,9 @@ export function extractGoSymbols(tree, _filePath) {
159159
}
160160
}
161161

162-
for (let i = 0; i < node.childCount; i++) walk(node.child(i));
162+
for (let i = 0; i < node.childCount; i++) walkGoNode(node.child(i));
163163
}
164164

165-
walk(tree.rootNode);
165+
walkGoNode(tree.rootNode);
166166
return { definitions, calls, imports, classes, exports };
167167
}

src/extractors/hcl.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function extractHCLSymbols(tree, _filePath) {
77
const definitions = [];
88
const imports = [];
99

10-
function walk(node) {
10+
function walkHclNode(node) {
1111
if (node.type === 'block') {
1212
const children = [];
1313
for (let i = 0; i < node.childCount; i++) children.push(node.child(i));
@@ -65,9 +65,9 @@ export function extractHCLSymbols(tree, _filePath) {
6565
}
6666
}
6767

68-
for (let i = 0; i < node.childCount; i++) walk(node.child(i));
68+
for (let i = 0; i < node.childCount; i++) walkHclNode(node.child(i));
6969
}
7070

71-
walk(tree.rootNode);
71+
walkHclNode(tree.rootNode);
7272
return { definitions, calls: [], imports, classes: [], exports: [] };
7373
}

src/extractors/java.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function extractJavaSymbols(tree, _filePath) {
2626
return null;
2727
}
2828

29-
function walk(node) {
29+
function walkJavaNode(node) {
3030
switch (node.type) {
3131
case 'class_declaration': {
3232
const nameNode = node.childForFieldName('name');
@@ -219,9 +219,9 @@ export function extractJavaSymbols(tree, _filePath) {
219219
}
220220
}
221221

222-
for (let i = 0; i < node.childCount; i++) walk(node.child(i));
222+
for (let i = 0; i < node.childCount; i++) walkJavaNode(node.child(i));
223223
}
224224

225-
walk(tree.rootNode);
225+
walkJavaNode(tree.rootNode);
226226
return { definitions, calls, imports, classes, exports };
227227
}

src/extractors/javascript.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function extractSymbols(tree, _filePath) {
1010
const classes = [];
1111
const exports = [];
1212

13-
function walk(node) {
13+
function walkJavaScriptNode(node) {
1414
switch (node.type) {
1515
case 'function_declaration': {
1616
const nameNode = node.childForFieldName('name');
@@ -254,11 +254,11 @@ export function extractSymbols(tree, _filePath) {
254254
}
255255

256256
for (let i = 0; i < node.childCount; i++) {
257-
walk(node.child(i));
257+
walkJavaScriptNode(node.child(i));
258258
}
259259
}
260260

261-
walk(tree.rootNode);
261+
walkJavaScriptNode(tree.rootNode);
262262
return { definitions, calls, imports, classes, exports };
263263
}
264264

src/extractors/php.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function extractPHPSymbols(tree, _filePath) {
2626
return null;
2727
}
2828

29-
function walk(node) {
29+
function walkPhpNode(node) {
3030
switch (node.type) {
3131
case 'function_definition': {
3232
const nameNode = node.childForFieldName('name');
@@ -229,9 +229,9 @@ export function extractPHPSymbols(tree, _filePath) {
229229
}
230230
}
231231

232-
for (let i = 0; i < node.childCount; i++) walk(node.child(i));
232+
for (let i = 0; i < node.childCount; i++) walkPhpNode(node.child(i));
233233
}
234234

235-
walk(tree.rootNode);
235+
walkPhpNode(tree.rootNode);
236236
return { definitions, calls, imports, classes, exports };
237237
}

src/extractors/python.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function extractPythonSymbols(tree, _filePath) {
1010
const classes = [];
1111
const exports = [];
1212

13-
function walk(node) {
13+
function walkPythonNode(node) {
1414
switch (node.type) {
1515
case 'function_definition': {
1616
const nameNode = node.childForFieldName('name');
@@ -61,7 +61,7 @@ export function extractPythonSymbols(tree, _filePath) {
6161
}
6262

6363
case 'decorated_definition': {
64-
for (let i = 0; i < node.childCount; i++) walk(node.child(i));
64+
for (let i = 0; i < node.childCount; i++) walkPythonNode(node.child(i));
6565
return;
6666
}
6767

@@ -123,7 +123,7 @@ export function extractPythonSymbols(tree, _filePath) {
123123
}
124124
}
125125

126-
for (let i = 0; i < node.childCount; i++) walk(node.child(i));
126+
for (let i = 0; i < node.childCount; i++) walkPythonNode(node.child(i));
127127
}
128128

129129
function findPythonParentClass(node) {
@@ -138,6 +138,6 @@ export function extractPythonSymbols(tree, _filePath) {
138138
return null;
139139
}
140140

141-
walk(tree.rootNode);
141+
walkPythonNode(tree.rootNode);
142142
return { definitions, calls, imports, classes, exports };
143143
}

src/extractors/ruby.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function extractRubySymbols(tree, _filePath) {
2626
return null;
2727
}
2828

29-
function walk(node) {
29+
function walkRubyNode(node) {
3030
switch (node.type) {
3131
case 'class': {
3232
const nameNode = node.childForFieldName('name');
@@ -177,9 +177,9 @@ export function extractRubySymbols(tree, _filePath) {
177177
}
178178
}
179179

180-
for (let i = 0; i < node.childCount; i++) walk(node.child(i));
180+
for (let i = 0; i < node.childCount; i++) walkRubyNode(node.child(i));
181181
}
182182

183-
walk(tree.rootNode);
183+
walkRubyNode(tree.rootNode);
184184
return { definitions, calls, imports, classes, exports };
185185
}

src/extractors/rust.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function extractRustSymbols(tree, _filePath) {
2222
return null;
2323
}
2424

25-
function walk(node) {
25+
function walkRustNode(node) {
2626
switch (node.type) {
2727
case 'function_item': {
2828
const nameNode = node.childForFieldName('name');
@@ -153,10 +153,10 @@ export function extractRustSymbols(tree, _filePath) {
153153
}
154154
}
155155

156-
for (let i = 0; i < node.childCount; i++) walk(node.child(i));
156+
for (let i = 0; i < node.childCount; i++) walkRustNode(node.child(i));
157157
}
158158

159-
walk(tree.rootNode);
159+
walkRustNode(tree.rootNode);
160160
return { definitions, calls, imports, classes, exports };
161161
}
162162

0 commit comments

Comments
 (0)