mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[java-highlighting] IDEA-365996 Constructor in an implicitly declared class is not highlighted as error
(cherry picked from commit 2de45c452608cea2ab314511060ac733259a8c18) GitOrigin-RevId: daed31a96a3fb96a6cbed183443ed90205b679f3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
35c774bf7d
commit
b3f8bbb608
@@ -2341,6 +2341,22 @@ public final class HighlightMethodUtil {
|
||||
return MethodSignatureUtil.areSignaturesErasureEqual(valueOfMethod, methodSignature);
|
||||
}
|
||||
|
||||
static HighlightInfo.@Nullable Builder checkConstructorInImplicitClass(@NotNull PsiMethod method) {
|
||||
if (!method.isConstructor()) {
|
||||
return null;
|
||||
}
|
||||
if (!(method.getContainingClass() instanceof PsiImplicitClass)) {
|
||||
return null;
|
||||
}
|
||||
String description = JavaErrorBundle.message("implicit.class.with.explicit.constructor");
|
||||
TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method);
|
||||
HighlightInfo.Builder builder =
|
||||
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description);
|
||||
IntentionAction action = QuickFixFactory.getInstance().createDeleteFix(method);
|
||||
builder.registerFix(action, null, null, null, null);
|
||||
return builder;
|
||||
}
|
||||
|
||||
private static final class ReturnModel {
|
||||
final PsiReturnStatement myStatement;
|
||||
final PsiType myType;
|
||||
|
||||
@@ -934,6 +934,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitMethod(@NotNull PsiMethod method) {
|
||||
super.visitMethod(method);
|
||||
if (!hasErrorResults()) add(HighlightMethodUtil.checkConstructorInImplicitClass(method));
|
||||
if (!hasErrorResults()) add(HighlightControlFlowUtil.checkUnreachableStatement(method.getBody()));
|
||||
if (!hasErrorResults()) add(HighlightMethodUtil.checkConstructorHandleSuperClassExceptions(method));
|
||||
if (!hasErrorResults()) add(GenericsHighlightUtil.checkSafeVarargsAnnotation(method, myLanguageLevel));
|
||||
|
||||
Reference in New Issue
Block a user