From ee482f14f7d774545542ab189b43f48d378f291d Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Fri, 2 Dec 2016 13:25:50 +0100 Subject: [PATCH] =?UTF-8?q?cleanup=20=E2=80=94=20use=20jdk=20Consumer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compiler/BaseCompilerTestCase.java | 49 +++++++++---------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/java/compiler/impl/testSrc/com/intellij/compiler/BaseCompilerTestCase.java b/java/compiler/impl/testSrc/com/intellij/compiler/BaseCompilerTestCase.java index 19c85de12c30..0609009dbf81 100644 --- a/java/compiler/impl/testSrc/com/intellij/compiler/BaseCompilerTestCase.java +++ b/java/compiler/impl/testSrc/com/intellij/compiler/BaseCompilerTestCase.java @@ -39,7 +39,6 @@ import com.intellij.packaging.artifacts.Artifact; import com.intellij.packaging.artifacts.ArtifactManager; import com.intellij.packaging.impl.compiler.ArtifactCompileScope; import com.intellij.testFramework.*; -import com.intellij.util.ParameterizedRunnable; import com.intellij.util.concurrency.Semaphore; import com.intellij.util.io.TestFileSystemBuilder; import com.intellij.util.ui.UIUtil; @@ -53,6 +52,7 @@ import javax.swing.*; import java.io.File; import java.io.IOException; import java.util.*; +import java.util.function.Consumer; /** * @author nik @@ -228,7 +228,7 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase { return compile(false, compileStatusNotification -> getCompilerManager().rebuild(compileStatusNotification)); } - protected CompilationLog compile(final boolean errorsExpected, final ParameterizedRunnable action) { + protected CompilationLog compile(final boolean errorsExpected, final Consumer action) { CompilationLog log = compile(action); if (errorsExpected && log.myErrors.length == 0) { Assert.fail("compilation finished without errors"); @@ -239,7 +239,7 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase { return log; } - private CompilationLog compile(final ParameterizedRunnable action) { + private CompilationLog compile(final Consumer action) { final Ref result = Ref.create(null); final Semaphore semaphore = new Semaphore(); semaphore.down(); @@ -250,32 +250,29 @@ public abstract class BaseCompilerTestCase extends ModuleTestCase { generatedFilePaths.add(relativePath); } }, getTestRootDisposable()); - UIUtil.invokeAndWaitIfNeeded(new Runnable() { - @Override - public void run() { + UIUtil.invokeAndWaitIfNeeded((Runnable)() -> { - final CompileStatusNotification callback = new CompileStatusNotification() { - @Override - public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) { - try { - if (aborted) { - Assert.fail("compilation aborted"); - } - ExitStatus status = CompileDriver.getExternalBuildExitStatus(compileContext); - result.set(new CompilationLog(status == ExitStatus.UP_TO_DATE, - generatedFilePaths, - compileContext.getMessages(CompilerMessageCategory.ERROR), - compileContext.getMessages(CompilerMessageCategory.WARNING))); - } - finally { - semaphore.up(); + final CompileStatusNotification callback = new CompileStatusNotification() { + @Override + public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) { + try { + if (aborted) { + Assert.fail("compilation aborted"); } + ExitStatus status = CompileDriver.getExternalBuildExitStatus(compileContext); + result.set(new CompilationLog(status == ExitStatus.UP_TO_DATE, + generatedFilePaths, + compileContext.getMessages(CompilerMessageCategory.ERROR), + compileContext.getMessages(CompilerMessageCategory.WARNING))); } - }; - PlatformTestUtil.saveProject(myProject); - CompilerTestUtil.saveApplicationSettings(); - action.run(callback); - } + finally { + semaphore.up(); + } + } + }; + PlatformTestUtil.saveProject(myProject); + CompilerTestUtil.saveApplicationSettings(); + action.accept(callback); }); final long start = System.currentTimeMillis();