eclipse-jdt / eclipse-jdt/eclipse.jdt.ui

'Add missing case statements' uses alphabetical order and not declaration order

Open
#2,397 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
59
Forks
127
Avg merge
23h 30m
Merged PRs (30d)
35

Description

This was originally reported [here](https://bugs.eclipse.org/bugs/show_bug.cgi?id=546984) but I think this might be a useful feature or worth a discussion at least.

-------------------
With JDT included in Eclipse 19-06 M1, using the quick action 'Add missing case statements' will generate unordered case statements.

For example, with this enum:
```
public enum ENodeIndex {
TIP, LEFT, MIDDLE, RIGHT
}
```

The generated code is:

```
switch (index) {
case LEFT:
break;
case MIDDLE:
break;
case RIGHT:
break;
case TIP:
break;
default:
break;
}
```

I think it would be better to keep the enum order.

----

Contributor guide

Open the contributing guide

Research direction

Start at the Eclipse JDT UI implementation of the “Add missing case statements” quick action and inspect how enum constants are ordered. Add coverage using the ENodeIndex example, and verify that generated cases retain the declaration order TIP, LEFT, MIDDLE, RIGHT.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.