diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/RemoveExportPackageResolution.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/RemoveExportPackageResolution.java index 053858f005..33c89051f3 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/RemoveExportPackageResolution.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/RemoveExportPackageResolution.java @@ -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 @@ -10,6 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Latha Patil (ETAS GmbH) - Issue #685 *******************************************************************************/ package org.eclipse.pde.internal.ui.correction; @@ -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 diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/RemoveImportPackageResolution.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/RemoveImportPackageResolution.java index 3338780c16..c7cea5ce4d 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/RemoveImportPackageResolution.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/RemoveImportPackageResolution.java @@ -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 @@ -10,6 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Latha Patil (ETAS GmbH) - Issue #685 *******************************************************************************/ package org.eclipse.pde.internal.ui.correction; @@ -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 diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/RemoveRequireBundleResolution.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/RemoveRequireBundleResolution.java index 5ebed9ff46..c95669c926 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/RemoveRequireBundleResolution.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/RemoveRequireBundleResolution.java @@ -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 @@ -10,6 +10,7 @@ * * Contributors: * IBM Corporation - initial API and implementation + * Latha Patil (ETAS GmbH) - Issue #685 *******************************************************************************/ package org.eclipse.pde.internal.ui.correction; @@ -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)