Mercurial > hg > graal-jvmci-8
diff graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateParser.java @ 8252:0905d796944a
Refactored codegen error model to make error redirection a lot easier.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 13 Mar 2013 19:58:28 +0100 |
parents | 5e3d1a68664e |
children | 8b2573c8d47f |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateParser.java Wed Mar 13 11:32:43 2013 +0100 +++ b/graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateParser.java Wed Mar 13 19:58:28 2013 +0100 @@ -43,9 +43,8 @@ return extensionParser; } - protected boolean verifyExclusiveMethodAnnotation(TypeElement type, Class<?>... annotationTypes) { - boolean valid = true; - List<ExecutableElement> methods = ElementFilter.methodsIn(type.getEnclosedElements()); + protected void verifyExclusiveMethodAnnotation(Template template, Class<?>... annotationTypes) { + List<ExecutableElement> methods = ElementFilter.methodsIn(template.getTemplateType().getEnclosedElements()); for (ExecutableElement method : methods) { List<AnnotationMirror> foundAnnotations = new ArrayList<>(); for (int i = 0; i < annotationTypes.length; i++) { @@ -61,34 +60,9 @@ annotationNames.add("@" + Utils.getSimpleName(mirror.getAnnotationType())); } - for (AnnotationMirror mirror : foundAnnotations) { - context.getLog().error(method, mirror, "Non exclusive usage of annotations %s.", annotationNames); - } - valid = false; + template.addError("Non exclusive usage of annotations %s.", annotationNames); } } - return valid; - } - - protected boolean verifyTemplateType(TypeElement template, AnnotationMirror annotation) { - // annotation type on class path!? - boolean valid = true; - TypeElement annotationTypeElement = processingEnv.getElementUtils().getTypeElement(getAnnotationType().getCanonicalName()); - if (annotationTypeElement == null) { - log.error(template, annotation, "Required class " + getAnnotationType().getName() + " is not on the classpath."); - valid = false; - } - if (template.getModifiers().contains(Modifier.PRIVATE)) { - log.error(template, annotation, "The annotated class must have at least package protected visibility."); - valid = false; - } - - if (template.getModifiers().contains(Modifier.FINAL)) { - log.error(template, annotation, "The annotated class must not be final."); - valid = false; - } - - return valid; } }