eclipse-jdt / eclipse-jdt/eclipse.jdt.core
Content Assist doesn't work with `switch` inside `Optional.ifPresentOrElse`.
- Dominant language
- Java
- Stars
- 237
- Forks
- 195
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 47
Description
In Eclipse ever since Java introduced lambdas and streams, there are many, many cases in which Content Assist fails when inside lambdas, e.g. in stream processing, `Optional` processing, etc. Here is one example. (In the code below I use `|` to represent the position of the cursor.) I'm using Eclipse EE 2025-06 on Windows 10.
```java
enum FooBar {
FOO, BAR
};
```
```java
Optional.of(FooBar.FOO).ifPresent(foo -> {
switch(foo) {
case FOO -> {
}
case | //<-- cursor is here
}
});
```
If I press `Ctrl+Space` to invoke Content Assist, the first two options are `FOO` and `BAR`, as I would expect. But watch what happens when I change `Optional.ifPresent(…)` to `Optional.ifPresentOrElse(…)`:
```java
Optional.of(FooBar.FOO).ifPresentOrElse(foo -> {
switch(foo) {
case FOO -> {
}
case | //<-- cursor is here
}
}, () -> System.out.println("no foobar"));
```
When I press `Ctrl+Space` to invoke Content Assist, I don't get any enum options anymore; both `FOO` and `BAR` are missing. This effectively breaks Content Assist and I'm stuck with basically a text editor.
Contributor guide
Assessment
This issue has not been assessed yet.