Java 类javax.lang.model.element.ElementVisitor 实例源码

项目:ocelot    文件:OcelotProcessor.java   
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    // check if process was done on previous round
    if (OcelotProcessor.isDone() || roundEnv.processingOver()) { // Returns true if types generated by this round will not be subject to a subsequent round of annotation processing; returns false otherwise.
        return true; //if is it : stop
    }
    writeCoreInClassesOutput();
    writeCoreInDirectory(jsdir, jsfwk); // one core.js in same time
    for (Element element : roundEnv.getElementsAnnotatedWith(DataService.class)) {
        processElement(element);
    }
    ElementVisitor visitor = new JsCacheRemoveVisitor(processingEnv);
    Set<TypeElement> elements = getTypeElementContainsJsRemoveAnno(roundEnv);
    for (TypeElement te : elements) {
        createPropertiesFile(te, visitor);
    }
    OcelotProcessor.setDone(true);
    return true;
}
项目:ocelot    文件:OcelotProcessorTest.java   
/**
 * Test of process method, of class OcelotProcessor.
 *
 * @throws java.io.IOException
 */
@Test
public void processJsCacheRemoveTest() throws IOException {
    System.out.println("process");
    OcelotProcessor.setDone(Boolean.FALSE);
    RoundEnvironment roundEnv = mock(RoundEnvironment.class);
    Set<? extends TypeElement> annotations = mock(Set.class);
    Set elements = new HashSet<>();
    elements.add(mock(TypeElement.class));
    elements.add(mock(TypeElement.class));

    when(roundEnv.processingOver()).thenReturn(Boolean.FALSE);
    doNothing().when(instance).writeCoreInClassesOutput();
    doNothing().when(instance).writeCoreInDirectory(anyString(), anyString());
    doNothing().when(instance).createPropertiesFile(any(TypeElement.class), any(ElementVisitor.class));
    doReturn(elements).when(instance).getTypeElementContainsJsRemoveAnno(any(RoundEnvironment.class));
    when(roundEnv.getElementsAnnotatedWith(eq(DataService.class))).thenReturn(Collections.EMPTY_SET);

    boolean result = instance.process(annotations, roundEnv);
    assertThat(result).isTrue();
    verify(instance, times(2)).createPropertiesFile(any(TypeElement.class), any(ElementVisitor.class));
}
项目:ocelot    文件:OcelotProcessorTest.java   
/**
 * Test of createPropertiesFile method, of class.
 * @throws java.io.IOException
 */
@Test
public void createPropertiesFileTest() throws IOException {
    System.out.println("createPropertiesFile");
    TypeElement te = mock(TypeElement.class);
    Name name = mock(Name.class);
    ElementVisitor visitor = mock(ElementVisitor.class);
    Writer writer = mock(Writer.class);
    when(te.getSimpleName()).thenReturn(name);
    when(name.toString()).thenReturn("ClassName");
    when(fws.getFileObjectWriterInClassOutput(eq("package"), eq("ClassName.properties"))).thenReturn(writer).thenThrow(IOException.class);
    doReturn("package").when(instance).getPackagePath(eq(te));
    instance.createPropertiesFile(te, visitor);
    instance.createPropertiesFile(te, visitor);
    verify(te).accept(eq(visitor), eq(writer));
}
项目:logging-log4j2    文件:PluginProcessor.java   
private void collectPlugins(final Iterable<? extends Element> elements) {
    final Elements elementUtils = processingEnv.getElementUtils();
    final ElementVisitor<PluginEntry, Plugin> pluginVisitor = new PluginElementVisitor(elementUtils);
    final ElementVisitor<Collection<PluginEntry>, Plugin> pluginAliasesVisitor = new PluginAliasesElementVisitor(
            elementUtils);
    for (final Element element : elements) {
        final Plugin plugin = element.getAnnotation(Plugin.class);
        if (plugin == null) {
            continue;
        }
        final PluginEntry entry = element.accept(pluginVisitor, plugin);
        final Map<String, PluginEntry> category = pluginCache.getCategory(entry.getCategory());
        category.put(entry.getKey(), entry);
        final Collection<PluginEntry> entries = element.accept(pluginAliasesVisitor, plugin);
        for (final PluginEntry pluginEntry : entries) {
            category.put(pluginEntry.getKey(), pluginEntry);
        }
    }
}
项目:incubator-netbeans    文件:LayerBuilderTest.java   
public void testOriginatingElementComments() throws Exception {
    b = new LayerBuilder(doc, new Element() {
        public @Override ElementKind getKind() {
            return ElementKind.OTHER;
        }
        public @Override String toString() {
            return "originating.Type";
        }
        public @Override TypeMirror asType() {return null;}
        public @Override List<? extends AnnotationMirror> getAnnotationMirrors() {return null;}
        public @Override <A extends Annotation> A getAnnotation(Class<A> annotationType) {return null;}
        public @Override Set<Modifier> getModifiers() {return null;}
        public @Override Name getSimpleName() {return null;}
        public @Override Element getEnclosingElement() {return null;}
        public @Override List<? extends Element> getEnclosedElements() {return null;}
        public @Override <R, P> R accept(ElementVisitor<R, P> v, P p) {return null;}
        @Override
        public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType) {
            return (A[]) Array.newInstance(annotationType, 0);
        }
    }, null);
    b.folder("f").write();
    assertEquals("<filesystem><folder name='f'><!--originating.Type--></folder></filesystem>", dump());
    // #180154: do not repeat after an incremental build
    b.folder("f").write();
    assertEquals("<filesystem><folder name='f'><!--originating.Type--></folder></filesystem>", dump());
}
项目:neo4j-sproc-compiler    文件:DsvSerializer.java   
public DsvSerializer( Elements elements, ElementVisitor<TypeElement,Void> enclosingTypeVisitor,
        MessagePrinter messagePrinter )
{

    this.elements = elements;
    this.enclosingTypeVisitor = enclosingTypeVisitor;
    this.messagePrinter = messagePrinter;
    this.fieldExporter = new DsvFieldExporter( elements );
}
项目:ocelot    文件:OcelotProcessor.java   
void createPropertiesFile(TypeElement te, ElementVisitor visitor) {
    try (Writer w = fws.getFileObjectWriterInClassOutput(getPackagePath(te), te.getSimpleName().toString()+".properties")) {
        te.accept(visitor, w);
    } catch(IOException ioe) {
        messager.printMessage(Diagnostic.Kind.ERROR, " properties generation class : " + te);
    }
}
项目:ocelot    文件:OcelotProcessor.java   
/**
 * generate js service in packagePath.fn in classes directory/packagePath
 *
 * @param element
 * @param visitor
 * @param packagePath
 * @param fn
 */
void writeJsFileToJsDir(TypeElement element, ElementVisitor visitor, String packagePath, String fn, String dir) {
    if (null != dir) {
        try (Writer w = fws.getFileObjectWriter(dir + File.separatorChar + "srvs", packagePath + "." + fn)) {
            messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " javascript generation class : " + element + " to : " + dir);
            element.accept(visitor, w);
        } catch (IOException ioe) {
            messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " FAILED TO CREATE : " + packagePath + "." + fn);
        }
    }
}
项目:ocelot    文件:OcelotProcessorTest.java   
/**
 * Test of writeJsFile method, of class.
 *
 * @throws java.io.IOException
 */
@Test
public void test_writeJsFile() throws IOException {
    System.out.println("writeJsFile");
    TypeElement element = mock(TypeElement.class);
    ElementVisitor visitor = mock(ElementVisitor.class);
    Writer writer = mock(Writer.class);
    when(fws.getFileObjectWriterInClassOutput(eq("packagePath"), eq("fn"))).thenReturn(writer).thenThrow(IOException.class);
    instance.writeJsFile(element, visitor, "packagePath", "fn");
    instance.writeJsFile(element, visitor, "packagePath", "fn");
    verify(element).accept(eq(visitor), eq(writer));
}
项目:ocelot    文件:OcelotProcessorTest.java   
/**
 * Test of writeJsFileToJsDir method, of class.
 *
 * @throws java.io.IOException
 */
@Test
public void test_writeJsFileToJsDir() throws IOException {
    System.out.println("writeJsFileToJsDir");
    TypeElement element = mock(TypeElement.class);
    ElementVisitor visitor = mock(ElementVisitor.class);
    Writer writer = mock(Writer.class);
    when(fws.getFileObjectWriter(eq("dir"+File.separatorChar+"srvs"), eq("packagePath.fn"))).thenReturn(writer).thenThrow(IOException.class);
    instance.writeJsFileToJsDir(element, visitor, "packagePath", "fn", "dir");
    instance.writeJsFileToJsDir(element, visitor, "packagePath", "fn", "dir");
    verify(element).accept(eq(visitor), eq(writer));
}
项目:damapping    文件:ReferencesScanner.java   
public ReferenceScanResult scan(TypeElement typeElement) throws IOException {
  ElementImports imports = processingEnvironment.getElementUtils().findImports(typeElement);
  ReferenceScanResult scanResult = new ReferenceScanResult(imports);
  ElementVisitor<Void, ReferenceScanResult> visitor = instanceVisitor(imports);
  typeElement.accept(visitor, scanResult);
  return scanResult;
}
项目:GitHub    文件:CachingElements.java   
@Override
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
  return delegate.accept(v, p);
}
项目:incubator-netbeans    文件:ElementOverlay.java   
@Override
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:incubator-netbeans    文件:ElementOverlay.java   
@Override
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:incubator-netbeans    文件:ElementOverlay.java   
@Override
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:incubator-netbeans    文件:ElementOverlay.java   
@Override
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:javaide    文件:Resolve.java   
@Override
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    throw new AssertionError();
}
项目:OpenJSharp    文件:Resolve.java   
@Override
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    throw new AssertionError();
}
项目:openjdk-jdk10    文件:Symbol.java   
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return other.accept(v, p);
}
项目:openjdk-jdk10    文件:Symbol.java   
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitTypeParameter(this, p);
}
项目:openjdk-jdk10    文件:Symbol.java   
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitModule(this, p);
}
项目:openjdk-jdk10    文件:Symbol.java   
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitPackage(this, p);
}
项目:openjdk-jdk10    文件:Symbol.java   
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitType(this, p);
}
项目:openjdk-jdk10    文件:Symbol.java   
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitVariable(this, p);
}
项目:openjdk-jdk10    文件:Symbol.java   
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitExecutable(this, p);
}
项目:openjdk-jdk10    文件:Resolve.java   
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    throw new AssertionError();
}
项目:openjdk-jdk10    文件:OverviewElement.java   
@Override
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitUnknown(this, p);
}
项目:openjdk9    文件:Symbol.java   
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return other.accept(v, p);
}
项目:openjdk9    文件:Symbol.java   
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitTypeParameter(this, p);
}
项目:openjdk9    文件:Symbol.java   
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitModule(this, p);
}
项目:openjdk9    文件:Symbol.java   
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitPackage(this, p);
}
项目:openjdk9    文件:Symbol.java   
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitType(this, p);
}
项目:openjdk9    文件:Symbol.java   
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitVariable(this, p);
}
项目:openjdk9    文件:Symbol.java   
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitExecutable(this, p);
}
项目:openjdk9    文件:Resolve.java   
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    throw new AssertionError();
}
项目:openjdk9    文件:OverviewElement.java   
@Override @DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    return v.visitUnknown(this, p);
}
项目:neo4j-sproc-compiler    文件:ConstantQualifiedNameable.java   
@Override
public <R, P> R accept( ElementVisitor<R,P> v, P p )
{
    return null;
}
项目:cloudkeeper    文件:TypeParameterElementImpl.java   
@Override
public <R, P> R accept(ElementVisitor<R, P> visitor, @Nullable P parameter) {
    return visitor.visitTypeParameter(this, parameter);
}
项目:cloudkeeper    文件:TypeDeclarationImpl.java   
@Override
@Nullable
public <T, P> T accept(ElementVisitor<T, P> visitor, @Nullable P parameter) {
    return visitor.visitType(this, parameter);
}
项目:lookaside_java-1.8.0-openjdk    文件:Resolve.java   
@Override
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
    throw new AssertionError();
}