feat: Promote "extends" to "implements" for class-to-interface relationships in edge creation

Addresses semantic accuracy in inheritance relationships where classes use "extends" syntax to implement interfaces. Adds target node inspection to detect interface/protocol targets and promotes the edge kind from "extends" to "implements" when the source is a concrete class or struct, ensuring proper representation of implementation vs inheritance relationships in the code graph.
This commit is contained in:
Colby McHenry
2026-04-07 00:02:47 -05:00
parent b712e4de63
commit 07d899b735
+26 -11
View File
@@ -422,17 +422,32 @@ export class ReferenceResolver {
* Create edges from resolved references * Create edges from resolved references
*/ */
createEdges(resolved: ResolvedRef[]): Edge[] { createEdges(resolved: ResolvedRef[]): Edge[] {
return resolved.map((ref) => ({ return resolved.map((ref) => {
source: ref.original.fromNodeId, let kind = ref.original.referenceKind;
target: ref.targetNodeId,
kind: ref.original.referenceKind, // Promote "extends" to "implements" when a class/struct targets an interface
line: ref.original.line, if (kind === 'extends') {
column: ref.original.column, const targetNode = this.queries.getNodeById(ref.targetNodeId);
metadata: { if (targetNode && (targetNode.kind === 'interface' || targetNode.kind === 'protocol')) {
confidence: ref.confidence, const sourceNode = this.queries.getNodeById(ref.original.fromNodeId);
resolvedBy: ref.resolvedBy, if (sourceNode && sourceNode.kind !== 'interface' && sourceNode.kind !== 'protocol') {
}, kind = 'implements';
})); }
}
}
return {
source: ref.original.fromNodeId,
target: ref.targetNodeId,
kind,
line: ref.original.line,
column: ref.original.column,
metadata: {
confidence: ref.confidence,
resolvedBy: ref.resolvedBy,
},
};
});
} }
/** /**