Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multifix resolution for removal of bundle/package from Quick Fix #685 #1196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading