Bug 270436 - [assist] Interface type proposed where only class is legal
Summary: [assist] Interface type proposed where only class is legal
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M1   Edit
Assignee: Pradeep Balachandran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-30 07:52 EDT by Srikanth Sankaran CLA
Modified: 2009-08-04 06:44 EDT (History)
2 users (show)

See Also:


Attachments
Code plugin patch - v0.5 (904 bytes, patch)
2009-05-25 14:01 EDT, Pradeep Balachandran CLA
no flags Details | Diff
Tests plugin patch - v0.5 (2.28 KB, patch)
2009-05-25 14:04 EDT, Pradeep Balachandran CLA
no flags Details | Diff
Code plugin patch - v0.6 (975 bytes, patch)
2009-06-01 07:53 EDT, Pradeep Balachandran CLA
srikanth_sankaran: iplog+
srikanth_sankaran: review+
Details | Diff
Tests plugin patch - v0.6 (3.58 KB, patch)
2009-06-01 07:55 EDT, Pradeep Balachandran CLA
srikanth_sankaran: iplog+
srikanth_sankaran: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Srikanth Sankaran CLA 2009-03-30 07:52:50 EDT
Build id: I20090313-0100 (3.5 M6)

1. Create a java project containing:

package test;
public final class TestClass {}
interface TestInterface {}
class Subclass extends test.Test|{}

2. At the '|' symbol do CTRL+SPACE. You will see
the token Test being completed into test.TestInterface

This proposal is bad and leads to an immediate error
(super class must be a class error)
Comment 1 Pradeep Balachandran CLA 2009-05-25 01:00:34 EDT
This is not reproducible in 3.5-M7.
Comment 2 Srikanth Sankaran CLA 2009-05-25 02:10:27 EDT
(In reply to comment #1)
> This is not reproducible in 3.5-M7.

Can you check again ? I could reproduce this with 

Eclipse SDK

Version: 3.5.0
Build id: I20090430-2300

which is M7 as well as with HEAD.



Comment 3 Pradeep Balachandran CLA 2009-05-25 03:19:30 EDT
Interesting .... when I have all these in the same compilation unit, I am able to reproduce it. But, if I create a project, add a package test, add TestClass, TestInterface, SubClass one after another (thus there are three compilation units), I am not able to reproduce this. So apparently this has something to do with all the types being in the same compilation unit.
Comment 4 Pradeep Balachandran CLA 2009-05-25 14:01:57 EDT
Created attachment 137046 [details]
Code plugin patch - v0.5

Patch for plugin org.eclipse.jdt.core, class CompletionEngine.
Comment 5 Pradeep Balachandran CLA 2009-05-25 14:04:06 EDT
Created attachment 137048 [details]
Tests plugin patch - v0.5

Patch for plugin org.eclipse.jdt.core.tests.model - added two tests to CompletionTests.
Comment 6 Pradeep Balachandran CLA 2009-05-25 14:11:58 EDT
There was one place where it was looping over the top-level types in a compilation unit where a few validation checks were missing. That also explains why it was reproducible only when the class and interface are in the same compilation unit.

While at it, I also fixed a related problem where the type itself (ie SubClass in this case) was being offered as a completion choice. 

Thus the attached code patch fixes two issues:
(1) the original problem described in this bug and
(2) the problem where the type itself is offered as a choice for completion.

The attached tests patch has one test each for the two problems listed above.
Comment 7 Pradeep Balachandran CLA 2009-06-01 07:53:40 EDT
Created attachment 137831 [details]
Code plugin patch - v0.6

Added another patch with one additional change to cater to another scenario which is the flip-side of the original problem.
This patch, in addition to fixing issues #1, #2 also fixes:
     (3) A class is being offered as a choice for the interface.
Comment 8 Pradeep Balachandran CLA 2009-06-01 07:55:44 EDT
Created attachment 137832 [details]
Tests plugin patch - v0.6

Added an additional test - altogether 3 tests including the 2 new tests in the previous patch, to ensure that a Class is not being offered as a choice when expecting an Interface.
Comment 9 Srikanth Sankaran CLA 2009-07-23 01:08:32 EDT
Released in HEAD for 3.6M1 (after minor clean up)
Comment 10 Frederic Fusier CLA 2009-08-04 06:44:29 EDT
Verified for 3.6M1 using build 20090802-2000.