pedro-w commented on code in PR #8662:
URL: https://github.com/apache/netbeans/pull/8662#discussion_r2297403267
##########
java/java.api.common/src/org/netbeans/modules/java/api/common/queries/ModuleInfoAccessibilityQueryImpl.java:
##########
@@ -232,48 +236,49 @@ private Collection<FileObject[]> collectModuleRoots(
final MultiModule model = MultiModule.getOrCreate(mods, src);
for (String modName : model.getModuleNames()) {
final ClassPath cp = model.getModuleSources(modName);
- res.add(cp.getRoots());
+ if (cp != null) {
+ res.add(cp.getRoots());
+ }
}
return res;
}
@NonNull
- private static Optional<Pair<Set<FileObject>,Set<FileObject>>> readExports(
- @NonNull final FileObject[] roots,
- @NonNull final Set<? super FileObject> rootsCollector) {
- Collections.addAll(rootsCollector, roots);
- final Optional<FileObject> moduleInfo = Arrays.stream(roots)
- .map((root) -> root.getFileObject(MODULE_INFO_JAVA))
- .filter((mi) -> mi != null)
+ private static Optional<Pair<Set<FileObject>, Set<FileObject>>>
extractExports(
+ @NonNull final FileObject[] roots) {
+ return Arrays.stream(roots)
+ .map(root -> root.getFileObject(MODULE_INFO_JAVA))
+ .filter(Objects::nonNull)
+ .map(mi -> {
+ Set<FileObject> rootsSet = new HashSet<>();
+ Collections.addAll(rootsSet, roots);
+ Set<FileObject> exportsSet = readExports(mi, rootsSet);
+ return Pair.of(rootsSet, exportsSet);
+ })
.findFirst();
Review Comment:
There isn't a constructor for HashSet` that takes an array (I don't think?)
so I used `Set.of` instead - AFAICS the set is only ever read from so this is
OK.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists