diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFactoryImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFactoryImpl.java index e05bed569f6e..ef71e69c5ae3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFactoryImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorFactoryImpl.java @@ -40,6 +40,7 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.EventDispatcher; import com.intellij.util.SmartList; import com.intellij.util.text.CharArrayCharSequence; +import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -84,19 +85,25 @@ public class EditorFactoryImpl extends EditorFactory { public void validateEditorsAreReleased(Project project) { for (Editor editor : myEditors) { if (editor.getProject() == project || editor.getProject() == null) { - fireEditorNotReleasedError(editor); + try { + LOG.error(notReleasedError(editor)); + } + finally { + releaseEditor(editor); + } } } } - private static void fireEditorNotReleasedError(final Editor editor) { + @NonNls + public static String notReleasedError(@NotNull Editor editor) { final String creator = editor.getUserData(EDITOR_CREATOR); if (creator == null) { - LOG.error("Editor for the document with class:" + editor.getClass().getName() + - " and the following text hasn't been released:\n" + editor.getDocument().getText()); + return "Editor of " + editor.getClass() + + " and the following text hasn't been released:\n" + editor.getDocument().getText(); } else { - LOG.error("Editor with class:" + editor.getClass().getName() + " hasn't been released:\n" + creator); + return "Editor of " + editor.getClass() + " hasn't been released:\n" + creator; } } diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index ebaec0f6a621..af5682fb6c93 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -42,6 +42,7 @@ import com.intellij.openapi.command.undo.UndoManager; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; +import com.intellij.openapi.editor.impl.EditorFactoryImpl; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl; import com.intellij.openapi.fileTypes.FileType; @@ -529,10 +530,12 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da public static void checkEditorsReleased() { final Editor[] allEditors = EditorFactory.getInstance().getAllEditors(); if (allEditors.length > 0) { - for (Editor allEditor : allEditors) { - EditorFactory.getInstance().releaseEditor(allEditor); + String fail = null; + for (Editor editor : allEditors) { + fail = EditorFactoryImpl.notReleasedError(editor); + EditorFactory.getInstance().releaseEditor(editor); } - fail("Unreleased editors: " + allEditors.length); + fail("Unreleased editors: " + allEditors.length + "\n"+fail); } }