public ErrorReceiverImpl(AnnotationProcessorEnvironment env) { this(env.getMessager()); }
/** * Get the XML type for the specified type. * * @param type The type mirror. * @return The xml type for the specified type mirror. * @throws XmlTypeException If the type is invalid or unknown as an xml type. */ public static XmlType getXmlType(Class type) throws XmlTypeException { AnnotationProcessorEnvironment env = Context.getCurrentEnvironment(); TypeDeclaration declaration = env.getTypeDeclaration(type.getName()); return getXmlType(env.getTypeUtils().getDeclaredType(declaration)); }
public Collection<com.sun.mirror.declaration.Declaration> getDeclarationsAnnotatedWith(AnnotationTypeDeclaration a) { return delegate.getDeclarationsAnnotatedWith(a); }
SpecCompliantClassAP(AnnotationProcessorEnvironment env) { this.env = env; specCompliantAnnotation = (AnnotationTypeDeclaration) env .getTypeDeclaration("org.apache.vysper.compliance.SpecCompliant"); specCompliantCollectionAnnotation = (AnnotationTypeDeclaration) env .getTypeDeclaration("org.apache.vysper.compliance.SpecCompliance"); try { fileWriter = env.getFiler().createTextFile(Filer.Location.SOURCE_TREE, "", new File("spec_compliance.html"), null); } catch (IOException e) { throw new RuntimeException("could not write to output file", e); } }
AnnotationParser(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env) { this.env = env; errorListener = new ErrorReceiverImpl(env.getMessager(),env.getOptions().containsKey(Const.DEBUG_OPTION)); }
Messager msg = env.getMessager(); Filer filer = env.getFiler(); env.getTypeDeclaration(Kind.Term.class.getName()); if (kindDecl == null) { msg.printError("Unable to find the Kind.Term annotation type"); Types typeUtils = env.getTypeUtils(); TypeDeclaration intfDecl = env.getTypeDeclaration(Kind.Adaptor.class.getName()); InterfaceType declaratorType = (InterfaceType)typeUtils.getDeclaredType(intfDecl); for (Declaration decl : env.getDeclarationsAnnotatedWith(kindDecl)) {
public void process() { PotentialThreatVisitor visitor = new PotentialThreatVisitor(); for (AnnotationTypeDeclaration atd : atds) { env.getMessager().printNotice("Collecting annotation "+atd); Collection<Declaration> decls = env.getDeclarationsAnnotatedWith(atd); for (Declaration decl : decls) { decl.accept(DeclarationVisitors.getDeclarationScanner(visitor, DeclarationVisitors.NO_OP)); } } try { visitor.print(); } catch (Exception e) { e.printStackTrace(); } }
public boolean isSubClassOf(TypeMirror sub, TypeMirror sup) { if(sup==DUMMY) // see ref(). if the sub type is known to APT, // its base class must be known. Thus if the sup is DUMMY, // it cannot possibly be the super type. return false; return env.getTypeUtils().isSubtype(sub,sup); }
public void process() { try { buf = new StringBuilder(); Messager log = env.getMessager(); DeclarationVisitor scanner = DeclarationVisitors.getDeclarationScanner( new Visitor(), DeclarationVisitors.NO_OP); for (TypeDeclaration typeDecl : env.getSpecifiedTypeDeclarations()) { typeDecl.accept(scanner); } if (buf.length() > 0) { writer = env.getFiler().createTextFile(Filer.Location.CLASS_TREE, "", new File("META-INF/web-types"), "UTF-8"); writer.print(buf.toString()); writer.close(); } } catch (IOException e) { e.printStackTrace(); } } }
public TypeDeclaration findClass(String className, TypeDeclaration referencePoint) { return env.getTypeDeclaration(className); }
private File createTargetDir() { String s = env.getOptions().get( "-s" ); File targetDir = new File( s ); if ( !targetDir.exists() ) { targetDir.mkdirs(); } return targetDir; } }
public void process() { List<Reference> decls = new ArrayList<Reference>(); for(TypeDeclaration d : env.getTypeDeclarations()) { env.getMessager().printNotice("Writing "+episodeFile); model.generateEpisodeFile(new StreamResult(episodeFile));
public void process() { PrintWriter outJAXB = openClassFile( "Jaxb" ); PrintWriter outJSON = openClassFile( "Json" ); PrintWriter outXML = openClassFile( "Xml" ); if ( outJAXB == null && outJSON == null && outXML == null ) { return; } final AnnotationTypeDeclaration annotationType = (AnnotationTypeDeclaration) processingEnv.getTypeDeclaration( "com.google.code.facebookapi.FacebookReturnType" ); Collection<Declaration> elements = processingEnv.getDeclarationsAnnotatedWith( annotationType ); AnnotationVisitor visitor = new AnnotationVisitor( outJAXB, outJSON, outXML ); for ( Declaration element : elements ) { element.accept( visitor ); } closeClassFile( outJAXB ); closeClassFile( outJSON ); closeClassFile( outXML ); }
public void process() { for( Map.Entry<String,String> me : env.getOptions().entrySet() ) { String key = me.getKey(); if (key.startsWith(Const.CONFIG_FILE_OPTION+'=')) { ConfigReader configReader = new ConfigReader(env,env.getTypeDeclarations(),configFile,errorListener);
Collection<TypeDeclaration> typeDeclarations = new ArrayList<TypeDeclaration>(env.getTypeDeclarations()); if (this.additionalApiClasses != null) { for (String additionalApiClass : this.additionalApiClasses) { TypeDeclaration declaration = env.getTypeDeclaration(additionalApiClass); if (declaration != null) { typeDeclarations.add(declaration);
public Collection<TypeDeclaration> getTypeDeclarations() { return delegate.getTypeDeclarations(); }
public Declarations getDeclarationUtils() { return delegate.getDeclarationUtils(); }
public Filer getFiler() { return delegate.getFiler(); }
public Collection<TypeDeclaration> getSpecifiedTypeDeclarations() { return delegate.getSpecifiedTypeDeclarations(); }
Messager msg = env.getMessager(); Filer filer = env.getFiler(); env.getTypeDeclaration(Kind.Term.class.getName()); if (kindDecl == null) { msg.printError("Unable to find the Kind.Term annotation type"); Types typeUtils = env.getTypeUtils(); TypeDeclaration intfDecl = env.getTypeDeclaration(Kind.Adaptor.class.getName()); InterfaceType declaratorType = (InterfaceType)typeUtils.getDeclaredType(intfDecl); for (Declaration decl : env.getDeclarationsAnnotatedWith(kindDecl)) {