eclipse-jdt / eclipse-jdt/eclipse.jdt.core

Completion after statement with a switch expression suggests `true` and `false`

Open
#4,184 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
237
Forks
195
Avg merge
1d 12h
Merged PRs (30d)
47

Description

eg. one of the completion results when opening completion at `|` is `true`:

```java
public class Main {
public static void main(String... args) {
int a = switch (null) {
default -> 12;
};
tru|
}
}
```

Here is a test case where the behaviour is said to be correct: https://github.com/eclipse-jdt/eclipse.jdt.core/blob/2df345c830abb008370b38f88841b76173c348e2/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTestsForRecordPattern.java#L79

However, this behaviour is inconsistent with completion after other kinds of statements. `true` is not suggested in these cases:

```java
public class Main {
public static void main(String... args) {
int a = 12;
tru|
}
}
```

```java
public class Main {
public static void main(String... args) {
System.out.println("yippee!");
tru|
}
}
```

```java
public class Main {
public static void main(String... args) {
for (int i = 0; i < 10; i++) {
System.out.println(i + ", yippee!");
}
tru|
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.