Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 321891 - Missing import-package quick fix
Summary: Missing import-package quick fix
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7 M2   Edit
Assignee: Ankur Sharma CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-05 11:10 EDT by Tim deBoer CLA
Modified: 2010-09-02 12:01 EDT (History)
2 users (show)

See Also:


Attachments
Project showing missing quick fix (2.99 KB, application/octet-stream)
2010-08-05 11:10 EDT, Tim deBoer CLA
no flags Details
Patch (2.41 KB, patch)
2010-08-10 05:56 EDT, Ankur Sharma CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tim deBoer CLA 2010-08-05 11:10:32 EDT
Created attachment 175951 [details]
Project showing missing quick fix

PDE has lots of validation errors and quick fixes. When a problem is due to missing dependencies in the manifest and PDE knows which bundle the missing package is from, there are usually two (or more) quick fixes:
 - add an import-package (listed first, as per the best practise)
 - add a require-bundle

Unfortunately, we've found one case where the first quick-fix is missing. This has caused some of our testers to chose the require-bundle option, which caused problems later on (import-package was a better option, and works more often in our runtime).

I've attached a project that shows this issue. It is a bit contrived, but I was trying to simplify a more complex testcase. I think I've determined that this issue only appears when the missing dependency is a package from a bundle you are already importing a different package from (i.e. the bundle is already in the PDE classpath container).

To see the issue, open BrokenClass.java and look at the compile errors on lines 3 and 8. The quick fix for line 3 has both options, but the quick fix for line 8 only shows require-bundle.
Comment 1 Ankur Sharma CLA 2010-08-10 05:56:43 EDT
Created attachment 176218 [details]
Patch

Tested with 

package test;

import org.eclipse.core.resources.IWorkspace;

public class BrokenClass {
	protected void brokenMethod() {
		IWorkspace w = null;
	}	
	
	public IWorkspace tryMethod(IWorkspace wrkspc) {
		//does nothing
		return null;
	}
}
Comment 2 Ankur Sharma CLA 2010-08-10 07:13:51 EDT
Fixed in HEAD
Comment 3 Tim deBoer CLA 2010-09-02 11:52:06 EDT
Hi,
Can you confirm that this only went into 3.7? I had built a temporary workaround on top of 3.6 to 'fix' this, so I just want to know if I can remove that in 3.6.1 or need to track it for 3.7.
Comment 4 Curtis Windatt CLA 2010-09-02 12:01:05 EDT
This was fixed in code from HEAD during M2.  It is available in recent 3.7 I Builds and will be available in the 3.7 M2 release.  The code was never backported to 3.6.x.