mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline functional expression: surround with parenthesis if inlined in method reference qualifier (IDEA-152600)
This commit is contained in:
+2
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user