本文整理汇总了Java中javax.lang.model.element.Element.accept方法的典型用法代码示例。如果您正苦于以下问题:Java Element.accept方法的具体用法?Java Element.accept怎么用?Java Element.accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.lang.model.element.Element
的用法示例。
在下文中一共展示了Element.accept方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitType
import javax.lang.model.element.Element; //导入方法依赖的package包/类
@Override
public TypeElement visitType(TypeElement typeElement, String binaryName) {
String bName = ElementUtilities.getBinaryName(typeElement);
if(binaryName.equals(bName)) {
return typeElement;
} else if(binaryName.startsWith(bName)) {
for(Element child : typeElement.getEnclosedElements()) {
if(!child.getKind().isClass()) {
continue;
}
TypeElement retVal = child.accept(this, binaryName);
if(retVal != null) {
return retVal;
}
}
}
return null;
}
示例2: visitPackage
import javax.lang.model.element.Element; //导入方法依赖的package包/类
@Override
public TypeElement visitPackage(PackageElement packElem, String binaryName) {
for (Element e : packElem.getEnclosedElements()) {
if (e.getKind().isClass()) {
TypeElement ret = e.accept(this, binaryName);
if (ret != null) {
return ret;
}
}
}
return null;
}
示例3: visitPackage
import javax.lang.model.element.Element; //导入方法依赖的package包/类
@Override
public TypeElement visitPackage(PackageElement packElem, String binaryName) {
for(Element e : packElem.getEnclosedElements()) {
if(e.getKind().isClass()) {
TypeElement ret = e.accept(this, binaryName);
if(ret != null) {
return ret;
}
}
}
return null;
}
示例4: run
import javax.lang.model.element.Element; //导入方法依赖的package包/类
public List<ErrorDescription> run(CompilationInfo compilationInfo,
TreePath treePath) {
stop = false;
Element e = compilationInfo.getTrees().getElement(treePath);
if (e == null) {
return null;
}
Boolean b = e.accept(this, null);
if (b) {
Element parent = e;
for (;;) {
if (stop) {
return null;
}
if (parent == null || parent.getKind() == ElementKind.PACKAGE) {
break;
}
if (!parent.getModifiers().contains(Modifier.PUBLIC) && !parent.getModifiers().contains(Modifier.PROTECTED)) {
return null;
}
parent = parent.getEnclosingElement();
}
//#124456: disabling the fix:
// List<Fix> fixes = Collections.<Fix>singletonList(new FixImpl(
// "MSG_ExportNonAccessibleElementMakeNonVisible", // NOI18N
// TreePathHandle.create(e, compilationInfo),
// compilationInfo.getFileObject()
// ));
int[] span = null;
switch (treePath.getLeaf().getKind()) {
case METHOD: span = compilationInfo.getTreeUtilities().findNameSpan((MethodTree) treePath.getLeaf()); break;
case ANNOTATION_TYPE:
case CLASS:
case ENUM:
case INTERFACE:
span = compilationInfo.getTreeUtilities().findNameSpan((ClassTree) treePath.getLeaf()); break;
case VARIABLE: span = compilationInfo.getTreeUtilities().findNameSpan((VariableTree) treePath.getLeaf()); break;
}
if (span != null) {
ErrorDescription ed = ErrorDescriptionFactory.createErrorDescription(
getSeverity().toEditorSeverity(),
NbBundle.getMessage(ExportNonAccessibleElement.class, "MSG_ExportNonAccessibleElement"),
// fixes,
compilationInfo.getFileObject(),
span[0],
span[1]
);
return Collections.singletonList(ed);
}
}
return null;
}
示例5: asType
import javax.lang.model.element.Element; //导入方法依赖的package包/类
public static TypeElement asType(Element element) {
return element.accept(TYPE_ELEMENT_VISITOR, null);
}
示例6: visit
import javax.lang.model.element.Element; //导入方法依赖的package包/类
@Override
public Void visit(Element e, Void p) {
return e.accept(this, p);
}
示例7: asExecutable
import javax.lang.model.element.Element; //导入方法依赖的package包/类
/**
* Convert the given {@link Element} to an {@link ExecutableElement}.
*
* @param element
* @return
*/
public static ExecutableElement asExecutable(Element element) {
return element.accept(EXECUTABLE_VISITOR, null);
}
示例8: asType
import javax.lang.model.element.Element; //导入方法依赖的package包/类
/**
* Convert the given {@link Element} to a {@link TypeElement}.
*
* @param element
* @return
*/
public static TypeElement asType(Element element) {
return element.accept(TYPE_VISITOR, null);
}
示例9: asPackage
import javax.lang.model.element.Element; //导入方法依赖的package包/类
/**
* Returns the given {@link Element} instance as {@link PackageElement}.
* <p/>
* <p>This method is functionally equivalent to an {@code instanceof} check and a cast, but should
* always be used over that idiom as instructed in the documentation for {@link Element}.
*
* @throws NullPointerException if {@code element} is {@code null}
* @throws IllegalArgumentException if {@code element} isn't a {@link PackageElement}.
*/
public static PackageElement asPackage(Element element) {
return element.accept(PACKAGE_ELEMENT_VISITOR, null);
}
示例10: asType
import javax.lang.model.element.Element; //导入方法依赖的package包/类
/**
* Returns the given {@link Element} instance as {@link TypeElement}.
* <p/>
* <p>This method is functionally equivalent to an {@code instanceof} check and a cast, but should
* always be used over that idiom as instructed in the documentation for {@link Element}.
*
* @throws NullPointerException if {@code element} is {@code null}
* @throws IllegalArgumentException if {@code element} isn't a {@link TypeElement}.
*/
public static TypeElement asType(Element element) {
return element.accept(TYPE_ELEMENT_VISITOR, null);
}
示例11: asVariable
import javax.lang.model.element.Element; //导入方法依赖的package包/类
/**
* Returns the given {@link Element} instance as {@link VariableElement}.
* <p/>
* <p>This method is functionally equivalent to an {@code instanceof} check and a cast, but should
* always be used over that idiom as instructed in the documentation for {@link Element}.
*
* @throws NullPointerException if {@code element} is {@code null}
* @throws IllegalArgumentException if {@code element} isn't a {@link VariableElement}.
*/
public static VariableElement asVariable(Element element) {
return element.accept(VARIABLE_ELEMENT_VISITOR, null);
}
示例12: asExecutable
import javax.lang.model.element.Element; //导入方法依赖的package包/类
/**
* Returns the given {@link Element} instance as {@link ExecutableElement}.
* <p/>
* <p>This method is functionally equivalent to an {@code instanceof} check and a cast, but should
* always be used over that idiom as instructed in the documentation for {@link Element}.
*
* @throws NullPointerException if {@code element} is {@code null}
* @throws IllegalArgumentException if {@code element} isn't a {@link ExecutableElement}.
*/
public static ExecutableElement asExecutable(Element element) {
return element.accept(EXECUTABLE_ELEMENT_VISITOR, null);
}