mapstruct / mapstruct-idea

An IntelliJ IDEA plugin for working with MapStruct
Other
141 stars 38 forks source link

Fix build with ideaVersion `LATEST-EAP-SNAPSHOT` #155

Closed thunderhook closed 7 months ago

thunderhook commented 1 year ago

In the LATEST-EAP-SNAPSHOT they changed the way how RemoveUnusedVariableFix works, see this commit

The org.mapstruct.intellij.inspection.WrongUsageOfMappersFactoryInspection.RemoveMappersFix won't compile anymore since it is expected to be an IntentionAction instead of a PsiBasedModCommandAction<PsiVariable>:

\IdeaProjects\mapstruct-idea\src\main\java\org\mapstruct\intellij\inspection\WrongUsageOfMappersFactoryInspection.java:132: error: method does not override or implement a method from a supertype
        @Override
        ^

\IdeaProjects\mapstruct-idea\src\main\java\org\mapstruct\intellij\inspection\WrongUsageOfMappersFactoryInspection.java:149: error: incompatible types: RemoveMappersFix cannot be converted to IntentionAction
                new RemoveMappersFix( (PsiVariable) parent ),
                ^

A quick-fix would be: copy the contents of the old code instead of extending RemoveUnusedVariableFix. Additionally it would be good to know why they changed it, and if this is a better way of handling fixes. Therefore we might change our RemoveMappersFix respectively.

To change the version inside the IDE just change the version to LATEST-EAP-SNAPSHOT in gradle.properties

thunderhook commented 11 months ago

I thought this would be easy. However, they changed a lot of code. My approach with copying the old classes did not work. They also removed the com.intellij.codeInsight.daemon.impl.quickfix.SideEffectWarningDialog class, see: https://github.com/mapstruct/mapstruct-idea/actions/runs/6916833362/job/18817324564

It is still only in the LATEST-EAP-SNAPSHOT, will be likely in main with 2023.3 though.

I think we should either:

I am not sure what happens when we switch to 2023.3 as the main version for development. I think this intention cannot run on older versions then? Or does it just not build with that version? We'll see.

filiphr commented 11 months ago

I had a look at it. They didn't remove it. They just changed it. They are now doing:

return new RemoveUnusedVariableFix(variable).asIntention();

I've done PR https://github.com/mapstruct/mapstruct-idea/pull/162 for this

filiphr commented 7 months ago

Done in PR #179