Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/verify/VerifyTruffleProcessor.java @ 21557:31fc2fce38f3
Merge.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 27 May 2015 13:32:18 +0200 |
parents | b1530a6cce8c f5b49d881909 |
children |
comparison
equal
deleted
inserted
replaced
21556:48c1ebd24120 | 21557:31fc2fce38f3 |
---|---|
32 import javax.lang.model.*; | 32 import javax.lang.model.*; |
33 import javax.lang.model.element.*; | 33 import javax.lang.model.element.*; |
34 import javax.tools.Diagnostic.Kind; | 34 import javax.tools.Diagnostic.Kind; |
35 | 35 |
36 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; | 36 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; |
37 import com.oracle.truffle.api.dsl.*; | |
38 import com.oracle.truffle.api.nodes.Node.Child; | 37 import com.oracle.truffle.api.nodes.Node.Child; |
38 import com.oracle.truffle.dsl.processor.*; | |
39 | 39 |
40 @SupportedAnnotationTypes({"com.oracle.truffle.api.CompilerDirectives.TruffleBoundary", "com.oracle.truffle.api.nodes.Node.Child"}) | 40 @SupportedAnnotationTypes({"com.oracle.truffle.api.CompilerDirectives.TruffleBoundary", "com.oracle.truffle.api.nodes.Node.Child"}) |
41 public class VerifyTruffleProcessor extends AbstractProcessor { | 41 public class VerifyTruffleProcessor extends AbstractProcessor { |
42 @Override | 42 @Override |
43 public SourceVersion getSupportedSourceVersion() { | 43 public SourceVersion getSupportedSourceVersion() { |
123 assertNoErrorExpected(e); | 123 assertNoErrorExpected(e); |
124 } | 124 } |
125 return false; | 125 return false; |
126 } | 126 } |
127 | 127 |
128 void assertNoErrorExpected(Element e) { | 128 void assertNoErrorExpected(Element element) { |
129 TypeElement eee = processingEnv.getElementUtils().getTypeElement(ExpectError.class.getName()); | 129 ExpectError.assertNoErrorExpected(processingEnv, element); |
130 for (AnnotationMirror am : e.getAnnotationMirrors()) { | |
131 if (am.getAnnotationType().asElement().equals(eee)) { | |
132 processingEnv.getMessager().printMessage(Kind.ERROR, "Expected an error, but none found!", e); | |
133 } | |
134 } | |
135 } | 130 } |
136 | 131 |
137 void emitError(String msg, Element e) { | 132 void emitError(String message, Element element) { |
138 TypeElement eee = processingEnv.getElementUtils().getTypeElement(ExpectError.class.getName()); | 133 if (ExpectError.isExpectedError(processingEnv, element, message)) { |
139 for (AnnotationMirror am : e.getAnnotationMirrors()) { | 134 return; |
140 if (am.getAnnotationType().asElement().equals(eee)) { | |
141 Map<? extends ExecutableElement, ? extends AnnotationValue> vals = am.getElementValues(); | |
142 if (vals.size() == 1) { | |
143 AnnotationValue av = vals.values().iterator().next(); | |
144 if (av.getValue() instanceof List) { | |
145 List<?> arr = (List<?>) av.getValue(); | |
146 for (Object o : arr) { | |
147 if (o instanceof AnnotationValue) { | |
148 AnnotationValue ov = (AnnotationValue) o; | |
149 if (msg.equals(ov.getValue())) { | |
150 return; | |
151 } | |
152 } | |
153 } | |
154 } | |
155 } | |
156 } | |
157 } | 135 } |
158 processingEnv.getMessager().printMessage(Kind.ERROR, msg, e); | 136 processingEnv.getMessager().printMessage(Kind.ERROR, message, element); |
159 } | 137 } |
160 | 138 |
161 /** | 139 /** |
162 * Determines if a given exception is (most likely) caused by <a | 140 * Determines if a given exception is (most likely) caused by <a |
163 * href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=367599">Bug 367599</a>. | 141 * href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=367599">Bug 367599</a>. |