Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Hammer2019-09-25 19:54:25 +0000
committerAlexander Kurtakov2019-10-14 12:20:49 +0000
commit14f4c89602076e92050a11bf8d9e3ed9b9c08e14 (patch)
tree21f3ff893ba070d4675186f419481ef04e489754 /bundles/org.eclipse.equinox.p2.director
parent680b7ea1ff9dd2dfc8248f3d9d1c92023bd746d4 (diff)
downloadrt.equinox.p2-14f4c89602076e92050a11bf8d9e3ed9b9c08e14.tar.gz
rt.equinox.p2-14f4c89602076e92050a11bf8d9e3ed9b9c08e14.tar.xz
rt.equinox.p2-14f4c89602076e92050a11bf8d9e3ed9b9c08e14.zip
Use jdk 5 for-each loop
Replace simple uses of Iterator with a corresponding for-loop. Also add missing braces on loops as necessary. Change-Id: I17efcb7827adbf5a4f2424d3bb51a5cb0e56a66a Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.director')
-rw-r--r--bundles/org.eclipse.equinox.p2.director/.settings/org.eclipse.jdt.core.prefs3
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java26
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/UserDefinedOptimizationFunction.java32
4 files changed, 34 insertions, 34 deletions
diff --git a/bundles/org.eclipse.equinox.p2.director/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.p2.director/.settings/org.eclipse.jdt.core.prefs
index a01c791c7..3bb5d9f8c 100644
--- a/bundles/org.eclipse.equinox.p2.director/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.equinox.p2.director/.settings/org.eclipse.jdt.core.prefs
@@ -69,7 +69,7 @@ org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
@@ -108,6 +108,7 @@ org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
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 b52d41216..978debf7f 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
@@ -526,29 +526,28 @@ public class Projector {
// noop(IU)-> ~ABS
// IU -> (noop(IU) or ABS)
// Therefore we only need one optional requirement statement per IU
- for (int i = 0; i < reqs.length; i++) {
+ for (IRequirement[] requirement : reqs) {
//The requirement is unchanged
- if (reqs[i][0] == reqs[i][1]) {
- if (reqs[i][0].getMax() == 0) {
- expandNegatedRequirement(reqs[i][0], iu, optionalAbstractRequirements, isRootIu);
+ if (requirement[0] == requirement[1]) {
+ if (requirement[0].getMax() == 0) {
+ expandNegatedRequirement(requirement[0], iu, optionalAbstractRequirements, isRootIu);
return;
}
- if (!isApplicable(reqs[i][0]))
+ if (!isApplicable(requirement[0])) {
continue;
-
- List<IInstallableUnitPatch> patchesAppliedElseWhere = unchangedRequirements.get(reqs[i][0]);
+ }
+ List<IInstallableUnitPatch> patchesAppliedElseWhere = unchangedRequirements.get(requirement[0]);
if (patchesAppliedElseWhere == null) {
patchesAppliedElseWhere = new ArrayList<>();
- unchangedRequirements.put(reqs[i][0], patchesAppliedElseWhere);
+ unchangedRequirements.put(requirement[0], patchesAppliedElseWhere);
}
patchesAppliedElseWhere.add(patch);
continue;
}
-
//Generate dependency when the patch is applied
//P1 -> (A -> D) equiv. (P1 & A) -> D
- if (isApplicable(reqs[i][1])) {
- IRequirement req = reqs[i][1];
+ if (isApplicable(requirement[1])) {
+ IRequirement req = requirement[1];
List<IInstallableUnit> matches = getApplicableMatches(req);
determinePotentialHostsForFragment(iu);
if (req.getMin() > 0) {
@@ -606,9 +605,8 @@ public class Projector {
}
//Generate dependency when the patch is not applied
//-P1 -> (A -> B) ( equiv. A -> (P1 or B) )
- if (isApplicable(reqs[i][0])) {
- IRequirement req = reqs[i][0];
-
+ if (isApplicable(requirement[0])) {
+ IRequirement req = requirement[0];
// Fix: if multiple patches apply to the same IU-req, we need to make sure we list each
// patch as an optional match
Pending pending = nonPatchedRequirements.get(req);
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 8453e9121..8de45dcbb 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
@@ -104,9 +104,10 @@ public class Slicer {
//This is a shortcut to simplify the error reporting when the filter of the ius we are being asked to install does not pass
private void validateInput(IInstallableUnit[] ius) {
- for (int i = 0; i < ius.length; i++) {
- if (!isApplicable(ius[i]))
- throw new IllegalStateException(NLS.bind(Messages.Explanation_missingRootFilter, ius[i]));
+ for (IInstallableUnit iu : ius) {
+ if (!isApplicable(iu)) {
+ throw new IllegalStateException(NLS.bind(Messages.Explanation_missingRootFilter, iu));
+ }
}
}
diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/UserDefinedOptimizationFunction.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/UserDefinedOptimizationFunction.java
index 83f506e54..4f699cf25 100644
--- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/UserDefinedOptimizationFunction.java
+++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/UserDefinedOptimizationFunction.java
@@ -9,7 +9,7 @@
*
* SPDX-License-Identifier: EPL-2.0
*
- * Contributors:
+ * Contributors:
* Daniel Le Berre - initial API and implementation
* Red Hat, Inc. - support for remediation page
******************************************************************************/
@@ -41,32 +41,32 @@ public class UserDefinedOptimizationFunction extends OptimizationFunction {
List<WeightedObject<?>> weightedObjects = new ArrayList<>();
List<Object> objects = new ArrayList<>();
BigInteger weight = BigInteger.valueOf(slice.size() + 1);
- String[] criteria = new String[] {"+new", "-notuptodate", "-changed", "-removed"}; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
- BigInteger currentWeight = weight.pow(criteria.length - 1);
+ String[] criterias = new String[] {"+new", "-notuptodate", "-changed", "-removed"}; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
+ BigInteger currentWeight = weight.pow(criterias.length - 1);
boolean maximizes;
Object thing;
- for (int i = 0; i < criteria.length; i++) {
- if (criteria[i].endsWith("new")) { //$NON-NLS-1$
+ for (String criteria : criterias) {
+ if (criteria.endsWith("new")) { //$NON-NLS-1$
weightedObjects.clear();
- newRoots(weightedObjects, criteria[i].startsWith("+") ? currentWeight.negate() : currentWeight, metaIu); //$NON-NLS-1$
+ newRoots(weightedObjects, criteria.startsWith("+") ? currentWeight.negate() : currentWeight, metaIu); //$NON-NLS-1$
currentWeight = currentWeight.divide(weight);
- } else if (criteria[i].endsWith("removed")) { //$NON-NLS-1$
+ } else if (criteria.endsWith("removed")) { //$NON-NLS-1$
weightedObjects.clear();
- removedRoots(weightedObjects, criteria[i].startsWith("+") ? currentWeight.negate() : currentWeight, metaIu); //$NON-NLS-1$
+ removedRoots(weightedObjects, criteria.startsWith("+") ? currentWeight.negate() : currentWeight, metaIu); //$NON-NLS-1$
currentWeight = currentWeight.divide(weight);
- } else if (criteria[i].endsWith("notuptodate")) { //$NON-NLS-1$
+ } else if (criteria.endsWith("notuptodate")) { //$NON-NLS-1$
weightedObjects.clear();
- notuptodate(weightedObjects, criteria[i].startsWith("+") ? currentWeight.negate() : currentWeight, metaIu); //$NON-NLS-1$
+ notuptodate(weightedObjects, criteria.startsWith("+") ? currentWeight.negate() : currentWeight, metaIu); //$NON-NLS-1$
currentWeight = currentWeight.divide(weight);
- } else if (criteria[i].endsWith("changed")) { //$NON-NLS-1$
+ } else if (criteria.endsWith("changed")) { //$NON-NLS-1$
weightedObjects.clear();
- changedRoots(weightedObjects, criteria[i].startsWith("+") ? currentWeight.negate() : currentWeight, metaIu); //$NON-NLS-1$
+ changedRoots(weightedObjects, criteria.startsWith("+") ? currentWeight.negate() : currentWeight, metaIu); //$NON-NLS-1$
currentWeight = currentWeight.divide(weight);
}
objects.clear();
- maximizes = criteria[i].startsWith("+"); //$NON-NLS-1$
- for (Iterator<WeightedObject<?>> it = weightedObjects.iterator(); it.hasNext();) {
- thing = it.next().thing;
+ maximizes = criteria.startsWith("+"); //$NON-NLS-1$
+ for (WeightedObject<?> weightedObject : weightedObjects) {
+ thing = weightedObject.thing;
if (maximizes) {
thing = dependencyHelper.not(thing);
}
@@ -159,7 +159,7 @@ public class UserDefinedOptimizationFunction extends OptimizationFunction {
Projector.AbstractVariable abs = new Projector.AbstractVariable();
Object notlatest = dependencyHelper.not(toSort.get(0));
try {
- // notuptodate <=> not iuvn and (iuv1 or iuv2 or ... iuvn-1)
+ // notuptodate <=> not iuvn and (iuv1 or iuv2 or ... iuvn-1)
dependencyHelper.implication(new Object[] {abs}).implies(notlatest).named(FakeExplanation.getInstance());
Object[] clause = new Object[toSort.size()];
toSort.toArray(clause);

Back to the top