Bug 520976 - Jump to constructor of enum is not available
Summary: Jump to constructor of enum is not available
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.8   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: 4.20 M1   Edit
Assignee: Kenneth Styrberg CLA
QA Contact: Jeff Johnston CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-15 06:38 EDT by Juergen Baier CLA
Modified: 2021-05-04 10:18 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Juergen Baier CLA 2017-08-15 06:38:50 EDT
When I have Java code such as in the editor

Foo f = new Foo(true, false, true);

and I STRG-Click on "Foo" on the right hand side the IDE jumps directly to the constructor.

If I have an enum:

public enum Bar {

  CASE_A(true,false),
  CASE_B(false,true);


  Bar(boolean a, boolean b) {
     ...
  }

}

and I STRG-Click on "CASE_A" then Eclipse does not jump to the constructor. 

There is currently no way to jump directly to the corresponding enum constructor. This is in particular a problem when you have enums with many elements and different constructors.

In my case I have several huge enums with different constructors and it is really inconvenient that this standard Eclipse behavior simply does not work the same way on enums.
Comment 1 Stephan Herrmann CLA 2017-08-15 07:28:57 EDT
I understand your expectation and s.t. like this is surely desirable.

Just to explain the status quo: in your example "CASE_A" is not a reference to a constructor but the declaration of an enum constant.

Ctrl+click, OTOH, normally applies on references only, not declarations.

If we directly associate selecting "CASE_A" with the constructor, then javadoc hover would no longer work here.

The argument list is the only syntax hinting at some constructor invocation being construed behind the scenes.

We have precendents where we fake a reference, like the "->" and "::" tokens. Technically this would suggest to make the "(" clickable, but users probably wont find this.

So, there is no *trivial* answer to this.
Comment 2 Juergen Baier CLA 2017-08-15 08:54:42 EDT
Note that my main problem is that there is currently no way to jump to the constructor. If this would be possible somehow (context menu, clicking on the "(" or something else) it would still be a huge improvement.
Comment 3 Eclipse Genie CLA 2021-03-14 09:57:36 EDT
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/177708
Comment 5 Jeff Johnston CLA 2021-03-24 19:00:28 EDT
Released for 4.20M1
Comment 6 Jeff Johnston CLA 2021-04-06 14:19:16 EDT
Verified for 4.20M1 using I20210406-0600 build
Comment 7 Juergen Baier CLA 2021-05-04 10:18:20 EDT
Thank you for fixing this - can't wait for the next Eclipse version :-)