Skip to content

Commit f7385d6

Browse files
authored
fix(java): set IsInterfaceMethod for interface methods (#194)
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.
1 parent 5a22592 commit f7385d6

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

lang/collect/export.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -417,18 +417,31 @@ func (c *Collector) exportSymbol(repo *uniast.Repository, symbol *DocumentSymbol
417417
switch k := symbol.Kind; k {
418418
// Function
419419
case SKFunction, SKMethod:
420+
info := c.funcs[symbol]
421+
// Detect interface-method via LSP parent first (cli.files populated).
422+
// Java IPC mode does not populate cli.files, so fall back to the
423+
// receiver symbol kind recorded by the scanner.
424+
isInterfaceMethod := false
420425
if c.cli != nil {
421426
if p := c.cli.GetParent(symbol); p != nil && p.Kind == SKInterface {
422-
// NOTICE: no need collect interface method
423-
break
427+
isInterfaceMethod = true
424428
}
425429
}
430+
if isInterfaceMethod {
431+
// NOTICE: no need collect interface method for non-Java langs.
432+
// Java still collects it but flags IsInterfaceMethod.
433+
break
434+
}
435+
if info.Method != nil && info.Method.Receiver.Symbol != nil &&
436+
info.Method.Receiver.Symbol.Kind == SKInterface {
437+
isInterfaceMethod = true
438+
}
426439
obj := &uniast.Function{
427-
FileLine: fileLine,
428-
Content: content,
429-
Exported: public,
440+
FileLine: fileLine,
441+
Content: content,
442+
Exported: public,
443+
IsInterfaceMethod: isInterfaceMethod,
430444
}
431-
info := c.funcs[symbol]
432445
obj.Signature = info.Signature
433446
// NOTICE: type parames collect into types
434447
if info.TypeParams != nil {

0 commit comments

Comments
 (0)