Skip to content

Fix "record" as non-type identifier in Java 16#3362

Merged
MysterAitch merged 13 commits into
javaparser:masterfrom
koppor:add-record-test
Sep 8, 2021
Merged

Fix "record" as non-type identifier in Java 16#3362
MysterAitch merged 13 commits into
javaparser:masterfrom
koppor:add-record-test

Conversation

@koppor

@koppor koppor commented Sep 2, 2021

Copy link
Copy Markdown
Contributor

Details at #3366.

Following statement is a valid statement in Java:

    Object record;

This PR creates a test for it and tries to provide a fix.

@koppor koppor changed the title Add test for "record" as name Fix "record" in Java 16 Sep 2, 2021
@koppor

koppor commented Sep 2, 2021

Copy link
Copy Markdown
Contributor Author

I added ReservedKeywordValidatorRecord to handle the record special case and adapted test cases accordingly.

@MysterAitch

Copy link
Copy Markdown
Member

Tests appear to be failing due to the Java 15 (preview) validator tests -- note that records were in preview for both Java 14 and Java 15 before being available in Java 16 👍

  • src/test/java/com/github/javaparser/ast/validator/Java15PreviewValidatorTest.java.

@MysterAitch

Copy link
Copy Markdown
Member

I think this is good to merge, just a few bits about naming to update -- thank you @koppor 👍

@MysterAitch MysterAitch added the PR: Fixed A PR that offers a fix or correction label Sep 3, 2021
@MysterAitch MysterAitch added this to the next release milestone Sep 3, 2021
@codecov

codecov Bot commented Sep 3, 2021

Copy link
Copy Markdown

Codecov Report

Merging #3362 (769e830) into master (8784566) will increase coverage by 0.007%.
The diff coverage is 75.000%.

❗ Current head 769e830 differs from pull request most recent head 7221976. Consider uploading reports for the commit 7221976 to get more accurate results
Impacted file tree graph

@@               Coverage Diff               @@
##              master     #3362       +/-   ##
===============================================
+ Coverage     57.328%   57.335%   +0.007%     
  Complexity      2576      2576               
===============================================
  Files            620       621        +1     
  Lines          34297     34312       +15     
  Branches        5808      5809        +1     
===============================================
+ Hits           19662     19673       +11     
- Misses         12668     12670        +2     
- Partials        1967      1969        +2     
Flag Coverage Δ
AlsoSlowTests 57.335% <75.000%> (+0.007%) ⬆️
javaparser-core 52.993% <75.000%> (+0.011%) ⬆️
javaparser-symbol-solver 35.422% <50.000%> (+0.004%) ⬆️
jdk-10 57.328% <75.000%> (+0.006%) ⬆️
jdk-11 57.328% <75.000%> (+0.006%) ⬆️
jdk-12 57.325% <75.000%> (+0.004%) ⬆️
jdk-13 57.328% <75.000%> (+0.006%) ⬆️
jdk-14 57.325% <75.000%> (+0.004%) ⬆️
jdk-15 57.328% <75.000%> (+0.009%) ⬆️
jdk-16 57.328% <75.000%> (+0.006%) ⬆️
jdk-8 57.333% <75.000%> (+0.006%) ⬆️
jdk-9 57.322% <75.000%> (+0.001%) ⬆️
macos-latest 57.329% <75.000%> (+0.006%) ⬆️
ubuntu-latest 57.321% <75.000%> (+0.004%) ⬆️
windows-latest 57.329% <75.000%> (+0.006%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...or/language_level_validations/Java16Validator.java 100.000% <ø> (ø)
...st/validator/RecordAsTypeIdentifierNotAllowed.java 73.333% <73.333%> (ø)
...or/language_level_validations/Java14Validator.java 100.000% <100.000%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8784566...7221976. Read the comment docs.

@MysterAitch MysterAitch linked an issue Sep 8, 2021 that may be closed by this pull request
class Java15PreviewValidatorTest {

private final JavaParser javaParser = new JavaParser(new ParserConfiguration().setLanguageLevel(JAVA_16));
private final JavaParser javaParser = new JavaParser(new ParserConfiguration().setLanguageLevel(JAVA_15_PREVIEW));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot, thanks! 👍

@MysterAitch MysterAitch changed the title Fix "record" in Java 16 Fix "record" as non-type identifier in Java 16 Sep 8, 2021
@MysterAitch MysterAitch merged commit f1f6baf into javaparser:master Sep 8, 2021
@koppor koppor deleted the add-record-test branch September 18, 2021 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Fixed A PR that offers a fix or correction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"record" is a valid variable name in Java 16

2 participants