Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/java/transform/OrganizedImports.java @ 16923:93e061157811
Truffle-DSL: better support for types with type arguments.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 25 Aug 2014 20:59:56 +0200 |
parents | d3f282a9e287 |
children | c22714b214d0 |
comparison
equal
deleted
inserted
replaced
16922:0ea0c4133b78 | 16923:93e061157811 |
---|---|
105 StringBuilder b = new StringBuilder(); | 105 StringBuilder b = new StringBuilder(); |
106 if (type.getExtendsBound() != null) { | 106 if (type.getExtendsBound() != null) { |
107 b.append("? extends ").append(createTypeReference(enclosedElement, type.getExtendsBound())); | 107 b.append("? extends ").append(createTypeReference(enclosedElement, type.getExtendsBound())); |
108 } else if (type.getSuperBound() != null) { | 108 } else if (type.getSuperBound() != null) { |
109 b.append("? super ").append(createTypeReference(enclosedElement, type.getExtendsBound())); | 109 b.append("? super ").append(createTypeReference(enclosedElement, type.getExtendsBound())); |
110 } else { | |
111 b.append("?"); | |
110 } | 112 } |
111 return b.toString(); | 113 return b.toString(); |
112 } | 114 } |
113 | 115 |
114 private String createDeclaredTypeName(Element enclosedElement, DeclaredType type) { | 116 private String createDeclaredTypeName(Element enclosedElement, DeclaredType type) { |
120 if (!qualifiedName.equals(qualifiedImport)) { | 122 if (!qualifiedName.equals(qualifiedImport)) { |
121 name = qualifiedName; | 123 name = qualifiedName; |
122 } | 124 } |
123 } | 125 } |
124 | 126 |
125 if (type.getTypeArguments().size() == 0) { | 127 List<? extends TypeMirror> genericTypes = type.getTypeArguments(); |
128 if (genericTypes.size() == 0) { | |
126 return name; | 129 return name; |
127 } | 130 } |
128 | 131 |
129 StringBuilder b = new StringBuilder(name); | 132 StringBuilder b = new StringBuilder(name); |
130 b.append("<"); | 133 b.append("<"); |
131 if (type.getTypeArguments().size() > 0) { | 134 for (int i = 0; i < genericTypes.size(); i++) { |
132 for (int i = 0; i < type.getTypeArguments().size(); i++) { | 135 TypeMirror genericType = i < genericTypes.size() ? genericTypes.get(i) : null; |
133 b.append(createTypeReference(enclosedElement, type.getTypeArguments().get(i))); | 136 if (genericType != null) { |
134 if (i < type.getTypeArguments().size() - 1) { | 137 b.append(createTypeReference(enclosedElement, genericType)); |
135 b.append(", "); | 138 } else { |
136 } | 139 b.append("?"); |
140 } | |
141 | |
142 if (i < genericTypes.size() - 1) { | |
143 b.append(", "); | |
137 } | 144 } |
138 } | 145 } |
139 b.append(">"); | 146 b.append(">"); |
140 return b.toString(); | 147 return b.toString(); |
141 } | 148 } |