IG: handle Evaluate Expression fragments in quick fix (IDEA-CR-45917)

This commit is contained in:
Bas Leijdekkers
2019-04-05 11:27:40 +02:00
parent 555820f175
commit 0645fc42ac
4 changed files with 9 additions and 3 deletions
@@ -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());
@@ -0,0 +1,4 @@
class BrokenCode {
String s = String.class.getConstructor().newInstance();
}
@@ -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 {