mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
EA-26767 - NPE: ExtractMethodProcessor.doRefactoring
This commit is contained in:
+2
-1
@@ -46,6 +46,7 @@ import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.controlFlow.ControlFlowUtil;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.search.LocalSearchScope;
|
||||
@@ -1047,7 +1048,7 @@ public class ExtractMethodProcessor implements MatchProvider {
|
||||
LOG.assertTrue(qualifierExpression != null);
|
||||
qualifierExpression.replace(instanceQualifier);
|
||||
}
|
||||
return expr;
|
||||
return (PsiMethodCallExpression)JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(expr);
|
||||
}
|
||||
|
||||
private void declareNecessaryVariablesInsideBody(PsiCodeBlock body) throws IncorrectOperationException {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.io.IOException;
|
||||
|
||||
class Test {
|
||||
void foo(Exception targetElement) {
|
||||
PsiPackage aPack = <selection>JavaDirectoryService.getInstance().getPackage((IOException)targetElement)</selection>;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import java.io.IOException;
|
||||
|
||||
class Test {
|
||||
void foo(Exception targetElement) {
|
||||
PsiPackage aPack = newMethod((IOException) targetElement);
|
||||
}
|
||||
|
||||
private PsiPackage newMethod(IOException targetElement) {
|
||||
return JavaDirectoryService.getInstance().getPackage((IOException)targetElement);
|
||||
}
|
||||
}
|
||||
@@ -489,6 +489,10 @@ public class ExtractMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testInvalidReference() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doPrepareErrorTest(final String expectedMessage) throws Exception {
|
||||
String expectedError = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user