aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2018-06-05 01:02:16 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2018-06-05 01:02:16 +0200
commit21b415df8be450d216e1305abf5da8eb4630c265 (patch)
tree649765d0dcdc373ef9f83456a1f924cc50e7715a /src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java
parent6e0f7eca3d17bfd13768a5c4d5a754b4b45c41b5 (diff)
downloadlombok-21b415df8be450d216e1305abf5da8eb4630c265.tar.gz
lombok-21b415df8be450d216e1305abf5da8eb4630c265.tar.bz2
lombok-21b415df8be450d216e1305abf5da8eb4630c265.zip
Fixes #1676 at least for eclipse: You can now use java10 var in an eclipse that supports this, without lombok getting in the way.
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java b/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java
index 46237dcf..d59b6a2e 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java
@@ -45,6 +45,7 @@ import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.ForeachStatement;
+import org.eclipse.jdt.internal.compiler.ast.ImportReference;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
@@ -66,8 +67,8 @@ public class PatchValEclipse {
ForeachStatement foreachDecl = (ForeachStatement) astStack[astPtr];
ASTNode init = foreachDecl.collection;
if (init == null) return;
- boolean val = couldBeVal(foreachDecl.elementVariable.type);
- boolean var = couldBeVar(foreachDecl.elementVariable.type);
+ boolean val = couldBeVal(parser == null ? null : parser.compilationUnit == null ? null : parser.compilationUnit.imports, foreachDecl.elementVariable.type);
+ boolean var = couldBeVar(parser == null ? null : parser.compilationUnit == null ? null : parser.compilationUnit.imports, foreachDecl.elementVariable.type);
if (foreachDecl.elementVariable == null || !(val || var)) return;
try {
@@ -91,8 +92,8 @@ public class PatchValEclipse {
if (!(variableDecl instanceof LocalDeclaration)) return;
ASTNode init = variableDecl.initialization;
if (init == null) return;
- boolean val = couldBeVal(variableDecl.type);
- boolean var = couldBeVar(variableDecl.type);
+ boolean val = couldBeVal(parser == null ? null : parser.compilationUnit == null ? null : parser.compilationUnit.imports, variableDecl.type);
+ boolean var = couldBeVar(parser == null ? null : parser.compilationUnit == null ? null : parser.compilationUnit.imports, variableDecl.type);
if (!(val || var)) return;
try {
@@ -102,8 +103,8 @@ public class PatchValEclipse {
}
}
- private static boolean couldBeVar(TypeReference type) {
- return PatchVal.couldBe("lombok.experimental.var", type) || PatchVal.couldBe("lombok.var", type);
+ private static boolean couldBeVar(ImportReference[] imports, TypeReference type) {
+ return PatchVal.couldBe(imports, "lombok.experimental.var", type) || PatchVal.couldBe(imports, "lombok.var", type);
}
public static void addFinalAndValAnnotationToSingleVariableDeclaration(Object converter, SingleVariableDeclaration out, LocalDeclaration in) {
@@ -124,7 +125,7 @@ public class PatchValEclipse {
Annotation valAnnotation = null;
for (Annotation ann : in.annotations) {
- if (couldBeVal(ann.type)) {
+ if (couldBeVal(null, ann.type)) {
found = true;
valAnnotation = ann;
break;
@@ -176,8 +177,8 @@ public class PatchValEclipse {
}
}
- private static boolean couldBeVal(TypeReference type) {
- return PatchVal.couldBe("lombok.val", type);
+ private static boolean couldBeVal(ImportReference[] imports, TypeReference type) {
+ return PatchVal.couldBe(imports, "lombok.val", type);
}
public static Modifier createModifier(AST ast, ModifierKeyword keyword, int start, int end) {