StatusBar deprecated API

已回答

Hi,
I'm developing a plugin which has a status bar widget - extending EditorBasedWidget among other interface implementations. I recently saw that some of the APIs I'm using - StatusBar.addWidget, StatusBar.removeWidget and StatusBarWidget.getPresentation, are scheduled to be removed (the last one is scheduled to remove in 2020.2).

My problem is that the suggested alternatives (according to the deprecation messages) are not available in older versions prior to 2018.3 and I have users still using 2018.1/2018.2 and even 2017.*
How should I handle this conflict?

0

You can continue to use Deprecated API as long as it will exist. You can then make a switch to new API and set your plugin's target minimum platform (and since-build) accordingly. If you want to continue both versions, creating dedicated branches is the safest way.

0

The way I handle APIs that are changed, removed, or added in newer versions is to have the following in the build.gradle file:

if (ext.intellij_version >= 182) {
sourceSets.main.java.srcDirs += 'src/182/native'
} else {
sourceSets.main.java.srcDirs += 'src/182/compat'
}

Typically, the native version is a type alias to the class/interface/etc., whereas the compat version provides a mapping from the old API to the new API.

The main code is then implemented using those compatibility APIs, so when you build for a specific version, the correct code is used for that version of IntelliJ.

0

请先登录再写评论。