JetBrains / MPS-extensions

MPS-extensions aims to ease language development within MPS.
https://jetbrains.github.io/MPS-extensions/
Apache License 2.0
83 stars 52 forks source link

2023.2: Remove uses of reflection from the grouped intention menu #1002

Open sergej-koscejev opened 3 weeks ago

sergej-koscejev commented 3 weeks ago

EditorComponent#setIntentionMenuProducer API was introduced in 2023.2 (or perhaps earlier) to support the use case of custom grouped intention menu, so it should be possible to rewrite the code without accessing myLightBulb via reflection. This is important because modifying private final fields got more complicated in Java 21 and the current code does not work with MPS master.

alexanderpann commented 3 weeks ago

Is our reflection approach with Java 21 even possible? I am not sure if we can rewrite the code but we can give it a try.

sergej-koscejev commented 3 weeks ago

I saw some quite complicated code here and there on StackOverflow to work around final in JDK 21 but I'd rather invest effort towards moving to the API than maintaining hacks.

sergej-koscejev commented 3 weeks ago

https://stackoverflow.com/a/78249703 is the code I was referring to, in case we do decide to follow that route.