Merge branch 'eclipse-synchronized-error' of https://github.com/Rawi01/lombok into eclipse-synchronized-error

This commit is contained in:
Reinier Zwitserloot committed 2024-10-18 00:07:39 +02:00
commit 1ac535f644
5 files changed
+47 -3

No files matched your search

@@ -875,6 +875,14 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable {
.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) {
@@ -892,6 +892,14 @@ final class PatchFixesHider {
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;
@@ -0,0 +1,9 @@
package pkg;
import lombok.Synchronized;
public class ClassWithSynchronized {
@Synchronized
public void test() {
}
}
@@ -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();
}
}
@@ -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 class NoErrorsTest {
ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("Usage.java");
List<IProblem> problems = collectProblems(cu);
assertTrue(problems.isEmpty());
assertEquals(Collections.emptyList(), problems);
}
@Test
@@ -57,7 +58,15 @@ public class NoErrorsTest {
ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("Usage.java");
List<IProblem> problems = collectProblems(cu);
assertTrue(problems.isEmpty());
assertEquals(Collections.emptyList(), problems);
}
@Test
public void synchronizedUsage() throws Exception {
ICompilationUnit cu = setup.getPackageFragment().getCompilationUnit("Usage.java");
List<IProblem> problems = collectProblems(cu);
assertEquals(Collections.emptyList(), problems);
}
private List<IProblem> collectProblems(ICompilationUnit cu) throws JavaModelException {