Skip to content

Commit 3533299

Browse files
committed
Refactor function findReferences using walkTreeFlatMapping
1 parent 3af5c1a commit 3533299

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
@@ -1351,26 +1351,23 @@ export function findReferences(
13511351
if (!node || node.type !== "id") return [];
13521352

13531353
const identifier = getNodeText(document, node);
1354-
const references: Location[] = [];
13551354

13561355
// [TODO]: Exclude false positives, i.e. occurrences
13571356
// of the name that are bound by different lambdas
13581357
// using the same identifier for their parameter
13591358

13601359
// Find all occurrences of this identifier
1361-
walkTree(tree.rootNode, (currentNode) => {
1360+
return walkTreeFlatMapping(tree.rootNode, (currentNode) => {
13621361
if (
13631362
currentNode.type === "id" &&
13641363
getNodeText(document, currentNode) === identifier
13651364
) {
1366-
references.push({
1365+
return [{
13671366
uri: document.uri,
13681367
range: nodeToRange(currentNode),
1369-
});
1370-
}
1368+
}];
1369+
} else return [];
13711370
});
1372-
1373-
return references;
13741371
}
13751372

13761373
export function prepareRename(

0 commit comments

Comments
 (0)