Skip to content

Commit 53b1d4d

Browse files
committed
Multifix resolution for removal of bundle/package from Quick Fix eclipse-pde#685
Fixes eclipse-pde#685
1 parent e39979b commit 53b1d4d

File tree

3 files changed

+34
-6
lines changed

3 files changed

+34
-6
lines changed

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

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2020 IBM Corporation and others.
2+
* Copyright (c) 2005, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
1010
*
1111
* Contributors:
1212
* IBM Corporation - initial API and implementation
13+
* Latha Patil (ETAS GmbH) - Issue #685
1314
*******************************************************************************/
1415
package org.eclipse.pde.internal.ui.correction;
1516

@@ -35,8 +36,19 @@ protected void createChange(BundleModel model) {
3536
String markerPackage = marker.getAttribute("packageName", (String) null); //$NON-NLS-1$
3637
Bundle bundle = (Bundle) model.getBundle();
3738
ExportPackageHeader header = (ExportPackageHeader) bundle.getManifestHeader(Constants.EXPORT_PACKAGE);
38-
if (header != null)
39+
if (header != null) {
40+
// Issue 685 - If `markerPackage` can be null, it might indicate
41+
// that the marker is related to the removal of RequireBundle or
42+
// others. If it is not null, then markerPackage might represent the
43+
// imported package or others, and the ExportPackageHeader(header)
44+
// does not include it.
45+
if (markerPackage == null || !header.hasPackage(markerPackage)) {
46+
MultiFixResolution multiFixResolution = new MultiFixResolution(marker, null);
47+
multiFixResolution.run(marker);
48+
} else {
3949
header.removePackage(markerPackage);
50+
}
51+
}
4052
}
4153

4254
@Override

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

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2019 IBM Corporation and others.
2+
* Copyright (c) 2005, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
1010
*
1111
* Contributors:
1212
* IBM Corporation - initial API and implementation
13+
* Latha Patil (ETAS GmbH) - Issue #685
1314
*******************************************************************************/
1415
package org.eclipse.pde.internal.ui.correction;
1516

@@ -33,8 +34,17 @@ public RemoveImportPackageResolution(int type, IMarker marker) {
3334
protected void createChange(BundleModel model) {
3435
Bundle bundle = (Bundle) model.getBundle();
3536
ImportPackageHeader header = (ImportPackageHeader) bundle.getManifestHeader(Constants.IMPORT_PACKAGE);
36-
if (header != null)
37-
header.removePackage(marker.getAttribute("packageName", (String) null)); //$NON-NLS-1$
37+
if (header != null) {
38+
String packageName = marker.getAttribute("packageName", (String) null); //$NON-NLS-1$
39+
//Issue 685 - If `packageName` can be null, it might indicate that the marker is related to the removal of RequireBundle or others. If it is not null, then `packageName` might represent the exported package or others, and the ImportPackageHeader(header) does not include it.
40+
41+
if (packageName == null || !header.hasPackage(packageName)) {
42+
MultiFixResolution multiFixResolution = new MultiFixResolution(marker, null);
43+
multiFixResolution.run(marker);
44+
} else {
45+
header.removePackage(packageName);
46+
}
47+
}
3848
}
3949

4050
@Override

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2019 IBM Corporation and others.
2+
* Copyright (c) 2005, 2024 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
1010
*
1111
* Contributors:
1212
* IBM Corporation - initial API and implementation
13+
* Latha Patil (ETAS GmbH) - Issue #685
1314
*******************************************************************************/
1415
package org.eclipse.pde.internal.ui.correction;
1516

@@ -33,6 +34,11 @@ public RemoveRequireBundleResolution(int type, String bundleID, IMarker marker)
3334
@Override
3435
protected void createChange(BundleModel model) {
3536
fBundleId = marker.getAttribute("bundleId", null); //$NON-NLS-1$
37+
// Issue 685 - If `fBundleId` can be null, it might indicate that the marker is related to the removal of import/export packages or others.
38+
if (fBundleId == null) {
39+
MultiFixResolution multiFixResolution = new MultiFixResolution(marker, null);
40+
multiFixResolution.run(marker);
41+
}
3642
Bundle bundle = (Bundle) model.getBundle();
3743
RequireBundleHeader header = (RequireBundleHeader) bundle.getManifestHeader(Constants.REQUIRE_BUNDLE);
3844
if (header != null)

0 commit comments

Comments
 (0)