mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
[lombok] IDEA-355551 Lombok plugin should show compilation error for @Slf4j over non-static inner class
GitOrigin-RevId: 94f463e78030b1e1f4bc39dfef5757dd18f6471f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fc9595d1b2
commit
1925127c52
+15
@@ -89,10 +89,25 @@ public abstract class AbstractLogProcessor extends AbstractClassProcessor {
|
||||
builder.addErrorMessage("inspection.message.not.generating.field.s.field.with.same.name.already.exists", loggerName);
|
||||
result = false;
|
||||
}
|
||||
|
||||
final boolean loggerStatic = isLoggerStatic(psiClass);
|
||||
if (psiClass.isRecord() && !loggerStatic) {
|
||||
builder.addErrorMessage("inspection.message.logger.fields.must.be.static.in.records");
|
||||
result = false;
|
||||
}
|
||||
|
||||
if (loggerStatic &&
|
||||
!(psiClass.hasModifierProperty(PsiModifier.STATIC) || psiClass.getContainingClass() == null || psiClass.isRecord())
|
||||
) {
|
||||
builder.addErrorMessage("inspection.message.logger.can.be.used.on.static.inner.classes.only", StringUtil.getShortName(getSupportedAnnotationClasses()[0]));
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void generatePsiElements(@NotNull PsiClass psiClass,
|
||||
@NotNull PsiAnnotation psiAnnotation,
|
||||
|
||||
@@ -77,6 +77,8 @@ inspection.message.field.name.constants.only.supported.on.class.enum.or.field.ty
|
||||
inspection.message.field.name.constants.inner.type=@FieldNameConstants inner type already exists, but asEnum={0} does not match existing type
|
||||
inspection.message.s.legal.only.on.classes.enums=''@{0}'' is legal only on classes and enums
|
||||
inspection.message.not.generating.field.s.field.with.same.name.already.exists=Not generating field ''{0}'': A field with same name already exists
|
||||
inspection.message.logger.fields.must.be.static.in.records=Logger fields must be static in records
|
||||
inspection.message.logger.can.be.used.on.static.inner.classes.only=''@{0}'' is not supported on non-static nested classes.
|
||||
inspection.message.custom.log.not.configured.correctly=The @CustomLog is not configured correctly; please set log.custom.declaration in lombok.config.
|
||||
inspection.message.custom.log.does.not.allow.topic=@CustomLog does not allow a topic.
|
||||
inspection.message.custom.log.requires.topic=@CustomLog requires a topic.
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package de.plushnikov.intellij.plugin.inspection;
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry;
|
||||
|
||||
public class Slf4jOnNonStaticInnerClassInspectionTest extends LombokInspectionTest {
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return super.getBasePath() + "/" + TEST_DATA_INSPECTION_DIRECTORY + "/slf4jOnNonStaticInner";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
return new LombokInspection();
|
||||
}
|
||||
|
||||
public void testSlf4jOnNonStaticInnerClass() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
class Slf4jOnNonStaticInnerClassOuter {
|
||||
<error descr="'@Slf4j' is not supported on non-static nested classes.">@Slf4j</error>
|
||||
class Inner {
|
||||
}
|
||||
|
||||
@Slf4j
|
||||
static class StaticInnerOk {
|
||||
}
|
||||
|
||||
@Slf4j
|
||||
record SomeRecord() {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user