-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Quick-fix for import package resolution failure due to missing mandatory
attributes:
- Loading branch information
1 parent
9b8d81e
commit 38b91df
Showing
7 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
.../org/eclipse/pde/internal/ui/correction/AddMandatoryAttributeImportPackageResolution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2023 IBM Corporation and others. | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*Qui | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
* Alshama M S <ALSHAMA.M.S@ibm.com> Initial implementation | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.pde.internal.ui.correction; | ||
|
||
import org.eclipse.core.resources.IMarker; | ||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.pde.internal.core.text.bundle.Bundle; | ||
import org.eclipse.pde.internal.core.text.bundle.BundleModel; | ||
import org.eclipse.pde.internal.core.text.bundle.ImportPackageHeader; | ||
import org.eclipse.pde.internal.core.text.bundle.ImportPackageObject; | ||
import org.eclipse.pde.internal.ui.PDEPlugin; | ||
import org.eclipse.pde.internal.ui.PDEUIMessages; | ||
import org.osgi.framework.Constants; | ||
|
||
/** | ||
* <p> | ||
* Represents a resolution to the problem of import package resolution failure | ||
* due to missing mandatory attributes | ||
* </p> | ||
*/ | ||
public class AddMandatoryAttributeImportPackageResolution extends AbstractManifestMarkerResolution { | ||
/** | ||
* Creates a new resolution | ||
*/ | ||
public AddMandatoryAttributeImportPackageResolution(IMarker marker) { | ||
super(AbstractPDEMarkerResolution.CREATE_TYPE, marker); | ||
} | ||
|
||
/** | ||
* Resolves the problem by adding mandatory attribute | ||
*/ | ||
@Override | ||
protected void createChange(BundleModel model) { | ||
try { | ||
String packagename = (String) marker.getAttribute("packageName"); //$NON-NLS-1$ | ||
Bundle bundle = (Bundle) model.getBundle(); | ||
ImportPackageHeader header = (ImportPackageHeader) bundle.getManifestHeader(Constants.IMPORT_PACKAGE); | ||
if (header != null) { | ||
ImportPackageObject obj = header.getPackage(packagename); | ||
obj.setAttribute((String) marker.getAttribute("mandatoryattrkey"), //$NON-NLS-1$ | ||
(String) marker.getAttribute("mandatoryvalue"));//$NON-NLS-1$ | ||
header.removePackage(packagename); | ||
header.addPackage(obj); | ||
} | ||
} catch (CoreException e) { | ||
PDEPlugin.log(e); | ||
} | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return PDEUIMessages.AddMandatoryAttrResolution_label; | ||
} | ||
|
||
@Override | ||
public String getLabel() { | ||
return PDEUIMessages.AddMandatoryAttrResolution_description; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters