|
55 | 55 | import javax.lang.model.SourceVersion;
|
56 | 56 | import javax.lang.model.element.Element;
|
57 | 57 | import javax.lang.model.element.ElementKind;
|
| 58 | +import javax.lang.model.element.ExecutableElement; |
58 | 59 | import javax.lang.model.element.TypeElement;
|
| 60 | +import javax.lang.model.element.VariableElement; |
| 61 | +import javax.lang.model.type.DeclaredType; |
59 | 62 | import javax.lang.model.type.TypeMirror;
|
60 | 63 | import javax.tools.Diagnostic.Kind;
|
61 | 64 | import javax.tools.JavaFileObject;
|
@@ -218,22 +221,41 @@ private HashMap<TypeElement, Set<TpSlotData>> collectEnclosingTypes(RoundEnviron
|
218 | 221 | for (Element e : elements) {
|
219 | 222 | log("Checking type '%s'", e);
|
220 | 223 | if (e.getKind() != ElementKind.CLASS) {
|
221 |
| - throw error(e, "@TpSlot annotation is applicable only to classes."); |
| 224 | + throw error(e, "@%s annotation is applicable only to classes.", Slot.class.getSimpleName()); |
222 | 225 | }
|
223 | 226 | TypeElement type = (TypeElement) e;
|
224 | 227 | if (type.getEnclosingElement() == null) {
|
225 |
| - throw error(e, "@TpSlot annotation supports only inner classes at moment."); |
| 228 | + throw error(e, "@%s annotation supports only inner classes at moment.", Slot.class.getSimpleName()); |
226 | 229 | }
|
227 | 230 |
|
228 | 231 | TypeElement enclosingType = (TypeElement) type.getEnclosingElement();
|
229 | 232 | for (Slot slotAnnotation : e.getAnnotationsByType(Slot.class)) {
|
| 233 | + if (!slotAnnotation.isComplex()) { |
| 234 | + verifySimpleNode(type); |
| 235 | + } |
230 | 236 | var tpSlotDataSet = enclosingTypes.computeIfAbsent(enclosingType, k -> new HashSet<>());
|
231 | 237 | tpSlotDataSet.add(new TpSlotData(slotAnnotation, enclosingType, type));
|
232 | 238 | }
|
233 | 239 | }
|
234 | 240 | return enclosingTypes;
|
235 | 241 | }
|
236 | 242 |
|
| 243 | + private static void verifySimpleNode(TypeElement type) throws ProcessingError { |
| 244 | + for (Element enclosed : type.getEnclosedElements()) { |
| 245 | + if (enclosed instanceof ExecutableElement executable) { |
| 246 | + if (executable.getAnnotationMirrors().stream().anyMatch(x -> x.getAnnotationType().asElement().getSimpleName().contentEquals("Specialization"))) { |
| 247 | + for (VariableElement param : executable.getParameters()) { |
| 248 | + if (param.asType() instanceof DeclaredType declType) { |
| 249 | + if (declType.asElement().getSimpleName().contentEquals("VirtualFrame")) { |
| 250 | + throw new ProcessingError(type, "Slot node has isComplex=false (the default), but seems to have methods that take VirtualFrame"); |
| 251 | + } |
| 252 | + } |
| 253 | + } |
| 254 | + } |
| 255 | + } |
| 256 | + } |
| 257 | + } |
| 258 | + |
237 | 259 | private static String getNodeFactory(TpSlotData slot, TypeElement node) {
|
238 | 260 | return slot.enclosingType.getQualifiedName() + "Factory." + node.getSimpleName() + "Factory";
|
239 | 261 | }
|
|
0 commit comments