mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-highlighting] IDEA-365996 Constructor in an implicitly declared class is not highlighted as error
GitOrigin-RevId: 2de45c452608cea2ab314511060ac733259a8c18
This commit is contained in:
committed by
intellij-monorepo-bot
parent
75f7bbf5da
commit
c28f1d89cc
+16
@@ -1734,6 +1734,22 @@ public final class HighlightMethodUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
+1
@@ -776,6 +776,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(HighlightMethodUtil.checkRecordAccessorDeclaration(method));
|
||||
|
||||
@@ -451,4 +451,5 @@ too.many.array.dimensions=Too many array dimensions
|
||||
error.cannot.infer.pattern.type=Cannot infer pattern type: {0}
|
||||
error.extra.semicolons.between.import.statements.not.allowed=Extra semicolons between import statements are not allowed
|
||||
remove.unused.imports.quickfix.text=Remove unused imports
|
||||
incomplete.project.state.pending.reference=Not resolved until the project is fully loaded
|
||||
incomplete.project.state.pending.reference=Not resolved until the project is fully loaded
|
||||
implicit.class.with.explicit.constructor=Explicit constructor in implicitly declared class is not allowed
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
void main(String[] args) {
|
||||
System.out.println("AAAAA");
|
||||
}
|
||||
|
||||
<error descr="Explicit constructor in implicitly declared class is not allowed">public ImplicitClassConstructorNoParam()</error> {
|
||||
System.out.println("BBBBB");
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
void main(String[] args) {
|
||||
System.out.println("AAAAA");
|
||||
}
|
||||
|
||||
<error descr="Explicit constructor in implicitly declared class is not allowed">public ImplicitClassConstructorParam(String a)</error> {
|
||||
System.out.println("BBBBB");
|
||||
}
|
||||
+8
@@ -164,6 +164,14 @@ class ImplicitClassHighlightingTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
})
|
||||
}
|
||||
|
||||
fun testImplicitClassConstructorNoParam() {
|
||||
doTest()
|
||||
}
|
||||
|
||||
fun testImplicitClassConstructorParam() {
|
||||
doTest()
|
||||
}
|
||||
|
||||
private fun doTest() {
|
||||
myFixture.configureByFile(getTestName(false) + ".java")
|
||||
myFixture.checkHighlighting()
|
||||
|
||||
Reference in New Issue
Block a user