diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index e4954f9b72..18d6594af0 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -875,6 +875,14 @@ private static void patchFixSourceTypeConverter(ScriptManager sm) { .target(new MethodTarget(SOURCE_TYPE_CONVERTER_SIG, "convertAnnotations", ANNOTATION_SIG + "[]", I_ANNOTATABLE_SIG)) .wrapMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "convertAnnotations", ANNOTATION_SIG + "[]", ANNOTATION_SIG + "[]", I_ANNOTATABLE_SIG)) .request(StackRequest.PARAM1, StackRequest.RETURN_VALUE).build()); + + sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.exitEarly() + .target(new MethodTarget(SOURCE_TYPE_CONVERTER_SIG, "parseMemberValue", "org.eclipse.jdt.internal.compiler.ast.Expression", "char[]")) + .decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "isEmpty", "boolean", "char[]")) + .valueMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "returnNullExpression", "org.eclipse.jdt.internal.compiler.ast.Expression", "java.lang.Object")) + .request(StackRequest.PARAM1) + .transplant() + .build()); } private static void patchEclipseDebugPatches(ScriptManager sm) { diff --git a/src/eclipseAgent/lombok/launch/PatchFixesHider.java b/src/eclipseAgent/lombok/launch/PatchFixesHider.java index 7ba663ccf4..1d29241001 100755 --- a/src/eclipseAgent/lombok/launch/PatchFixesHider.java +++ b/src/eclipseAgent/lombok/launch/PatchFixesHider.java @@ -892,6 +892,14 @@ public static Annotation[] convertAnnotations(Annotation[] out, IAnnotatable ann return replace; } + public static boolean isEmpty(char[] array) { + return array.length == 0; + } + + public static Expression returnNullExpression(Object string) { + return null; + } + public static String getRealNodeSource(String original, org.eclipse.jdt.internal.compiler.ast.ASTNode node) { if (!isGenerated(node)) return original; diff --git a/test/eclipse/resource/noerrors/synchronizedUsage/ClassWithSynchronized.java b/test/eclipse/resource/noerrors/synchronizedUsage/ClassWithSynchronized.java new file mode 100644 index 0000000000..736ffafaf4 --- /dev/null +++ b/test/eclipse/resource/noerrors/synchronizedUsage/ClassWithSynchronized.java @@ -0,0 +1,9 @@ +package pkg; + +import lombok.Synchronized; + +public class ClassWithSynchronized { + @Synchronized + public void test() { + } +} \ No newline at end of file diff --git a/test/eclipse/resource/noerrors/synchronizedUsage/Usage.java b/test/eclipse/resource/noerrors/synchronizedUsage/Usage.java new file mode 100644 index 0000000000..f871e5ee03 --- /dev/null +++ b/test/eclipse/resource/noerrors/synchronizedUsage/Usage.java @@ -0,0 +1,10 @@ +package pkg; + +public class Usage { + private ClassWithSynchronized test; + + // Prevent "The value of the field Usage.test is not used" + public void test() { + test.test(); + } +} \ No newline at end of file diff --git a/test/eclipse/src/lombok/eclipse/compile/NoErrorsTest.java b/test/eclipse/src/lombok/eclipse/compile/NoErrorsTest.java index d504967051..a140b6979a 100644 --- a/test/eclipse/src/lombok/eclipse/compile/NoErrorsTest.java +++ b/test/eclipse/src/lombok/eclipse/compile/NoErrorsTest.java @@ -21,9 +21,10 @@ */ package lombok.eclipse.compile; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.eclipse.jdt.core.ICompilationUnit; @@ -49,7 +50,7 @@ public void fieldNameConstantsInAnnotation() throws Exception { ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("Usage.java"); List problems = collectProblems(cu); - assertTrue(problems.isEmpty()); + assertEquals(Collections.emptyList(), problems); } @Test @@ -57,7 +58,15 @@ public void builderJavadoc() throws Exception { ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("Usage.java"); List problems = collectProblems(cu); - assertTrue(problems.isEmpty()); + assertEquals(Collections.emptyList(), problems); + } + + @Test + public void synchronizedUsage() throws Exception { + ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("Usage.java"); + + List problems = collectProblems(cu); + assertEquals(Collections.emptyList(), problems); } private List collectProblems(ICompilationUnit cu) throws JavaModelException {