javax.lang.model.util.SimpleElementVisitor9 Java Examples
The following examples show how to use
javax.lang.model.util.SimpleElementVisitor9.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Utils.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public boolean isSpecified(Element e) { if (specifiedVisitor == null) { specifiedVisitor = new SimpleElementVisitor9<Boolean, Void>() { @Override public Boolean visitModule(ModuleElement e, Void p) { return configuration.getSpecifiedModuleElements().contains(e); } @Override public Boolean visitPackage(PackageElement e, Void p) { return configuration.getSpecifiedPackageElements().contains(e); } @Override public Boolean visitType(TypeElement e, Void p) { return configuration.getSpecifiedTypeElements().contains(e); } @Override protected Boolean defaultAction(Element e, Void p) { return false; } }; } return specifiedVisitor.visit(e); }
Example #2
Source File: ElementsTable.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns true if the element is selected, by applying * the access filter checks. Special treatment is applied to * types, for a top level type the access filter applies completely, * however if is a nested type then it is allowed either if * the enclosing is a static or the enclosing is also selected. * * @param e the element to be checked * @return true if the element is visible */ public boolean isSelected(Element e) { if (toolEnv.isSynthetic((Symbol) e)) { return false; } if (visibleElementVisitor == null) { visibleElementVisitor = new SimpleElementVisitor9<Boolean, Void>() { @Override public Boolean visitType(TypeElement e, Void p) { if (!accessFilter.checkModifier(e)) { return false; // it is not allowed } Element encl = e.getEnclosingElement(); // check if nested if (encl.getKind() == ElementKind.PACKAGE) return true; // top-level class, allow it // is enclosed static if (encl.getModifiers().contains(Modifier.STATIC)) return true; // allowed // check the enclosing return visit(encl); } @Override protected Boolean defaultAction(Element e, Void p) { return accessFilter.checkModifier(e); } @Override public Boolean visitUnknown(Element e, Void p) { throw new AssertionError("unkown element: " + p); } }; } return visibleElementVisitor.visit(e); }
Example #3
Source File: Utils.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private boolean shouldDocument(Element e) { if (shouldDocumentVisitor == null) { shouldDocumentVisitor = new SimpleElementVisitor9<Boolean, Void>() { private boolean hasSource(TypeElement e) { return configuration.docEnv.getFileKind(e) == javax.tools.JavaFileObject.Kind.SOURCE; } // handle types @Override public Boolean visitType(TypeElement e, Void p) { return configuration.docEnv.isSelected(e) && hasSource(e); } // handle everything else @Override protected Boolean defaultAction(Element e, Void p) { return configuration.docEnv.isSelected(e); } @Override public Boolean visitUnknown(Element e, Void p) { throw new AssertionError("unkown element: " + p); } }; } return shouldDocumentVisitor.visit(e); }
Example #4
Source File: Utils.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private String getSimpleName0(Element e) { if (snvisitor == null) { snvisitor = new SimpleElementVisitor9<String, Void>() { @Override public String visitModule(ModuleElement e, Void p) { return e.getQualifiedName().toString(); // temp fix for 8182736 } @Override public String visitType(TypeElement e, Void p) { StringBuilder sb = new StringBuilder(e.getSimpleName()); Element enclosed = e.getEnclosingElement(); while (enclosed != null && (enclosed.getKind().isClass() || enclosed.getKind().isInterface())) { sb.insert(0, enclosed.getSimpleName() + "."); enclosed = enclosed.getEnclosingElement(); } return sb.toString(); } @Override public String visitExecutable(ExecutableElement e, Void p) { if (e.getKind() == CONSTRUCTOR || e.getKind() == STATIC_INIT) { return e.getEnclosingElement().getSimpleName().toString(); } return e.getSimpleName().toString(); } @Override protected String defaultAction(Element e, Void p) { return e.getSimpleName().toString(); } }; } return snvisitor.visit(e); }