apache / apache/netbeans

Additional formatting / highlighting options for Java

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

Description

### Description

Provide options to insert a comment after the closing brace containing the class, method, if-statements, ... header without parameters.

Due to the fact that e.g. class headers and closing braces could already be recognized and blank lines "\n" added after them (see the picture below), this might be easy to implement. Of course one should make sure that the code does not get spammed with brace comments if something goes wrong.

Some examples:
```
if ( 1 < 2 ) {
return true;
} // if
```

```
public void method( int a ) {
a += 1;
} // public void method
```

![Java-Formatting-Options](https://github.com/apache/netbeans/assets/55635116/338aff94-e889-4e93-8072-46bb9e5afe29)

The feature would look similar to these plugins except that the "visual aids" are written to the file:

* https://marketplace.visualstudio.com/items?itemName=wraith13.bracket-lens or that plugin
* https://marketplace.visualstudio.com/items?itemName=wraith13.bracket-lens

Alternatively it might be a compromise to rebuild the functionality of the aforementioned plugins to avoid inserting brace comments.

### Use case/motivation

At work, we use these brace comments to keep track of which closing brace belongs to which opening brace.
I know that there's already syntax highlighting for that, but when there's an syntax error, this does not work any longer. Additionally if one would use the visual solution like the vscode plugins do, the benefits are lost when the code is pushed to a repository that is managed trough a web browser. One would need to check out the code in the IDE to get back the additional information.

Before any critic:

* I know that these comments might not make sense for small function like primitive getter functions.
* Maybe this is something retro and was abandoned in the past for good reason. I haven't been developing software for so long.
* It might violate some Clean Code rules.

### Related issues

_No response_

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

Yes

Contributor guide

Open the contributing guide

Research direction

The issue names Java formatting and syntax highlighting as the affected entry points but provides no files or tests. First clarify whether the goal is inserted brace comments or visual aids, then define configurable cases and safeguards; done means the selected behavior works without spamming comments.

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.