MCPcopy Index your code
hub / github.com/continuedev/continue / getQueryForFile

Function getQueryForFile

core/util/treeSitter.ts:174–198  ·  view source on GitHub ↗
(
  filepath: string,
  queryPath: string,
)

Source from the content-addressed store, hash-verified

172};
173
174export async function getQueryForFile(
175 filepath: string,
176 queryPath: string,
177): Promise<Parser.Query | undefined> {
178 const language = await getLanguageForFile(filepath);
179 if (!language) {
180 return undefined;
181 }
182
183 const sourcePath = path.join(
184 process.env.NODE_ENV === "test" ? process.cwd() : __dirname,
185 "..",
186 ...(process.env.NODE_ENV === "test"
187 ? ["extensions", "vscode", "tree-sitter"]
188 : ["tree-sitter"]),
189 queryPath,
190 );
191 if (!fs.existsSync(sourcePath)) {
192 return undefined;
193 }
194 const querySource = fs.readFileSync(sourcePath).toString();
195
196 const query = language.query(querySource);
197 return query;
198}
199
200async function loadLanguageForFileExt(
201 fileExtension: string,

Callers 7

getSnippetsInFileMethod · 0.90
_getFileInfoMethod · 0.90
getSnippetsForNodeMethod · 0.90
extractTopLevelDeclsFunction · 0.90
getHoleContextMethod · 0.90

Calls 2

getLanguageForFileFunction · 0.85
queryMethod · 0.65

Tested by

no test coverage detected