mirror of
https://github.com/Egonex-AI/Understand-Anything.git
synced 2026-06-22 10:58:03 +08:00
feat(core): scaffold DartExtractor + register in builtinExtractors
Empty extractor that satisfies the LanguageExtractor interface so the plugin pipeline can load it. Real extraction logic lands in subsequent TDD commits.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import type { StructuralAnalysis, CallGraphEntry } from "../../types.js";
|
||||
import type { LanguageExtractor, TreeSitterNode } from "./types.js";
|
||||
import { findChild, findChildren } from "./base-extractor.js";
|
||||
|
||||
/**
|
||||
* Whether a Dart name is exported.
|
||||
*
|
||||
* Dart's visibility rule is name-based and the INVERSE of Kotlin's: names
|
||||
* starting with `_` are library-private, everything else is exported. There
|
||||
* is no `public` / `private` keyword to inspect — only the leading character.
|
||||
*/
|
||||
function isExported(name: string): boolean {
|
||||
return !name.startsWith("_");
|
||||
}
|
||||
|
||||
/**
|
||||
* Dart extractor for tree-sitter structural analysis + call graph.
|
||||
*
|
||||
* Approach (matching `KotlinExtractor` convention): mixin / extension / enum
|
||||
* declarations are folded into `StructuralAnalysis.classes[]` because the
|
||||
* shared schema does not have a first-class slot for them. Extension
|
||||
* declarations without a name surface as `"on <TargetType>"` so they aren't
|
||||
* silently dropped.
|
||||
*/
|
||||
export class DartExtractor implements LanguageExtractor {
|
||||
readonly languageIds = ["dart"];
|
||||
|
||||
extractStructure(rootNode: TreeSitterNode): StructuralAnalysis {
|
||||
const functions: StructuralAnalysis["functions"] = [];
|
||||
const classes: StructuralAnalysis["classes"] = [];
|
||||
const imports: StructuralAnalysis["imports"] = [];
|
||||
const exports: StructuralAnalysis["exports"] = [];
|
||||
|
||||
// Implementation lands in subsequent tasks.
|
||||
void rootNode;
|
||||
void findChild;
|
||||
void findChildren;
|
||||
void isExported;
|
||||
|
||||
return { functions, classes, imports, exports };
|
||||
}
|
||||
|
||||
extractCallGraph(rootNode: TreeSitterNode): CallGraphEntry[] {
|
||||
// Implementation lands in a later task.
|
||||
void rootNode;
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ export { RubyExtractor } from "./ruby-extractor.js";
|
||||
export { PhpExtractor } from "./php-extractor.js";
|
||||
export { CppExtractor } from "./cpp-extractor.js";
|
||||
export { CSharpExtractor } from "./csharp-extractor.js";
|
||||
export { DartExtractor } from "./dart-extractor.js";
|
||||
export { KotlinExtractor } from "./kotlin-extractor.js";
|
||||
|
||||
import type { LanguageExtractor } from "./types.js";
|
||||
@@ -21,6 +22,7 @@ import { RubyExtractor } from "./ruby-extractor.js";
|
||||
import { PhpExtractor } from "./php-extractor.js";
|
||||
import { CppExtractor } from "./cpp-extractor.js";
|
||||
import { CSharpExtractor } from "./csharp-extractor.js";
|
||||
import { DartExtractor } from "./dart-extractor.js";
|
||||
import { KotlinExtractor } from "./kotlin-extractor.js";
|
||||
|
||||
export const builtinExtractors: LanguageExtractor[] = [
|
||||
@@ -33,5 +35,6 @@ export const builtinExtractors: LanguageExtractor[] = [
|
||||
new PhpExtractor(),
|
||||
new CppExtractor(),
|
||||
new CSharpExtractor(),
|
||||
new DartExtractor(),
|
||||
new KotlinExtractor(),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user