diff --git a/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/inspection/DeprecatedLombokAnnotationInspection.java b/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/inspection/DeprecatedLombokAnnotationInspection.java
index 718286e435ce..f59f76440984 100644
--- a/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/inspection/DeprecatedLombokAnnotationInspection.java
+++ b/plugins/lombok/src/main/java/de/plushnikov/intellij/plugin/inspection/DeprecatedLombokAnnotationInspection.java
@@ -37,20 +37,15 @@ public class DeprecatedLombokAnnotationInspection extends LombokJavaInspectionBa
checkFor("lombok.experimental.Wither", LombokClassNames.WITH, annotation);
}
- private void checkFor(String deprecatedAnnotationFQN, String newAnnotationFQN, PsiAnnotation psiAnnotation) {
- if (psiAnnotation.hasQualifiedName(deprecatedAnnotationFQN)) {
+ private void checkFor(String deprecatedFQN, String newFQN, PsiAnnotation psiAnnotation) {
+ if (psiAnnotation.hasQualifiedName(deprecatedFQN)) {
final PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(psiAnnotation, PsiModifierListOwner.class, false);
if (null != listOwner) {
-
- holder.registerProblem(psiAnnotation,
- LombokBundle
- .message("inspection.message.lombok.annotation.deprecated.not.supported", deprecatedAnnotationFQN,
- newAnnotationFQN),
- ProblemHighlightType.ERROR,
- new AddAnnotationFix(newAnnotationFQN,
- listOwner,
+ String message = LombokBundle.message("inspection.message.lombok.annotation.deprecated.not.supported", deprecatedFQN, newFQN);
+ holder.registerProblem(psiAnnotation, message, ProblemHighlightType.ERROR,
+ new AddAnnotationFix(newFQN, listOwner,
psiAnnotation.getParameterList().getAttributes(),
- deprecatedAnnotationFQN));
+ deprecatedFQN));
}
}
}
diff --git a/plugins/lombok/src/main/resources/intentionDescriptions/ReplaceSynchronizedWithLombokAction/after.java.template b/plugins/lombok/src/main/resources/intentionDescriptions/ReplaceSynchronizedWithLombokAction/after.java.template
new file mode 100644
index 000000000000..163c4db88c0b
--- /dev/null
+++ b/plugins/lombok/src/main/resources/intentionDescriptions/ReplaceSynchronizedWithLombokAction/after.java.template
@@ -0,0 +1,9 @@
+import lombok.Synchronized;
+
+public class X {
+
+ @Synchronized
+ public void doSomething() {
+ // do something
+ }
+}
\ No newline at end of file
diff --git a/plugins/lombok/src/main/resources/intentionDescriptions/ReplaceSynchronizedWithLombokAction/before.java.template b/plugins/lombok/src/main/resources/intentionDescriptions/ReplaceSynchronizedWithLombokAction/before.java.template
new file mode 100644
index 000000000000..88def5e3d2db
--- /dev/null
+++ b/plugins/lombok/src/main/resources/intentionDescriptions/ReplaceSynchronizedWithLombokAction/before.java.template
@@ -0,0 +1,6 @@
+public class X {
+
+ public
synchronized modifiers, that can be converted to Lombok's @Synchronized annotation
+See for more details
+ + diff --git a/plugins/lombok/src/main/resources/messages/LombokBundle.properties b/plugins/lombok/src/main/resources/messages/LombokBundle.properties index e4516722bbe9..50131f5c7bc9 100644 --- a/plugins/lombok/src/main/resources/messages/LombokBundle.properties +++ b/plugins/lombok/src/main/resources/messages/LombokBundle.properties @@ -13,7 +13,7 @@ replace.explicit.type.with.0.lombok=Replace explicit type with ''{0}'' (Lombok) dialog.message.logger.field.s.not.private.sfinal.field.named.s.refactor.anyway=Logger field: "{0}" Is not private {1, choice, 0#|1#static }final field named "{2}". Refactor anyway? dialog.title.attention=Attention! dialog.message.this.element.cannot.be.renamed=This element cannot be renamed. -inspection.message.lombok.annotation.deprecated.not.supported=Lombok's annotation ''{0}'' is deprecated and not supported by lombok-plugin anymore. Use ''{1}'' instead. +inspection.message.lombok.annotation.deprecated.not.supported=Lombok''s annotation ''{0}'' is deprecated and not supported by lombok-plugin anymore. Use ''{1}'' instead. inspection.message.default.constructor.doesn.t.exist=Default constructor doesn't exist inspection.message.slf4j.logger.defined.explicitly=Slf4j Logger is defined explicitly. Use Lombok @Slf4j annotation instead. intention.name.replace.with.lombok=Replace with Lombok @@ -104,8 +104,8 @@ inspection.message.s.can.be.used.on.classes.only=''@{0}'' can be used on classes inspection.message.syntax.either.obtain.via.field=The syntax is either @ObtainVia(field = "fieldName") or @ObtainVia(method = "methodName"). inspection.message.lombok.annotations.are.not.allowed.on.builder.class=Lombok's annotations are not allowed on builder class. inspection.message.s.not.valid.identifier=''{0}'' is not a valid identifier -inspection.message.can.t.singularize.this.name=Can't singularize this name: ''{0}''; please specify the singular explicitly (i.e. @Singular("sheep")) -inspection.message.lombok.does.not.know=Lombok does not know how to create the singular-form builder methods for type ''{0}''; they won't be generated. +inspection.message.can.t.singularize.this.name=Can''t singularize this name: ''{0}''; please specify the singular explicitly (i.e. @Singular("sheep")) +inspection.message.lombok.does.not.know=Lombok does not know how to create the singular-form builder methods for type ''{0}''; they won''t be generated. inspection.message.builder.default.requires.initializing.expression=@Builder.Default requires an initializing expression (' = something;'). inspection.message.builder.default.singular.cannot.be.mixed=@Builder.Default and @Singular cannot be mixed. inspection.message.obtain.via.is.static.true.not.valid.unless.method.has.been.set=@ObtainVia(isStatic = true) is not valid unless 'method' has been set. diff --git a/plugins/lombok/src/test/java/de/plushnikov/intellij/plugin/inspection/DeprecatedLombokAnnotationInspectionTest.java b/plugins/lombok/src/test/java/de/plushnikov/intellij/plugin/inspection/DeprecatedLombokAnnotationInspectionTest.java new file mode 100644 index 000000000000..ad513dc13fdb --- /dev/null +++ b/plugins/lombok/src/test/java/de/plushnikov/intellij/plugin/inspection/DeprecatedLombokAnnotationInspectionTest.java @@ -0,0 +1,68 @@ +package de.plushnikov.intellij.plugin.inspection; + +import com.intellij.codeInspection.InspectionProfileEntry; +import org.intellij.lang.annotations.Language; + +public class DeprecatedLombokAnnotationInspectionTest extends LombokInspectionTest { + + @Override + protected InspectionProfileEntry getInspection() { + return new DeprecatedLombokAnnotationInspection(); + } + + private void addOldClassDefinition(String className) { + final @Language("JAVA") String template = """ + package lombok.experimental; + + import java.lang.annotation.ElementType; + import java.lang.annotation.Retention; + import java.lang.annotation.RetentionPolicy; + import java.lang.annotation.Target; + + @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE, ElementType.ANNOTATION_TYPE}) + @Retention(RetentionPolicy.RUNTIME) + public @interface {className} { + String value() default ""; + }"""; + myFixture.addClass(template.replace("{className}", className)); + } + + public void testDeprecatedBuilder() { + final @Language("JAVA") String testClassText = """ +