From 7fe577ef2b4bd54290032496ee0b6db32a56bc67 Mon Sep 17 00:00:00 2001 From: "wangzekun.zekin" Date: Mon, 18 May 2026 14:21:26 +0800 Subject: [PATCH] fix(java): set IsInterfaceMethod for interface methods In Java IPC mode `cli.files` is never populated, so the existing `GetParent` check in export.go could not detect interface parents and every interface method was emitted with `IsInterfaceMethod=false`. Fall back to the receiver symbol's Kind (set to SKInterface by the IPC scanner via `classKind(ci)`) when the LSP-based check yields nil. Non-Java paths keep their original behaviour: when GetParent succeeds and reports an interface parent, the method is still skipped. Co-Authored-By: Claude Opus 4.7 (1M context) --- lang/collect/export.go | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lang/collect/export.go b/lang/collect/export.go index f7e7d560..bad885ac 100644 --- a/lang/collect/export.go +++ b/lang/collect/export.go @@ -417,18 +417,31 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol switch k := symbol.Kind; k { // Function case SKFunction, SKMethod: + info := c.funcs[symbol] + // Detect interface-method via LSP parent first (cli.files populated). + // Java IPC mode does not populate cli.files, so fall back to the + // receiver symbol kind recorded by the scanner. + isInterfaceMethod := false if c.cli != nil { if p := c.cli.GetParent(symbol); p != nil && p.Kind == SKInterface { - // NOTICE: no need collect interface method - break + isInterfaceMethod = true } } + if isInterfaceMethod { + // NOTICE: no need collect interface method for non-Java langs. + // Java still collects it but flags IsInterfaceMethod. + break + } + if info.Method != nil && info.Method.Receiver.Symbol != nil && + info.Method.Receiver.Symbol.Kind == SKInterface { + isInterfaceMethod = true + } obj := &uniast.Function{ - FileLine: fileLine, - Content: content, - Exported: public, + FileLine: fileLine, + Content: content, + Exported: public, + IsInterfaceMethod: isInterfaceMethod, } - info := c.funcs[symbol] obj.Signature = info.Signature // NOTICE: type parames collect into types if info.TypeParams != nil {