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

Make Groovy Parser correctly handle nested parenthesis #4801

Merged
merged 22 commits into from
Dec 19, 2024

Conversation

Laurens-W
Copy link
Contributor

What's changed?

Nested parentheses around method invocations are supported as well for the groovy parser.

What's your motivation?

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@Laurens-W Laurens-W added bug Something isn't working parser-groovy labels Dec 19, 2024
@Laurens-W Laurens-W self-assigned this Dec 19, 2024
@jevanlingen
Copy link
Contributor

Very nice work, at last we have a working implementation!

@jevanlingen jevanlingen marked this pull request as ready for review December 19, 2024 16:28
@Laurens-W Laurens-W merged commit 91a031a into main Dec 19, 2024
2 checks passed
@Laurens-W Laurens-W deleted the groovy-parser-parenthesis-pt3 branch December 19, 2024 16:51
timtebeek added a commit that referenced this pull request Dec 27, 2024
timtebeek added a commit that referenced this pull request Dec 27, 2024
* Revert "Try alternative way of determining parenthesis level for `BinaryExpression` when AST doesn't provide `_INSIDE_PARENTHESES_LEVEL` flag (#4807)"

This reverts commit e59e48b.

* Revert "Make Groovy Parser correctly handle nested parenthesis (#4801)"

This reverts commit 91a031a.
amishra-u pushed a commit to amishra-u/rewrite that referenced this pull request Dec 28, 2024
)

* WIP

* Format

* Format

* Move grabbing of whitespace and resetting cursor to where it is actually required

* Extra check is not required

* Use toString

* Add `emptyListLiteralWithParentheses` test

* Add `insideFourParenthesesAndEnters` test

* Move list tests all to ListTest

* Add `emptyMapLiteralWithParentheses`

* Review feedback and fix new testcases

* Add `attributeWithParentheses`

* Improve AttributeTest

* Improve AttributeTest

* Improve AttributeTest

* Improve AttributeTest

* Improve AttributeTest

* Review fix new testcases

* Revert edit to testcase

* Add and fix testcase with newline

* Add JavaDoc and move logic regarding whitespace and resetting cursor

---------

Co-authored-by: lingenj <[email protected]>
amishra-u pushed a commit to amishra-u/rewrite that referenced this pull request Dec 28, 2024
* Revert "Try alternative way of determining parenthesis level for `BinaryExpression` when AST doesn't provide `_INSIDE_PARENTHESES_LEVEL` flag (openrewrite#4807)"

This reverts commit e59e48b.

* Revert "Make Groovy Parser correctly handle nested parenthesis (openrewrite#4801)"

This reverts commit 91a031a.
timtebeek added a commit that referenced this pull request Dec 31, 2024
* Add lombok support for java-11

* Handle erroneous nodes in open rewrite (#4412)

* Handle erroneous nodes in a tree

* Add visitErroneous to all java parser visitors

* Override the visitVariable to handle erroneous identifier names set by JavacParser

* retain name and suffix for erroneous varDecl

* override the visitVariable to handle error identifiers in all java parser visitors

* Remove sysout

* Update rewrite-java-test/src/test/java/org/openrewrite/java/JavaParserTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update rewrite-java-test/src/test/java/org/openrewrite/java/JavaParserTest.java

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* handle errors in method params, variable declarations, fix tests

* Add missing license headers

* fix compilation error

* fix compilation error in Java8ParserVisitor

* Apply code suggestions from bot

* fix cases for statementDelim

* fix block statement template generator to handle adding semicolon

* fix ChangeStaticFieldToMethod recipe

* Record compiler errors from erroneous LST nodes

* Adjustments for comments

* Java 17 parser adjustment alos in 8, 11 and 21

* Add `FindCompileErrorsTest` & move away from deprecated `print()`

---------

Co-authored-by: Jonathan Schnéider <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Tim te Beek <[email protected]>
Co-authored-by: aboyko <[email protected]>

* Make Groovy Parser correctly handle nested parenthesis (#4801)

* WIP

* Format

* Format

* Move grabbing of whitespace and resetting cursor to where it is actually required

* Extra check is not required

* Use toString

* Add `emptyListLiteralWithParentheses` test

* Add `insideFourParenthesesAndEnters` test

* Move list tests all to ListTest

* Add `emptyMapLiteralWithParentheses`

* Review feedback and fix new testcases

* Add `attributeWithParentheses`

* Improve AttributeTest

* Improve AttributeTest

* Improve AttributeTest

* Improve AttributeTest

* Improve AttributeTest

* Review fix new testcases

* Revert edit to testcase

* Add and fix testcase with newline

* Add JavaDoc and move logic regarding whitespace and resetting cursor

---------

Co-authored-by: lingenj <[email protected]>

* suppress javax.json (#4804)

* suppress javax.json

* Update suppressions.xml

* Refactor SpringReference (#4805)

* Separating and clearer naming

* Add license header

* Review feedback

* refactor: Update Gradle wrapper (#4808)

Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.gradle.UpdateGradleWrapper?organizationId=T3BlblJld3JpdGU%3D#defaults=W3sibmFtZSI6ImFkZElmTWlzc2luZyIsInZhbHVlIjoiRmFsc2UifV0=

Co-authored-by: Moderne <[email protected]>

* Add recipe to remove Gradle Enterprise and Develocity (#4809)

* Add recipe to remove Gradle Enterprise and Develocity

* Remove left over java plugin

* Add a UsesType precondition to ReplaceConstant

* Allow file scheme in `RemoteArchive` to simplify testing (#4791)

* Allow file scheme in `RemoteArchive` to simplify testing

While it might look a bit controversial, the file scheme can also point to a remote (for instance a mounted network share) file. By allowing the `file://` scheme we can use `RemoteArchive` for those files.

As a useful side effect, this makes testing RemoteArchive handling a lot easier.

* fix test

* Update rewrite-core/src/test/java/org/openrewrite/remote/RemoteArchiveTest.java

Co-authored-by: Sam Snyder <[email protected]>

---------

Co-authored-by: Sam Snyder <[email protected]>

* Try alternative way of determining parenthesis level for `BinaryExpression` when AST doesn't provide `_INSIDE_PARENTHESES_LEVEL` flag (#4807)

* Add a `isClassAvailable` method to the ReflectionUtils (#4810)

* Add a `isClassAvailable` method to the ReflectionUtils

* Add a `isClassAvailable` method to the ReflectionUtils

* Add a `isClassAvailable` method to the ReflectionUtils

* Update rewrite.yml to enforce CompareEnumsWithEqualityOperator

* Correctly map generic return and parameter types in `JavaReflectionTypeMapping` (#4812)

* Polish formatting

* Add more scenarios to JavaTypeGoat for simply typed fields and methods that return exceptions.

* Support mapping of generic thrown exception types (#4813)

* refactor: Enum values should be compared with "==" (#4811)

Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.staticanalysis.CompareEnumsWithEqualityOperator?organizationId=T3BlblJld3JpdGU%3D

Co-authored-by: Moderne <[email protected]>

* Keep the names of generic type variables defined by methods. (#4814)

* Make the same performance improvement to parameter names allocations that we previously made to Java 17/21 in #3345.

* Fix Java reflection mapping of generic typed fields. (#4815)

* Revert parenthesis changes (#4818)

* Revert "Try alternative way of determining parenthesis level for `BinaryExpression` when AST doesn't provide `_INSIDE_PARENTHESES_LEVEL` flag (#4807)"

This reverts commit e59e48b.

* Revert "Make Groovy Parser correctly handle nested parenthesis (#4801)"

This reverts commit 91a031a.

* JavaTemplate bug when inserting `final var` into for-each (#4806)

* JavaTemplate bug when inserting `final var` into for-each

* Split variable declarations when they contain stop comment

* Reduce accidental changes between Java 11 and 17 parsers

* Add missing import

---------

Co-authored-by: Udayani Vaka <[email protected]>
Co-authored-by: Jonathan Schnéider <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Tim te Beek <[email protected]>
Co-authored-by: aboyko <[email protected]>
Co-authored-by: Laurens Westerlaken <[email protected]>
Co-authored-by: lingenj <[email protected]>
Co-authored-by: Peter Streef <[email protected]>
Co-authored-by: Shannon Pamperl <[email protected]>
Co-authored-by: Moderne <[email protected]>
Co-authored-by: Sam Snyder <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser-groovy
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants