當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。