当前位置: 首页>>代码示例>>Java>>正文


Java Element.accept方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:JavaUtils.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:JPAEditorUtil.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:JavaUtils.java

示例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;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:61,代码来源:ExportNonAccessibleElement.java

示例5: asType

import javax.lang.model.element.Element; //导入方法依赖的package包/类
public static TypeElement asType(Element element) {
    return element.accept(TYPE_ELEMENT_VISITOR, null);
}
 
开发者ID:zillachan,项目名称:AndZilla,代码行数:4,代码来源:LifecycleProcessor.java

示例6: visit

import javax.lang.model.element.Element; //导入方法依赖的package包/类
@Override
public Void visit(Element e, Void p) {
    return e.accept(this, p);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:ElementStructureTest.java

示例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);
}
 
开发者ID:codegen-io,项目名称:jso-builder,代码行数:10,代码来源:TypeMapper.java

示例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);
}
 
开发者ID:codegen-io,项目名称:jso-builder,代码行数:10,代码来源:TypeMapper.java

示例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);
}
 
开发者ID:foodora,项目名称:android-auto-mapper,代码行数:13,代码来源:MoreElements.java

示例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);
}
 
开发者ID:foodora,项目名称:android-auto-mapper,代码行数:13,代码来源:MoreElements.java

示例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);
}
 
开发者ID:foodora,项目名称:android-auto-mapper,代码行数:13,代码来源:MoreElements.java

示例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);
}
 
开发者ID:foodora,项目名称:android-auto-mapper,代码行数:13,代码来源:MoreElements.java


注:本文中的javax.lang.model.element.Element.accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。