Bug 20881

Summary: "organize imports" does not find an import statement "add import" does. [code manipulation]
Product: [Eclipse Project] JDT Reporter: Andreas Krüger <andreas.krueger>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: dirk_baeumer
Version: 2.0   
Target Milestone: 2.1 M2   
Hardware: PC   
OS: Windows 2000   
Whiteboard:
Attachments:
Description Flags
Resonably short example that reproduces the problem. none

Description Andreas Krüger CLA 2002-06-24 10:01:18 EDT
I have this interface that's the newest offspring in a grand family
of interfaces.  It extends two older family members and adds just one single
method.  That method throws IOException, plus two other exceptions you've
never heard about.

The interface has a compilation error "IOException cannot be resolved".
When I use "add import", "import java.io.IOException;" is added with no
questions asked.  Fine.  Previously, when I had tried "organize imports"
instead, nothing happened and the compilation error remained.

I have tagged this situation in CVS, so I can reproduce it.
Comment 1 Dirk Baeumer CLA 2002-07-30 06:54:46 EDT
Andreas, can you please provide better steps to reproduce the problem. Organize 
import uses the AST and therefore requires some structural correctness of the 
CU. Without a test case it is hard to tell what caused the error.
Comment 2 Andreas Krüger CLA 2002-07-30 08:52:27 EDT
Created attachment 1766 [details]
Resonably short example that reproduces the problem.
Comment 3 Dirk Baeumer CLA 2002-07-30 09:34:02 EDT
Thanks for the test case.

Martin, both add import and quick fix work, but not organize import. Please 
investigate.
Comment 4 Martin Aeschlimann CLA 2002-09-16 09:11:39 EDT
20020911

The AST does not correctly resolve 'IOExpresion':

1. import the given source
2. set breakpoint in OrganizeImportsOperation.TypeReferenceProcessor.process
3. do organize imports
4. The first entry comming in is SimpleName. 'process' does a 'resolveBinding' 
on it. Strangly, the resolved binding goes to type X1

Moving to JCore
Comment 5 Olivier Thomann CLA 2002-09-20 17:22:07 EDT
The compiler binding of the name IOException is X1. I don't understand why.
Comment 6 Olivier Thomann CLA 2002-09-23 10:46:40 EDT
The method that binds TypeReference and its bindings is boggus. I am working on 
a fix.
Comment 7 Olivier Thomann CLA 2002-09-23 11:08:50 EDT
Fixed and released in 2.1 stream.
Comment 8 David Audel CLA 2002-10-17 10:11:58 EDT
Verified.