Skip to content

Commit b98cd3d

Browse files
author
Calvinn Ng
committed
code to snippet from code node
1 parent b4ae362 commit b98cd3d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

extensions/vscode/src/util/expandSnippet.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Chunk, IDE } from "core";
2+
import { languageForFilepath } from "core/autocomplete/constructPrompt";
23
import { DEFAULT_IGNORE_DIRS } from "core/indexing/ignore";
34
import { deduplicateArray } from "core/util";
45
import { getParserForFile } from "core/util/treeSitter";
5-
import { SyntaxNode } from "web-tree-sitter";
6+
import type { SyntaxNode } from "web-tree-sitter";
67
import { getDefinitionsForNode } from "../autocomplete/lsp";
78

89
export async function expandSnippet(
@@ -20,8 +21,8 @@ export async function expandSnippet(
2021
const root: SyntaxNode = parser.parse(fullFileContents).rootNode;
2122

2223
// Find all nodes contained in the range
23-
let containedInRange: SyntaxNode[] = [];
24-
let toExplore: SyntaxNode[] = [root];
24+
const containedInRange: SyntaxNode[] = [];
25+
const toExplore: SyntaxNode[] = [root];
2526
while (toExplore.length > 0) {
2627
const node = toExplore.pop()!;
2728
for (const child of node.namedChildren) {
@@ -49,7 +50,12 @@ export async function expandSnippet(
4950
let callExpressionDefinitions = (
5051
await Promise.all(
5152
callExpressions.map(async (node) => {
52-
return getDefinitionsForNode(filepath, node);
53+
return getDefinitionsForNode(
54+
filepath,
55+
node,
56+
ide,
57+
languageForFilepath(filepath),
58+
);
5359
}),
5460
)
5561
).flat();
@@ -103,4 +109,4 @@ export async function expandSnippet(
103109
}),
104110
);
105111
return chunks;
106-
}
112+
}

0 commit comments

Comments
 (0)