apache / apache/netbeans

CodeLens-style Reference Count in NetBeans Java Editor

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

Description

### Description

![Image](https://github.com/user-attachments/assets/e0c3e9cf-f2b3-4d81-ae21-bf6c5b3fb02e)

**Summary**
I would like to request a CodeLens-style feature in the NetBeans Java Editor that displays reference counts above methods and classes, similar to Visual Studio. This feature would integrate with the existing Find Usages functionality in NetBeans, allowing users to see and navigate to method/class references efficiently.

**Feature Description**
This feature would analyze Java source code using the Java Source API and dynamically update a reference count for each method and class. The reference count would be displayed inline above the method/class definition in the editor. Clicking on the reference count should open the existing Find Usages UI, listing all references and allowing users to navigate to each occurrence.

**Key Features & Functionality**

**Display Reference Count Above Methods and Classes**
- Show how many times a method or class is referenced in the project.
- Update dynamically when the file or project is modified.

**Integration with Existing "Find Usages" Feature**

- Clicking on the reference count should trigger Find Usages.
- Display results using the existing "Find Usages" UI, ensuring consistency with NetBeans’ workflow.

**Non-intrusive UI Design**

- Display the reference count inline above the method/class, not in the gutter.
- Allow enabling/disabling the feature via settings.

**Efficient and Performant**

- Perform the analysis in the background using NetBeans Java Source API.
- Optimize for large projects by leveraging Find Usages indexing instead of scanning files manually.

**Why This Feature is Important?**

- Boosts productivity by eliminating the need to manually run "Find Usages" for frequently used methods.
- Improves code readability by instantly showing usage counts.
- Enhances navigation by providing quick access to usages through a familiar UI.

**Implementation Approach**

1. Use Java Source API to analyze method and class references.
2. Display reference count annotations above methods/classes in the editor.
3. On clicking the reference count, invoke the existing Find Usages UI to display results.

**Additional Notes**
This feature would modernize the NetBeans Java Editor by providing a lightweight but powerful way to navigate code references. Since NetBeans already has a strong Find Usages implementation, this proposal focuses on seamless integration rather than reinventing functionality.

Would love to hear thoughts from the NetBeans team and community!
Thanks for considering this feature request.

### Use case/motivation

_No response_

### Related issues

_No response_

### Are you willing to submit a pull request?

Yes

Contributor guide

Open the contributing guide

Research direction

Start by locating the NetBeans Java Editor's existing Find Usages UI and Java Source API integration; the issue names no files or tests. The work is done when configurable, background-updated reference counts appear above methods and classes and clicking one opens the existing Find Usages results.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.