From ba5fdb2f1faedd6f0e5549cea506049624049b00 Mon Sep 17 00:00:00 2001 From: Max Hsu Date: Sun, 31 May 2026 23:04:47 +0800 Subject: [PATCH] feat(mybatis): index and link statements that use it (#592) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MyBatis XML extractor indexed but not , so "which statements use this result map" queries found nothing. Index each as a node (same method-shaped model as the existing statements/sql fragments, qualified ::) and emit a reference from any statement carrying resultMap="..." to it — mirroring the existing link. Also guard the Java↔XML bridge: it suffix-matches xml method nodes by ::, so without a filter a Java method whose name collides with a / id would wrongly bridge to it. Skip those non-statement nodes (identified by signature) — only real statements map to Java methods. Tests: a is indexed and a \n' + + ' SELECT id, email FROM users WHERE id = #{id}\n' + + ' \n' + + '\n' + ); + + const cg = CodeGraph.initSync(tmpDir); + await cg.indexAll(); + + const methods = cg.getNodesByKind('method'); + const resultMap = methods.find((n) => n.name === 'userResult' && n.language === 'xml'); + const findById = methods.find((n) => n.name === 'findById' && n.language === 'xml'); + expect(resultMap, ' should be indexed').toBeDefined(); + expect(resultMap!.qualifiedName).toBe('com.example.dao.UserMapper::userResult'); + expect(resultMap!.signature).toBe(' type=User'); + expect(findById).toBeDefined(); + + // still + // bridges to its Java mapper method. + const javaFindById = methods.find((n) => n.name === 'findById' && n.language === 'java'); + expect(javaFindById).toBeDefined(); + const realBridge = cg + .getOutgoingEdges(javaFindById!.id) + .find((e) => e.target === findById!.id); + expect(realBridge, 'Java findById should still bridge to its XML