mirror of
https://github.com/Egonex-AI/Understand-Anything.git
synced 2026-06-22 10:58:03 +08:00
feat(core): make resolveImports optional on AnalyzerPlugin
Update PluginRegistry.resolveImports() to check for plugin.resolveImports existence before calling it. Non-code plugins (e.g., markdown, dockerfile) don't need import resolution, so this method is now optional. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -178,4 +178,17 @@ describe("PluginRegistry", () => {
|
||||
const result = registry.resolveImports("main.py", "import os");
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
it("handles plugins with optional resolveImports (non-code plugins)", () => {
|
||||
const markdownPlugin: AnalyzerPlugin = {
|
||||
name: "markdown",
|
||||
languages: ["markdown"],
|
||||
analyzeFile: () => ({ functions: [], classes: [], imports: [], exports: [] }),
|
||||
// No resolveImports — optional for non-code plugins
|
||||
};
|
||||
const registry = new PluginRegistry();
|
||||
registry.register(markdownPlugin);
|
||||
const result = registry.resolveImports("README.md", "# Hello");
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ export class PluginRegistry {
|
||||
|
||||
resolveImports(filePath: string, content: string): ImportResolution[] | null {
|
||||
const plugin = this.getPluginForFile(filePath);
|
||||
if (!plugin) return null;
|
||||
if (!plugin || !plugin.resolveImports) return null;
|
||||
return plugin.resolveImports(filePath, content);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user