Add support for Java record definitions in JavaXref#4933
Open
NA-V10 wants to merge 1 commit intooracle:masterfrom
Open
Add support for Java record definitions in JavaXref#4933NA-V10 wants to merge 1 commit intooracle:masterfrom
NA-V10 wants to merge 1 commit intooracle:masterfrom
Conversation
Author
|
Hello, I have opened this PR to add support for Java The change introduces a dedicated lexer rule so record names are recognized similarly to classes, interfaces, and enums. I verified that the record User(String name, int age) {}Please let me know if you would like me to also add a dedicated test case for record declarations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This change adds handling for Java record declarations in JavaXref.lex.
Previously, record declarations were treated as normal identifiers, so the record name was not highlighted or indexed similarly to classes, interfaces, and enums.
This update adds a dedicated lexer rule for:
record User(String name, int age) {}
so that User is recognized as a symbol and can participate in navigation and definition lookup.
Why are these changes needed?
Java records are now commonly used in modern Java codebases, but OpenGrok did not recognize record declarations in the same way as other type definitions.
Without this change, record names were not indexed correctly, making navigation less useful for projects using Java records.
How was this patch tested?
Built the opengrok-indexer module successfully with Java 21
Verified that the updated lexer compiles correctly
Added a sample Java record declaration locally to confirm the lexer rule matches record definitions
Example used during testing:
record User(String name, int age) {}
Related Issue
Fixes #4930