com.sun.mirror.declaration.Declaration.accept()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中com.sun.mirror.declaration.Declaration.accept()方法的一些代码示例,展示了Declaration.accept()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Declaration.accept()方法的具体详情如下:
包路径:com.sun.mirror.declaration.Declaration
类名称:Declaration
方法名:accept

Declaration.accept介绍

暂无

代码示例

代码示例来源:origin: net.sf.apt-jelly/apt-jelly-core

/**
 * Decorates a collection of declarations.
 *
 * @param declarations The declarations to decorate.
 * @return The decorated declarations.
 */
@SuppressWarnings({"unchecked"})
public static <D extends Declaration> Collection<D> decorate(Collection<D> declarations) {
 if (declarations == null) {
  return null;
 }
 DeclarationDecorator decorator = getInstance();
 ArrayList<D> decls = new ArrayList<D>(declarations.size());
 for (D declaration : declarations) {
  declaration.accept(decorator);
  decls.add((D) decorator.getDecoratedDeclaration());
 }
 return decls;
}

代码示例来源:origin: net.sf.apt-jelly/apt-jelly-core

/**
 * Decorates a declaration.
 *
 * @param declaration The declaration to decorate.
 * @return The decorated declaration.
 */
@SuppressWarnings({"unchecked"})
public static <D extends Declaration> D decorate(D declaration) {
 if (declaration == null) {
  return null;
 }
 DeclarationDecorator decorator = getInstance();
 declaration.accept(decorator);
 return (D) decorator.getDecoratedDeclaration();
}

代码示例来源:origin: uk.ac.ebi.intact.core/intact-apt

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();
 }
}

代码示例来源:origin: uk.ac.ebi.intact/intact-apt

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();
 }
}

代码示例来源:origin: uk.ac.ebi.intact.sanity/intact-sanity-commons

public void process() {
  SanityRuleVisitor visitor = new SanityRuleVisitor();
  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 ) );
    }
  }
  List<DeclaredRule> rules = visitor.getRules();
  try {
    File targetDir = createTargetDir();
    File targetFile = new File( targetDir, DeclaredRuleManager.RULES_XML_PATH );
    targetFile.getParentFile().mkdirs();
    env.getMessager().printNotice( "Writing " + rules.size() + " sanity rules to: " + targetFile );
    Writer writer = new FileWriter( targetFile );
    DeclaredRules jaxbRules = new DeclaredRules();
    jaxbRules.getDeclaredRules().addAll( rules );
    DeclaredRuleManager.writeRulesXml( jaxbRules, writer );
    writer.close();
  } catch ( Exception e ) {
    e.printStackTrace();
    throw new SanityRuleException( e );
  }
}

代码示例来源:origin: uk.ac.ebi.intact.core/intact-apt

public void process() {
  File targetDir = createTargetDir();
  for (AnnotationTypeDeclaration atd : atds) {
    env.getMessager().printNotice("Processing annotation " + atd);
    Collection<Declaration> decls = env.getDeclarationsAnnotatedWith(atd);
    
    for (Declaration decl : decls) {
      MockableVisitor visitor = new MockableVisitor(env, targetDir);
      decl.accept(DeclarationVisitors.getDeclarationScanner(visitor, DeclarationVisitors.NO_OP));
      try {
        visitor.generateMock();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
}

代码示例来源:origin: com.google.code.facebookapi/facebook-java-api-annotation-processor

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 );
}

相关文章