mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
change parameter class: allow for constructor calls (IDEA-64657); for variable assignments (IDEA-71592 )
This commit is contained in:
+1
@@ -1271,6 +1271,7 @@ public class HighlightMethodUtil {
|
||||
ConstructorParametersFixer.registerFixActions(classReference, constructorCall, info, getFixRange(infoElement));
|
||||
ChangeMethodSignatureFromUsageFix.registerIntentions(results, list, info, null);
|
||||
PermuteArgumentsFix.registerFix(info, constructorCall, toMethodCandidates(results), getFixRange(list));
|
||||
ChangeParameterClassFix.registerQuickFixActions(constructorCall, list, info);
|
||||
QuickFixAction.registerQuickFixAction(info, getFixRange(list), new SurroundWithArrayFix(constructorCall), null);
|
||||
}
|
||||
info.navigationShift = +1;
|
||||
|
||||
@@ -2271,6 +2271,7 @@ public class HighlightUtil {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, action, null);
|
||||
}
|
||||
}
|
||||
ChangeParameterClassFix.registerQuickFixAction(parameter, itemType, highlightInfo);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
+11
-2
@@ -110,8 +110,17 @@ public class ChangeParameterClassFix extends ExtendsListFix {
|
||||
UndoUtil.markPsiFileForUndo(file);
|
||||
}
|
||||
|
||||
public static void registerQuickFixActions(PsiMethodCallExpression methodCall, PsiExpressionList list, HighlightInfo highlightInfo) {
|
||||
final JavaResolveResult result = methodCall.getMethodExpression().advancedResolve(false);
|
||||
public static void registerQuickFixAction(PsiVariable variable, PsiType returnType, HighlightInfo info) {
|
||||
final PsiClass psiClass = PsiUtil.resolveClassInClassTypeOnly(returnType);
|
||||
final PsiType variableType = variable.getType();
|
||||
final PsiClass variableClass = PsiUtil.resolveClassInClassTypeOnly(variableType);
|
||||
if (psiClass != null && variableClass != null && !psiClass.isInheritor(variableClass, true)) {
|
||||
QuickFixAction.registerQuickFixAction(info, new ChangeParameterClassFix(psiClass, (PsiClassType)variableType));
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerQuickFixActions(PsiCall methodCall, PsiExpressionList list, HighlightInfo highlightInfo) {
|
||||
final JavaResolveResult result = methodCall.resolveMethodGenerics();
|
||||
PsiMethod method = (PsiMethod) result.getElement();
|
||||
final PsiSubstitutor substitutor = result.getSubstitutor();
|
||||
PsiExpression[] expressions = list.getExpressions();
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Make 'A' extend 'B'" "true"
|
||||
class B {}
|
||||
|
||||
class A extends B {
|
||||
A(B b) {
|
||||
}
|
||||
|
||||
A a = new A(this);
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Make 'A' extend 'B'" "true"
|
||||
class B {}
|
||||
|
||||
class A extends B {
|
||||
int foo(B b) {
|
||||
B bz = this;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Make 'A' extend 'B'" "true"
|
||||
class B {}
|
||||
|
||||
class A {
|
||||
A(B b) {
|
||||
}
|
||||
|
||||
A a = new A(th<caret>is);
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// "Make 'A' extend 'B'" "true"
|
||||
class B {}
|
||||
|
||||
class A {
|
||||
int foo(B b) {
|
||||
B bz = t<caret>his;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user