lbownik commented on code in PR #5711:
URL: https://github.com/apache/netbeans/pull/5711#discussion_r1147872559
##########
platform/o.n.bootstrap/src/org/netbeans/ModuleManager.java:
##########
@@ -1751,74 +1775,97 @@ private void maybeAddToEnableList(Set<Module>
willEnable, Set<Module> mightEnabl
// Cannot satisfy its dependencies, exclude it.
return;
}
+ if (reported.add(m)) {
+ if (addedBecauseOfDependent == null) {
+ DEPLOG.log(Level.FINE, "DEP: \"" + m.getCodeNameBase() + '"' +
(eagerActivation ? "[color=cornsilk]" : ""));
+ } else if
(!addedBecauseOfDependent.getCodeNameBase().equals(m.getCodeNameBase())) {
+ DEPLOG.log(Level.FINE, "DEP: \"" +
addedBecauseOfDependent.getCodeNameBase() + "\" "+ "->\""
+ + (reason != null ? "[label=\"" + reason + "\"]" : "")
+ + " " + m.getCodeNameBase() + '"');
+ }
+ }
+
if (!willEnable.add(m)) {
// Already there, done.
return;
}
- // need to register fragments eagerly, so they are available during
- // dependency sort
- Module host = attachModuleFragment(m);
- if (host != null && !host.isEnabled()) {
- maybeAddToEnableList(willEnable, mightEnable, host, okToFail);
- }
- // Also add anything it depends on, if not already there,
- // or already enabled.
- for (Dependency dep : m.getDependenciesArray()) {
- if (dep.getType() == Dependency.TYPE_MODULE) {
- String codeNameBase =
(String)Util.parseCodeName(dep.getName())[0];
- Module other = get(codeNameBase);
- // Should never happen:
- if (other == null) throw new IllegalStateException("Should
have found module: " + codeNameBase); // NOI18N
- if (! other.isEnabled()) {
- maybeAddToEnableList(willEnable, mightEnable, other,
false);
- }
- } else if (
- dep.getType() == Dependency.TYPE_REQUIRES ||
- dep.getType() == Dependency.TYPE_NEEDS ||
- dep.getType() == Dependency.TYPE_RECOMMENDS
- ) {
- Set<Module> providers = getProvidersOf().get(dep.getName());
- if (providers == null) {
- assert dep.getType() == Dependency.TYPE_RECOMMENDS :
"Should have found a provider of " + dep;
- continue;
- }
- // First check if >= 1 is already enabled or will be soon. If
so, great.
- boolean foundOne = false;
- for (Module other : providers) {
- if (other.isEnabled() ||
- (other.getProblems().isEmpty() &&
mightEnable.contains(other))) {
- foundOne = true;
- break;
+ Module outer = addedBecauseOfDependent;
+ boolean outerEagerActivatioon = eagerActivation;
+ Set<Module> outerReported = reported;
+ try {
+ reported = new HashSet<>();
+ addedBecauseOfDependent = m;
+ // need to register fragments eagerly, so they are available during
+ // dependency sort
+ Module host = attachModuleFragment(m);
+ if (host != null && !host.isEnabled()) {
+ maybeAddToEnableList(willEnable, mightEnable, host, okToFail,
"Fragment host");
+ }
+
+ // Also add anything it depends on, if not already there,
+ // or already enabled.
+ for (Dependency dep : m.getDependenciesArray()) {
+ if (dep.getType() == Dependency.TYPE_MODULE) {
+ String codeNameBase =
(String)Util.parseCodeName(dep.getName())[0];
+ Module other = get(codeNameBase);
+ // Should never happen:
+ if (other == null) throw new IllegalStateException("Should
have found module: " + codeNameBase); // NOI18N
+ if (! other.isEnabled()) {
+ maybeAddToEnableList(willEnable, mightEnable, other,
false, null);
}
- }
- if (foundOne) {
- // OK, we are satisfied.
- continue;
- }
- // All disabled. So add them all to the enable list.
- for (Module other : providers) {
- // It is OK if one of them fails.
- maybeAddToEnableList(willEnable, mightEnable, other, true);
- // But we still check to ensure that at least one did not!
- if (!foundOne && willEnable.contains(other)) {
- foundOne = true;
- // and continue with the others, try to add them too...
+ } else if (
+ dep.getType() == Dependency.TYPE_REQUIRES ||
+ dep.getType() == Dependency.TYPE_NEEDS ||
+ dep.getType() == Dependency.TYPE_RECOMMENDS
+ ) {
+ Set<Module> providers =
getProvidersOf().get(dep.getName());
+ if (providers == null) {
+ assert dep.getType() == Dependency.TYPE_RECOMMENDS :
"Should have found a provider of " + dep;
+ continue;
}
+ // First check if >= 1 is already enabled or will be soon.
If so, great.
+ boolean foundOne = false;
+ for (Module other : providers) {
Review Comment:
wouldn't the following be more readable?
if(providers.stream().anyMatch(other -> other.isEnabled() ||
(other.getProblems().isEmpty() &&
mightEnable.contains(other))) {
continue;
}
--
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