Search in sources :

Example 6 with CodeAnnotationValue

use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue in project graal by oracle.

the class FixWarningsVisitor method createIgnoreDeprecations.

private CodeAnnotationMirror createIgnoreDeprecations() {
    CodeAnnotationMirror mirror = new CodeAnnotationMirror(suppressWarnings);
    mirror.setElementValue(mirror.findExecutableElement("value"), new CodeAnnotationValue("deprecation"));
    return mirror;
}
Also used : CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) CodeAnnotationValue(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue)

Example 7 with CodeAnnotationValue

use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue in project graal by oracle.

the class InstrumentableProcessor method generateWrapperAndFactory.

private CodeTypeElement generateWrapperAndFactory(ProcessorContext context, Element e) {
    CodeTypeElement wrapper = generateWrapper(context, e, false);
    if (wrapper == null) {
        return null;
    }
    CodeTypeElement factory = generateFactory(context, e, wrapper);
    // add @SuppressWarnings("deprecation")
    DeclaredType suppressWarnings = context.getDeclaredType(SuppressWarnings.class);
    CodeAnnotationMirror suppressWarningsAnnotation = new CodeAnnotationMirror(suppressWarnings);
    suppressWarningsAnnotation.setElementValue(ElementUtils.findExecutableElement(suppressWarnings, "value"), new CodeAnnotationValue(Arrays.asList(new CodeAnnotationValue("deprecation"))));
    factory.getAnnotationMirrors().add(suppressWarningsAnnotation);
    wrapper.getModifiers().add(Modifier.STATIC);
    factory.add(wrapper);
    assertNoErrorExpected(e);
    return factory;
}
Also used : CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) CodeTypeElement(com.oracle.truffle.dsl.processor.java.model.CodeTypeElement) DeclaredType(javax.lang.model.type.DeclaredType) CodeAnnotationValue(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue)

Example 8 with CodeAnnotationValue

use of com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue in project graal by oracle.

the class InstrumentableProcessor method addGeneratedBy.

private static void addGeneratedBy(ProcessorContext context, CodeTypeElement generatedType, TypeElement generatedByType) {
    DeclaredType generatedBy = (DeclaredType) context.getType(GeneratedBy.class);
    // only do this if generatedBy is on the classpath.
    if (generatedBy != null) {
        CodeAnnotationMirror generatedByAnnotation = new CodeAnnotationMirror(generatedBy);
        generatedByAnnotation.setElementValue(generatedByAnnotation.findExecutableElement("value"), new CodeAnnotationValue(generatedByType.asType()));
        generatedType.addAnnotationMirror(generatedByAnnotation);
    }
}
Also used : CodeAnnotationMirror(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror) GeneratedBy(com.oracle.truffle.api.dsl.GeneratedBy) DeclaredType(javax.lang.model.type.DeclaredType) CodeAnnotationValue(com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue)

Aggregations

CodeAnnotationMirror (com.oracle.truffle.dsl.processor.java.model.CodeAnnotationMirror)8 CodeAnnotationValue (com.oracle.truffle.dsl.processor.java.model.CodeAnnotationValue)8 CodeTypeElement (com.oracle.truffle.dsl.processor.java.model.CodeTypeElement)3 DeclaredType (javax.lang.model.type.DeclaredType)3 TypeMirror (javax.lang.model.type.TypeMirror)2 CompilationFinal (com.oracle.truffle.api.CompilerDirectives.CompilationFinal)1 GeneratedBy (com.oracle.truffle.api.dsl.GeneratedBy)1 ExplodeLoop (com.oracle.truffle.api.nodes.ExplodeLoop)1 ProcessorContext (com.oracle.truffle.dsl.processor.ProcessorContext)1 ElementUtils.fromTypeMirror (com.oracle.truffle.dsl.processor.java.ElementUtils.fromTypeMirror)1 CodeVariableElement (com.oracle.truffle.dsl.processor.java.model.CodeVariableElement)1 Modifier (javax.lang.model.element.Modifier)1 PackageElement (javax.lang.model.element.PackageElement)1 TypeElement (javax.lang.model.element.TypeElement)1 VariableElement (javax.lang.model.element.VariableElement)1