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

[quick fix] No quickfix suggestion for switch over sealed interfaces #1795

Closed
jubax opened this issue Nov 12, 2024 · 0 comments
Closed

[quick fix] No quickfix suggestion for switch over sealed interfaces #1795

jubax opened this issue Nov 12, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@jubax
Copy link

jubax commented Nov 12, 2024

I was pointed to the jdt.ui project for quick fix bugs. See eclipse-jdt/eclipse.jdt.core#3300. I copied and modified the quickfix-related part to this new issue.

If you have a class with a "sealed interface" then no appropriate case labels are generated for quick fix.

public class SealedInterfaceContentAssist {

	sealed interface Foo {
		record FooImpl_a(String x) implements Foo {
		}

		record FooImpl_b(String y, String z) implements Foo {
		}
	}

	public static void main(String[] args) {
		Foo foo = getFoo();
		switch (foo) { // <== No quickfix for creating the case labels
		}
	}

	private static Foo getFoo() {
		return new Foo.FooImpl_b("a", "b");
	}

}

This quick fix would be important because there also is no appropriate content assist for this case. And the syntax for complex cases makes it hard to type it.

The quick fix should generate

	public static void main(String[] args) {
		Foo foo = getFoo();
		switch (foo) {
			case FooImpl_a(String x) -> ;
			case FooImpl_b(String y, String z) -> ;
		}
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants