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
recorddeclarations 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-javadid not correctly process Javarecorddeclarations, leading to:This update ensures:
recorddeclarations are parsed correctly.equals(),hashCode(),toString()) are accounted for.RecordComponententity 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-testBreaking Changes
Yes, this is a breaking change:
analysis.jsonformat has been updated:record_componentsis now included in Type entity.RecordComponentthat has been introduced:analysis.jsonwill need to update their handling logic to accommodaterecord_components.Types of changes
Checklist
Additional Context
This implementation ensures that
codeanalyzer-javais compatible with modern Java records (introduced in Java 14, finalized in Java 16). By recognizing records as distinct entities and introducingRecordComponentlombok class, this update improves analysis accuracy for modern Java applications.Users consuming
analysis.jsonshould be aware of the newrecord_componentsfield and update their deserialization logic accordingly.