Community
Participate
Working Groups
I20120502-1800, but broken in older releases too. [quick fix] Add 'org.junit' to required bundles appears twice. Test Case: 1. paste "class X extends TestCase {}" into Package Explorer 2. convert the project to a plug-in project 3. in the Java editor invoke Ctrl+1 on 'TestCase'
This quick fix comes from PDE. The quick fix string is in /org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties
The problem is in org.eclipse.pde.internal.ui.correction.java.FindClassResolutionsOperation.run(IProgressMonitor). "getValidPackages(packageName)" call returns 2 packages - one for JUnit 4 and one for JUnit 3 - and hence the quick fix appears twice. I don't know what the fix should be... (Also initially I was not able to reproduce this problem in my target workbench because there I did not have both JUnit 3 and Junit 4, mentioning in case any one else also runs into this while debugging)
I would expect 2 proposals, one for JUnit 3 that adds an upper bound and one for JUnit 4.
(In reply to comment #3) > I would expect 2 proposals, one for JUnit 3 that adds an upper bound and one > for JUnit 4. Sure, but currently both proposals do the same thing - add 'Require-Bundle: org.junit' to manifest.mf.
Currently the change object does not consider the bundle version at all. It would have to be enhanced to do so (as a boolean option). The quickfix would have to specify the version in its text. org.eclipse.pde.internal.ui.correction.java.JavaResolutionFactory.RequireBundleManifestChange The QuickFixProcessor would have to then figure out if there are two results that have the same symbolic name and turn on the boolean setting. Recognizing that there should be an upper bound is more difficult as not all bundles may follow the major/minor segment rules.
The 'easier' fix of checking for duplicate names requires a bit of extra checking that require bundles entries are being created and not import package entries.
http://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit/?id=8a995036b04c87f19146f6760784224a947f29f0 Fixed in master along with bug 406232 and bug 406217. The quick fix will not consider version contraints or add any constraint to the manifest, but the proposal generator will now only generate one proposal for a bundle. I also added code to check that skips proposals that would add a require bundle entry that already exists in the manifest.
Verified in I20130428-2000