eclipse-jdt / eclipse-jdt/eclipse.jdt.ui
Hovering over an NLS message doesn't show the contents if the bundle name isn't constant
- Dominant language
- Java
- Stars
- 59
- Forks
- 127
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 35
Description
### Introduction
When creating a message bundle using the "Externalize strings wizard", the java class is initialized with a `BUNDLE_NAME` variable which contains the fully-qualified name of the message properties file, like:
`private static final String BUNDLE_NAME = NlsDemoMsg.class.getPackageName() + ".nlsdemomsg"; //$NON-NLS-1$`
In this case, it would resolve to `com.example.jdt.nls.msg.nlsdemomsg` which indeed resolves to a file called `nlsdemomsg.properties` in the `com.example.jdt.nls.msg` package.
---
### Problem
When using any messages from a class created in this way, hovering over the message does not show the contents, and you are not able to quickly goto it in the properties file:


I am assuming this is PDE's version of the wizard since it uses `org.eclipse.osgi.util.NLS` instead of `ResourceBundle`, but the plain-old Java version does the same thing, using `Messages.getString("key")` instead. The hover and goto only work if the `BUNDLE_NAME` is a constant string.
---
### Workaround
If the `BUNDLE_NAME` is changed to be just the string itself, like
`private static final String BUNDLE_NAME = "com.example.jdt.nls.msg.nlsdemomsg"; //$NON-NLS-1$`
then those things work:


---
### Expected
Ideally these features would work in all cases, especially as the wizard that makes this file does it the first way by calling `getPackageName()`.
Contributor guide
Research direction
Start with the Externalize strings wizard output and the hover/goto handling for BUNDLE_NAME expressions. Compare resolution of the getPackageName() form with a constant string, including the org.eclipse.osgi.util.NLS and ResourceBundle cases described in the report. Done means message hover contents and navigation work for generated bundles without changing BUNDLE_NAME manually.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100