inline functional expression: surround with parenthesis if inlined in method reference qualifier (IDEA-152600)

This commit is contained in:
Anna Kozlova
2016-03-04 19:58:08 +01:00
parent 2e3e5f6dd1
commit e6a5fc8f31
4 changed files with 29 additions and 3 deletions
@@ -64,7 +64,7 @@ public class ReplaceExpressionUtil {
else if (i == JavaElementType.POSTFIX_EXPRESSION) {
return priority <= parentPriority;
}
else if (i == JavaElementType.REFERENCE_EXPRESSION) {
else if (i == JavaElementType.REFERENCE_EXPRESSION || i == JavaElementType.METHOD_REF_EXPRESSION) {
return priority < parentPriority;
}
else if (i == JavaElementType.METHOD_CALL_EXPRESSION) {
@@ -87,8 +87,7 @@ public class ReplaceExpressionUtil {
i == JavaElementType.THIS_EXPRESSION ||
i == JavaElementType.SUPER_EXPRESSION ||
i == JavaElementType.CLASS_OBJECT_ACCESS_EXPRESSION ||
i == JavaElementType.LAMBDA_EXPRESSION ||
i == JavaElementType.METHOD_REF_EXPRESSION ) {
i == JavaElementType.LAMBDA_EXPRESSION) {
return false;
}
@@ -0,0 +1,12 @@
class Test {
interface Task {
void doit();
}
class SuperClient {
public static void main(String[] args) {
Task t = () -> System.out.println("hello");
Runnable r = <caret>t::doit;
}
}
}
@@ -0,0 +1,11 @@
class Test {
interface Task {
void doit();
}
class SuperClient {
public static void main(String[] args) {
Runnable r = ((Task) () -> System.out.println("hello"))::doit;
}
}
}
@@ -248,6 +248,10 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
doTest(true);
}
public void testParenthesisAroundInlinedLambda() throws Exception {
doTest(true);
}
public void testArrayAccessPriority() throws Exception {
doTest(true);
}