當前位置: 首頁>>代碼示例>>Java>>正文


Java ElementFilter.packagesIn方法代碼示例

本文整理匯總了Java中javax.lang.model.util.ElementFilter.packagesIn方法的典型用法代碼示例。如果您正苦於以下問題:Java ElementFilter.packagesIn方法的具體用法?Java ElementFilter.packagesIn怎麽用?Java ElementFilter.packagesIn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.lang.model.util.ElementFilter的用法示例。


在下文中一共展示了ElementFilter.packagesIn方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addClassListing

import javax.lang.model.util.ElementFilter; //導入方法依賴的package包/類
/**
 * Add class listing for all the classes in this module. Divide class
 * listing as per the class kind and generate separate listing for
 * Classes, Interfaces, Exceptions and Errors.
 *
 * @param contentTree the content tree to which the listing will be added
 */
protected void addClassListing(HtmlTree contentTree) {
    List<PackageElement> packagesIn = ElementFilter.packagesIn(mdle.getEnclosedElements());
    SortedSet<TypeElement> interfaces = new TreeSet<>(utils.makeGeneralPurposeComparator());
    SortedSet<TypeElement> classes = new TreeSet<>(utils.makeGeneralPurposeComparator());
    SortedSet<TypeElement> enums = new TreeSet<>(utils.makeGeneralPurposeComparator());
    SortedSet<TypeElement> exceptions = new TreeSet<>(utils.makeGeneralPurposeComparator());
    SortedSet<TypeElement> errors = new TreeSet<>(utils.makeGeneralPurposeComparator());
    SortedSet<TypeElement> annotationTypes = new TreeSet<>(utils.makeGeneralPurposeComparator());
    for (PackageElement pkg : packagesIn) {
        if (utils.isIncluded(pkg)) {
            interfaces.addAll(utils.getInterfaces(pkg));
            classes.addAll(utils.getOrdinaryClasses(pkg));
            enums.addAll(utils.getEnums(pkg));
            exceptions.addAll(utils.getExceptions(pkg));
            errors.addAll(utils.getErrors(pkg));
            annotationTypes.addAll(utils.getAnnotationTypes(pkg));
        }
    }
    addClassKindListing(interfaces, contents.interfaces, contentTree);
    addClassKindListing(classes, contents.classes, contentTree);
    addClassKindListing(enums, contents.enums, contentTree);
    addClassKindListing(exceptions, contents.exceptions, contentTree);
    addClassKindListing(errors, contents.errors, contentTree);
    addClassKindListing(annotationTypes, contents.annotationTypes, contentTree);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:33,代碼來源:ModuleFrameWriter.java

示例2: getAllSelectedElements

import javax.lang.model.util.ElementFilter; //導入方法依賴的package包/類
Set<Element> getAllSelectedElements(DocletEnvironment docenv) {
    Set<Element> result = new TreeSet<Element>((Element e1, Element e2) -> {
        // some grouping by kind preferred
        int rc = e1.getKind().compareTo(e2.getKind());
        if (rc != 0) return rc;
        rc = e1.toString().compareTo(e2.toString());
        if (rc != 0) return rc;
        return Integer.compare(e1.hashCode(), e2.hashCode());
    });
    Set<? extends Element> elements = docenv.getIncludedElements();
    for (ModuleElement me : ElementFilter.modulesIn(elements)) {
        addEnclosedElements(docenv, result, me);
    }
    for (PackageElement pe : ElementFilter.packagesIn(elements)) {
        ModuleElement mdle = docenv.getElementUtils().getModuleOf(pe);
        if (mdle != null)
            addEnclosedElements(docenv, result, mdle);
        addEnclosedElements(docenv, result, pe);
    }
    for (TypeElement te : ElementFilter.typesIn(elements)) {
        addEnclosedElements(docenv, result, te);
    }
    return result;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:ModuleTestBase.java

示例3: computeModulePackages

import javax.lang.model.util.ElementFilter; //導入方法依賴的package包/類
private Set<PackageElement> computeModulePackages() throws ToolException {
    AccessKind accessValue = accessFilter.getAccessValue(ElementKind.PACKAGE);
    final boolean documentAllModulePackages = (accessValue == AccessKind.PACKAGE ||
            accessValue == AccessKind.PRIVATE);

    accessValue = accessFilter.getAccessValue(ElementKind.MODULE);
    final boolean moduleDetailedMode = (accessValue == AccessKind.PACKAGE ||
            accessValue == AccessKind.PRIVATE);
    Set<PackageElement> expandedModulePackages = new LinkedHashSet<>();

    for (ModuleElement mdle : specifiedModuleElements) {
        if (documentAllModulePackages) { // include all packages
            List<PackageElement> packages = ElementFilter.packagesIn(mdle.getEnclosedElements());
            expandedModulePackages.addAll(packages);
            expandedModulePackages.addAll(getAllModulePackages(mdle));
        } else { // selectively include required packages
            List<ExportsDirective> exports = ElementFilter.exportsIn(mdle.getDirectives());
            for (ExportsDirective export : exports) {
                // add if fully exported or add qualified exports only if desired
                if (export.getTargetModules() == null
                        || documentAllModulePackages || moduleDetailedMode) {
                    expandedModulePackages.add(export.getPackage());
                }
            }
        }

        // add all packages specified on the command line
        // belonging to this module
        if (!cmdLinePackages.isEmpty()) {
            for (ModulePackage modpkg : cmdLinePackages) {
                PackageElement pkg = toolEnv.elements.getPackageElement(mdle,
                        modpkg.packageName);
                if (pkg != null) {
                    expandedModulePackages.add(pkg);
                }
            }
        }
    }
    return expandedModulePackages;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:41,代碼來源:ElementsTable.java


注:本文中的javax.lang.model.util.ElementFilter.packagesIn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。