Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
TypeScript antigravity-skillsbusiness-knowledgeclaude-codeclaude-skillscodebase-analysiscodexcodex-skillsdeveloper-tools-ai-agentgemini-cli-skillskarpathy-llm-wikiknowledge-baseknowledge-graphmemoryopencode-skillspi-agentunderstandcodevibe-coding
feat(core): DartExtractor — constructor naming (default/named/factory)
thejesh893208efb36b
diff --git a/understand-anything-plugin/packages/core/src/plugins/extractors/__tests__/dart-extractor.test.ts b/understand-anything-plugin/packages/core/src/plugins/extractors/__tests__/dart-extractor.test.tsindex 5aa34451..e9f98d6f 100644--- a/understand-anything-plugin/packages/core/src/plugins/extractors/__tests__/dart-extractor.test.ts+++ b/understand-anything-plugin/packages/core/src/plugins/extractors/__tests__/dart-extractor.test.ts@@ -148,4 +148,46 @@ describe("DartExtractor", () => {parser.delete();});});++ describe("extractStructure - constructors", () => {+ it("treats an unnamed constructor as a method named after the class", () => {+ const { tree, parser, root } = parse(`class Foo {+ int x;+ Foo(this.x);+}+`);+ const result = extractor.extractStructure(root);++ expect(result.classes[0].methods).toContain("Foo");+ tree.delete();+ parser.delete();+ });++ it("treats a named constructor as Class.named", () => {+ const { tree, parser, root } = parse(`class Foo {+ int x;+ Foo.zero() : x = 0;+}+`);+ const result = extractor.extractStructure(root);++ expect(result.classes[0].methods).toContain("Foo.zero");+ tree.delete();+ parser.delete();+ });++ it("treats a factory named constructor as Class.named", () => {+ const { tree, parser, root } = parse(`class Foo {+ int x;+ Foo(this.x);+ factory Foo.fromString(String s) => Foo(int.parse(s));+}+`);+ const result = extractor.extractStructure(root);++ expect(result.classes[0].methods).toContain("Foo.fromString");+ tree.delete();+ parser.delete();+ });+ });});diff --git a/understand-anything-plugin/packages/core/src/plugins/extractors/dart-extractor.ts b/understand-anything-plugin/packages/core/src/plugins/extractors/dart-extractor.tsindex 443af3d2..baae9c13 100644--- a/understand-anything-plugin/packages/core/src/plugins/extractors/dart-extractor.ts+++ b/understand-anything-plugin/packages/core/src/plugins/extractors/dart-extractor.ts@@ -113,6 +113,29 @@ function pushMethod(}}+/**+ * Build a constructor's method-graph name from a constructor_signature /+ * factory_constructor_signature node:+ * - one identifier → unnamed constructor, name = "<Class>"+ * - two identifiers → named constructor, name = "<Class>.<named>"+ *+ * Returns null when no identifier is present (defensive — should not happen+ * for a real constructor declaration).+ *+ * Probe findings (2026-06-13): the plan's claimed AST shapes match exactly.+ * - Unnamed: constructor_signature { identifier[Foo], formal_parameter_list }+ * - Named: constructor_signature { identifier[Foo], identifier[zero], formal_parameter_list, ... }+ * - Factory: factory_constructor_signature { <unnamed "factory">, identifier[Foo], identifier[fromString], formal_parameter_list }+ * extractReturnType returns undefined for all three (factory keyword is unnamed,+ * so it is skipped; the loop stops at the first identifier).+ */+function constructorName(sig: TreeSitterNode): string | null {+ const ids = findChildren(sig, "identifier");+ if (ids.length === 0) return null;+ if (ids.length === 1) return ids[0].text;+ return `${ids[0].text}.${ids[1].text}`;+}+/*** Walk a `class_body` (or `extension_body` / `enum_body`) and collect* `method_signature` declarations into the class's `methods` array AND the@@ -135,6 +158,15 @@ function collectClassBody(if (!member) continue;if (member.type === "method_signature") {+ // Factory constructor lives inside method_signature.+ const factory = findChild(member, "factory_constructor_signature");+ if (factory) {+ const name = constructorName(factory);+ if (name) {+ pushMethod(member, factory, name, methods, functions, exports);+ }+ continue;+ }// Concrete method: `method_signature > function_signature`.// NOTE: `getter_signature` also nests under `method_signature` but is a// separate node type — getters are not yet surfaced (documented limitation).@@ -144,6 +176,15 @@ function collectClassBody(if (!name) continue;pushMethod(member, inner, name, methods, functions, exports);} else if (member.type === "declaration") {+ // Regular constructor: `declaration > constructor_signature`.+ const ctor = findChild(member, "constructor_signature");+ if (ctor) {+ const name = constructorName(ctor);+ if (name) {+ pushMethod(member, ctor, name, methods, functions, exports);+ }+ continue;+ }// Abstract method declarations (e.g. `double area();`) appear as// `declaration > function_signature` — not wrapped in `method_signature`.const fnSig = findChild(member, "function_signature");