Skip to content

Commit 1b810d7

Browse files
committed
Fix incomplete computation of version ranges for quick-fixes
Follow-up on - #2120
1 parent 85b502b commit 1b810d7

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/ManifestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ public static Optional<VersionRange> createConsumerRequirementRange(Version vers
406406
new Version(version.getMajor() + 1, 0, 0), //
407407
VersionRange.RIGHT_OPEN));
408408
}
409-
return null;
409+
return Optional.empty();
410410
}
411411

412412
/**

ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/java/JavaResolutionFactory.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
import java.text.MessageFormat;
1717
import java.util.Arrays;
18-
import java.util.Optional;
1918

2019
import org.eclipse.core.resources.IFile;
2120
import org.eclipse.core.resources.IProject;
@@ -196,25 +195,24 @@ protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws Co
196195
}
197196
BundleDescription requiredBundle = getChangeObject();
198197
String pluginId = requiredBundle.getSymbolicName();
198+
VersionRange versionRange = ManifestUtils
199+
.createConsumerRequirementRange(requiredBundle.getVersion()).orElse(null);
199200
IPluginImport[] imports = base.getPluginBase().getImports();
200201
if (!isUndo()) {
201202
if (Arrays.stream(imports).map(IPluginImport::getId).anyMatch(pluginId::equals)) {
202203
return;
203204
}
204205
IPluginImport impt = base.getPluginFactory().createImport();
205206
impt.setId(pluginId);
206-
Optional<String> versionRange = ManifestUtils
207-
.createConsumerRequirementRange(requiredBundle.getVersion())
208-
.map(VersionRange::toString);
209-
if (versionRange.isPresent()) {
210-
impt.setVersion(versionRange.get());
207+
if (versionRange != null) {
208+
impt.setVersion(versionRange.toString());
211209
}
212210
base.getPluginBase().add(impt);
213211
} else {
214212
for (IPluginImport pluginImport : imports) {
215-
if (pluginImport.getId().equals(pluginId)) {
213+
if (pluginImport.getId().equals(pluginId) && (versionRange == null
214+
|| versionRange.includes(Version.parseVersion(pluginImport.getVersion())))) {
216215
base.getPluginBase().remove(pluginImport);
217-
// TODO: Consider version too!
218216
}
219217
}
220218
}

0 commit comments

Comments
 (0)