deprecate Before.Adapter

This commit is contained in:
Vladimir Krivosheev
2018-04-20 16:10:53 +02:00
parent 4ca8b482c7
commit 4f2ecb1dbf
4 changed files with 17 additions and 23 deletions
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.fileEditor;
import com.intellij.openapi.vfs.VirtualFile;
@@ -38,9 +24,16 @@ public interface FileEditorManagerListener extends EventListener{
Topic<Before> FILE_EDITOR_MANAGER =
new Topic<>("file editor before events", Before.class, Topic.BroadcastDirection.TO_PARENT);
void beforeFileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file);
void beforeFileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file);
default void beforeFileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
}
default void beforeFileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
}
/**
* @deprecated use {@link Before} directly
*/
@Deprecated
class Adapter implements Before {
@Override
public void beforeFileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) { }
@@ -55,7 +55,7 @@ public final class EditorHistoryManager implements PersistentStateComponent<Elem
connection.subscribe(UISettingsListener.TOPIC, uiSettings -> trimToSize());
connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, new FileEditorManagerListener.Before.Adapter() {
connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, new FileEditorManagerListener.Before() {
@Override
public void beforeFileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
updateHistoryEntry(file, false);
@@ -80,7 +80,7 @@ class IdeaDecompiler : ClassFileDecompilers.Light() {
private fun intercept() {
val app = ApplicationManager.getApplication()
val connection = app.messageBus.connect(app)
connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, object : FileEditorManagerListener.Before.Adapter() {
connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, object : FileEditorManagerListener.Before {
override fun beforeFileOpened(source: FileEditorManager, file: VirtualFile) {
if (!myLegalNoticeAccepted && file.fileType === StdFileTypes.CLASS && ClassFileDecompilers.find(file) === this@IdeaDecompiler) {
myFutures[file] = app.executeOnPooledThread(Callable<CharSequence> { decompile(file) })
@@ -96,10 +96,10 @@ class IdeaDecompiler : ClassFileDecompilers.Light() {
PropertiesComponent.getInstance().setValue(LEGAL_NOTICE_KEY, true)
myLegalNoticeAccepted = true
app.invokeLater({
app.invokeLater {
RefreshQueue.getInstance().processSingleEvent(
VFileContentChangeEvent(this@IdeaDecompiler, file, file.modificationStamp, -1, false))
})
VFileContentChangeEvent(this@IdeaDecompiler, file, file.modificationStamp, -1, false))
}
connection.disconnect()
}
@@ -1,3 +1,4 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.plugins.ipnb.editor;
import com.google.common.collect.Lists;
@@ -59,7 +60,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor {
public IpnbFileEditor(Project project, final VirtualFile vFile) {
myDocument = FileDocumentManager.getInstance().getDocument(vFile);
project.getMessageBus().connect(this)
.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, new FileEditorManagerListener.Before.Adapter() {
.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, new FileEditorManagerListener.Before() {
@Override
public void beforeFileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
if (!new File(file.getPath()).exists()) return;