eclipse-jdt / eclipse.jdt.ui

Eclipse Public License 2.0
36 stars 86 forks source link

Prevent potential `ClassCastException` in 'add service provider' quickfix #1599

Closed datho7561 closed 1 week ago

datho7561 commented 3 weeks ago

Fixes #1598

What it does

Switch && to || to prevent a ClassCastException in the case that the parent node is not a ProvidesDirective.

How to test

Set a debug point before the line that was changed, and modify the AST so that the parent node is not a ProvidesDirective. The method should return on the line after the line that was changed.

I don't have a method to reproduce this without modifying variables in memory, since the bug relies on a faulty error range or AST being generated by the compiler.

Author checklist

jjohnstn commented 3 weeks ago

This will have to wait until 4.34 M1 is open as it is not critical for RC2.

datho7561 commented 1 week ago

@jjohnstn if you have some time, could you please take a look at this?

jjohnstn commented 1 week ago

@datho7561 Will do so today