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

Function isFunInterfaceNode

src/extraction/languages/kotlin.ts:154–177  ·  view source on GitHub ↗

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

(node: SyntaxNode)

Source from the content-addressed store, hash-verified

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