aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok
diff options
context:
space:
mode:
Diffstat (limited to 'src/eclipseAgent/lombok')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java5
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchVal.java27
2 files changed, 25 insertions, 7 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java
index d4b8c763..2370d3ff 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchFixes.java
@@ -256,10 +256,7 @@ public class PatchFixes {
org.eclipse.jdt.internal.compiler.ast.ASTNode internalNode) throws Exception {
if (internalNode == null || domNode == null) return;
boolean isGenerated = internalNode.getClass().getField("$generatedBy").get(internalNode) != null;
- if (isGenerated) {
- domNode.getClass().getField("$isGenerated").set(domNode, true);
- domNode.setFlags(domNode.getFlags() & ~org.eclipse.jdt.core.dom.ASTNode.ORIGINAL);
- }
+ if (isGenerated) domNode.getClass().getField("$isGenerated").set(domNode, true);
}
public static void setIsGeneratedFlagForName(org.eclipse.jdt.core.dom.Name name, Object internalNode) throws Exception {
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
index 16f11769..59fbe9d0 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
@@ -53,12 +53,20 @@ public class PatchVal {
public static TypeBinding skipResolveInitializerIfAlreadyCalled(Expression expr, BlockScope scope) {
if (expr.resolvedType != null) return expr.resolvedType;
- return expr.resolveType(scope);
+ try {
+ return expr.resolveType(scope);
+ } catch (NullPointerException e) {
+ return null;
+ }
}
public static TypeBinding skipResolveInitializerIfAlreadyCalled2(Expression expr, BlockScope scope, LocalDeclaration decl) {
if (decl != null && LocalDeclaration.class.equals(decl.getClass()) && expr.resolvedType != null) return expr.resolvedType;
- return expr.resolveType(scope);
+ try {
+ return expr.resolveType(scope);
+ } catch (NullPointerException e) {
+ return null;
+ }
}
public static boolean matches(String key, char[] array) {
@@ -143,7 +151,20 @@ public class PatchVal {
TypeReference replacement = null;
if (init != null) {
- TypeBinding resolved = decomponent ? getForEachComponentType(init, scope) : init.resolveType(scope);
+ if (init.getClass().getName().equals("org.eclipse.jdt.internal.compiler.ast.LambdaExpression")) {
+ return false;
+ }
+
+ TypeBinding resolved = null;
+ try {
+ resolved = decomponent ? getForEachComponentType(init, scope) : init.resolveType(scope);
+ } catch (NullPointerException e) {
+ // This definitely occurs if as part of resolving the initializer expression, a
+ // lambda expression in it must also be resolved (such as when lambdas are part of
+ // a ternary expression). This can't result in a viable 'val' matching, so, we
+ // just go with 'Object' and let the IDE print the appropriate errors.
+ resolved = null;
+ }
if (resolved != null) {
replacement = makeType(resolved, local.type, false);
}