[Java. Inspections] disable suggestion of adding excepion to signature in base methods if they are synthetic

IDEA-358300

GitOrigin-RevId: c042955003e44d4d575569543c4247ac223c02ec
This commit is contained in:
Georgii Ustinov
2024-09-09 19:17:32 +03:00
committed by intellij-monorepo-bot
parent bc8f0bf7c5
commit ae1025c38d
5 changed files with 68 additions and 3 deletions

View File

@@ -0,0 +1,25 @@
package com.intellij.java.lomboktest
import com.intellij.codeInsight.daemon.QuickFixBundle
import com.intellij.openapi.command.executeCommand
import com.intellij.refactoring.suggested.LightJavaCodeInsightFixtureTestCaseWithUtils
import com.intellij.testFramework.LightProjectDescriptor
import de.plushnikov.intellij.plugin.LombokTestUtil.LOMBOK_DESCRIPTOR
class LombokAddRuntimeExceptionToThrowsActionTest: LightJavaCodeInsightFixtureTestCaseWithUtils() {
override fun getProjectDescriptor(): LightProjectDescriptor = LOMBOK_DESCRIPTOR
override fun getBasePath(): String = "community/plugins/lombok/testData/intention/addExceptionToThrows"
fun testOverridingSyntheticElement() = doTest()
private fun doTest() {
val name = getTestName(false)
myFixture.configureByFile("before$name.java")
val intention = myFixture.availableIntentions.singleOrNull { it.familyName == QuickFixBundle.message("add.runtime.exception.to.throws.family") }
assertNotNull(intention)
executeCommand { intention?.invoke(project, editor, file) }
myFixture.checkResultByFile("after$name.java")
}
}

View File

@@ -0,0 +1,20 @@
import lombok.Getter;
public class A {
@Getter
private String s;
private static class B extends A {
@Override
public String getS() {
throw new RuntimeException();
}
}
private static class C extends B {
@Override
public String getS() throws RuntimeException {
throw new Runtime<caret>Exception();
}
}
}

View File

@@ -0,0 +1,20 @@
import lombok.Getter;
public class A {
@Getter
private String s;
private static class B extends A {
@Override
public String getS() {
throw new RuntimeException();
}
}
private static class C extends B {
@Override
public String getS() {
throw new Runtime<caret>Exception();
}
}
}