1
1
import { Chunk , IDE } from "core" ;
2
+ import { languageForFilepath } from "core/autocomplete/constructPrompt" ;
2
3
import { DEFAULT_IGNORE_DIRS } from "core/indexing/ignore" ;
3
4
import { deduplicateArray } from "core/util" ;
4
5
import { getParserForFile } from "core/util/treeSitter" ;
5
- import { SyntaxNode } from "web-tree-sitter" ;
6
+ import type { SyntaxNode } from "web-tree-sitter" ;
6
7
import { getDefinitionsForNode } from "../autocomplete/lsp" ;
7
8
8
9
export async function expandSnippet (
@@ -20,8 +21,8 @@ export async function expandSnippet(
20
21
const root : SyntaxNode = parser . parse ( fullFileContents ) . rootNode ;
21
22
22
23
// 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 ] ;
25
26
while ( toExplore . length > 0 ) {
26
27
const node = toExplore . pop ( ) ! ;
27
28
for ( const child of node . namedChildren ) {
@@ -49,7 +50,12 @@ export async function expandSnippet(
49
50
let callExpressionDefinitions = (
50
51
await Promise . all (
51
52
callExpressions . map ( async ( node ) => {
52
- return getDefinitionsForNode ( filepath , node ) ;
53
+ return getDefinitionsForNode (
54
+ filepath ,
55
+ node ,
56
+ ide ,
57
+ languageForFilepath ( filepath ) ,
58
+ ) ;
53
59
} ) ,
54
60
)
55
61
) . flat ( ) ;
@@ -103,4 +109,4 @@ export async function expandSnippet(
103
109
} ) ,
104
110
) ;
105
111
return chunks ;
106
- }
112
+ }
0 commit comments