mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
IDEA-28534 Intention enhancement: "Make class Foo implement interface Bar" implemented
This commit is contained in:
@@ -540,6 +540,7 @@ public class HighlightUtil {
|
||||
if (errorResult != null && valueType != null) {
|
||||
IntentionAction fix = QUICK_FIX_FACTORY.createMethodReturnFix(method, valueType, true);
|
||||
QuickFixAction.registerQuickFixAction(errorResult, fix);
|
||||
ChangeParameterClassFix.registerQuickFixAction(returnType, valueType, errorResult);
|
||||
if (returnType instanceof PsiArrayType && TypeConversionUtil.isAssignable(((PsiArrayType)returnType).getComponentType(), valueType)) {
|
||||
QuickFixAction.registerQuickFixAction(errorResult, new SurroundWithArrayFix(null) {
|
||||
@Override
|
||||
@@ -2507,7 +2508,7 @@ public class HighlightUtil {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, action);
|
||||
}
|
||||
}
|
||||
ChangeParameterClassFix.registerQuickFixAction(parameter, itemType, highlightInfo);
|
||||
ChangeParameterClassFix.registerQuickFixAction(parameter.getType(), itemType, highlightInfo);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -114,16 +114,16 @@ public class ChangeParameterClassFix extends ExtendsListFix {
|
||||
UndoUtil.markPsiFileForUndo(file);
|
||||
}
|
||||
|
||||
public static void registerQuickFixAction(PsiVariable variable, PsiType returnType, HighlightInfo info) {
|
||||
final PsiClass returnClass = PsiUtil.resolveClassInClassTypeOnly(returnType);
|
||||
final PsiType variableType = variable.getType();
|
||||
final PsiClass variableClass = PsiUtil.resolveClassInClassTypeOnly(variableType);
|
||||
public static void registerQuickFixAction(PsiType lType, PsiType rType, HighlightInfo info) {
|
||||
final PsiClass lClass = PsiUtil.resolveClassInClassTypeOnly(lType);
|
||||
final PsiClass rClass = PsiUtil.resolveClassInClassTypeOnly(rType);
|
||||
|
||||
if (returnClass == null || variableClass == null) return;
|
||||
if (returnClass instanceof PsiAnonymousClass) return;
|
||||
if (returnClass.isInheritor(variableClass, true)) return;
|
||||
if (rClass == null || lClass == null) return;
|
||||
if (rClass instanceof PsiAnonymousClass) return;
|
||||
if (rClass.isInheritor(lClass, true)) return;
|
||||
if (lClass.isInheritor(rClass, true)) return;
|
||||
|
||||
QuickFixAction.registerQuickFixAction(info, new ChangeParameterClassFix(returnClass, (PsiClassType)variableType));
|
||||
QuickFixAction.registerQuickFixAction(info, new ChangeParameterClassFix(rClass, (PsiClassType)lType));
|
||||
}
|
||||
|
||||
public static void registerQuickFixActions(PsiCall methodCall, PsiExpressionList list, HighlightInfo highlightInfo) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Make 'Foo' implement 'Foo.Bar'" "true"
|
||||
public class Foo implements Foo.Bar {
|
||||
|
||||
public Bar getBar() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public interface Bar {}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Make 'Foo' implement 'Foo.Bar'" "false"
|
||||
public class Foo {
|
||||
|
||||
public void getBar() {
|
||||
Bar f = new F<caret>oo();
|
||||
}
|
||||
|
||||
public class Bar extends Foo {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Make 'Foo' implement 'Foo.Bar'" "true"
|
||||
public class Foo {
|
||||
|
||||
public Bar getBar() {
|
||||
return t<caret>his;
|
||||
}
|
||||
|
||||
public interface Bar {}
|
||||
}
|
||||
Reference in New Issue
Block a user