Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/codewriter/OrganizedImports.java @ 9968:3df534c97af1
Create Suites instance in runtime.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Mon, 10 Jun 2013 16:06:09 +0200 |
parents | 67bee207f20c |
children |
rev | line source |
---|---|
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.codegen.processor.codewriter; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import static com.oracle.truffle.codegen.processor.Utils.*; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import java.util.*; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 import javax.lang.model.element.*; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 import javax.lang.model.type.*; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 import javax.lang.model.util.*; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 import com.oracle.truffle.codegen.processor.*; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 import com.oracle.truffle.codegen.processor.ast.*; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 public final class OrganizedImports { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
38 private final Set<TypeMirror> staticImportUsage = new HashSet<>(); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 private final Map<String, TypeMirror> simpleNamesUsed = new HashMap<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 private final Set<String> declaredStaticMethods = new HashSet<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 private final Set<String> declaredStaticFields = new HashSet<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 private final Set<String> ambiguousStaticMethods = new HashSet<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 private final Set<String> ambiguousStaticFields = new HashSet<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 private final CodeTypeElement topLevelClass; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 private OrganizedImports(CodeTypeElement topLevelClass) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 this.topLevelClass = topLevelClass; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 public static OrganizedImports organize(CodeTypeElement topLevelClass) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 OrganizedImports organized = new OrganizedImports(topLevelClass); |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
55 organized.organizeImpl(); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 return organized; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
59 private void organizeImpl() { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
60 ImportTypeReferenceVisitor reference = new ImportTypeReferenceVisitor(); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
61 topLevelClass.accept(reference, null); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
62 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
63 processStaticImports(topLevelClass); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
64 List<TypeElement> types = Utils.getSuperTypes(topLevelClass); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
65 for (TypeElement typeElement : types) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
66 processStaticImports(typeElement); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
67 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
68 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
69 for (TypeMirror type : staticImportUsage) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
70 TypeElement element = fromTypeMirror(type); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
71 if (element != null) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
72 // already processed by supertype |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
73 if (types.contains(element)) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
74 continue; |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
75 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
76 processStaticImports(element); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
77 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
78 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
79 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
80 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
81 public String createTypeReference(Element enclosedElement, TypeMirror type) { |
7857
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
82 switch (type.getKind()) { |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
83 case BOOLEAN: |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
84 case BYTE: |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
85 case CHAR: |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
86 case DOUBLE: |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
87 case FLOAT: |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
88 case SHORT: |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
89 case INT: |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
90 case LONG: |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
91 case VOID: |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
92 return Utils.getSimpleName(type); |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
93 case DECLARED: |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
94 return createDeclaredTypeName(enclosedElement, (DeclaredType) type); |
7857
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
95 case ARRAY: |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
96 return createTypeReference(enclosedElement, ((ArrayType) type).getComponentType()) + "[]"; |
7857
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
97 case WILDCARD: |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
98 return createWildcardName(enclosedElement, (WildcardType) type); |
7857
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
99 case TYPEVAR: |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
100 return "?"; |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
101 default: |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
102 throw new RuntimeException("Unknown type specified " + type.getKind() + " mirror: " + type); |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
103 } |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
104 } |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
105 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
106 public String createStaticFieldReference(Element enclosedElement, TypeMirror type, String fieldName) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
107 return createStaticReference(enclosedElement, type, fieldName, ambiguousStaticFields, declaredStaticFields); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
108 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
109 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
110 public String createStaticMethodReference(Element enclosedElement, TypeMirror type, String methodName) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
111 return createStaticReference(enclosedElement, type, methodName, ambiguousStaticMethods, declaredStaticMethods); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
112 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
113 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
114 private String createStaticReference(Element enclosedElement, TypeMirror type, String name, Set<String> ambiguousSymbols, Set<String> declaredSymbols) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
115 if (ambiguousSymbols.contains(name)) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
116 // ambiguous import |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
117 return createTypeReference(enclosedElement, type) + "." + name; |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
118 } else if (!declaredSymbols.contains(name)) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
119 // not imported at all |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
120 return createTypeReference(enclosedElement, type) + "." + name; |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
121 } else { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
122 // import declared and not ambiguous |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
123 return name; |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
124 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
125 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
126 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
127 private String createWildcardName(Element enclosedElement, WildcardType type) { |
7857
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
128 StringBuilder b = new StringBuilder(); |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
129 if (type.getExtendsBound() != null) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
130 b.append("? extends ").append(createTypeReference(enclosedElement, type.getExtendsBound())); |
7857
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
131 } else if (type.getSuperBound() != null) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
132 b.append("? super ").append(createTypeReference(enclosedElement, type.getExtendsBound())); |
7857
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
133 } |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
134 return b.toString(); |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
135 } |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
136 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
137 private String createDeclaredTypeName(Element enclosedElement, DeclaredType type) { |
7857
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
138 String name = type.asElement().getSimpleName().toString(); |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
139 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
140 if (needsImport(enclosedElement, type)) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
141 TypeMirror usedByType = simpleNamesUsed.get(name); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
142 if (usedByType == null) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
143 simpleNamesUsed.put(name, type); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
144 usedByType = type; |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
145 } |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
146 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
147 if (!typeEquals(type, usedByType)) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
148 name = getQualifiedName(type); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
149 } |
7857
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
150 } |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
151 |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
152 if (type.getTypeArguments().size() == 0) { |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
153 return name; |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
154 } |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
155 |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
156 StringBuilder b = new StringBuilder(name); |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
157 b.append("<"); |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
158 if (type.getTypeArguments().size() > 0) { |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
159 for (int i = 0; i < type.getTypeArguments().size(); i++) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
160 b.append(createTypeReference(enclosedElement, type.getTypeArguments().get(i))); |
7857
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
161 if (i < type.getTypeArguments().size() - 1) { |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
162 b.append(", "); |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
163 } |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
164 } |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
165 } |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
166 b.append(">"); |
c8e1c5abf6ed
Organize imports now handles generic and array types properly.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
167 return b.toString(); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
168 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
169 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
170 public Set<CodeImport> generateImports() { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
171 Set<CodeImport> imports = new HashSet<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
172 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
173 imports.addAll(generateImports(simpleNamesUsed.values())); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
174 imports.addAll(generateStaticImports(staticImportUsage)); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
175 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
176 return imports; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
177 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
178 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
179 boolean processStaticImports(TypeElement element) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
180 Set<String> importedMethods = new HashSet<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
181 List<ExecutableElement> methods = ElementFilter.methodsIn(element.getEnclosedElements()); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
182 for (ExecutableElement method : methods) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
183 if (method.getModifiers().contains(Modifier.STATIC)) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
184 importedMethods.add(method.getSimpleName().toString()); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
185 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
186 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
187 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
188 boolean allMethodsAmbiguous = processStaticImportElements(importedMethods, this.ambiguousStaticMethods, this.declaredStaticMethods); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
189 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
190 Set<String> importedFields = new HashSet<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
191 List<VariableElement> fields = ElementFilter.fieldsIn(element.getEnclosedElements()); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
192 for (VariableElement field : fields) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
193 if (field.getModifiers().contains(Modifier.STATIC)) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
194 importedFields.add(field.getSimpleName().toString()); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
195 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
196 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
197 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
198 boolean allFieldsAmbiguous = processStaticImportElements(importedFields, this.ambiguousStaticFields, this.declaredStaticFields); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
199 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
200 return allMethodsAmbiguous && allFieldsAmbiguous; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
201 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
202 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
203 private static boolean processStaticImportElements(Set<String> newElements, Set<String> ambiguousElements, Set<String> declaredElements) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
204 boolean allAmbiguous = false; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
205 if (declaredElements.containsAll(newElements)) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7502
diff
changeset
|
206 // all types already declared -> we can remove the import completely -> they will all |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7502
diff
changeset
|
207 // get ambiguous |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
208 allAmbiguous = true; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
209 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
210 Set<String> newAmbiguous = new HashSet<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
211 Set<String> newDeclared = new HashSet<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
212 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
213 for (String newElement : newElements) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
214 if (declaredElements.contains(newElement)) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
215 newAmbiguous.add(newElement); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
216 } else if (ambiguousElements.contains(newElement)) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
217 // nothing to do |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
218 } else { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
219 newDeclared.add(newElement); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
220 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
221 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
222 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
223 ambiguousElements.addAll(newAmbiguous); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
224 declaredElements.addAll(newDeclared); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
225 return allAmbiguous; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
226 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
227 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
228 private boolean needsImport(Element enclosedElement, TypeMirror importType) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
229 String importPackagName = getPackageName(importType); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
230 if (importPackagName == null) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
231 return false; |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
232 } else if (importPackagName.equals("java.lang")) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
233 return false; |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
234 } else if (importPackagName.equals(getPackageName(topLevelClass)) && Utils.isTopLevelClass(importType)) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
235 return false; // same package name -> no import |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
236 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
237 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
238 List<Element> elements = Utils.getElementHierarchy(enclosedElement); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
239 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
240 Set<String> autoImportedTypes = new HashSet<>(); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
241 for (Element element : elements) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
242 if (element.getKind().isClass()) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
243 collectSuperTypeImports((TypeElement) element, autoImportedTypes); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
244 collectInnerTypeImports((TypeElement) element, autoImportedTypes); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
245 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
246 } |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
247 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
248 String qualifiedName = getQualifiedName(importType); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
249 if (autoImportedTypes.contains(qualifiedName)) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
250 return false; |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
251 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
252 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
253 return true; |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
254 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
255 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
256 private static Set<CodeImport> generateImports(Collection<TypeMirror> toGenerate) { |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
257 TreeSet<CodeImport> importObjects = new TreeSet<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
258 for (TypeMirror importType : toGenerate) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
259 importObjects.add(new CodeImport(importType, getQualifiedName(importType), false)); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
260 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
261 return importObjects; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
262 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
263 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
264 private static void collectInnerTypeImports(TypeElement e, Set<String> autoImportedTypes) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
265 autoImportedTypes.add(getQualifiedName(e)); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
266 for (TypeElement innerClass : ElementFilter.typesIn(e.getEnclosedElements())) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
267 collectInnerTypeImports(innerClass, autoImportedTypes); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
268 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
269 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
270 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
271 private static void collectSuperTypeImports(TypeElement e, Set<String> autoImportedTypes) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
272 List<TypeElement> superTypes = getSuperTypes(e); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
273 for (TypeElement superType : superTypes) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
274 List<TypeElement> declaredTypes = getDeclaredTypes(superType); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
275 for (TypeElement declaredType : declaredTypes) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
276 autoImportedTypes.add(getQualifiedName(declaredType)); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
277 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
278 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
279 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
280 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
281 private Set<CodeImport> generateStaticImports(Set<TypeMirror> toGenerate) { |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
282 Set<String> autoImportedStaticTypes = new HashSet<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
283 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
284 // if type is declared inside a super type of this class -> no import |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
285 autoImportedStaticTypes.add(getQualifiedName(topLevelClass)); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
286 autoImportedStaticTypes.addAll(getQualifiedSuperTypeNames(topLevelClass)); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
287 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
288 TreeSet<CodeImport> importObjects = new TreeSet<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
289 for (TypeMirror importType : toGenerate) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
290 if (getPackageName(importType) == null) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
291 continue; // no package name -> no import |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
292 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
293 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
294 String qualifiedName = getQualifiedName(importType); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
295 if (autoImportedStaticTypes.contains(qualifiedName)) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
296 continue; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
297 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
298 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
299 importObjects.add(new CodeImport(importType, qualifiedName + ".*", true)); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
300 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
301 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
302 return importObjects; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
303 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
304 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
305 private abstract static class TypeReferenceVisitor extends CodeElementScanner<Void, Void> { |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
306 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
307 @Override |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
308 public void visitTree(CodeTree e, Void p) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
309 if (e.getCodeKind() == CodeTreeKind.STATIC_FIELD_REFERENCE) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
310 visitStaticFieldReference(e, e.getType(), e.getString()); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
311 } else if (e.getCodeKind() == CodeTreeKind.STATIC_METHOD_REFERENCE) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
312 visitStaticMethodReference(e, e.getType(), e.getString()); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
313 } else if (e.getType() != null) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
314 visitTypeReference(e, e.getType()); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
315 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
316 super.visitTree(e, p); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
317 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
318 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
319 @Override |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
320 public Void visitExecutable(CodeExecutableElement e, Void p) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
321 visitAnnotations(e, e.getAnnotationMirrors()); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
322 if (e.getReturnType() != null) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
323 visitTypeReference(e, e.getReturnType()); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
324 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
325 for (TypeMirror type : e.getThrownTypes()) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
326 visitTypeReference(e, type); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
327 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
328 return super.visitExecutable(e, p); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
329 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
330 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
331 @Override |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
332 public Void visitType(CodeTypeElement e, Void p) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
333 visitAnnotations(e, e.getAnnotationMirrors()); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
334 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
335 visitTypeReference(e, e.getSuperclass()); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
336 for (TypeMirror type : e.getImplements()) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
337 visitTypeReference(e, type); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
338 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
339 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
340 return super.visitType(e, p); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
341 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
342 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
343 private void visitAnnotations(Element enclosingElement, List<? extends AnnotationMirror> mirrors) { |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
344 for (AnnotationMirror mirror : mirrors) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
345 visitAnnotation(enclosingElement, mirror); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
346 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
347 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
348 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
349 public void visitAnnotation(Element enclosingElement, AnnotationMirror e) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
350 visitTypeReference(enclosingElement, e.getAnnotationType()); |
8244
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
351 if (!e.getElementValues().isEmpty()) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
352 Map<? extends ExecutableElement, ? extends AnnotationValue> values = e.getElementValues(); |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
353 Set<? extends ExecutableElement> methodsSet = values.keySet(); |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
354 List<ExecutableElement> methodsList = new ArrayList<>(); |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
355 for (ExecutableElement method : methodsSet) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
356 if (values.get(method) == null) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
357 continue; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
358 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
359 methodsList.add(method); |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
360 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
361 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
362 for (int i = 0; i < methodsList.size(); i++) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
363 AnnotationValue value = values.get(methodsList.get(i)); |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
364 visitAnnotationValue(enclosingElement, value); |
8244
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
365 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
366 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
367 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
368 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
369 public void visitAnnotationValue(Element enclosingElement, AnnotationValue e) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
370 e.accept(new AnnotationValueReferenceVisitor(enclosingElement), null); |
8244
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
371 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
372 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
373 private class AnnotationValueReferenceVisitor extends AbstractAnnotationValueVisitor7<Void, Void> { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
374 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
375 private final Element enclosingElement; |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
376 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
377 public AnnotationValueReferenceVisitor(Element enclosedElement) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
378 this.enclosingElement = enclosedElement; |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
379 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
380 |
8244
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
381 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
382 public Void visitBoolean(boolean b, Void p) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
383 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
384 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
385 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
386 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
387 public Void visitByte(byte b, Void p) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
388 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
389 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
390 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
391 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
392 public Void visitChar(char c, Void p) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
393 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
394 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
395 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
396 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
397 public Void visitDouble(double d, Void p) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
398 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
399 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
400 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
401 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
402 public Void visitFloat(float f, Void p) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
403 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
404 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
405 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
406 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
407 public Void visitInt(int i, Void p) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
408 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
409 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
410 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
411 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
412 public Void visitLong(long i, Void p) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
413 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
414 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
415 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
416 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
417 public Void visitShort(short s, Void p) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
418 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
419 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
420 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
421 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
422 public Void visitString(String s, Void p) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
423 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
424 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
425 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
426 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
427 public Void visitType(TypeMirror t, Void p) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
428 visitTypeReference(enclosingElement, t); |
8244
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
429 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
430 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
431 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
432 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
433 public Void visitEnumConstant(VariableElement c, Void p) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
434 visitTypeReference(enclosingElement, c.asType()); |
8244
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
435 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
436 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
437 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
438 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
439 public Void visitAnnotation(AnnotationMirror a, Void p) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
440 TypeReferenceVisitor.this.visitAnnotation(enclosingElement, a); |
8244
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
441 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
442 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
443 |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
444 @Override |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
445 public Void visitArray(List<? extends AnnotationValue> vals, Void p) { |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
446 for (int i = 0; i < vals.size(); i++) { |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
447 TypeReferenceVisitor.this.visitAnnotationValue(enclosingElement, vals.get(i)); |
8244
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
448 } |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
449 return null; |
10d37f893471
Fixed import generation.
Christian Humer <christian.humer@gmail.com>
parents:
7857
diff
changeset
|
450 } |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
451 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
452 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
453 @Override |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
454 public Void visitVariable(VariableElement f, Void p) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
455 visitAnnotations(f, f.getAnnotationMirrors()); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
456 visitTypeReference(f, f.asType()); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
457 return super.visitVariable(f, p); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
458 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
459 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
460 @Override |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
461 public void visitImport(CodeImport e, Void p) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
462 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
463 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
464 public abstract void visitTypeReference(Element enclosedType, TypeMirror type); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
465 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
466 public abstract void visitStaticMethodReference(Element enclosedType, TypeMirror type, String elementName); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
467 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
468 public abstract void visitStaticFieldReference(Element enclosedType, TypeMirror type, String elementName); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
469 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
470 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
471 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
472 private class ImportTypeReferenceVisitor extends TypeReferenceVisitor { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
473 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
474 @Override |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
475 public void visitStaticFieldReference(Element enclosedType, TypeMirror type, String elementName) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
476 staticImportUsage.add(type); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
477 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
478 |
9221
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
479 @Override |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
480 public void visitStaticMethodReference(Element enclosedType, TypeMirror type, String elementName) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
481 staticImportUsage.add(type); |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
482 } |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
483 |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
484 @Override |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
485 public void visitTypeReference(Element enclosedType, TypeMirror type) { |
67bee207f20c
Made import generation more robust.
Christian Humer <christian.humer@gmail.com>
parents:
8244
diff
changeset
|
486 createTypeReference(enclosedType, type); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
487 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
488 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
489 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
490 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
491 } |