mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
support for disjunction types in create from usage intentions (IDEA-129453)
This commit is contained in:
+1
@@ -403,6 +403,7 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction/*, Hig
|
||||
if (varargParam != null && pi >= parameters.length) return false;
|
||||
PsiType exprType = RefactoringUtil.getTypeByExpression(expression);
|
||||
if (exprType == null) return false;
|
||||
exprType = GenericsUtil.getVariableTypeByExpressionType(exprType);
|
||||
JavaCodeStyleManager codeStyleManager = JavaCodeStyleManager.getInstance(expression.getProject());
|
||||
String name = suggestUniqueParameterName(codeStyleManager, expression, exprType, existingNames);
|
||||
final ParameterInfoImpl newParameterInfo = new ParameterInfoImpl(-1, name, exprType, expression.getText().replace('\n', ' '));
|
||||
|
||||
@@ -351,6 +351,9 @@ public class GenericsUtil {
|
||||
@Nullable
|
||||
public static PsiType getVariableTypeByExpressionType(@Nullable PsiType type, final boolean openCaptured) {
|
||||
if (type == null) return null;
|
||||
if (type instanceof PsiDisjunctionType) {
|
||||
type = ((PsiDisjunctionType)type).getLeastUpperBound();
|
||||
}
|
||||
if (type instanceof PsiCapturedWildcardType) {
|
||||
type = ((PsiCapturedWildcardType)type).getWildcard();
|
||||
}
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Add 'Exception' as 1st parameter to method 'f'" "true"
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
class Test {
|
||||
public void createFileInputStream() {
|
||||
try {
|
||||
new FileInputStream("test");
|
||||
} catch (IOException |NullPointerException e) {
|
||||
f(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void f(Exception e) { }
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// "Add 'Exception' as 1st parameter to method 'f'" "true"
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
class Test {
|
||||
public void createFileInputStream() {
|
||||
try {
|
||||
new FileInputStream("test");
|
||||
} catch (IOException |NullPointerException e) {
|
||||
f(<caret>e);
|
||||
}
|
||||
}
|
||||
|
||||
public void f() { }
|
||||
}
|
||||
Reference in New Issue
Block a user