Skip to content

Commit 3750edb

Browse files
committed
Refactor function findReferences using walkTreeFlatMapping
1 parent f8c75ce commit 3750edb

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

server/src/server.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,26 +1347,23 @@ export function findReferences(
13471347
if (!node || node.type !== "id") return [];
13481348

13491349
const identifier = getNodeText(document, node);
1350-
const references: Location[] = [];
13511350

13521351
// [TODO]: Exclude false positives, i.e. occurrences
13531352
// of the name that are bound by different lambdas
13541353
// using the same identifier for their parameter
13551354

13561355
// Find all occurrences of this identifier
1357-
walkTree(tree.rootNode, (currentNode) => {
1356+
return walkTreeFlatMapping(tree.rootNode, (currentNode) => {
13581357
if (
13591358
currentNode.type === "id" &&
13601359
getNodeText(document, currentNode) === identifier
13611360
) {
1362-
references.push({
1361+
return [{
13631362
uri: document.uri,
13641363
range: nodeToRange(currentNode),
1365-
});
1366-
}
1364+
}];
1365+
} else return [];
13671366
});
1368-
1369-
return references;
13701367
}
13711368

13721369
export function prepareRename(

0 commit comments

Comments
 (0)