Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 318509

Summary: Navigation to constructor/method intertype broken if regular declaration with same number of args exists
Product: [Tools] AJDT Reporter: Kris De Volder <kdevolder>
Component: UIAssignee: AJDT-inbox <AJDT-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: andrew.eisenberg, kdevolder
Version: 2.0.2Flags: andrew.eisenberg: review+
Target Milestone: 2.1.0   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
zip of a source folder with small example (few classes and an aspect)
none
mylyn/context/zip
none
patch fixing this bug + testcase andrew.eisenberg: iplog+

Description Kris De Volder CLA 2010-06-30 14:02:59 EDT
Created attachment 173135 [details]
zip of a source folder with small example (few classes and an aspect)

When there are two constructors for a type, both with the same number of arguments but overloaded on type, one of the constructors defined in the class itself and the other one defined as a intertype member... when we navigate from a call to a constructor to its declaration we always get taken to the constructor in the class (even when we should be taken to the one in the aspect).

This doesn't seem to happen when the constructors have different numbers of arguments.

I am attaching a .zip file with a small example. 

In the method com.springsource,DeparmentTest.testDepartmentBean()

there are two calls to Deparment constructors one in an aspect and one in the class itself.
Comment 1 Kris De Volder CLA 2010-06-30 15:46:13 EDT
This bug is not restricted to constructors. I have verified... it also happens for ordinary methods.

The reason why it happens is that Java's selection finder does not bother to check the argument types when it only finds one method/constructor in the declaring type that has the same name and number of arguments as the selection.

AJDT's intertype finder explicitly assumes that if exactly one element is found by the java selection finder it must be correct and so it does not try to find ITDs.
Comment 2 Kris De Volder CLA 2010-06-30 19:52:41 EDT
Created attachment 173159 [details]
mylyn/context/zip

Mylin context for work on this bug
Comment 3 Kris De Volder CLA 2010-06-30 20:00:51 EDT
Created attachment 173160 [details]
patch fixing this bug + testcase

I also fixed a small bug in the findRegion method used across the other test cases. I pulled that bugfix up to a superclass so it is shared by all sub testcases that had replicated copies.

Luckily fixing the bug in that method, didn't actually cause any of the existing tests to fail :-)
Comment 4 Andrew Eisenberg CLA 2010-06-30 23:25:27 EDT
Thanks, Kris.  I will apply this patch when I return from vacation.
Comment 5 Kris De Volder CLA 2010-07-24 12:13:53 EDT
Did this patch ever get applied?
Comment 6 Andrew Eisenberg CLA 2010-07-24 18:42:59 EDT
Nope.  It is now.  Applied patch.  Thanks.