aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2019-02-19 01:47:49 +0100
committerRoel Spilker <r.spilker@gmail.com>2019-02-19 01:47:49 +0100
commit8479edb4262a7eb8cb76baba138f0ea5aae841c5 (patch)
tree06be11d07b5b216f8a5d422b00a4f800391ceeb3 /src/core/lombok
parentfd9045dac2a3d9b26125b8ccc865b23d8f7cd8d4 (diff)
downloadlombok-8479edb4262a7eb8cb76baba138f0ea5aae841c5.tar.gz
lombok-8479edb4262a7eb8cb76baba138f0ea5aae841c5.tar.bz2
lombok-8479edb4262a7eb8cb76baba138f0ea5aae841c5.zip
var/val in Eclipse can now handle intersection types, fixes #1986
Diffstat (limited to 'src/core/lombok')
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 026c2383..9439caf3 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2018 The Project Lombok Authors.
+ * Copyright (C) 2009-2019 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -306,10 +306,14 @@ public class EclipseHandlerUtil {
public static final Field STRING_LITERAL__LINE_NUMBER;
public static final Field ANNOTATION__MEMBER_VALUE_PAIR_NAME;
public static final Field TYPE_REFERENCE__ANNOTATIONS;
+ public static final Class<?> INTERSECTION_BINDING;
+ public static final Field INTERSECTION_BINDING_TYPES;
static {
STRING_LITERAL__LINE_NUMBER = getField(StringLiteral.class, "lineNumber");
ANNOTATION__MEMBER_VALUE_PAIR_NAME = getField(Annotation.class, "memberValuePairName");
TYPE_REFERENCE__ANNOTATIONS = getField(TypeReference.class, "annotations");
+ INTERSECTION_BINDING = getClass("org.eclipse.jdt.internal.compiler.lookup.IntersectionTypeBinding18");
+ INTERSECTION_BINDING_TYPES = INTERSECTION_BINDING == null ? null : getField(INTERSECTION_BINDING, "intersectingTypes");
}
public static int reflectInt(Field f, Object o) {
@@ -336,6 +340,14 @@ public class EclipseHandlerUtil {
}
}
+ private static Class<?> getClass(String fqn) {
+ try {
+ return Class.forName(fqn);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
private static Field getField(Class<?> c, String fName) {
try {
return Permit.getField(c, fName);
@@ -791,6 +803,11 @@ public class EclipseHandlerUtil {
}
public static TypeReference makeType(TypeBinding binding, ASTNode pos, boolean allowCompound) {
+
+ if (binding.getClass() == EclipseReflectiveMembers.INTERSECTION_BINDING) {
+ Object[] arr = (Object[]) EclipseReflectiveMembers.reflect(EclipseReflectiveMembers.INTERSECTION_BINDING_TYPES, binding);
+ binding = (TypeBinding) arr[0];
+ }
int dims = binding.dimensions();
binding = binding.leafComponentType();