@@ -185,11 +185,6 @@ private RequireBundleManifestChange(IProject project, ExportPackageDescription d
185185 super (project , desc , cu , qualifiedTypeToImport );
186186 }
187187
188- private RequireBundleManifestChange (IProject project , String desc , CompilationUnit cu ,
189- String qualifiedTypeToImport ) {
190- super (project , desc , cu , qualifiedTypeToImport );
191- }
192-
193188 @ Override
194189 public Change perform (IProgressMonitor pm ) throws CoreException {
195190 PDEModelUtility .modifyModel (new ModelModification (getProject ()) {
@@ -198,69 +193,43 @@ protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws Co
198193 if (!(model instanceof IPluginModelBase base )) {
199194 return ;
200195 }
201- String [] pluginIdStrings = null ;
202- if ("JUnit 5 bundles" .equals (getChangeObject ())) { //$NON-NLS-1$
203- pluginIdStrings = getJUnit5Bundles ();
204- }
205- if (getChangeObject () instanceof ExportPackageDescription ) {
206- pluginIdStrings = new String [1 ];
207- pluginIdStrings [0 ] = ((ExportPackageDescription ) getChangeObject ()).getSupplier ()
208- .getSymbolicName ();
209- }
210- for (int i = 0 ; i < pluginIdStrings .length ; i ++) {
211- String pluginId = pluginIdStrings [i ];
212- if (!isUndo ()) {
213- IPluginImport [] imports = base .getPluginBase ().getImports ();
214- boolean duplicate = false ;
215- for (IPluginImport iPluginImport : imports ) {
216- if (iPluginImport .getId ().equals (pluginId )) {
217- duplicate = true ;
218- break ;
219- }
220- }
221- if (duplicate ) {
222- continue ;
196+ String pluginId = ((ExportPackageDescription ) getChangeObject ()).getSupplier ().getSymbolicName ();
197+ if (!isUndo ()) {
198+ IPluginImport [] imports = base .getPluginBase ().getImports ();
199+ boolean duplicate = false ;
200+ for (IPluginImport iPluginImport : imports ) {
201+ if (iPluginImport .getId ().equals (pluginId )) {
202+ duplicate = true ;
203+ break ;
223204 }
224- IPluginImport impt = base .getPluginFactory ().createImport ();
225- impt .setId (pluginId );
226- base .getPluginBase ().add (impt );
227- } else {
228- IPluginImport [] imports = base .getPluginBase ().getImports ();
229- for (IPluginImport pluginImport : imports ) {
230- if (pluginImport .getId ().equals (pluginId )) {
231- base .getPluginBase ().remove (pluginImport );
232- }
205+ }
206+ if (duplicate ) {
207+ return ;
208+ }
209+ IPluginImport impt = base .getPluginFactory ().createImport ();
210+ impt .setId (pluginId );
211+ base .getPluginBase ().add (impt );
212+ } else {
213+ IPluginImport [] imports = base .getPluginBase ().getImports ();
214+ for (IPluginImport pluginImport : imports ) {
215+ if (pluginImport .getId ().equals (pluginId )) {
216+ base .getPluginBase ().remove (pluginImport );
233217 }
234218 }
235219 }
236220 }
237-
238- private String [] getJUnit5Bundles () {
239- return new String [] { "org.junit" , "junit-jupiter-api" }; //$NON-NLS-1$ //$NON-NLS-2$
240- }
241221 }, new NullProgressMonitor ());
242222
243223 insertImport (getCompilationUnit (), getQualifiedTypeToImport (), pm );
244224
245225 if (!isUndo ()) {
246- if (getChangeObject () instanceof ExportPackageDescription ) {
247- return new RequireBundleManifestChange (getProject (), (ExportPackageDescription ) getChangeObject (),
248- getCompilationUnit (), getQualifiedTypeToImport ()) {
249- @ Override
250- public boolean isUndo () {
251- return true ;
252- }
253- };
254- }
255- if (getChangeObject () instanceof String ) {
256- return new RequireBundleManifestChange (getProject (),(String ) getChangeObject (),
257- getCompilationUnit (), getQualifiedTypeToImport ()) {
258- @ Override
259- public boolean isUndo () {
260- return true ;
261- }
262- };
263- }
226+ return new RequireBundleManifestChange (getProject (), (ExportPackageDescription ) getChangeObject (),
227+ getCompilationUnit (), getQualifiedTypeToImport ()) {
228+ @ Override
229+ public boolean isUndo () {
230+ return true ;
231+ }
232+ };
264233 }
265234 return null ;
266235 }
@@ -474,39 +443,6 @@ public static final Object createRequireBundleProposal(IProject project, ExportP
474443 return createWrapper (change , type , relevance );
475444 }
476445
477- /**
478- * Creates and returns a proposal which create multiple Require-Bundle entry in the
479- * MANIFEST.MF (or corresponding plugin.xml) for desc name.
480- *
481- * @param project
482- * the project to be updated
483- * @param desc
484- * multiple bundles that is to be added as a Require-Bundle dependency
485- * based on description name
486- * @param type
487- * the type of the proposal to be returned
488- * @param relevance
489- * the relevance of the new proposal
490- * @param qualifiedTypeToImport
491- * the qualified type name of the type that requires this
492- * proposal. If this argument and cu are supplied the proposal
493- * will add an import statement for this type to the source file
494- * in which the proposal was invoked.
495- * @param cu
496- * the AST root of the java source file in which this fix was
497- * invoked
498- * @see JavaResolutionFactory#TYPE_JAVA_COMPLETION
499- * @see JavaResolutionFactory#TYPE_CLASSPATH_FIX
500- */
501- public static final Object createRequireBundleProposal (IProject project , String desc , int type , int relevance ,
502- CompilationUnit cu , String qualifiedTypeToImport ) {
503- if (desc == null ) {
504- return null ;
505- }
506- AbstractManifestChange change = new RequireBundleManifestChange (project , desc , cu , qualifiedTypeToImport );
507- return createWrapper (change , type , relevance );
508- }
509-
510446 /**
511447 * Creates and returns a proposal which create an Import-Package entry in
512448 * the MANIFEST.MF for the package represented by desc. The object will be
0 commit comments