Skip to content

Commit

Permalink
Fix #39 - Slicer should allow filtering of a requirement based on the IU
Browse files Browse the repository at this point in the history
currently processed
  • Loading branch information
laeubi committed Apr 20, 2022
1 parent eb384f9 commit 49c84d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.director;singleton:=true
Bundle-Version: 2.5.200.qualifier
Bundle-Version: 2.5.300.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.equinox.internal.p2.director.DirectorActivator
Bundle-Vendor: %providerName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007, 2017 IBM Corporation and others.
* Copyright (c) 2007, 2022 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -11,6 +11,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Sonatype, Inc. - ongoing development
* Christoph Läubrich - Issue #39 - Slicer should allow filtering of a requirement based on the IU currently processed
*******************************************************************************/
package org.eclipse.equinox.internal.p2.director;

Expand Down Expand Up @@ -86,12 +87,13 @@ private void computeNonGreedyIUs() {
IQueryable<IInstallableUnit> queryable = new QueryableArray(considered.toArray(new IInstallableUnit[considered.size()]));
Iterator<IInstallableUnit> it = queryable.query(QueryUtil.ALL_UNITS, new NullProgressMonitor()).iterator();
while (it.hasNext()) {
Collection<IRequirement> reqs = getRequirements(it.next().unresolved());
IInstallableUnit iu = it.next().unresolved();
Collection<IRequirement> reqs = getRequirements(iu);
for (IRequirement req : reqs) {
if (!isApplicable(req))
if (!isApplicable(iu, req))
continue;

if (!isGreedy(req)) {
if (!isGreedy(iu, req)) {
nonGreedyIUs.addAll(queryable.query(QueryUtil.createMatchQuery(req.getMatches()), null).toUnmodifiableSet());
}
}
Expand All @@ -112,6 +114,11 @@ private void validateInput(IInstallableUnit[] ius) {
}

// Check whether the requirement is applicable

protected boolean isApplicable(IInstallableUnit unit, IRequirement req) {
return isApplicable(req);
}

protected boolean isApplicable(IRequirement req) {
IMatchExpression<IInstallableUnit> filter = req.getFilter();
return filter == null || filter.isMatch(selectionContext);
Expand Down Expand Up @@ -140,17 +147,21 @@ protected void processIU(IInstallableUnit iu) {
if (reqs.isEmpty())
return;
for (IRequirement req : reqs) {
if (!isApplicable(req))
if (!isApplicable(iu, req))
continue;

if (!isGreedy(req)) {
if (!isGreedy(iu, req)) {
continue;
}

expandRequirement(iu, req);
}
}

protected boolean isGreedy(IInstallableUnit unit, IRequirement req) {
return isGreedy(req);
}

protected boolean isGreedy(IRequirement req) {
return req.isGreedy();
}
Expand Down

0 comments on commit 49c84d9

Please sign in to comment.