eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Add Import command doesn't work with nested Java classes.
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
The "Add Import" (`Ctrl+Shift+M` on Windows) command doesn't seem to work as well as it did years ago. Let's say I have:
```java
Optional.ofNullable("foo");
```
If I put my cursor on `ofNullable` and hit `Ctrl+Shift+M`, Eclipse adds an import and changes that to:
```java
ofNullable("foo");
```
Great that works. But let's say I have this class structure:
```java
public final class CloudFormationSupport {
public static final class Outputs {
public static SequencedMap toMap(final Iterable outputs) {
…
```
I call it that method like this:
```java
final Map outputsByKey = CloudFormationSupport.Outputs.toMap(stack.outputs());
```
If I put my cursor on `Outputs`, I expect Eclipse to add an import and give me this:
```java
final Map outputsByKey = Outputs.toMap(stack.outputs());
```
But it doesn't. Eclipse doesn't do anything.
And this is frustrating because my code is well organized and I have many things organized by subclass. It's tedious to go add all the imports so that the code is concise and reads nicely. That's what `Ctrl+Shift+M` is supposed to do for me.
It seems like it used to work more often; nowadays it hardly seems to work at all (especially inside lambdas!). Maybe my memory is looking through rose-colored glasses. In any case, `Ctrl+Shift+M` only seems to work about half the time now.
Contributor guide
Assessment
This issue has not been assessed yet.