aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok/eclipse
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2015-11-22 23:47:24 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2015-11-22 23:47:24 +0100
commitb8ced807a79660eef87f1833d1ec95d774a4f4a2 (patch)
treec0252d68a2eae613d18c552fe5bfd9be02e70a03 /src/eclipseAgent/lombok/eclipse
parentba2cde332acedebb0905fb8c42bc516b07400917 (diff)
downloadlombok-b8ced807a79660eef87f1833d1ec95d774a4f4a2.tar.gz
lombok-b8ced807a79660eef87f1833d1ec95d774a4f4a2.tar.bz2
lombok-b8ced807a79660eef87f1833d1ec95d774a4f4a2.zip
[Fixes #970] Eclipse would generate some internal IDE errors if using ‘val’ on invalid expressions. This fixes one such case.
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchVal.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
index 30574ea6..2b8dfbaa 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
@@ -57,6 +57,9 @@ public class PatchVal {
return expr.resolveType(scope);
} catch (NullPointerException e) {
return null;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // This will occur internally due to for example 'val x = mth("X");', where mth takes 2 arguments.
+ return null;
}
}
@@ -66,6 +69,9 @@ public class PatchVal {
return expr.resolveType(scope);
} catch (NullPointerException e) {
return null;
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // This will occur internally due to for example 'val x = mth("X");', where mth takes 2 arguments.
+ return null;
}
}
@@ -164,7 +170,7 @@ public class PatchVal {
TypeBinding resolved = null;
try {
- resolved = decomponent ? getForEachComponentType(init, scope) : init.resolveType(scope);
+ resolved = decomponent ? getForEachComponentType(init, scope) : resolveForExpression(init, 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
@@ -222,7 +228,7 @@ public class PatchVal {
private static TypeBinding getForEachComponentType(Expression collection, BlockScope scope) {
if (collection != null) {
TypeBinding resolved = collection.resolvedType;
- if (resolved == null) resolved = collection.resolveType(scope);
+ if (resolved == null) resolved = resolveForExpression(collection, scope);
if (resolved == null) return null;
if (resolved.isArrayType()) {
resolved = ((ArrayBinding) resolved).elementsType();
@@ -250,4 +256,13 @@ public class PatchVal {
return null;
}
+
+ private static TypeBinding resolveForExpression(Expression collection, BlockScope scope) {
+ try {
+ return collection.resolveType(scope);
+ } catch (ArrayIndexOutOfBoundsException e) {
+ // Known cause of issues; for example: val e = mth("X"), where mth takes 2 arguments.
+ return null;
+ }
+ }
}