mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: don't report uninitialized fields when constructor has incorrect name (IDEA-380080)
GitOrigin-RevId: c83193e8b72f9730e1102220f7a12c35e2722223
This commit is contained in:
committed by
intellij-monorepo-bot
parent
8f6afc90fe
commit
38729705c8
+2
-1
@@ -224,7 +224,8 @@ method.inheritance.clash.unrelated.return.types={0}; methods have unrelated retu
|
||||
method.inheritance.clash.incompatible.return.types={0}; incompatible return type
|
||||
method.inheritance.clash.does.not.throw={0}; overridden method does not throw ''{1}''
|
||||
method.no.parameter.list=Parameter list expected
|
||||
method.missing.return.type=Invalid method declaration; return type required
|
||||
method.missing.return.type.not.constructor=Method return type missing
|
||||
method.missing.return.type=Method return type missing or constructor name does not match class name
|
||||
method.generic.same.erasure={0}; both methods have same erasure
|
||||
method.generic.same.erasure.override={0}; both methods have same erasure, yet neither overrides the other
|
||||
method.generic.same.erasure.hide={0}; both methods have same erasure, yet neither hides the other
|
||||
|
||||
+8
-3
@@ -7,7 +7,6 @@ import com.intellij.codeInsight.daemon.impl.analysis.JavaGenericsUtil;
|
||||
import com.intellij.java.codeserver.core.JavaPsiMethodUtil;
|
||||
import com.intellij.java.codeserver.highlighting.errors.JavaCompilationError;
|
||||
import com.intellij.java.codeserver.highlighting.errors.JavaErrorKinds;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.java.JavaFeature;
|
||||
@@ -415,8 +414,14 @@ final class MethodChecker {
|
||||
void checkConstructorName(PsiMethod method) {
|
||||
PsiClass aClass = method.getContainingClass();
|
||||
if (aClass != null) {
|
||||
String className = aClass instanceof PsiAnonymousClass ? null : aClass.getName();
|
||||
if (className == null || !Comparing.strEqual(method.getName(), className)) {
|
||||
String className = aClass.getName();
|
||||
if (method.getName().equals(className)) {
|
||||
return;
|
||||
}
|
||||
if (aClass.isInterface() || aClass instanceof PsiAnonymousClass || className == null) {
|
||||
myVisitor.report(JavaErrorKinds.METHOD_MISSING_RETURN_TYPE_NOT_CONSTRUCTOR.create(method));
|
||||
}
|
||||
else {
|
||||
myVisitor.report(JavaErrorKinds.METHOD_MISSING_RETURN_TYPE.create(method, className));
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -765,9 +765,12 @@ public final class JavaErrorKinds {
|
||||
.withDescription((cls, ctx) -> message("method.inheritance.clash.does.not.throw",
|
||||
formatClashMethodMessage(ctx.method(), ctx.superMethod()),
|
||||
formatType(ctx.exceptionType())));
|
||||
public static final Parameterized<PsiMethod, String> METHOD_MISSING_RETURN_TYPE =
|
||||
public static final Parameterized<PsiMethod, @NotNull String> METHOD_MISSING_RETURN_TYPE =
|
||||
parameterized(PsiMethod.class, String.class, "method.missing.return.type")
|
||||
.withAnchor(method -> requireNonNullElse(method.getNameIdentifier(), method));
|
||||
public static final Simple<PsiMethod> METHOD_MISSING_RETURN_TYPE_NOT_CONSTRUCTOR =
|
||||
error(PsiMethod.class, "method.missing.return.type.not.constructor")
|
||||
.withAnchor(method -> requireNonNullElse(method.getNameIdentifier(), method));
|
||||
|
||||
public static final Parameterized<PsiMember, AmbiguousImplicitConstructorCallContext> CONSTRUCTOR_AMBIGUOUS_IMPLICIT_CALL =
|
||||
parameterized(PsiMember.class, AmbiguousImplicitConstructorCallContext.class, "constructor.ambiguous.implicit.call")
|
||||
|
||||
Reference in New Issue
Block a user