diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyTruffleProcessor.java @ 21494:f5b49d881909

Truffle-DSL: move internal @ExpectError annotation from public API to the test package only; share expect error handling between new processors.
author Christian Humer <christian.humer@gmail.com>
date Tue, 26 May 2015 20:04:08 +0200
parents bb51b9a142b3
children 31fc2fce38f3
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyTruffleProcessor.java	Tue May 26 20:04:07 2015 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyTruffleProcessor.java	Tue May 26 20:04:08 2015 +0200
@@ -34,8 +34,8 @@
 import javax.tools.Diagnostic.Kind;
 
 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
-import com.oracle.truffle.api.dsl.ExpectError;
 import com.oracle.truffle.api.nodes.Node.Child;
+import com.oracle.truffle.dsl.processor.*;
 
 @SupportedAnnotationTypes({"com.oracle.truffle.api.CompilerDirectives.TruffleBoundary", "com.oracle.truffle.api.nodes.Node.Child"})
 public class VerifyTruffleProcessor extends AbstractProcessor {
@@ -125,37 +125,15 @@
         return false;
     }
 
-    void assertNoErrorExpected(Element e) {
-        TypeElement eee = processingEnv.getElementUtils().getTypeElement(ExpectError.class.getName());
-        for (AnnotationMirror am : e.getAnnotationMirrors()) {
-            if (am.getAnnotationType().asElement().equals(eee)) {
-                processingEnv.getMessager().printMessage(Kind.ERROR, "Expected an error, but none found!", e);
-            }
-        }
+    void assertNoErrorExpected(Element element) {
+        ExpectError.assertNoErrorExpected(processingEnv, element);
     }
 
-    void emitError(String msg, Element e) {
-        TypeElement eee = processingEnv.getElementUtils().getTypeElement(ExpectError.class.getName());
-        for (AnnotationMirror am : e.getAnnotationMirrors()) {
-            if (am.getAnnotationType().asElement().equals(eee)) {
-                Map<? extends ExecutableElement, ? extends AnnotationValue> vals = am.getElementValues();
-                if (vals.size() == 1) {
-                    AnnotationValue av = vals.values().iterator().next();
-                    if (av.getValue() instanceof List) {
-                        List<?> arr = (List<?>) av.getValue();
-                        for (Object o : arr) {
-                            if (o instanceof AnnotationValue) {
-                                AnnotationValue ov = (AnnotationValue) o;
-                                if (msg.equals(ov.getValue())) {
-                                    return;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
+    void emitError(String message, Element element) {
+        if (ExpectError.isExpectedError(processingEnv, element, message)) {
+            return;
         }
-        processingEnv.getMessager().printMessage(Kind.ERROR, msg, e);
+        processingEnv.getMessager().printMessage(Kind.ERROR, message, element);
     }
 
     /**