apache / apache/netbeans

No Java code template context for variable initializer

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

Description

### Apache NetBeans version

Apache NetBeans 29

### What happened

There doesn't seem to be a Java code template context for variable initializers (or I can't figure it out).

### Language / Project Type / NetBeans Component

_No response_

### How to reproduce

In a suitable Java code context, start declaring a variable with initializer like this:
```java
String s =
```
Try to invoke the code template "sw" (imagine the template is changed to a switch expression, so it makes sense in that context). => It is not offered.

Try to find an assignable context under Options > Editor > Code Templates > Java that would make the code template appear. => I couldn't find any.

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Windows

### JDK

21

### Apache NetBeans packaging

Apache NetBeans binary zip

### Anything else

_No response_

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

No

Contributor guide

Open the contributing guide

Research direction

No implementation files, tests, or entry points are named. Start by reproducing the missing template in a Java variable initializer and inspect the Java code-template context handling used by the editor. Done means an assignable context is available and the “sw” template is offered after `String s =`.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 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.