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

Created type doesn't implement sealed interface, #1553

Closed
fbricon opened this issue Sep 28, 2020 · 2 comments · Fixed by #1560
Closed

Created type doesn't implement sealed interface, #1553

fbricon opened this issue Sep 28, 2020 · 2 comments · Fixed by #1560

Comments

@fbricon
Copy link
Contributor

fbricon commented Sep 28, 2020

In a Java 15 project, given sealed interface Foo:

public sealed interface Foo permits Bar {}

Bar doesn't exist so there's a code action to create a new class/interface. But, when applied, the new class doesn't implement Foo though, as it should.

@rgrunber
Copy link
Contributor

rgrunber commented Sep 28, 2020

This seems similar to Bug 564473. JDT UI still has to add the support for sealed/non-sealed/permits modifiers. However this would apply to the their wizard, which JDT-LS doesn't use. I suspect that JDT-LS has some specialized code to create the class and I'll probably just need to update it.

Update : Entry point would be around https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/corrections/proposals/NewCUProposal.java#L273

rgrunber added a commit to rgrunber/eclipse.jdt.ls that referenced this issue Oct 6, 2020
- Add quick fix to generate proper type declaration for sealed type
- Fixed eclipse-jdtls#1553
- Add testcase

Signed-off-by: Roland Grunberg <[email protected]>
rgrunber added a commit to rgrunber/eclipse.jdt.ls that referenced this issue Oct 7, 2020
- Add quick fix to generate proper type declaration for sealed type
- Fixes eclipse-jdtls#1553
- Add testcase

Signed-off-by: Roland Grunberg <[email protected]>
rgrunber added a commit to rgrunber/eclipse.jdt.ls that referenced this issue Oct 8, 2020
- Add quick fix to generate proper type declaration for sealed type
- Fixes eclipse-jdtls#1553
- Add testcase

Signed-off-by: Roland Grunberg <[email protected]>
fbricon pushed a commit that referenced this issue Oct 14, 2020
- Add quick fix to generate proper type declaration for sealed type
- Fixes #1553
- Add testcase

Signed-off-by: Roland Grunberg <[email protected]>
@fbricon fbricon added this to the Mid October 2020 milestone Oct 14, 2020
@fbricon
Copy link
Contributor Author

fbricon commented Oct 14, 2020

This is partially completed for now, the generated class now declares it implements the interface, but the interface methods are not implemented a that point. One needs to apply the code action that adds unimplemented methods.

rgrunber added a commit to rgrunber/eclipse.jdt.ls that referenced this issue Oct 14, 2020
- When a non-existent type is permitted by a sealed class, the newly
  created type should implement the necessary methods
- Related eclipse-jdtls#1553
rgrunber added a commit to rgrunber/eclipse.jdt.ls that referenced this issue Oct 14, 2020
- When a non-existent type is permitted by a sealed class, the newly
  created type should implement the necessary methods
- Related eclipse-jdtls#1553

Signed-off-by: Roland Grunberg <[email protected]>
rgrunber added a commit to rgrunber/eclipse.jdt.ls that referenced this issue Jun 25, 2022
- When a non-existent type is permitted by a sealed class, the newly
  created type should implement the necessary methods
- Related eclipse-jdtls#1553

Signed-off-by: Roland Grunberg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants