本文整理匯總了Java中javax.lang.model.element.ElementVisitor類的典型用法代碼示例。如果您正苦於以下問題:Java ElementVisitor類的具體用法?Java ElementVisitor怎麽用?Java ElementVisitor使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ElementVisitor類屬於javax.lang.model.element包,在下文中一共展示了ElementVisitor類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: process
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
@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;
}
示例2: processJsCacheRemoveTest
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
/**
* 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));
}
示例3: createPropertiesFileTest
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
/**
* 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));
}
示例4: collectPlugins
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
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);
}
}
}
示例5: testOriginatingElementComments
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
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());
}
示例6: DsvSerializer
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
public DsvSerializer( Elements elements, ElementVisitor<TypeElement,Void> enclosingTypeVisitor,
MessagePrinter messagePrinter )
{
this.elements = elements;
this.enclosingTypeVisitor = enclosingTypeVisitor;
this.messagePrinter = messagePrinter;
this.fieldExporter = new DsvFieldExporter( elements );
}
示例7: createPropertiesFile
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
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);
}
}
示例8: writeJsFileToJsDir
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
/**
* 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);
}
}
}
示例9: test_writeJsFile
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
/**
* 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));
}
示例10: test_writeJsFileToJsDir
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
/**
* 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));
}
示例11: scan
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
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;
}
示例12: accept
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
@Override
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
return delegate.accept(v, p);
}
示例13: accept
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
@Override
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
throw new UnsupportedOperationException("Not supported yet.");
}
示例14: accept
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
@Override
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
throw new AssertionError();
}
示例15: accept
import javax.lang.model.element.ElementVisitor; //導入依賴的package包/類
@DefinedBy(Api.LANGUAGE_MODEL)
public <R, P> R accept(ElementVisitor<R, P> v, P p) {
return other.accept(v, p);
}