Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch on sealed types should offer autocomplete of types branches and not just the default branch #2565

Closed
nlisker opened this issue Jun 13, 2024 · 4 comments

Comments

@nlisker
Copy link

nlisker commented Jun 13, 2024

Original issue here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=576204. Still relevant in 4.31.

Concrete example:

sealed interface Type {

	final class A implements Type {}
	final class B implements Type {}

	default void a() {
		Type t;
		switch (t) {
		}
	}
}

image

A choice to get this result or thereabout should be offered:

switch (t) {
	case A a -> {}
	case B b -> {}
}

Note also that currently the default branch is added a switch statement (with default: break) rather than an expression (default -> {}), which users might not want as the default completion.

@stephan-herrmann
Copy link
Contributor

See also #1531

@stephan-herrmann
Copy link
Contributor

Note also that currently the default branch is added a switch statement (with default: break) rather than an expression (default -> {}), which users might not want as the default completion.

As this is a quickfix, not completion, and since quickfixes are implemented in jdt.ui, could you please file a separate ticket there? TIA

@nlisker
Copy link
Author

nlisker commented Jun 14, 2024

Transferred to eclipse-jdt/eclipse.jdt.ui#1459.

Is there any point in keeping this issue open, or does #1531 and the UI issue cover this?

@stephan-herrmann
Copy link
Contributor

Transferred to eclipse-jdt/eclipse.jdt.ui#1459.

Is there any point in keeping this issue open, or does #1531 and the UI issue cover this?

thanks for the reminder, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants