Groovy: Fix parsing of generated code that contains ternery operator #7859
Open
gtiwari333 wants to merge 2 commits into
Open
Groovy: Fix parsing of generated code that contains ternery operator #7859gtiwari333 wants to merge 2 commits into
gtiwari333 wants to merge 2 commits into
Conversation
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.
Im fixing the parsing error as described on the repo: https://github.com/gtiwari333/openrewrite-groovy-bug#error-3-cant-parse-conditional-statements-from-generated-code-eg-slf4j
The following code was failing to parse during code migration.
What's changed?
Added defensive checks in
GroovyParserVisitorto detect and skip synthetic nodes:boolean expression.getLineNumber() < 0, and if so, visit onlythe true branch directly, bypassing the synthetic wrapper.
lineNumber < 0toavoid negative array index access during parenthesis level computation.
What's your motivation?
Working on using openrewrite to migrate groovy based repositories. Blocked by this bug.
Anything in particular you'd like reviewers to focus on?
N/A
Anyone you would like to review specifically?
N/A
Have you considered any alternatives or workarounds?
No.
Any additional context
Checklist
Full stacktrace