mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: handle Evaluate Expression fragments in quick fix (IDEA-CR-45917)
This commit is contained in:
-3
@@ -90,9 +90,6 @@ public class ClassNewInstanceInspection extends BaseInspection {
|
||||
final PsiMethod method = (PsiMethod)parentOfType;
|
||||
addThrowsClause(method, "java.lang.NoSuchMethodException", "java.lang.reflect.InvocationTargetException");
|
||||
}
|
||||
else {
|
||||
assert false;
|
||||
}
|
||||
final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)grandParent;
|
||||
@NonNls final String newExpression = qualifier.getText() + ".getConstructor().newInstance()";
|
||||
PsiReplacementUtil.replaceExpression(methodCallExpression, newExpression, new CommentTracker());
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
class BrokenCode {
|
||||
|
||||
String s = String.class.getConstructor().newInstance();
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
class BrokenCode {
|
||||
|
||||
String s = String.class.newInstance<caret>();
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class ClassNewInstanceFixTest extends IGQuickFixesTestCase {
|
||||
public void testCreateCatchBlocks() { doTest(); }
|
||||
public void testSkipCatchBlocks() { doTest(); }
|
||||
public void testAddThrows() { doTest(); }
|
||||
public void testBrokenCode() { doTest(); }
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user