MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / isFunInterfaceNode

Function isFunInterfaceNode

src/extraction/languages/kotlin.ts:155–178  ·  view source on GitHub ↗

Check if a node matches the `fun interface` misparse pattern

(node: SyntaxNode)

Source from the content-addressed store, hash-verified

153
154/** Check if a node matches the `fun interface` misparse pattern */
155function isFunInterfaceNode(node: SyntaxNode): boolean {
156 let hasFun = false;
157 let hasInterfaceType = false;
158 for (let i = 0; i < node.childCount; i++) {
159 const child = node.child(i);
160 if (!child) continue;
161 if (child.type === 'fun' && !child.isNamed) hasFun = true;
162 if (child.type === 'user_type') {
163 const typeId = child.namedChildren.find((c: SyntaxNode) => c.type === 'type_identifier');
164 if (typeId && typeId.text === 'interface') hasInterfaceType = true;
165 }
166 // Pattern 2b: user_type("interface") is inside an ERROR child
167 if (child.type === 'ERROR') {
168 for (let j = 0; j < child.childCount; j++) {
169 const gc = child.child(j);
170 if (gc && gc.type === 'user_type') {
171 const typeId = gc.namedChildren.find((c: SyntaxNode) => c.type === 'type_identifier');
172 if (typeId && typeId.text === 'interface') hasInterfaceType = true;
173 }
174 }
175 }
176 }
177 return hasFun && hasInterfaceType;
178}
179
180/**
181 * tree-sitter-kotlin predates functional interfaces (Kotlin 1.4): `fun

Callers 1

kotlin.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected