Java 类javax.lang.model.util.ElementKindVisitor8 实例源码

项目:xapi    文件:XapiAnnotationProcessor.java   
private void generate(CompilationUnitTree cup, XApiInjectionConfiguration config) {
  final Element type = config.getElement();

  final ClassTree tr = trees.getTree((TypeElement) type);
  final java.util.List<InjectionBinding> results = new InjectionTargetSearchVisitor(service, cup)
      .scan(trees.getTree(type), new ArrayList<>());
  trees.getTree(type);

  ElementFilter.fieldsIn(type.getEnclosedElements())
      .stream().filter(ElementUtil.withAnnotation(Inject.class))
      .forEach(field->{
        // A field annotated with @Inject.
        Optional<InjectionBinding> binding = service.getInjectionBinding(config, field.asType());
        if (binding.isPresent()) {
          // we have a valid injection result; insert it
          final List<Compound> attrs = ((VarSymbol) field).getRawAttributes();
          Pointer<ExecutableElement> initializer = Pointer.pointer();
          ClassSymbol t = (ClassSymbol) type;
          final Scope members = (((ClassSymbol) type).members());
            final TreePath path = trees.getPath(type);
            if (path != null)
            path.forEach(tree->{
              final Tree.Kind k = tree.getKind();
          });
          t.members().getElements().forEach(sym->{
            log.printMessage(Kind.NOTE, "Symbol " + sym.getClass()+" : " + sym);
          });

          type.accept(new ElementKindVisitor8<Void, Void>(){
            @Override
            public Void visitExecutable(ExecutableElement e, Void aVoid) {
              initializer.in(e);
              return null;
            }
          }, null);
        } else {
          // ignore this field
        }
      });
}