Skip to content

Commit

Permalink
Multifix resolution for removal of bundle/package from Quick Fix ecli…
Browse files Browse the repository at this point in the history
  • Loading branch information
lathapatil committed Mar 18, 2024
1 parent e39979b commit 53b1d4d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2020 IBM Corporation and others.
* Copyright (c) 2005, 2024 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 @@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Latha Patil (ETAS GmbH) - Issue #685
*******************************************************************************/
package org.eclipse.pde.internal.ui.correction;

Expand All @@ -35,8 +36,19 @@ protected void createChange(BundleModel model) {
String markerPackage = marker.getAttribute("packageName", (String) null); //$NON-NLS-1$
Bundle bundle = (Bundle) model.getBundle();
ExportPackageHeader header = (ExportPackageHeader) bundle.getManifestHeader(Constants.EXPORT_PACKAGE);
if (header != null)
if (header != null) {
// Issue 685 - If `markerPackage` can be null, it might indicate
// that the marker is related to the removal of RequireBundle or
// others. If it is not null, then markerPackage might represent the
// imported package or others, and the ExportPackageHeader(header)
// does not include it.
if (markerPackage == null || !header.hasPackage(markerPackage)) {
MultiFixResolution multiFixResolution = new MultiFixResolution(marker, null);
multiFixResolution.run(marker);
} else {
header.removePackage(markerPackage);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2019 IBM Corporation and others.
* Copyright (c) 2005, 2024 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 @@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Latha Patil (ETAS GmbH) - Issue #685
*******************************************************************************/
package org.eclipse.pde.internal.ui.correction;

Expand All @@ -33,8 +34,17 @@ public RemoveImportPackageResolution(int type, IMarker marker) {
protected void createChange(BundleModel model) {
Bundle bundle = (Bundle) model.getBundle();
ImportPackageHeader header = (ImportPackageHeader) bundle.getManifestHeader(Constants.IMPORT_PACKAGE);
if (header != null)
header.removePackage(marker.getAttribute("packageName", (String) null)); //$NON-NLS-1$
if (header != null) {
String packageName = marker.getAttribute("packageName", (String) null); //$NON-NLS-1$
//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.

if (packageName == null || !header.hasPackage(packageName)) {
MultiFixResolution multiFixResolution = new MultiFixResolution(marker, null);
multiFixResolution.run(marker);
} else {
header.removePackage(packageName);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2005, 2019 IBM Corporation and others.
* Copyright (c) 2005, 2024 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 @@ -10,6 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Latha Patil (ETAS GmbH) - Issue #685
*******************************************************************************/
package org.eclipse.pde.internal.ui.correction;

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

0 comments on commit 53b1d4d

Please sign in to comment.