eclipse-jdt / eclipse.jdt.ui

Eclipse Public License 2.0
36 stars 86 forks source link

Logic error in `LocalCorrectionsSubProcessor.addServiceProviderProposal` causes `ClassCastException` when AST is broken #1598

Closed datho7561 closed 1 week ago

datho7561 commented 3 weeks ago

See https://github.com/eclipse-jdt/eclipse.jdt.ui/blob/1c68e46548bf6e38f541275ac6197bb4011f56e4/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.java#L2653

In order to prevent a ClassCastException when the child is a Name and the parent is not a ProvidesDirective, this should be || instead of &&.

There is likely no way to reproduce this in Eclipse, since if the error is reported correctly the child should always be a Name and the parent should always be a ProvidesDirective.

I was able to find this bug since I was using https://github.com/eclipse-jdtls/eclipse-jdt-core-incubator, which still has some bugs in the error and AST translation that we are working on fixing.