Skip to content

Commit

Permalink
support method invocation called from object in object
Browse files Browse the repository at this point in the history
  • Loading branch information
jevanlingen committed Dec 27, 2024
1 parent 9efc391 commit 9405ee4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2543,7 +2543,6 @@ private int sourceLengthOfString(ConstantExpression expr) {
} else if (node instanceof BinaryExpression) {
BinaryExpression expr = (BinaryExpression) node;
return determineParenthesisLevel(expr.getLeftExpression().getLineNumber(), expr.getLineNumber(), expr.getLeftExpression().getColumnNumber(), expr.getColumnNumber());

}
return null;
}
Expand Down Expand Up @@ -2572,6 +2571,9 @@ private int determineParenthesisLevel(int childLineNumber, int parentLineNumber,
if (source.charAt(i) == '(') {
count++;
}
if (source.charAt(i) == ')') {
count--;
}
}
cursor = saveCursor;
return count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,22 @@ def acceptsClosure(Closure cl) {}
);
}

@Test
void closureInObjectInObject() {
rewriteRun(
groovy(
"""
class Test {
Test child = new Test()
def acceptsClosure(Closure cl) {}
}
new Test().child.acceptsClosure {}
"""
)
);
}

@Issue("https://github.com/openrewrite/rewrite/issues/4766")
@Test
void gradleFileWithMultipleClosuresWithoutParentheses() {
Expand Down

0 comments on commit 9405ee4

Please sign in to comment.