Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interface member detection to support inner records #492

Merged
merged 3 commits into from
Jul 19, 2021

Conversation

rnorth
Copy link
Contributor

@rnorth rnorth commented Jul 18, 2021

What changed with this PR:

This PR is intended to fix an error when parsing interfaces with inner records.

Example

Before fix

// Input
public interface SomeInterface {
  record SomeRecord(
      String param
  ) implements AnyInterface { }
}
// Output

AssertionError: expected [Function] to not throw an error but 
Error: Sad sad panda, parsing errors detected in line: 5, column: 9!
Expecting: one of these possible Token sequences:\n  1. [\'{\'] 2. [\';\']
  but found: \'implements\'!
->compilationUnit
->ordinaryCompilationUnit
->typeDeclaration
->interfaceDeclaration
->normalInterfaceDeclaration
->interfaceBody
->interfaceMemberDeclaration
->interfaceMethodDeclaration
->methodBody' was thrown

As I understand it, interfaceMemberDeclaration->interfaceMethodDeclaration is a sign that the inner record is being identified as a method declaration, when it should be identified as a 'class' (record) definition.

After fix

Parses without throwing

Relative issues or prs:

None filed; I'd be happy to file one retrospectively if needed.

@CLAassistant
Copy link

CLAassistant commented Jul 18, 2021

CLA assistant check
All committers have signed the CLA.

@rnorth rnorth marked this pull request as ready for review July 18, 2021 14:52
@clementdessoude clementdessoude merged commit 1f4b729 into jhipster:main Jul 19, 2021
@clementdessoude
Copy link
Contributor

Hi @rnorth !!

Thanks a lot for this PR ! It's awesome :)

@rnorth
Copy link
Contributor Author

rnorth commented Jul 28, 2021

@clementdessoude I'm sorry to ask, but is there any possibility of triggering a patch release for this?

Or do you know of any way to use an unreleased version with the spotless Gradle plugin? (I've tried but it doesn't seem this is possible)

Thank you!

@clementdessoude
Copy link
Contributor

Sorry, I should have done it right after merging the PR, and then I was away for some holidays. It should be good now :)

@rnorth
Copy link
Contributor Author

rnorth commented Aug 2, 2021

Awesome, I was on vacation myself but am back now and will give it a spin. Thanks so much!

clementdessoude pushed a commit to clementdessoude/prettier-java that referenced this pull request Mar 4, 2023
* Add a failing test and tests for debugging

* Fix interface member detection

* Add formatting tests for completeness
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants