Bug 378319 - [quick fix] Add 'org.junit' to required bundles appears twice
Summary: [quick fix] Add 'org.junit' to required bundles appears twice
Status: VERIFIED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 4.3 M7   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2012-05-03 02:54 EDT by Dani Megert CLA
Modified: 2013-04-29 11:06 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2012-05-03 02:54:17 EDT
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'
Comment 1 Deepak Azad CLA 2012-05-03 04:56:28 EDT
This quick fix comes from PDE. The quick fix string is in /org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties
Comment 2 Deepak Azad CLA 2012-05-03 05:59:51 EDT
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)
Comment 3 Markus Keller CLA 2012-05-04 10:51:48 EDT
I would expect 2 proposals, one for JUnit 3 that adds an upper bound and one for JUnit 4.
Comment 4 Deepak Azad CLA 2012-05-04 12:04:09 EDT
(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.
Comment 5 Curtis Windatt CLA 2012-05-04 13:08:36 EDT
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.
Comment 6 Curtis Windatt CLA 2012-05-04 15:52:54 EDT
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.
Comment 7 Curtis Windatt CLA 2013-04-23 11:26:34 EDT
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.
Comment 8 Curtis Windatt CLA 2013-04-29 11:06:20 EDT
Verified in I20130428-2000