Skip to content

Commit

Permalink
Merge pull request #112 in G/truffle from ~CHRISTIAN.HUMER_ORACLE.COM…
Browse files Browse the repository at this point in the history
…/truffle:fix_dsl_for_eclipse_neon to master

* commit '9d6708adf9d1a57d32f15ecd5bf2063790d83244':
  Fix DSL JDT compiler support for Eclipse Neon.
  • Loading branch information
chumer committed Jun 26, 2016
2 parents 606e36f + 9d6708a commit 26cc3e2
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class JDTCompiler extends AbstractCompiler {

public static boolean isValidElement(Element currentElement) {
try {
Class<?> elementClass = Class.forName("org.eclipse.jdt.internal.compiler.apt.model.ElementImpl");
Class<?> elementClass = currentElement.getClass().getClassLoader().loadClass("org.eclipse.jdt.internal.compiler.apt.model.ElementImpl");
return elementClass.isAssignableFrom(currentElement.getClass());
} catch (ClassNotFoundException e) {
return false;
Expand Down Expand Up @@ -145,8 +145,9 @@ private static List<Object> lookupDeclarationOrder(TypeElement type) {
List<Object> declarationOrder;
try {
Object binding = field(type, "_binding");
Class<?> sourceTypeBinding = Class.forName("org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding");
Class<?> binaryTypeBinding = Class.forName("org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding");
ClassLoader classLoader = binding.getClass().getClassLoader();
Class<?> sourceTypeBinding = classLoader.loadClass("org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding");
Class<?> binaryTypeBinding = classLoader.loadClass("org.eclipse.jdt.internal.compiler.lookup.BinaryTypeBinding");

declarationOrder = null;
if (sourceTypeBinding.isAssignableFrom(binding.getClass())) {
Expand Down Expand Up @@ -190,9 +191,10 @@ public int compare(Object o1, Object o2) {
}
});

Class<?> binaryMethod = Class.forName("org.eclipse.jdt.internal.compiler.env.IBinaryMethod");
Class<?> binaryField = Class.forName("org.eclipse.jdt.internal.compiler.env.IBinaryField");
Class<?> nestedType = Class.forName("org.eclipse.jdt.internal.compiler.env.IBinaryNestedType");
ClassLoader classLoader = binding.getClass().getClassLoader();
Class<?> binaryMethod = classLoader.loadClass("org.eclipse.jdt.internal.compiler.env.IBinaryMethod");
Class<?> binaryField = classLoader.loadClass("org.eclipse.jdt.internal.compiler.env.IBinaryField");
Class<?> nestedType = classLoader.loadClass("org.eclipse.jdt.internal.compiler.env.IBinaryNestedType");

List<Object> bindings = new ArrayList<>();
for (Object sortedElement : sortedElements) {
Expand Down Expand Up @@ -304,8 +306,9 @@ private static char[] getSource(Element element) throws Exception {
*/

Object binding = field(element, "_binding");
Class<?> methodBindingClass = Class.forName("org.eclipse.jdt.internal.compiler.lookup.MethodBinding");
Class<?> referenceBindingClass = Class.forName("org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding");
ClassLoader classLoader = binding.getClass().getClassLoader();
Class<?> methodBindingClass = classLoader.loadClass("org.eclipse.jdt.internal.compiler.lookup.MethodBinding");
Class<?> referenceBindingClass = classLoader.loadClass("org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding");

char[] source = null;
if (methodBindingClass.isAssignableFrom(binding.getClass())) {
Expand Down

0 comments on commit 26cc3e2

Please sign in to comment.