fix(apex): emit extends edges for interface multiple inheritance
interface X extends A, B captured the parent list in iface_re group 2 but the handler only read group 1, so no inheritance edge was emitted. Split the parent list and emit one extends edge per parent (mirroring the class branch).
This commit is contained in:
@@ -6297,6 +6297,16 @@ def extract_apex(path: Path) -> dict:
|
||||
add_node(iface_nid, iface_name, lineno)
|
||||
add_edge(file_nid if current_class_nid is None else current_class_nid,
|
||||
iface_nid, "contains", lineno)
|
||||
if im.group(2):
|
||||
for parent in im.group(2).split(","):
|
||||
parent = parent.strip()
|
||||
if parent:
|
||||
parent_nid = _make_id(stem, parent)
|
||||
if parent_nid not in seen_ids:
|
||||
parent_nid = _make_id(parent)
|
||||
if parent_nid not in seen_ids:
|
||||
add_node(parent_nid, parent, lineno)
|
||||
add_edge(iface_nid, parent_nid, "extends", lineno, confidence="INFERRED")
|
||||
pending_annotations = []
|
||||
continue
|
||||
|
||||
|
||||
@@ -2627,6 +2627,16 @@ def test_apex_interface_extraction():
|
||||
labels = _labels(r)
|
||||
assert "Notifiable" in labels
|
||||
|
||||
def test_apex_interface_extends(tmp_path):
|
||||
source = tmp_path / "PaymentProcessor.cls"
|
||||
source.write_text(
|
||||
"public interface PaymentProcessor extends Processor, Auditable { void process(); }\n"
|
||||
)
|
||||
result = extract_apex(source)
|
||||
inheritance = _edge_labels(result, "extends") | _edge_labels(result, "implements")
|
||||
assert ("PaymentProcessor", "Processor") in inheritance
|
||||
assert ("PaymentProcessor", "Auditable") in inheritance
|
||||
|
||||
def test_apex_method_extraction():
|
||||
r = extract_apex(FIXTURES / "sample.cls")
|
||||
labels = _labels(r)
|
||||
|
||||
Reference in New Issue
Block a user