diff options
author | Till Brychcy <till.brychcy@mercateo.com> | 2019-06-15 11:41:40 +0200 |
---|---|---|
committer | Till Brychcy <till.brychcy@mercateo.com> | 2019-06-15 17:03:09 +0200 |
commit | 8a6603d191f7b8d1f27d32f3b2fa25d1c2eb8e53 (patch) | |
tree | bbeaa9d76d8b31e83126dd7eec62bc33cb28810c /src/eclipseAgent/lombok/eclipse | |
parent | d9b8b14575280cd6411a6a157b6c4e8117edb1ba (diff) | |
download | lombok-8a6603d191f7b8d1f27d32f3b2fa25d1c2eb8e53.tar.gz lombok-8a6603d191f7b8d1f27d32f3b2fa25d1c2eb8e53.tar.bz2 lombok-8a6603d191f7b8d1f27d32f3b2fa25d1c2eb8e53.zip |
Avoid Eclipse warnings about null checks generated for lombok.NonNull when NonNullByDefault is used
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index 0e74dfaf..24c1216e 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -122,6 +122,7 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { patchEcjTransformers(sm, ecjOnly); patchExtensionMethod(sm, ecjOnly); patchRenameField(sm); + patchNullCheck(sm); if (reloadExistingClasses) sm.reloadClasses(instrumentation); } @@ -774,4 +775,24 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { .build()); } } + + private static void patchNullCheck(ScriptManager sm) { + /* Avoid warnings caused by the null check generated for lombok.NonNull if NonNullByDefault is used. */ + + /* Avoid "Redundant null check: comparing '@NonNull String' against null" */ + sm.addScript(ScriptBuilder.exitEarly() + .target(new MethodTarget("org.eclipse.jdt.internal.compiler.problem.ProblemReporter", "expressionNonNullComparison", "boolean", "org.eclipse.jdt.internal.compiler.ast.Expression", "boolean")) + .decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.internal.compiler.ast.ASTNode")) + .valueMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "returnTrue", "boolean", "java.lang.Object")) + .request(StackRequest.PARAM1) + .transplant().build()); + + /* Avoid "Dead code" */ + sm.addScript(ScriptBuilder.exitEarly() + .target(new MethodTarget("org.eclipse.jdt.internal.compiler.problem.ProblemReporter", "fakeReachable", "void", "org.eclipse.jdt.internal.compiler.ast.ASTNode")) + .decisionMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "isGenerated", "boolean", "org.eclipse.jdt.internal.compiler.ast.ASTNode")) + .request(StackRequest.PARAM1) + .transplant().build()); + } + } |