Address Issue 118: Support Record Declarations #121
Merged
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.
Summary
Added support for parsing and analyzing
record
declarations incodeanalyzer-java
. This includes integration with the symbol table and call graph analysis, ensuring record components and implicit methods are correctly handled.Motivation and Context
Previously,
codeanalyzer-java
did not correctly process Javarecord
declarations, leading to:This update ensures:
record
declarations are parsed correctly.equals()
,hashCode()
,toString()
) are accounted for.RecordComponent
entity is introduced to represent individual components of a record.How Has This Been Tested?
symbolTableShouldHaveRecords()
: Verifies that records are correctly stored in the symbol table.symbolTableShouldHaveDefaultRecordComponents()
: Ensures default record components are recognized and stored.src/test/resources/test-applications/record-class-test
Breaking Changes
Yes, this is a breaking change:
analysis.json
format has been updated:record_components
is now included in Type entity.RecordComponent
that has been introduced:analysis.json
will need to update their handling logic to accommodaterecord_components
.Types of changes
Checklist
Additional Context
This implementation ensures that
codeanalyzer-java
is compatible with modern Java records (introduced in Java 14, finalized in Java 16). By recognizing records as distinct entities and introducingRecordComponent
lombok class, this update improves analysis accuracy for modern Java applications.Users consuming
analysis.json
should be aware of the newrecord_components
field and update their deserialization logic accordingly.