<commit_before>package org.antlr.intellij.plugin.editor;

import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
import static com.intellij.openapi.wm.impl.ToolWindowHeadlessManagerImpl.MockToolWindow;
import org.antlr.intellij.plugin.ANTLRv4PluginController;
import org.antlr.intellij.plugin.preview.PreviewPanel;
import org.jetbrains.annotations.Nullable;
import org.junit.Test;
import org.junit.Assert;

public class Issue559Test extends BasePlatformTestCase {

    @Test
    public void test_shouldNotClosePanel() {

        Project project = getProject();
        VirtualFile[] vFiles = new VirtualFile[]{openFile("T1.g4"), openFile("T2.g4")};

        // Setup
        ANTLRv4PluginController controller = ANTLRv4PluginController.getInstance(project);
        PreviewPanel panel = controller.getPreviewPanel();
        ToolWindow previewWindow = controller.previewWindow = createToolWindow();
        FileEditorManager source = FileEditorManager.getInstance(project);

        // Close file 1
        controller.myFileEditorManagerAdapter.fileClosed(source, vFiles[0]);
        Assert.assertTrue(previewWindow.isVisible());
        Assert.assertTrue(panel.isEnabled());

        // Close file 2
        controller.myFileEditorManagerAdapter.fileClosed(source, vFiles[1]);
        Assert.assertFalse(previewWindow.isVisible());
        Assert.assertFalse(panel.isEnabled());

    }

    private VirtualFile openFile(String file) {
        VirtualFile vf = myFixture.configureByFile(file).getVirtualFile();
        myFixture.openFileInEditor(vf);
        return vf;
    }

    private MockToolWindow createToolWindow() {

        return new MockToolWindow(getProject()) {

            private Boolean isVisible = true;

            @Override
            public void hide(@Nullable Runnable runnable) {
                isVisible = false;
            }

            @Override
            public boolean isVisible() {
                return isVisible;
            }
        };
    }

    @Override
    protected String getTestDataPath() {
        return "src/test/resources/editor";
    }

    @Override
    protected void tearDown() {
        EditorFactory.getInstance().releaseEditor(myFixture.getEditor());
    }


}<commit_msg>Fixing static class import<commit_after>package org.antlr.intellij.plugin.editor;

import com.intellij.openapi.editor.EditorFactory;
import com.intellij.openapi.fileEditor.FileEditorManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.testFramework.fixtures.BasePlatformTestCase;
import com.intellij.openapi.wm.impl.ToolWindowHeadlessManagerImpl;
import org.antlr.intellij.plugin.ANTLRv4PluginController;
import org.antlr.intellij.plugin.preview.PreviewPanel;
import org.jetbrains.annotations.Nullable;
import org.junit.Test;
import org.junit.Assert;

public class Issue559Test extends BasePlatformTestCase {

    @Test
    public void test_shouldNotClosePanel() {

        Project project = getProject();
        VirtualFile[] vFiles = new VirtualFile[]{openFile("T1.g4"), openFile("T2.g4")};

        // Setup
        ANTLRv4PluginController controller = ANTLRv4PluginController.getInstance(project);
        PreviewPanel panel = controller.getPreviewPanel();
        ToolWindow previewWindow = controller.previewWindow = createToolWindow();
        FileEditorManager source = FileEditorManager.getInstance(project);

        // Close file 1
        controller.myFileEditorManagerAdapter.fileClosed(source, vFiles[0]);
        Assert.assertTrue(previewWindow.isVisible());
        Assert.assertTrue(panel.isEnabled());

        // Close file 2
        controller.myFileEditorManagerAdapter.fileClosed(source, vFiles[1]);
        Assert.assertFalse(previewWindow.isVisible());
        Assert.assertFalse(panel.isEnabled());

    }

    private VirtualFile openFile(String file) {
        VirtualFile vf = myFixture.configureByFile(file).getVirtualFile();
        myFixture.openFileInEditor(vf);
        return vf;
    }

    private ToolWindowHeadlessManagerImpl.MockToolWindow createToolWindow() {

        return new ToolWindowHeadlessManagerImpl.MockToolWindow(getProject()) {

            private Boolean isVisible = true;

            @Override
            public void hide(@Nullable Runnable runnable) {
                isVisible = false;
            }

            @Override
            public boolean isVisible() {
                return isVisible;
            }
        };
    }

    @Override
    protected String getTestDataPath() {
        return "src/test/resources/editor";
    }

    @Override
    protected void tearDown() {
        EditorFactory.getInstance().releaseEditor(myFixture.getEditor());
    }


}
{'fraction_non_alphanumeric': 0.09467809447877218, 'fraction_numerical': 0.0055810245166434125, 'mean_word_length': 3.223905723905724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '15436', 'n_tokens_mistral': 1390, 'n_tokens_neox': 1336, 'n_words': 236}