get_file_references
Find all files that reference or import a specific file in Svelte projects. Use this tool to track dependencies and understand file relationships during development.
Instructions
Find all files that reference/import the specified file.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filePath | Yes | Absolute path to the file |
Implementation Reference
- src/tools/svelte.ts:110-145 (handler)The tool "get_file_references" is registered and handled within the `registerSvelteTools` function in `src/tools/svelte.ts`. It takes a `filePath` input, converts it to a URI, and makes an LSP request to `$/getFileReferences`.
server.registerTool( "get_file_references", { title: "Get File References", description: "Find all files that reference/import the specified file.", inputSchema: z.object({ filePath: z.string().describe("Absolute path to the file"), }), }, async ({ filePath }): Promise<ToolResult> => { try { const uri = pathToUri(filePath); const result = await lsp.request("$/getFileReferences", uri); if (!result || !Array.isArray(result) || result.length === 0) { return textResult( `No references found for ${basename(filePath)}.` ); } return textResult(formatLocations(result, "file reference")); } catch (ex) { if ( String(ex).includes("Unhandled method") || String(ex).includes("not supported") ) { return textResult( "$/getFileReferences is not supported by this version of svelteserver." ); } return textResult(formatError(ex)); } } );