Bug 20881 - "organize imports" does not find an import statement "add import" does. [code manipulation]
Summary: "organize imports" does not find an import statement "add import" does. [code...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1 M2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-24 10:01 EDT by Andreas Krüger CLA
Modified: 2002-10-17 10:11 EDT (History)
1 user (show)

See Also:


Attachments
Resonably short example that reproduces the problem. (2.59 KB, application/zip)
2002-07-30 08:52 EDT, Andreas Krüger CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.