Mark occurrences of enum constructors
Description
Unlike constructors of regular classes, the "mark occurrences" mechanism doesn't mark usages of enum constructors. Example:
class Example
{
@SuppressWarnings("unused")
static class Class
{
static final Class A = new Class();
static final Class B = new Class();
static final Class C = new Class();
Class() { }
}
enum Enum
{
A(),
B(),
C();
Enum() { }
}
}
Place the cursor on the Class() constructor => The three new Class() invocations are highlighted and shown in the right-hand editor sidebar.
Place the cursor on the Enum() constructor => The three invocations from the enum constants are not highlighted.
Use case/motivation
In large enum classes, where the enum constants have implementations that may span many lines, an/or where the constants may have extensive Javadoc comments, highlighting the constants (which effectively are constructor invocations) would be useful.
Related issues
#8985
Are you willing to submit a pull request?
No
While I see the use-case, this is not comparable. For the class (I renamed it to Demo) the type usage is highlighted, not the instances:
For the enum, there is not type in front of its instances.
@matthiasblaesing: This is not about the class name, but about the constructor invocation. This may be more obvious when the Enum constructor has arguments. The enum constants serve a double purpose: they are constants, but they are also constructor invocations.
What I mean is the equivalent of
for enum classes. In other words, when the cursor is on the enum constructor, I would be expecting this:
Note that this would be consistent with Call Hierarchy and Find Usages on the enum constructor:
(The latter displays a weird subtree for some reason.)
enums need many special cases since they work differently to most other java code. Constructor invocation name != class name etc. This looks like a nice-to-have to me but is probably low priority.