diff --git a/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsArtifactSerializationTest.java b/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsArtifactSerializationTest.java index f03b784c2c53..4e784bc998b6 100644 --- a/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsArtifactSerializationTest.java +++ b/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsArtifactSerializationTest.java @@ -23,7 +23,6 @@ import org.jetbrains.jps.model.artifact.JpsArtifactService; import org.jetbrains.jps.model.serialization.artifact.JpsArtifactSerializer; import java.io.File; -import java.io.IOException; import java.util.Collections; import java.util.List; @@ -53,17 +52,12 @@ public class JpsArtifactSerializationTest extends JpsSerializationTestCase { } private void doTestSaveArtifact(JpsArtifact artifact, File expectedFile) { - try { - Element actual = new Element("component").setAttribute("name", "ArtifactManager"); - JpsArtifactSerializer.saveArtifact(artifact, actual); - JpsMacroExpander - expander = JpsProjectLoader.createProjectMacroExpander(Collections.emptyMap(), new File(getTestDataFileAbsolutePath(SAMPLE_PROJECT_PATH))); - Element expected = JpsLoaderBase.loadRootElement(expectedFile, expander); - PlatformTestUtil.assertElementsEqual(expected, actual); - } - catch (IOException e) { - throw new RuntimeException(e); - } + Element actual = new Element("component").setAttribute("name", "ArtifactManager"); + JpsArtifactSerializer.saveArtifact(artifact, actual); + JpsMacroExpander + expander = JpsProjectLoader.createProjectMacroExpander(Collections.emptyMap(), new File(getTestDataFileAbsolutePath(SAMPLE_PROJECT_PATH))); + Element expected = JpsLoaderBase.loadRootElement(expectedFile, expander); + PlatformTestUtil.assertElementsEqual(expected, actual); } private static JpsArtifactService getService() { diff --git a/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsGlobalSerializationTest.java b/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsGlobalSerializationTest.java index a99daa8c9b14..86012a3c2ada 100644 --- a/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsGlobalSerializationTest.java +++ b/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsGlobalSerializationTest.java @@ -80,15 +80,10 @@ public class JpsGlobalSerializationTest extends JpsSerializationTestCase { } private void assertOptionsFilesEqual(File originalOptionsDir, File targetOptionsDir, final String fileName) { - try { - JpsMacroExpander expander = new JpsMacroExpander(getPathVariables()); - Element expected = JpsLoaderBase.loadRootElement(new File(originalOptionsDir, fileName), expander); - Element actual = JpsLoaderBase.loadRootElement(new File(targetOptionsDir, fileName), expander); - PlatformTestUtil.assertElementsEqual(expected, actual); - } - catch (IOException e) { - throw new RuntimeException(e); - } + JpsMacroExpander expander = new JpsMacroExpander(getPathVariables()); + Element expected = JpsLoaderBase.loadRootElement(new File(originalOptionsDir, fileName), expander); + Element actual = JpsLoaderBase.loadRootElement(new File(targetOptionsDir, fileName), expander); + PlatformTestUtil.assertElementsEqual(expected, actual); } public void testLoadEncoding() { diff --git a/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsProjectSerializationTest.java b/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsProjectSerializationTest.java index 506c6fcc7f27..342a956f71ac 100644 --- a/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsProjectSerializationTest.java +++ b/jps/model-serialization/testSrc/org/jetbrains/jps/model/serialization/JpsProjectSerializationTest.java @@ -32,7 +32,6 @@ import org.jetbrains.jps.model.serialization.library.JpsLibraryTableSerializer; import org.jetbrains.jps.model.serialization.module.JpsModuleRootModelSerializer; import java.io.File; -import java.io.IOException; import java.util.Collections; import java.util.List; @@ -215,18 +214,13 @@ public class JpsProjectSerializationTest extends JpsSerializationTestCase { } private void doTestSaveLibrary(File libFile, String libName, JpsLibrary library) { - try { - Element actual = new Element("library"); - JpsLibraryTableSerializer.saveLibrary(library, actual, libName); - JpsMacroExpander - macroExpander = JpsProjectLoader.createProjectMacroExpander(Collections.emptyMap(), getFileInSampleProject("")); - Element rootElement = JpsLoaderBase.loadRootElement(libFile, macroExpander); - Element expected = rootElement.getChild("library"); - PlatformTestUtil.assertElementsEqual(expected, actual); - } - catch (IOException e) { - throw new RuntimeException(e); - } + Element actual = new Element("library"); + JpsLibraryTableSerializer.saveLibrary(library, actual, libName); + JpsMacroExpander + macroExpander = JpsProjectLoader.createProjectMacroExpander(Collections.emptyMap(), getFileInSampleProject("")); + Element rootElement = JpsLoaderBase.loadRootElement(libFile, macroExpander); + Element expected = rootElement.getChild("library"); + PlatformTestUtil.assertElementsEqual(expected, actual); } private void doTestSaveModule(JpsModule module, final String moduleFilePath) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/LibraryDependentToolWindowManager.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/LibraryDependentToolWindowManager.java index 86a5dfdeb1d8..5083d4746fad 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/LibraryDependentToolWindowManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/LibraryDependentToolWindowManager.java @@ -33,8 +33,7 @@ import org.jetbrains.annotations.NotNull; public class LibraryDependentToolWindowManager extends AbstractProjectComponent { private final ToolWindowManagerEx myToolWindowManager; - protected LibraryDependentToolWindowManager(Project project, - ToolWindowManagerEx toolWindowManager) { + protected LibraryDependentToolWindowManager(Project project, ToolWindowManagerEx toolWindowManager) { super(project); myToolWindowManager = toolWindowManager; } @@ -42,6 +41,7 @@ public class LibraryDependentToolWindowManager extends AbstractProjectComponent @Override public void projectOpened() { final ModuleRootListener rootListener = new ModuleRootListener() { + @Override public void rootsChanged(ModuleRootEvent event) { if (!myProject.isDisposed()) { checkToolWindowStatuses(myProject); @@ -62,6 +62,7 @@ public class LibraryDependentToolWindowManager extends AbstractProjectComponent assert !project.isDisposed(); DumbService.getInstance(project).smartInvokeLater(new Runnable() { + @Override public void run() { for (LibraryDependentToolWindow libraryToolWindow : Extensions.getExtensions(LibraryDependentToolWindow.EXTENSION_POINT_NAME)) { boolean exists; diff --git a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java index 7bf77251cb49..820a3da099ea 100644 --- a/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java +++ b/platform/testFramework/src/com/intellij/testFramework/PlatformTestUtil.java @@ -132,12 +132,7 @@ public class PlatformTestUtil { public static void registerExtension(@NotNull ExtensionsArea area, @NotNull ExtensionPointName name, @NotNull final T t, @NotNull Disposable parentDisposable) { final ExtensionPoint extensionPoint = area.getExtensionPoint(name.getName()); extensionPoint.registerExtension(t); - Disposer.register(parentDisposable, new Disposable() { - @Override - public void dispose() { - extensionPoint.unregisterExtension(t); - } - }); + Disposer.register(parentDisposable, () -> extensionPoint.unregisterExtension(t)); } @Nullable @@ -334,6 +329,7 @@ public class PlatformTestUtil { @TestOnly public static AWTEvent dispatchNextEventIfAny(@NotNull IdeEventQueue eventQueue) throws InterruptedException { + assert SwingUtilities.isEventDispatchThread() : Thread.currentThread(); AWTEvent event = eventQueue.peekEvent(); if (event == null) return null; AWTEvent event1 = eventQueue.getNextEvent(); @@ -824,21 +820,13 @@ public class PlatformTestUtil { final File tempDirectory1; final File tempDirectory2; - final JarFile jarFile1 = new JarFile(file1); - try { - final JarFile jarFile2 = new JarFile(file2); - try { + try (JarFile jarFile1 = new JarFile(file1)) { + try (JarFile jarFile2 = new JarFile(file2)) { tempDirectory1 = PlatformTestCase.createTempDir("tmp1"); tempDirectory2 = PlatformTestCase.createTempDir("tmp2"); ZipUtil.extract(jarFile1, tempDirectory1, null); ZipUtil.extract(jarFile2, tempDirectory2, null); } - finally { - jarFile2.close(); - } - } - finally { - jarFile1.close(); } final VirtualFile dirAfter = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDirectory1); @@ -852,7 +840,7 @@ public class PlatformTestUtil { assertDirectoriesEqual(dirAfter, dirBefore); } - public static void assertElementsEqual(final Element expected, final Element actual) throws IOException { + public static void assertElementsEqual(final Element expected, final Element actual) { if (!JDOMUtil.areElementsEqual(expected, actual)) { Assert.assertEquals(JDOMUtil.writeElement(expected), JDOMUtil.writeElement(actual)); } @@ -937,7 +925,7 @@ public class PlatformTestUtil { @SuppressWarnings("IOResourceOpenedButNotSafelyClosed") private static final OutputStream NULL = new OutputStream() { @Override - public void write(int b) throws IOException { } + public void write(int b) { } }; public static void assertSuccessful(@NotNull GeneralCommandLine command) {