Java Code Examples for javax.lang.model.element.ModuleElement#isUnnamed()
The following examples show how to use
javax.lang.model.element.ModuleElement#isUnnamed() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModuleClassPaths.java From netbeans with Apache License 2.0 | 6 votes |
private static boolean dependsOnUnnamed( @NonNull final ModuleElement module, final boolean transitive, final boolean topLevel, final Set<ModuleElement> seen) { if (module.isUnnamed()) { return true; } if (seen.add(module)) { for (ModuleElement.Directive d : module.getDirectives()) { if (d.getKind() == ModuleElement.DirectiveKind.REQUIRES) { final ModuleElement.RequiresDirective rd = (ModuleElement.RequiresDirective) d; if (topLevel || (transitive && rd.isTransitive())) { if (dependsOnUnnamed(rd.getDependency(), transitive, false, seen)) { return true; } } } } } return false; }
Example 2
Source File: ModuleIndexWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Adds list of modules in the index table. Generate link to each module. * * @param tbody the documentation tree to which the list will be added */ protected void addModulesList(Collection<ModuleElement> modules, Content tbody) { boolean altColor = true; for (ModuleElement mdle : modules) { if (!mdle.isUnnamed()) { Content moduleLinkContent = getModuleLink(mdle, new StringContent(mdle.getQualifiedName().toString())); Content thModule = HtmlTree.TH_ROW_SCOPE(HtmlStyle.colFirst, moduleLinkContent); HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); tdSummary.addStyle(HtmlStyle.colLast); addSummaryComment(mdle, tdSummary); HtmlTree tr = HtmlTree.TR(thModule); tr.addContent(tdSummary); tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); tbody.addContent(tr); } altColor = !altColor; } }
Example 3
Source File: JavadocHelper.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private Pair<JavacTask, TreePath> getSourceElement(JavacTask origin, Element el) throws IOException { String handle = elementSignature(el); Pair<JavacTask, TreePath> cached = signature2Source.get(handle); if (cached != null) { return cached.fst != null ? cached : null; } TypeElement type = topLevelType(el); if (type == null) return null; Elements elements = origin.getElements(); String binaryName = elements.getBinaryName(type).toString(); ModuleElement module = elements.getModuleOf(type); String moduleName = module == null || module.isUnnamed() ? null : module.getQualifiedName().toString(); Pair<JavacTask, CompilationUnitTree> source = findSource(moduleName, binaryName); if (source == null) return null; fillElementCache(source.fst, source.snd); cached = signature2Source.get(handle); if (cached != null) { return cached; } else { signature2Source.put(handle, Pair.of(null, null)); return null; } }
Example 4
Source File: Group.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Group the modules according the grouping information provided on the * command line. Given a list of modules, search each module name in * regular expression map as well as module name map to get the * corresponding group name. Create another map with mapping of group name * to the module list, which will fall under the specified group. If any * module doesn't belong to any specified group on the command line, then * a new group named "Other Modules" will be created for it. If there are * no groups found, in other words if "-group" option is not at all used, * then all the modules will be grouped under group "Modules". * * @param modules Specified modules. * @return map of group names and set of module elements. */ public Map<String, SortedSet<ModuleElement>> groupModules(Set<ModuleElement> modules) { Map<String, SortedSet<ModuleElement>> groupModuleMap = new HashMap<>(); String defaultGroupName = (elementNameGroupMap.isEmpty() && regExpGroupMap.isEmpty())? configuration.getResources().getText("doclet.Modules") : configuration.getResources().getText("doclet.Other_Modules"); // if the user has not used the default group name, add it if (!groupList.contains(defaultGroupName)) { groupList.add(defaultGroupName); } for (ModuleElement mdl : modules) { String moduleName = mdl.isUnnamed() ? null : mdl.getQualifiedName().toString(); String groupName = mdl.isUnnamed() ? null : elementNameGroupMap.get(moduleName); // if this module is not explicitly assigned to a group, // try matching it to group specified by regular expression if (groupName == null) { groupName = regExpGroupName(moduleName); } // if it is in neither group map, put it in the default // group if (groupName == null) { groupName = defaultGroupName; } getModuleList(groupModuleMap, groupName).add(mdl); } return groupModuleMap; }
Example 5
Source File: EdgeCases.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (round++ != 0) return false; Elements elements = processingEnv.getElementUtils(); PackageElement pe = elements.getPackageElement(""); if (pe == null) { System.out.println("null"); } else { ModuleElement mod = (ModuleElement) pe.getEnclosingElement(); if (mod == null) { System.out.println("noModule"); } else if (mod.isUnnamed()) { System.out.println("unnamedModule"); } else { System.out.println(mod); } } ModuleElement m1x = elements.getModuleElement("m1x"); ModuleElement m2x = elements.getModuleElement("m2x"); if (m1x != null && m2x != null) { System.out.println("m1x: " + (elements.getPackageElement(m1x, "") != null)); System.out.println("m2x: " + (elements.getPackageElement(m2x, "") != null)); } return false; }