apache / apache/netbeans

Mark occurrences of enum constructors

Open
#8,986 3 comments 0 reactions 0 assignees View on GitHub
Java kind:feature needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Description

Unlike constructors of regular classes, the "mark occurrences" mechanism doesn't mark usages of enum constructors. Example:

```java
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

Contributor guide

Open the contributing guide

Research direction

Start by locating NetBeans' Java editor implementation of the “mark occurrences” mechanism and its handling of constructor references. Reproduce the example with the cursor on Class() and Enum(), then trace how enum constants are represented. Done means enum constructor occurrences are highlighted consistently with regular class constructor invocations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.