Skip to content

fix(java): recognize interface TypeKind and preserve Implements relation#192

Merged
wzekin merged 1 commit into
mainfrom
fix/java-interface-impl
May 14, 2026
Merged

fix(java): recognize interface TypeKind and preserve Implements relation#192
wzekin merged 1 commit into
mainfrom
fix/java-interface-impl

Conversation

@wzekin
Copy link
Copy Markdown
Collaborator

@wzekin wzekin commented May 14, 2026

What type of PR is this?

fix

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
Two pieces wired through the Java IPC pipeline:

  1. Interface kind detection. java_parser used to hardcode
    ClassInfo.classType = "class" for every TypeDeclaration. Now the
    parser classifies declarations as class / interface / enum /
    annotation / record (RepoAnalyzer/DependencyResolver) and the
    StreamingResultSender forwards the value verbatim. abcoder's
    collect.classKind already mapped CLASS_TYPE_INTERFACE/ENUM to the
    right SymbolKind, so the universal AST's Type.TypeKind now correctly
    says "interface"/"enum" instead of always "struct".

  2. Implements relation. java_parser already emitted
    ImplementsTypes/ImplementsDetails per class, and abcoder's collector
    recorded them in c.deps, but export.go blended them into the generic
    SubStruct dependency list and Type.Implements stayed empty. Add an
    implementsRel map on Collector (kept parallel to c.deps), populate it
    from both the javaIPC scanner path and the tree-sitter
    class_declaration path, and have exportSymbol emit Type.Implements
    while de-duping the same target from SubStruct.

Bundled jar refreshed to carry the classType emission.
zh(optional):

(Optional) Which issue(s) this PR fixes:

(optional) The PR that updates user documentation:

@wzekin wzekin force-pushed the fix/java-interface-impl branch from 3f048df to 6d5cfee Compare May 14, 2026 12:23
Two pieces wired through the Java IPC pipeline:

1. **Interface kind detection.** java_parser used to hardcode
   ClassInfo.classType = "class" for every TypeDeclaration. Now the
   parser classifies declarations as class / interface / enum /
   annotation / record (RepoAnalyzer/DependencyResolver) and the
   StreamingResultSender forwards the value verbatim. abcoder's
   collect.classKind already mapped CLASS_TYPE_INTERFACE/ENUM to the
   right SymbolKind, so the universal AST's Type.TypeKind now correctly
   says "interface"/"enum" instead of always "struct".

2. **Implements relation.** java_parser already emitted
   ImplementsTypes/ImplementsDetails per class, and abcoder's collector
   recorded them in c.deps, but export.go blended them into the generic
   SubStruct dependency list and Type.Implements stayed empty. Add an
   implementsRel map on Collector (kept parallel to c.deps), populate it
   from both the javaIPC scanner path and the tree-sitter
   class_declaration path, and have exportSymbol emit Type.Implements
   while de-duping the same target from SubStruct.

Bundled jar refreshed to carry the classType emission.

Test: lang/collect/java_interface_test.go builds a minimal mocked
javaipc.Converter for a tiny fixture (Animal/Swimmer interfaces,
Dog/Fish classes implementing them) and asserts TypeKind and Implements
on the exported uniast — runs without needing the real parser binary.
testdata/java/5_interface_impl/ holds the matching source so e2e
parsing also covers it.

End-to-end on testdata/java/4_full_maven_repo:
  UserRepository:        TypeKind=interface  (was struct)
  UserStatus:            TypeKind=enum       (was struct)
  InMemoryUserRepository: Implements=[UserRepository], no longer
                         duplicated in SubStruct
@wzekin wzekin force-pushed the fix/java-interface-impl branch from 6d5cfee to ec9cfad Compare May 14, 2026 12:43
@wzekin wzekin merged commit ec2fdcd into main May 14, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants