Java 类javax.lang.model.element.ModuleElement 实例源码

项目:incubator-netbeans    文件:ElementIcons.java   
/**
 * Returns an icon for the given {@link ModuleElement.DirectiveKind}.
 * @param kind the {@link ModuleElement.DirectiveKind} to return an icon for.
 * @return the icon
 * @since 1.45
 */
public static Icon getModuleDirectiveIcon(@NonNull final ModuleElement.DirectiveKind kind) {
    Parameters.notNull("kind", kind);   //NOI18N
    switch (kind) {
        case EXPORTS:
            return ImageUtilities.loadImageIcon(EXPORTS_ICON, true);
        case REQUIRES:
            return ImageUtilities.loadImageIcon(REQUIRES_ICON, true);
        case USES:
            return ImageUtilities.loadImageIcon(USES_ICON, true);
        case PROVIDES:
            return ImageUtilities.loadImageIcon(PROVIDES_ICON, true);
        case OPENS:
            return ImageUtilities.loadImageIcon(OPENS_ICON, true);
        default:
            throw new IllegalArgumentException(kind.toString());
    }
}
项目:incubator-netbeans    文件:ElementOverlay.java   
public Element resolve(ASTService ast, Elements elements, String what, ModuleElement modle) {
    Element result = null;

    if (classes.containsKey(what)) {
        result = createElement(ast, elements, what, null, modle);
    }

    if (result == null) {
        result = modle != null ? elements.getTypeElement(modle, what) : elements.getTypeElement(what);
    }

    if (result == null) {
        result = modle != null ? elements.getPackageElement(modle, what) : elements.getPackageElement(what);
    }

    result = createElement(ast, elements, what, result, modle);

    return result;
}
项目:incubator-netbeans    文件:ElementOverlay.java   
public Collection<? extends Element> getAllVisibleThrough(ASTService ast, Elements elements, String what, ClassTree tree, ModuleElement modle) {
    Collection<Element> result = new ArrayList<Element>();
    Element current = what != null ? resolve(ast, elements, what, modle) : null;

    if (current == null) {
        //can happen if:
        //what == null: anonymous class
        //TODO: what != null: apparently happens for JDK (where the same class occurs twice on one source path)
        //might be possible to use ASTService.getElementImpl(tree) to thet the correct element
        //use only supertypes:
        //XXX: will probably not work correctly for newly created NCT (as the ClassTree does not have the correct extends/implements:
        for (String sup : superFQNs(tree)) {
            Element c = resolve(ast, elements, sup, modle);

            if (c != null) {//may legitimely be null, e.g. if the super type is not resolvable at all.
                result.add(c);
            }
        }
    } else {
        result.addAll(getAllMembers(ast, elements, current));
    }

    return result;
}
项目:incubator-netbeans    文件:SourceAnalyzerFactory.java   
public UsagesVisitor (
        @NonNull final JavacTaskImpl jt,
        @NonNull final CompilationUnitTree cu,
        @NonNull final JavaFileManager manager,
        @NonNull final javax.tools.JavaFileObject sibling,
        @NullAllowed final Set<? super ElementHandle<TypeElement>> newTypes,
        @NullAllowed final Set<? super ElementHandle<ModuleElement>> newModules,
        final JavaCustomIndexer.CompileTuple tuple) throws MalformedURLException, IllegalArgumentException {
    this(
            jt,
            cu,
            inferBinaryName(manager, sibling),
            tuple.virtual ? tuple.indexable.getURL() : sibling.toUri().toURL(),
            true,
            tuple.virtual,
            newTypes,
            newModules,
            null);
}
项目:incubator-netbeans    文件:CompileWorker.java   
private ParsingOutput(
        final boolean success,
        final boolean lowMemory,
        @NullAllowed final String moduleName,
        Map<JavaFileObject, List<String>> file2FQNs,
        Set<ElementHandle<TypeElement>> addedTypes,
        Set<ElementHandle<ModuleElement>> addedModules,
        Set<File> createdFiles,
        Set<Indexable> finishedFiles,
        Set<ElementHandle<TypeElement>> modifiedTypes,
        Set<javax.tools.FileObject> aptGenerated) {
    assert (success && !lowMemory) || !success;
    this.success = success;
    this.lowMemory = lowMemory;
    this.moduleName = moduleName;
    this.file2FQNs = file2FQNs;
    this.addedTypes = addedTypes;
    this.addedModules = addedModules;
    this.createdFiles = createdFiles;
    this.finishedFiles = finishedFiles;
    this.modifiedTypes = modifiedTypes;
    this.aptGenerated = aptGenerated;
}
项目:incubator-netbeans    文件:ElementUtils.java   
public static TypeElement getTypeElementByBinaryName(JavacTask task, String name) {
    Set<? extends ModuleElement> allModules = task.getElements().getAllModuleElements();

    if (allModules.isEmpty()) {
        Context ctx = ((JavacTaskImpl) task).getContext();
        Symtab syms = Symtab.instance(ctx);

        return getTypeElementByBinaryName(task, syms.noModule, name);
    }

    TypeElement result = null;

    for (ModuleElement me : allModules) {
        TypeElement found = getTypeElementByBinaryName(task, me, name);

        if (found != null) {
            if (result != null) return null;
            result = found;
        }
    }

    return result;
}
项目:incubator-netbeans    文件:ElementUtils.java   
public static TypeElement getTypeElementByBinaryName(JavacTask task, ModuleElement mod, String name) {
    Context ctx = ((JavacTaskImpl) task).getContext();
    Names names = Names.instance(ctx);
    Symtab syms = Symtab.instance(ctx);
    final Name wrappedName = names.fromString(name);
    ClassSymbol clazz = syms.enterClass((ModuleSymbol) mod, wrappedName);

    try {
        clazz.complete();

        if (clazz.kind == Kind.TYP &&
            clazz.flatName() == wrappedName) {
            return clazz;
        }
    } catch (CompletionFailure cf) {
    }

    return null;
}
项目:incubator-netbeans    文件:ElementHandle.java   
/**
 * Resolves an {@link Element} from the {@link ElementHandle}.
 * @param compilationInfo representing the {@link javax.tools.CompilationTask}
 * in which the {@link Element} should be resolved.
 * @return resolved subclass of {@link Element} or null if the elment does not exist on
 * the classpath/sourcepath of {@link javax.tools.CompilationTask}.
 */
@SuppressWarnings ("unchecked")     // NOI18N
public @CheckForNull T resolve (@NonNull final CompilationInfo compilationInfo) {
    Parameters.notNull("compilationInfo", compilationInfo); // NOI18N
    ModuleElement module = compilationInfo.getFileObject() != null
            ? ((JCTree.JCCompilationUnit)compilationInfo.getCompilationUnit()).modle
            : null;
    T result = resolveImpl (module, compilationInfo.impl.getJavacTask());
    if (result == null) {
        if (log.isLoggable(Level.INFO))
            log.log(Level.INFO, "Cannot resolve: {0}", toString()); //NOI18N                
    } else {
        if (log.isLoggable(Level.FINE))
            log.log(Level.FINE, "Resolved element = {0}", result);
    }
    return result;
}
项目:incubator-netbeans    文件:ModuleInfoSupport.java   
private static Set<String> getDeclaredModules(final JavaSource src) {
    Set<String> declaredModuleNames = new HashSet<>();
    try {
        src.runUserActionTask((cc)-> {
            cc.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
            final List<? extends Tree> decls = cc.getCompilationUnit().getTypeDecls();
            final ModuleElement me =  !decls.isEmpty() && decls.get(0).getKind() == Tree.Kind.MODULE ?
                    (ModuleElement) cc.getTrees().getElement(TreePath.getPath(cc.getCompilationUnit(), decls.get(0))) :
                    null;
            if (me != null) {
                for (ModuleElement.Directive d : me.getDirectives()) {
                    if (d.getKind() == ModuleElement.DirectiveKind.REQUIRES) {
                        final ModuleElement.RequiresDirective reqD = (ModuleElement.RequiresDirective) d;
                        final String name = reqD.getDependency().getQualifiedName().toString();
                        declaredModuleNames.add(name);
                    }
                }
            }
        }, true);
    } catch (IOException ex) {
        LOG.log(Level.WARNING, null, ex);
    }
    log("Declared modules:", declaredModuleNames); // NOI18N
    return declaredModuleNames;
}
项目:openjdk-jdk10    文件:ModuleWriterImpl.java   
/**
 * Add the indirect packages for the module being documented.
 *
 * @param tbody the content tree to which the table will be added
 * @param ip indirect packages to be added
 */
public void addIndirectPackages(Content tbody, Map<ModuleElement, SortedSet<PackageElement>> ip) {
    boolean altColor = true;
    for (Map.Entry<ModuleElement, SortedSet<PackageElement>> entry : ip.entrySet()) {
        ModuleElement m = entry.getKey();
        SortedSet<PackageElement> pkgList = entry.getValue();
        Content moduleLinkContent = getModuleLink(m, new StringContent(m.getQualifiedName()));
        Content thModule = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, moduleLinkContent);
        HtmlTree tdPackages = new HtmlTree(HtmlTag.TD);
        tdPackages.addStyle(HtmlStyle.colLast);
        String sep = "";
        for (PackageElement pkg : pkgList) {
            tdPackages.addContent(sep);
            tdPackages.addContent(getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))));
            sep = " ";
        }
        HtmlTree tr = HtmlTree.TR(thModule);
        tr.addContent(tdPackages);
        tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor);
        tbody.addContent(tr);
        altColor = !altColor;
    }
}
项目:openjdk-jdk10    文件:AnnotationProcessing.java   
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    TypeElement api = processingEnv.getElementUtils().getTypeElement("api.Api");

    assertNonNull("Cannot find api.Api", api);

    ModuleElement modle = (ModuleElement) processingEnv.getElementUtils().getPackageOf(api).getEnclosingElement();

    assertNonNull("modle is null", modle);

    List<? extends UsesDirective> uses = ElementFilter.usesIn(modle.getDirectives());
    assertEquals(1, uses.size());
    assertEquals("api.Api", uses.iterator().next().getService().getQualifiedName().toString());

    List<? extends ProvidesDirective> provides = ElementFilter.providesIn(modle.getDirectives());
    assertEquals(1, provides.size());
    assertEquals("api.Api", provides.iterator().next().getService().getQualifiedName().toString());
    assertEquals("impl.Impl", provides.iterator().next().getImplementations().get(0).getQualifiedName().toString());

    return false;
}
项目:incubator-netbeans    文件:ModuleClassPathsTest.java   
private static void collectDeps(
    @NullAllowed final ModuleElement me,
    @NonNull final Collection<? super String> modNames) {
    if (me != null) {
        final String mn = me.getQualifiedName().toString();
        if (!modNames.contains(mn)) {
            modNames.add(mn);
            for (ModuleElement.Directive d : me.getDirectives()) {
                if (d.getKind() == ModuleElement.DirectiveKind.REQUIRES) {
                    final ModuleElement.RequiresDirective rd = (ModuleElement.RequiresDirective)d;
                    if (rd.isTransitive()|| isMandated(rd)) {
                        collectDeps(rd.getDependency(), modNames);
                    }
                }
            }
        }
    }
}
项目:openjdk-jdk10    文件:ModuleIndexWriter.java   
/**
 * Add the list of modules.
 *
 * @param text The table caption
 * @param tableSummary the summary of the table tag
 * @param body the content tree to which the module list will be added
 */
protected void addModulesList(Collection<ModuleElement> modules, String text, String tableSummary, Content body) {
    Content table = (configuration.isOutputHtml5())
            ? HtmlTree.TABLE(HtmlStyle.overviewSummary, getTableCaption(new RawHtml(text)))
            : HtmlTree.TABLE(HtmlStyle.overviewSummary, tableSummary, getTableCaption(new RawHtml(text)));
    table.addContent(getSummaryTableHeader(moduleTableHeader, "col"));
    Content tbody = new HtmlTree(HtmlTag.TBODY);
    addModulesList(modules, tbody);
    table.addContent(tbody);
    Content anchor = getMarkerAnchor(text);
    Content div = HtmlTree.DIV(HtmlStyle.contentContainer, anchor);
    div.addContent(table);
    if (configuration.allowTag(HtmlTag.MAIN)) {
        htmlTree.addContent(div);
    } else {
        body.addContent(div);
    }
}
项目:incubator-netbeans    文件:ElementNode.java   
private static int directivePosInKind(ModuleElement.DirectiveKind kind) {
    switch (kind) {
        case EXPORTS:
            return 0;
        case OPENS:
            return 1;
        case REQUIRES:
            return 2;
        case USES:
            return 3;
        case PROVIDES:
            return 4;
        default:
            return 100;
    }
}
项目:incubator-netbeans    文件:OpenAction.java   
@NonNull
public static Openable openable(
    @NonNull final ModuleElement module,
    @NonNull final ModuleElement.Directive directive,
    @NonNull final ClasspathInfo cpInfo) {
    final String displayName = module.getQualifiedName().toString();
    final ElementHandle<ModuleElement> moduleHandle = ElementHandle.create(module);
    final Object[] directiveHandle = createDirectiveHandle(directive);
    return () -> {
        final FileObject source = SourceUtils.getFile(moduleHandle, cpInfo);
        if (source == null) {
            noSource(displayName);
        }
        TreePathHandle path = resolveDirectiveHandle(source, directiveHandle);
        if (path == null) {
            noSource(displayName);
        }
        if (!ElementOpen.open(source, path)) {
            noSource(displayName);
        }
    };
}
项目:incubator-netbeans    文件:OpenAction.java   
@NonNull
private static Object[] createDirectiveHandle(@NonNull ModuleElement.Directive dir) {
    switch (dir.getKind()) {
        case EXPORTS:
            return new Object[] {dir.getKind(), ((ModuleElement.ExportsDirective)dir).getPackage().getQualifiedName().toString()};
        case OPENS:
            return new Object[] {dir.getKind(), ((ModuleElement.OpensDirective)dir).getPackage().getQualifiedName().toString()};
        case REQUIRES:
            return new Object[] {dir.getKind(), ((ModuleElement.RequiresDirective)dir).getDependency().getQualifiedName().toString()};
        case USES:
            return new Object[] {dir.getKind(), ((ModuleElement.UsesDirective)dir).getService().getQualifiedName().toString()};
        case PROVIDES:
            return new Object[] {dir.getKind(), ((ModuleElement.ProvidesDirective)dir).getService().getQualifiedName().toString()};
        default:
            throw new IllegalArgumentException(String.valueOf(dir));
    }
}
项目:openjdk-jdk10    文件:ModuleInfoTreeAccess.java   
@Test
public void testTreePathForModuleDeclWithImport(Path base) throws Exception {
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
        Path src = base.resolve("src");
        tb.writeJavaFiles(src, "import java.lang.Deprecated; /** Test module */ @Deprecated module m1x {}");

        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(findJavaFiles(src));
        JavacTask task = (JavacTask) compiler.getTask(null, fm, null, null, null, files);

        task.analyze();
        JavacTrees trees = JavacTrees.instance(task);
        ModuleElement mdle = (ModuleElement) task.getElements().getModuleElement("m1x");

        TreePath path = trees.getPath(mdle);
        assertNotNull("path", path);

        ModuleElement mdle1 = (ModuleElement) trees.getElement(path);
        assertNotNull("mdle1", mdle1);

        DocCommentTree docCommentTree = trees.getDocCommentTree(mdle);
        assertNotNull("docCommentTree", docCommentTree);
    }
}
项目:incubator-netbeans    文件:ElementScanningTask.java   
@Override
public Context visitModule(ModuleTree node, Void p) {
    final ModuleElement module = (ModuleElement) trees.getElement(getCurrentPath());
    if (module != null) {
        ctx.pos.put(module, this.sourcePositions.getStartPosition(cu, node));
        final List<? extends ModuleElement.Directive> de = module.getDirectives();
        final List<? extends DirectiveTree> dt = node.getDirectives();
        for (int i = 0, j = 0; i < de.size() ; i++) {
            if (isImportant(de.get(i))) {
                ctx.directives.put(de.get(i), dt.get(j));
                ctx.pos.put(de.get(i), this.sourcePositions.getStartPosition(cu, dt.get(j)));
                j += 1;
            }
        }
    }
    return super.visitModule(node, p);
}
项目:incubator-netbeans    文件:ElementScanningTask.java   
/**
 * Tests if the directive is important (neither synthetic nor mandated).
 * Hack of missing javac API for testing synthetic directives
 */
private static boolean isImportant(@NonNull final ModuleElement.Directive directive) {
    if (directive instanceof ModuleElement.RequiresDirective) {
        try {
            final Set<?> flags = (Set) directive.getClass().getField("flags").get(directive);   //NOI18N
            int expectedSize = 0;
            if (((ModuleElement.RequiresDirective)directive).isStatic())
                expectedSize++;
            if (((ModuleElement.RequiresDirective)directive).isTransitive())
                expectedSize++;
            return flags.size() == expectedSize;
        } catch (ReflectiveOperationException e) {
            throw new IllegalStateException(e);
        }
    } else {
        return true;
    }
}
项目:openjdk-jdk10    文件:TraverseProc.java   
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
    if (roundEnv.processingOver()) {
        return false;
    }

    Set<ModuleElement> modules = new HashSet<>();
    for (String mname : moduleRoots) {
        ModuleElement me = elements.getModuleElement(mname);
        if (me == null) {
            messager.printMessage(Diagnostic.Kind.ERROR,
                                  String.format("module %s not found%n", mname));
        } else {
            modules.addAll(findModules(me));
        }
    }

    Set<PackageElement> packages = findPackages(modules);

    publicTypes = findPublicTypes(packages);

    return true;
}
项目:openjdk-jdk10    文件:HtmlDoclet.java   
/**
 * {@inheritDoc}
 */
@Override // defined by AbstractDoclet
protected void generateModuleFiles() throws DocletException {
    if (configuration.showModules) {
        if (configuration.frames  && configuration.modules.size() > 1) {
            ModuleIndexFrameWriter.generate(configuration);
        }
        ModuleElement prevModule = null, nextModule;
        List<ModuleElement> mdles = new ArrayList<>(configuration.modulePackages.keySet());
        int i = 0;
        for (ModuleElement mdle : mdles) {
            if (configuration.frames && configuration.modules.size() > 1) {
                ModulePackageIndexFrameWriter.generate(configuration, mdle);
                ModuleFrameWriter.generate(configuration, mdle);
            }
            nextModule = (i + 1 < mdles.size()) ? mdles.get(i + 1) : null;
            AbstractBuilder moduleSummaryBuilder =
                    configuration.getBuilderFactory().getModuleSummaryBuilder(
                    mdle, prevModule, nextModule);
            moduleSummaryBuilder.build();
            prevModule = mdle;
            i++;
        }
    }
}
项目:openjdk-jdk10    文件:ElementsTable.java   
/**
 * Returns the "requires" modules for the target module.
 * @param mdle the target module element
 * @param onlyTransitive true gets all the requires transitive, otherwise
 *                 gets all the non-transitive requires
 *
 * @return a set of modules
 */
private Set<ModuleElement> getModuleRequires(ModuleElement mdle, boolean onlyTransitive) throws ToolException {
    Set<ModuleElement> result = new HashSet<>();
    for (RequiresDirective rd : ElementFilter.requiresIn(mdle.getDirectives())) {
        ModuleElement dep = rd.getDependency();
        if (result.contains(dep))
            continue;
        if (!isMandated(mdle, rd) && onlyTransitive == rd.isTransitive()) {
            if (!haveModuleSources(dep)) {
                messager.printWarning(dep, "main.module_not_found", dep.getSimpleName());
            }
            result.add(dep);
        } else if (isMandated(mdle, rd) && haveModuleSources(dep)) {
            result.add(dep);
        }
    }
    return result;
}
项目:openjdk-jdk10    文件:ModuleIndexFrameWriter.java   
/**
 * {@inheritDoc}
 */
protected void addModulesList(Collection<ModuleElement> modules, String text,
        String tableSummary, Content body) {
    Content heading = HtmlTree.HEADING(HtmlConstants.MODULE_HEADING, true,
            contents.modulesLabel);
    HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
            ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
            : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
    HtmlTree ul = new HtmlTree(HtmlTag.UL);
    ul.setTitle(contents.modulesLabel);
    for (ModuleElement mdle: modules) {
        ul.addContent(getModuleLink(mdle));
    }
    htmlTree.addContent(ul);
    body.addContent(htmlTree);
}
项目:openjdk-jdk10    文件:ElementsTable.java   
private void computeSpecifiedPackages() throws ToolException {

        computeSubpackages();

        Set<PackageElement> packlist = new LinkedHashSet<>();
        cmdLinePackages.forEach((modpkg) -> {
            PackageElement pkg;
            if (modpkg.hasModule()) {
                ModuleElement mdle = toolEnv.elements.getModuleElement(modpkg.moduleName);
                pkg = toolEnv.elements.getPackageElement(mdle, modpkg.packageName);
            } else {
                pkg = toolEnv.elements.getPackageElement(modpkg.toString());
            }

            if (pkg != null) {
                packlist.add(pkg);
            } else {
                messager.printWarningUsingKey("main.package_not_found", modpkg.toString());
            }
        });
        specifiedPackageElements = Collections.unmodifiableSet(packlist);
    }
项目:openjdk-jdk10    文件:Utils.java   
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);
}
项目:openjdk-jdk10    文件:ModulePackageIndexFrameWriter.java   
/**
 * {@inheritDoc}
 */
protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
        String tableSummary, Content body, ModuleElement mdle) {
    Content profNameContent = new StringContent(mdle.getQualifiedName().toString());
    Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
            getTargetModuleLink("classFrame", profNameContent, mdle));
    heading.addContent(Contents.SPACE);
    heading.addContent(contents.packagesLabel);
    HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
            ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
            : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
    HtmlTree ul = new HtmlTree(HtmlTag.UL);
    ul.setTitle(contents.packagesLabel);
    List<PackageElement> packages = new ArrayList<>(modules.get(mdle));
    for (PackageElement pkg : packages) {
        if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) {
            ul.addContent(getPackage(pkg, mdle));
        }
    }
    htmlTree.addContent(ul);
    body.addContent(htmlTree);
}
项目:openjdk-jdk10    文件:ModulePackageIndexFrameWriter.java   
/**
 * {@inheritDoc}
 */
protected void addModulePackagesList(Set<ModuleElement> modules, String text,
        String tableSummary, Content body, ModuleElement mdle) {
    Content moduleNameContent = new StringContent(mdle.getQualifiedName().toString());
    Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true,
            getTargetModuleLink("classFrame", moduleNameContent, mdle));
    heading.addContent(Contents.SPACE);
    heading.addContent(contents.packagesLabel);
    HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN))
            ? HtmlTree.MAIN(HtmlStyle.indexContainer, heading)
            : HtmlTree.DIV(HtmlStyle.indexContainer, heading);
    HtmlTree ul = new HtmlTree(HtmlTag.UL);
    ul.setTitle(contents.packagesLabel);
    Set<PackageElement> modulePackages = configuration.modulePackages.get(mdle);
    for (PackageElement pkg: modulePackages) {
        if ((!(configuration.nodeprecated && utils.isDeprecated(pkg)))) {
            ul.addContent(getPackage(pkg, mdle));
        }
    }
    htmlTree.addContent(ul);
    body.addContent(htmlTree);
}
项目:openjdk-jdk10    文件:ModulePackageIndexFrameWriter.java   
/**
 * Returns each package name as a separate link.
 *
 * @param pkg PackageElement
 * @param mdle the module being documented
 * @return content for the package link
 */
protected Content getPackage(PackageElement pkg, ModuleElement mdle) {
    Content packageLinkContent;
    Content pkgLabel;
    if (!pkg.isUnnamed()) {
        pkgLabel = getPackageLabel(utils.getPackageName(pkg));
        packageLinkContent = getHyperLink(pathString(pkg,
                 DocPaths.PACKAGE_FRAME), pkgLabel, "",
                "packageFrame");
    } else {
        pkgLabel = new StringContent("<unnamed package>");
        packageLinkContent = getHyperLink(DocPaths.PACKAGE_FRAME,
                pkgLabel, "", "packageFrame");
    }
    Content li = HtmlTree.LI(packageLinkContent);
    return li;
}
项目:incubator-netbeans    文件:ElementJavadoc.java   
private StringBuilder getElementHeader(final Element element, final CompilationInfo info) {
    final StringBuilder sb = new StringBuilder();
    if (element != null) {
        sb.append(getContainingClassOrPackageHeader(element, info.getElements(), info.getElementUtilities()));
        switch(element.getKind()) {
            case METHOD:
            case CONSTRUCTOR:
                sb.append(getMethodHeader((ExecutableElement)element));
                break;
            case FIELD:
            case ENUM_CONSTANT:
                sb.append(getFieldHeader((VariableElement)element));
                break;
            case CLASS:
            case INTERFACE:
            case ENUM:
            case ANNOTATION_TYPE:
                sb.append(getClassHeader((TypeElement)element));
                break;
            case PACKAGE:
                sb.append(getPackageHeader((PackageElement)element));
                break;
            case MODULE:
                sb.append(getModuleHeader((ModuleElement)element));
                break;
        }
    }
    return sb;
}
项目:incubator-netbeans    文件:ElementJavadoc.java   
private StringBuilder getModuleHeader(ModuleElement mdoc) {
    StringBuilder sb = new StringBuilder();
    sb.append("<pre>"); //NOI18N
    mdoc.getAnnotationMirrors().forEach((annotationDesc) -> {
        appendAnnotation(sb, annotationDesc, true);
    });
    sb.append("module <b>").append(mdoc.getQualifiedName()).append("</b>"); //NOI18N
    sb.append("</pre>"); //NOI18N
    return sb;
}
项目:openjdk-jdk10    文件:ModuleIndexFrameWriter.java   
/**
 * Returns each module name as a separate link.
 *
 * @param mdle the module being documented
 * @return content for the module link
 */
protected Content getModuleLink(ModuleElement mdle) {
    Content moduleLinkContent;
    Content mdlLabel = new StringContent(mdle.getQualifiedName());
    moduleLinkContent = getModuleFramesHyperLink(mdle, mdlLabel, "packageListFrame");
    Content li = HtmlTree.LI(moduleLinkContent);
    return li;
}
项目:incubator-netbeans    文件:ElementOverlay.java   
public FakeTypeElement(ASTService ast, Elements elements, Name simpleName, Name fqn, String fqnString, Element parent, Set<Modifier> mods, ModuleElement modle) {
    this.ast = ast;
    this.elements = elements;
    this.simpleName = simpleName;
    this.fqn = fqn;
    this.fqnString = fqnString;
    this.parent = parent;
    this.mods = mods;
    this.modle = modle;
}
项目:incubator-netbeans    文件:ElementOverlay.java   
public FakePackageElement(ASTService ast, Elements elements, Name fqn, String fqnString, Name simpleName, ModuleElement modle) {
    this.ast = ast;
    this.elements = elements;
    this.fqn = fqn;
    this.fqnString = fqnString;
    this.simpleName = simpleName;
    this.modle = modle;
}
项目:incubator-netbeans    文件:SourceAnalyzerFactory.java   
private UsagesVisitor(
        @NonNull final JavacTaskImpl jt,
        @NonNull final CompilationUnitTree cu,
        @NonNull final String sourceName,
        @NonNull final URL siblingUrl,
        final boolean sigFiles,
        final boolean virtual,
        @NullAllowed final Set<? super ElementHandle<TypeElement>> newTypes,
        @NullAllowed final Set<? super ElementHandle<ModuleElement>> newModules,
        @NullAllowed final Set<? super Pair<String,String>> topLevels) {
    assert sourceName != null;
    assert jt != null;
    assert cu != null;
    this.activeClass = new Stack<> ();
    this.imports = new HashSet<> ();
    this.staticImports = new HashSet<> ();
    this.unusedPkgImports = new HashSet<>();
    this.importIdents = new HashSet<>();
    this.packageAnnotationIdents = new HashSet<>();
    this.packageAnnotations = new HashSet<>();
    this.names = Names.instance(jt.getContext());
    this.trees = Trees.instance(jt);
    this.state = State.OTHER;
    this.cu = cu;
    this.signatureFiles = sigFiles;
    this.virtual = virtual;
    this.newTypes = newTypes;
    this.newModules = newModules;
    this.topLevels = topLevels;
    this.sourceName = sourceName;
    this.siblingUrl = siblingUrl;
}
项目:incubator-netbeans    文件:ClassIndexEventsTransaction.java   
/**
 * Notifies the {@link ClassIndexEventsTransaction} that types were added
 * in the root.
 * @param root the root in which the types were added.
 * @param added the added types.
 */
public void addedTypes(
    @NonNull final URL root,
    @NullAllowed final ElementHandle<ModuleElement> module,
    @NonNull final Collection<? extends ElementHandle<TypeElement>> added) {
    checkClosedTx();
    assert root != null;
    assert added != null;
    assert changesInRoot == null || changesInRoot.equals(root);
    assert addedRoot == null || addedRoot.equals(root);
    assert addedModule == null || module == null;
    addedModule = reduce(addedModule, module);
    addedTypes.addAll(added);
    changesInRoot = root;
}
项目:incubator-netbeans    文件:ClassIndexEventsTransaction.java   
/**
 * Notifies the {@link ClassIndexEventsTransaction} that types were removed
 * from the root.
 * @param root the root from which the types were removed.
 * @param removed the removed types.
 */
public void removedTypes(
    @NonNull final URL root,
    @NullAllowed final ElementHandle<ModuleElement> module,
    @NonNull final Collection<? extends ElementHandle<TypeElement>> removed) {
    checkClosedTx();
    assert root != null;
    assert removed != null;
    assert changesInRoot == null || changesInRoot.equals(root);
    assert addedRoot == null || addedRoot.equals(root);
    assert removedModule == null || module == null;
    removedModule = reduce(removedModule, module);
    removedTypes.addAll(removed);
    changesInRoot = root;
}
项目:incubator-netbeans    文件:ClassIndexEventsTransaction.java   
/**
 * Notifies the {@link ClassIndexEventsTransaction} that types were changed
 * in the root.
 * @param root the root in which the types were changed.
 * @param changed the changed types.
 */
public void changedTypes(
    @NonNull final URL root,
    @NullAllowed final ElementHandle<ModuleElement> module,
    @NonNull final Collection<? extends ElementHandle<TypeElement>> changed) {
    checkClosedTx();
    assert root != null;
    assert changed != null;
    assert changesInRoot == null || changesInRoot.equals(root);
    assert addedRoot == null || addedRoot.equals(root);
    assert changedModule == null || module == null;
    changedModule = reduce(changedModule, module);
    changedTypes.addAll(changed);
    changesInRoot = root;
}
项目:incubator-netbeans    文件:CompileWorker.java   
public static ParsingOutput success (
        @NullAllowed final String moduleName,
        final Map<JavaFileObject, List<String>> file2FQNs,
        final Set<ElementHandle<TypeElement>> addedTypes,
        final Set<ElementHandle<ModuleElement>> addedModules,
        final Set<File> createdFiles,
        final Set<Indexable> finishedFiles,
        final Set<ElementHandle<TypeElement>> modifiedTypes,
        final Set<javax.tools.FileObject> aptGenerated) {
    return new ParsingOutput(true, false, moduleName, file2FQNs,
            addedTypes, addedModules, createdFiles, finishedFiles,
            modifiedTypes, aptGenerated);
}
项目:incubator-netbeans    文件:CompileWorker.java   
public static ParsingOutput failure(
        @NullAllowed final String moduleName,
        final Map<JavaFileObject, List<String>> file2FQNs,
        final Set<ElementHandle<TypeElement>> addedTypes,
        final Set<ElementHandle<ModuleElement>> addedModules,
        final Set<File> createdFiles,
        final Set<Indexable> finishedFiles,
        final Set<ElementHandle<TypeElement>> modifiedTypes,
        final Set<javax.tools.FileObject> aptGenerated) {
    return new ParsingOutput(false, false, moduleName, file2FQNs,
            addedTypes, addedModules, createdFiles, finishedFiles,
            modifiedTypes, aptGenerated);
}
项目:openjdk-jdk10    文件:ModuleIndexWriter.java   
/**
 * Adds module index contents.
 *
 * @param title the title of the section
 * @param tableSummary summary for the table
 * @param body the document tree to which the index contents will be added
 */
protected void addIndexContents(Collection<ModuleElement> modules, String title, String tableSummary, Content body) {
    HtmlTree htmltree = (configuration.allowTag(HtmlTag.NAV))
            ? HtmlTree.NAV()
            : new HtmlTree(HtmlTag.DIV);
    htmltree.addStyle(HtmlStyle.indexNav);
    HtmlTree ul = new HtmlTree(HtmlTag.UL);
    addAllClassesLink(ul);
    if (configuration.showModules) {
        addAllModulesLink(ul);
    }
    htmltree.addContent(ul);
    body.addContent(htmltree);
    addModulesList(modules, title, tableSummary, body);
}