mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not migrate from type to self
This commit is contained in:
+6
-3
@@ -97,17 +97,20 @@ public class VariableTypeFromCallFix implements IntentionAction {
|
||||
}
|
||||
final PsiElement resolved = ((PsiReferenceExpression)qualifierExpression).resolve();
|
||||
if (resolved instanceof PsiVariable) {
|
||||
final PsiClass varClass = PsiUtil.resolveClassInType(((PsiVariable)resolved).getType());
|
||||
final PsiType varType = ((PsiVariable)resolved).getType();
|
||||
final PsiClass varClass = PsiUtil.resolveClassInType(varType);
|
||||
final PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(expression.getProject()).getResolveHelper();
|
||||
if (varClass != null) {
|
||||
final PsiSubstitutor psiSubstitutor = resolveHelper.inferTypeArguments(varClass.getTypeParameters(),
|
||||
parameters,
|
||||
expressions, PsiSubstitutor.EMPTY, resolved, false);
|
||||
final PsiClassType appropriateVarType = JavaPsiFacade.getElementFactory(expression.getProject()).createType(varClass, psiSubstitutor);
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new VariableTypeFromCallFix(appropriateVarType, (PsiVariable) resolved));
|
||||
if (!varType.equals(appropriateVarType)) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, new VariableTypeFromCallFix(appropriateVarType, (PsiVariable) resolved));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Change 'var' type to 'Foo" "false"
|
||||
public class Test {
|
||||
void foo() {
|
||||
final Foo var = new Foo();
|
||||
var.foo("", 6<caret>6);
|
||||
}
|
||||
}
|
||||
|
||||
class Foo {
|
||||
void foo(String str, String str1){}
|
||||
}
|
||||
Reference in New Issue
Block a user