Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2010-05-08 02:23:45 +0000
committerPascal Rapicault2010-05-08 02:23:45 +0000
commit73d2bad38b82c7129c8e9c516c79b96fd7ebe308 (patch)
tree94d5fc5a5be2753908f8e41b4888fb8189286cdd /bundles/org.eclipse.equinox.p2.director/src
parent754cb2fba5c9148bfe14c8f92171af80c04968e7 (diff)
downloadrt.equinox.p2-73d2bad38b82c7129c8e9c516c79b96fd7ebe308.tar.gz
rt.equinox.p2-73d2bad38b82c7129c8e9c516c79b96fd7ebe308.tar.xz
rt.equinox.p2-73d2bad38b82c7129c8e9c516c79b96fd7ebe308.zip
Bug 222157 - [planner] Projector should get fragments dependencies
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.director/src')
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java68
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java49
2 files changed, 57 insertions, 60 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
index dec329860..b84d8150f 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java
@@ -404,6 +404,19 @@ public class Projector {
createNegationImplication(iu, matches, explanation);
}
+ private void determinePotentialHostsForFragment(IInstallableUnit iu) {
+ // determine matching hosts only for fragments
+ if (!(iu instanceof IInstallableUnitFragment))
+ return;
+
+ IInstallableUnitFragment fragment = (IInstallableUnitFragment) iu;
+ // for each host requirement, find matches and remember them
+ for (IRequirement req : fragment.getHost()) {
+ List<IInstallableUnit> matches = getApplicableMatches(req);
+ rememberHostMatches((IInstallableUnitFragment) iu, matches);
+ }
+ }
+
private void expandRequirement(IRequirement req, IInstallableUnit iu, List<AbstractVariable> optionalAbstractRequirements, boolean isRootIu) throws ContradictionException {
if (req.getMax() == 0) {
expandNegatedRequirement(req, iu, optionalAbstractRequirements, isRootIu);
@@ -412,9 +425,7 @@ public class Projector {
if (!isApplicable(req))
return;
List<IInstallableUnit> matches = getApplicableMatches(req);
- if (isHostRequirement(iu, req)) {
- rememberHostMatches((IInstallableUnitFragment) iu, matches);
- }
+ determinePotentialHostsForFragment(iu);
if (req.getMin() > 0) {
if (matches.isEmpty()) {
if (iu == entryPoint && emptyBecauseFiltered) {
@@ -524,18 +535,21 @@ public class Projector {
}
private Collection<IRequirement> getRequiredCapabilities(IInstallableUnit iu) {
- Collection<IRequirement> rqs = iu.getRequirements();
- if (!considerMetaRequirements)
- return rqs;
-
- Collection<IRequirement> metaRqs = iu.getMetaRequirements();
- if (metaRqs.isEmpty())
- return rqs;
-
- ArrayList<IRequirement> aggregatedRqs = new ArrayList<IRequirement>(rqs.size() + metaRqs.size());
- aggregatedRqs.addAll(rqs);
- aggregatedRqs.addAll(metaRqs);
- return aggregatedRqs;
+ boolean isFragment = iu instanceof IInstallableUnitFragment;
+ //Short-circuit for the case of an IInstallableUnit
+ if ((!isFragment) && iu.getMetaRequirements().size() == 0)
+ return iu.getRequirements();
+
+ ArrayList<IRequirement> aggregatedRequirements = new ArrayList<IRequirement>(iu.getRequirements().size() + iu.getMetaRequirements().size() + (isFragment ? ((IInstallableUnitFragment) iu).getHost().size() : 0));
+ aggregatedRequirements.addAll(iu.getRequirements());
+
+ if (iu instanceof IInstallableUnitFragment) {
+ aggregatedRequirements.addAll(((IInstallableUnitFragment) iu).getHost());
+ }
+
+ if (considerMetaRequirements)
+ aggregatedRequirements.addAll(iu.getMetaRequirements());
+ return aggregatedRequirements;
}
static final class Pending {
@@ -585,9 +599,7 @@ public class Projector {
if (isApplicable(reqs[i][1])) {
IRequirement req = reqs[i][1];
List<IInstallableUnit> matches = getApplicableMatches(req);
- if (isHostRequirement(iu, req)) {
- rememberHostMatches((IInstallableUnitFragment) iu, matches);
- }
+ determinePotentialHostsForFragment(iu);
if (req.getMin() > 0) {
if (matches.isEmpty()) {
missingRequirement(patch, req);
@@ -661,9 +673,7 @@ public class Projector {
}
List<IInstallableUnit> matches = getApplicableMatches(req);
- if (isHostRequirement(iu, req)) {
- rememberHostMatches((IInstallableUnitFragment) iu, matches);
- }
+ determinePotentialHostsForFragment(iu);
if (req.getMin() > 0) {
if (matches.isEmpty()) {
dependencyHelper.implication(new Object[] {iu}).implies(patch).named(new Explanation.HardRequirement(iu, null));
@@ -766,9 +776,7 @@ public class Projector {
}
IRequirement req = entry.getKey();
List<IInstallableUnit> matches = getApplicableMatches(req);
- if (isHostRequirement(iu, req)) {
- rememberHostMatches((IInstallableUnitFragment) iu, matches);
- }
+ determinePotentialHostsForFragment(iu);
if (req.getMin() > 0) {
if (matches.isEmpty()) {
if (requiredPatches.isEmpty()) {
@@ -1176,16 +1184,4 @@ public class Projector {
}
existingMatches.retainAll(matches);
}
-
- private boolean isHostRequirement(IInstallableUnit iu, IRequirement req) {
- if (!(iu instanceof IInstallableUnitFragment))
- return false;
- IInstallableUnitFragment fragment = (IInstallableUnitFragment) iu;
- for (IRequirement hostReqs : fragment.getHost()) {
- if (req.equals(hostReqs))
- return true;
- }
- return false;
- }
-
} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java
index 4f5d87a76..a7dd4aa6f 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java
@@ -16,6 +16,7 @@ import org.eclipse.core.runtime.*;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.core.helpers.Tracing;
import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
+import org.eclipse.equinox.internal.p2.metadata.InstallableUnitPatch;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.expression.IMatchExpression;
import org.eclipse.equinox.p2.query.*;
@@ -105,6 +106,7 @@ public class Slicer {
Map<Version, IInstallableUnit> iuSlice = slice.get(iu.getId());
if (iuSlice == null) {
+
iuSlice = new HashMap<Version, IInstallableUnit>();
slice.put(iu.getId(), iuSlice);
}
@@ -113,7 +115,7 @@ public class Slicer {
return;
}
- Collection<IRequirement> reqs = getRequiredCapabilities(iu);
+ Collection<IRequirement> reqs = getRequirements(iu);
if (reqs.isEmpty())
return;
for (IRequirement req : reqs) {
@@ -133,31 +135,30 @@ public class Slicer {
return req.isGreedy();
}
- private Collection<IRequirement> getRequiredCapabilities(IInstallableUnit iu) {
- Collection<IRequirement> iuRequirements = iu.getRequirements();
- int initialRequirementCount = iuRequirements.size();
- if (!(iu instanceof IInstallableUnitPatch)) {
- if (!considerMetaRequirements)
- return iuRequirements;
-
- Collection<IRequirement> iuMetaRequirements = iu.getMetaRequirements();
- int metaSize = iuMetaRequirements.size();
- if (metaSize == 0)
- return iuRequirements;
-
- ArrayList<IRequirement> aggregatedCapabilities = new ArrayList<IRequirement>(initialRequirementCount + metaSize);
- aggregatedCapabilities.addAll(iuRequirements);
- aggregatedCapabilities.addAll(iuMetaRequirements);
- return aggregatedCapabilities;
+ private Collection<IRequirement> getRequirements(IInstallableUnit iu) {
+ boolean isPatch = iu instanceof IInstallableUnitPatch;
+ boolean isFragment = iu instanceof IInstallableUnitFragment;
+ //Short-circuit for the case of an IInstallableUnit
+ if ((!isFragment) && (!isPatch) && iu.getMetaRequirements().size() == 0)
+ return iu.getRequirements();
+
+ ArrayList<IRequirement> aggregatedRequirements = new ArrayList<IRequirement>(iu.getRequirements().size() + iu.getMetaRequirements().size() + (isFragment ? ((IInstallableUnitFragment) iu).getHost().size() : 0) + (isPatch ? ((IInstallableUnitPatch) iu).getRequirementsChange().size() : 0));
+ aggregatedRequirements.addAll(iu.getRequirements());
+
+ if (iu instanceof IInstallableUnitFragment) {
+ aggregatedRequirements.addAll(((IInstallableUnitFragment) iu).getHost());
+ }
+
+ if (iu instanceof InstallableUnitPatch) {
+ IInstallableUnitPatch patchIU = (IInstallableUnitPatch) iu;
+ List<IRequirementChange> changes = patchIU.getRequirementsChange();
+ for (int i = 0; i < changes.size(); i++)
+ aggregatedRequirements.add(changes.get(i).newValue());
}
- IInstallableUnitPatch patchIU = (IInstallableUnitPatch) iu;
- List<IRequirementChange> changes = patchIU.getRequirementsChange();
- ArrayList<IRequirement> aggregatedCapabilities = new ArrayList<IRequirement>(initialRequirementCount + changes.size());
- aggregatedCapabilities.addAll(iuRequirements);
- for (int i = 0; i < changes.size(); i++)
- aggregatedCapabilities.add(changes.get(i).newValue());
- return aggregatedCapabilities;
+ if (considerMetaRequirements)
+ aggregatedRequirements.addAll(iu.getMetaRequirements());
+ return aggregatedRequirements;
}
private void expandRequirement(IInstallableUnit iu, IRequirement req) {

Back to the top