Introduce wrapper for EditorFactoryListener to warn about compatibility issues

This commit is contained in:
Nikolay Krasko
2019-01-17 16:59:40 +03:00
parent 74bc440e44
commit 3548d25095
5 changed files with 42 additions and 7 deletions
+1
View File
@@ -116,6 +116,7 @@
<Problem reference="com.intellij.openapi.extensions.ExtensionPointName#getPoint" reason="Absent in 182." />
<Problem reference="com.intellij.openapi.extensions.ExtensionPointName#findExtensionOrFail" reason="Absent in 182." />
<Problem reference="com.intellij.openapi.ui.popup.PopupChooserBuilder#PopupChooserBuilder(javax.swing.JList)" reason="Generified in 182. Use PopupChooserBuilderWrapper instead." />
<Problem reference="com.intellij.openapi.editor.event.EditorFactoryListener" reason="Default implementations were added in 183. Use EditorFactoryListenerWrapper for inheritance instead." />
</list>
</option>
</inspection_tool>
@@ -28,9 +28,9 @@ import com.intellij.openapi.editor.RangeMarker
import com.intellij.openapi.editor.event.CaretEvent
import com.intellij.openapi.editor.event.CaretListener
import com.intellij.openapi.editor.event.EditorFactoryEvent
import com.intellij.openapi.editor.event.EditorFactoryListener
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key
import org.jetbrains.kotlin.idea.util.compat.EditorFactoryListenerWrapper
class LookupCancelWatcher(val project: Project) : ProjectComponent {
private class Reminiscence(editor: Editor, offset: Int) {
@@ -105,17 +105,12 @@ class LookupCancelWatcher(val project: Project) : ProjectComponent {
override fun initComponent() {
EditorFactory.getInstance().addEditorFactoryListener(
object : EditorFactoryListener {
object : EditorFactoryListenerWrapper {
override fun editorReleased(event: EditorFactoryEvent) {
if (lastReminiscence?.editor == event.editor) {
lastReminiscence!!.dispose()
}
}
override fun editorCreated(event: EditorFactoryEvent) {
// BUNCH: 182 Has default implementation since 183
// Do nothing
}
},
project
)
@@ -0,0 +1,25 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea.util.compat;
import com.intellij.openapi.editor.event.EditorFactoryEvent;
import com.intellij.openapi.editor.event.EditorFactoryListener;
import org.jetbrains.annotations.NotNull;
// Default implementation for interface methods were added in 183.
// BUNCH: 182
@SuppressWarnings("IncompatibleAPI")
public interface EditorFactoryListenerWrapper extends EditorFactoryListener {
@Override
default void editorCreated(@NotNull EditorFactoryEvent event) {
}
@Override
default void editorReleased(@NotNull EditorFactoryEvent event) {
}
}
@@ -0,0 +1,14 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
@file:Suppress("IncompatibleAPI")
package org.jetbrains.kotlin.idea.util.compat
import com.intellij.openapi.editor.event.EditorFactoryListener
// Default implementation for interface methods were added in 183.
// BUNCH: 182
typealias EditorFactoryListenerWrapper = EditorFactoryListener