mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 10:20:15 +07:00
[java-highlighting] IDEA-216255 Provide fix for the "Foo is not a functional interface" error and the like
GitOrigin-RevId: 9658873f49ff547a4f9c424e87a202e3546e0993
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a82219bc5a
commit
3753fdc967
@@ -595,14 +595,19 @@ public final class AnnotationsHighlightUtil {
|
||||
if (parent instanceof PsiClass) {
|
||||
final String errorMessage = LambdaHighlightingUtil.checkInterfaceFunctional((PsiClass)parent, JavaErrorBundle.message("not.a.functional.interface", ((PsiClass)parent).getName()));
|
||||
if (errorMessage != null) {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(annotation).descriptionAndTooltip(errorMessage).create();
|
||||
HighlightInfo info =
|
||||
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(annotation).descriptionAndTooltip(errorMessage).create();
|
||||
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createDeleteFix(annotation));
|
||||
return info;
|
||||
}
|
||||
|
||||
if (((PsiClass)parent).hasModifierProperty(PsiModifier.SEALED)) {
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
.range(annotation)
|
||||
.descriptionAndTooltip(JavaErrorBundle.message("functional.interface.must.not.be.sealed.error.description", PsiModifier.SEALED))
|
||||
.create();
|
||||
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createDeleteFix(annotation));
|
||||
return info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// "Remove annotation" "true"
|
||||
interface Test {
|
||||
void foo();
|
||||
void bar();
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
// "Remove annotation" "true"
|
||||
public interface Test {}
|
||||
@@ -0,0 +1,2 @@
|
||||
// "Remove annotation" "true"
|
||||
class Test {}
|
||||
@@ -0,0 +1,6 @@
|
||||
// "Remove annotation" "true"
|
||||
@FunctionalInterface<caret>
|
||||
interface Test {
|
||||
void foo();
|
||||
void bar();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
// "Remove annotation" "true"
|
||||
@FunctionalInterface<caret>
|
||||
public interface Test {}
|
||||
@@ -0,0 +1,3 @@
|
||||
// "Remove annotation" "true"
|
||||
@FunctionalInterface<caret>
|
||||
class Test {}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase;
|
||||
|
||||
public class RemoveFunctionalInterfaceAnnotationTest extends LightQuickFixParameterizedTestCase {
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/removeFunctionalInterfaceAnnotation";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user