diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/ArgumentCompletionContributorTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/ArgumentCompletionContributorTest.java index 7b1ff97ecc9..eb2a2409ff8 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/ArgumentCompletionContributorTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/ArgumentCompletionContributorTest.java @@ -20,9 +20,10 @@ import com.google.idea.blaze.base.lang.buildfile.BuildFileIntegrationTestCase; import com.google.idea.blaze.base.lang.buildfile.psi.BuildFile; import com.google.idea.blaze.base.model.primitives.WorkspacePath; +import com.google.idea.sdkcompat.testframework.fixtures.CompletionAutoPopupTesterAdapter; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.openapi.editor.Editor; -import com.intellij.testFramework.fixtures.CompletionAutoPopupTester; +import com.intellij.util.ThrowableRunnable; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,11 +33,11 @@ @RunWith(JUnit4.class) public class ArgumentCompletionContributorTest extends BuildFileIntegrationTestCase { - private CompletionAutoPopupTester completionTester; + private CompletionAutoPopupTesterAdapter completionTester; @Before public final void before() { - completionTester = new CompletionAutoPopupTester(testFixture); + completionTester = new CompletionAutoPopupTesterAdapter(testFixture); } /** Completion UI testing can't be run on the EDT. */ @@ -47,64 +48,72 @@ protected boolean runTestsOnEdt() { @Test public void testIncompleteFuncall() throws Throwable { + // #api202: remove redundant cast "(ThrowableRunnable)" completionTester.runWithAutoPopupEnabled( - () -> { - BuildFile file = - createBuildFile( - new WorkspacePath("BUILD"), - "def function(name, deps, srcs):", - " # empty function", - "function(de"); - - Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); - editorTest.setCaretPosition(editor, 2, "function(de".length()); - - completionTester.typeWithPauses("p"); - LookupElement[] completionItems = testFixture.completeBasic(); - assertThat(completionItems).isNull(); - - assertFileContents( - file, "def function(name, deps, srcs):", " # empty function", "function(deps"); - }); + (ThrowableRunnable) + () -> { + BuildFile file = + createBuildFile( + new WorkspacePath("BUILD"), + "def function(name, deps, srcs):", + " # empty function", + "function(de"); + + Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); + editorTest.setCaretPosition(editor, 2, "function(de".length()); + + completionTester.typeWithPauses("p"); + LookupElement[] completionItems = testFixture.completeBasic(); + assertThat(completionItems).isNull(); + + assertFileContents( + file, "def function(name, deps, srcs):", " # empty function", "function(deps"); + }); } @Test public void testExistingKeywordArg() throws Throwable { + // #api202: remove redundant cast "(ThrowableRunnable)" completionTester.runWithAutoPopupEnabled( - () -> { - BuildFile file = - createBuildFile( - new WorkspacePath("BUILD"), - "def function(name, deps, srcs):", - " # empty function", - "function(name = \"lib\")"); - - Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); - editorTest.setCaretPosition(editor, 2, "function(".length()); - - completionTester.joinAutopopup(); - completionTester.joinCompletion(); - String[] completionItems = editorTest.getCompletionItemsAsStrings(); - assertThat(completionItems).asList().containsAllOf("name", "deps", "srcs", "function"); - }); + (ThrowableRunnable) + () -> { + BuildFile file = + createBuildFile( + new WorkspacePath("BUILD"), + "def function(name, deps, srcs):", + " # empty function", + "function(name = \"lib\")"); + + Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); + editorTest.setCaretPosition(editor, 2, "function(".length()); + + completionTester.joinAutopopup(); + completionTester.joinCompletion(); + String[] completionItems = editorTest.getCompletionItemsAsStrings(); + assertThat(completionItems) + .asList() + .containsAllOf("name", "deps", "srcs", "function"); + }); } @Test public void testNoArgumentCompletionInComment() throws Throwable { + // #api202: remove redundant cast "(ThrowableRunnable)" completionTester.runWithAutoPopupEnabled( - () -> { - BuildFile file = - createBuildFile( - new WorkspacePath("BUILD"), - "def function(name, deps, srcs):", - " # empty function", - "function(#"); - - Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); - editorTest.setCaretPosition(editor, 2, "function(#".length()); - - completionTester.typeWithPauses("n"); - assertThat(testFixture.getLookup()).isNull(); - }); + (ThrowableRunnable) + () -> { + BuildFile file = + createBuildFile( + new WorkspacePath("BUILD"), + "def function(name, deps, srcs):", + " # empty function", + "function(#"); + + Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); + editorTest.setCaretPosition(editor, 2, "function(#".length()); + + completionTester.typeWithPauses("n"); + assertThat(testFixture.getLookup()).isNull(); + }); } } diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuildFileAutoCompletionTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuildFileAutoCompletionTest.java index c578d0a6bcc..6413d9e5a2e 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuildFileAutoCompletionTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuildFileAutoCompletionTest.java @@ -21,10 +21,11 @@ import com.google.idea.blaze.base.lang.buildfile.BuildFileIntegrationTestCase; import com.google.idea.blaze.base.lang.buildfile.psi.BuildFile; import com.google.idea.blaze.base.model.primitives.WorkspacePath; +import com.google.idea.sdkcompat.testframework.fixtures.CompletionAutoPopupTesterAdapter; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.impl.LookupImpl; import com.intellij.openapi.editor.Editor; -import com.intellij.testFramework.fixtures.CompletionAutoPopupTester; +import com.intellij.util.ThrowableRunnable; import java.util.List; import java.util.stream.Collectors; import org.junit.Before; @@ -36,11 +37,11 @@ @RunWith(JUnit4.class) public class BuildFileAutoCompletionTest extends BuildFileIntegrationTestCase { - private CompletionAutoPopupTester completionTester; + private CompletionAutoPopupTesterAdapter completionTester; @Before public final void before() { - completionTester = new CompletionAutoPopupTester(testFixture); + completionTester = new CompletionAutoPopupTesterAdapter(testFixture); } /** Completion UI testing can't be run on the EDT. */ @@ -50,23 +51,25 @@ protected boolean runTestsOnEdt() { } @Test - public void testNoPopupAfterNumber() { + public void testNoPopupAfterNumber() throws Throwable { + // #api202: remove redundant cast "(ThrowableRunnable)" completionTester.runWithAutoPopupEnabled( - () -> { - createBuildFile(new WorkspacePath("java/com/foo/BUILD")); - BuildFile file = - createBuildFile( - new WorkspacePath("BUILD"), - "java_library(", - " name = 'lib',", - " testonly = "); + (ThrowableRunnable) + () -> { + createBuildFile(new WorkspacePath("java/com/foo/BUILD")); + BuildFile file = + createBuildFile( + new WorkspacePath("BUILD"), + "java_library(", + " name = 'lib',", + " testonly = "); - Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); - editorTest.setCaretPosition(editor, 2, " testonly = ".length()); + Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); + editorTest.setCaretPosition(editor, 2, " testonly = ".length()); - completionTester.typeWithPauses("1"); - assertThat(currentLookupStrings()).isEmpty(); - }); + completionTester.typeWithPauses("1"); + assertThat(currentLookupStrings()).isEmpty(); + }); } private List currentLookupStrings() { @@ -74,9 +77,7 @@ private List currentLookupStrings() { if (lookup == null) { return ImmutableList.of(); } - return lookup - .getItems() - .stream() + return lookup.getItems().stream() .map(LookupElement::getLookupString) .collect(Collectors.toList()); } diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuildLabelAutoCompletionTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuildLabelAutoCompletionTest.java index bfeb7aaa857..c14e8c9db4f 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuildLabelAutoCompletionTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuildLabelAutoCompletionTest.java @@ -21,10 +21,11 @@ import com.google.idea.blaze.base.lang.buildfile.BuildFileIntegrationTestCase; import com.google.idea.blaze.base.lang.buildfile.psi.BuildFile; import com.google.idea.blaze.base.model.primitives.WorkspacePath; +import com.google.idea.sdkcompat.testframework.fixtures.CompletionAutoPopupTesterAdapter; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.impl.LookupImpl; import com.intellij.openapi.editor.Editor; -import com.intellij.testFramework.fixtures.CompletionAutoPopupTester; +import com.intellij.util.ThrowableRunnable; import java.util.List; import java.util.stream.Collectors; import org.junit.Before; @@ -36,11 +37,11 @@ @RunWith(JUnit4.class) public class BuildLabelAutoCompletionTest extends BuildFileIntegrationTestCase { - private CompletionAutoPopupTester completionTester; + private CompletionAutoPopupTesterAdapter completionTester; @Before public final void before() { - completionTester = new CompletionAutoPopupTester(testFixture); + completionTester = new CompletionAutoPopupTesterAdapter(testFixture); } /** Completion UI testing can't be run on the EDT. */ @@ -50,64 +51,71 @@ protected boolean runTestsOnEdt() { } @Test - public void testPopupAutocompleteAfterSlash() { + public void testPopupAutocompleteAfterSlash() throws Throwable { + // #api202: remove redundant cast "(ThrowableRunnable)" completionTester.runWithAutoPopupEnabled( - () -> { - createBuildFile(new WorkspacePath("java/com/foo/BUILD")); - BuildFile file = - createBuildFile( - new WorkspacePath("BUILD"), - "java_library(", - " name = 'lib',", - " srcs = [''],"); - - Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); - editorTest.setCaretPosition(editor, 2, " srcs = ['".length()); - - completionTester.typeWithPauses("/"); - assertThat(currentLookupStrings()).containsExactly("'//java/com/foo'"); - }); + (ThrowableRunnable) + () -> { + createBuildFile(new WorkspacePath("java/com/foo/BUILD")); + BuildFile file = + createBuildFile( + new WorkspacePath("BUILD"), + "java_library(", + " name = 'lib',", + " srcs = [''],"); + + Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); + editorTest.setCaretPosition(editor, 2, " srcs = ['".length()); + + completionTester.typeWithPauses("/"); + assertThat(currentLookupStrings()).containsExactly("'//java/com/foo'"); + }); } @Test - public void testPopupAutocompleteAfterColon() { + public void testPopupAutocompleteAfterColon() throws Throwable { + // #api202: remove redundant cast "(ThrowableRunnable)" completionTester.runWithAutoPopupEnabled( - () -> { - createBuildFile(new WorkspacePath("java/com/foo/BUILD"), "java_library(name = 'target')"); - BuildFile file = + (ThrowableRunnable) + () -> { createBuildFile( - new WorkspacePath("BUILD"), - "java_library(", - " name = 'lib',", - " srcs = ['//java/com/foo'],"); - - Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); - editorTest.setCaretPosition(editor, 2, " srcs = ['//java/com/foo".length()); - - completionTester.typeWithPauses(":"); - assertThat(currentLookupStrings()).containsExactly("'//java/com/foo:target'"); - }); + new WorkspacePath("java/com/foo/BUILD"), "java_library(name = 'target')"); + BuildFile file = + createBuildFile( + new WorkspacePath("BUILD"), + "java_library(", + " name = 'lib',", + " srcs = ['//java/com/foo'],"); + + Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); + editorTest.setCaretPosition(editor, 2, " srcs = ['//java/com/foo".length()); + + completionTester.typeWithPauses(":"); + assertThat(currentLookupStrings()).containsExactly("'//java/com/foo:target'"); + }); } @Test - public void testPopupAutocompleteAfterLetter() { - // test for IntelliJ's standard autocomplete popup trigger + public void testPopupAutocompleteAfterLetter() throws Throwable { + // #api202: remove redundant cast "(ThrowableRunnable)" completionTester.runWithAutoPopupEnabled( - () -> { - createBuildFile(new WorkspacePath("java/com/foo/BUILD"), "java_library(name = 'target')"); - BuildFile file = + (ThrowableRunnable) + () -> { createBuildFile( - new WorkspacePath("BUILD"), - "java_library(", - " name = 'lib',", - " srcs = ['//'],"); - - Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); - editorTest.setCaretPosition(editor, 2, " srcs = ['//".length()); - - completionTester.typeWithPauses("j"); - assertThat(currentLookupStrings()).containsExactly("'//java/com/foo'"); - }); + new WorkspacePath("java/com/foo/BUILD"), "java_library(name = 'target')"); + BuildFile file = + createBuildFile( + new WorkspacePath("BUILD"), + "java_library(", + " name = 'lib',", + " srcs = ['//'],"); + + Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); + editorTest.setCaretPosition(editor, 2, " srcs = ['//".length()); + + completionTester.typeWithPauses("j"); + assertThat(currentLookupStrings()).containsExactly("'//java/com/foo'"); + }); } private List currentLookupStrings() { @@ -115,9 +123,7 @@ private List currentLookupStrings() { if (lookup == null) { return ImmutableList.of(); } - return lookup - .getItems() - .stream() + return lookup.getItems().stream() .map(LookupElement::getLookupString) .collect(Collectors.toList()); } diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuiltInFunctionAttributeCompletionContributorTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuiltInFunctionAttributeCompletionContributorTest.java index 14fc5cef81c..44d0fc4b517 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuiltInFunctionAttributeCompletionContributorTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuiltInFunctionAttributeCompletionContributorTest.java @@ -50,7 +50,7 @@ public final void before() { } @Test - public void testSimpleCompletion() { + public void testSimpleCompletion() throws Throwable { setRuleAndAttributes("sh_binary", "name", "deps", "srcs", "data"); BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "sh_binary("); @@ -63,7 +63,7 @@ public void testSimpleCompletion() { } @Test - public void testSimpleSingleCompletion() { + public void testSimpleSingleCompletion() throws Throwable { setRuleAndAttributes("sh_binary", "name", "deps", "srcs", "data"); BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "sh_binary(", " nam"); @@ -77,7 +77,7 @@ public void testSimpleSingleCompletion() { } @Test - public void testNoCompletionInUnknownRule() { + public void testNoCompletionInUnknownRule() throws Throwable { ServiceHelper.unregisterLanguageExtensionPoint( "com.intellij.completion.contributor", BuiltInSymbolCompletionContributor.class, @@ -99,7 +99,7 @@ public void testNoCompletionInUnknownRule() { } @Test - public void testNoCompletionInComment() { + public void testNoCompletionInComment() throws Throwable { setRuleAndAttributes("sh_binary", "name", "deps", "srcs", "data"); BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "sh_binary(#"); @@ -110,7 +110,7 @@ public void testNoCompletionInComment() { } @Test - public void testNoCompletionAfterInteger() { + public void testNoCompletionAfterInteger() throws Throwable { setRuleAndAttributes("sh_binary", "name", "deps", "srcs", "data"); BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "sh_binary(testonly = 1,"); @@ -121,7 +121,7 @@ public void testNoCompletionAfterInteger() { } @Test - public void testDoNotShowExistingAttributesInAutocompleteSuggestions() { + public void testDoNotShowExistingAttributesInAutocompleteSuggestions() throws Throwable { setRuleAndAttributes("sh_binary", "name", "deps", "srcs", "data"); BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "sh_binary(name = 'bin', )"); @@ -135,7 +135,7 @@ public void testDoNotShowExistingAttributesInAutocompleteSuggestions() { } @Test - public void testCompletionAtEndOfElement() { + public void testCompletionAtEndOfElement() throws Throwable { setRuleAndAttributes("sh_binary", "name", "deps", "srcs", "data"); BuildFile file = @@ -158,7 +158,7 @@ public void testCompletionAtEndOfElement() { } @Test - public void testCompletionInSkylarkExtension() { + public void testCompletionInSkylarkExtension() throws Throwable { setRuleAndAttributes("sh_binary", "name", "deps", "srcs", "data"); BuildFile file = createBuildFile(new WorkspacePath("skylark.bzl"), "native.sh_binary("); diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuiltInFunctionCompletionContributorTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuiltInFunctionCompletionContributorTest.java index 2770246cce9..6e757cd4249 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuiltInFunctionCompletionContributorTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuiltInFunctionCompletionContributorTest.java @@ -50,7 +50,7 @@ public final void before() { } @Test - public void testSimpleTopLevelCompletion() { + public void testSimpleTopLevelCompletion() throws Throwable { setRules("rule_one", "rule_two"); BuildFile file = createBuildFile(new WorkspacePath("BUILD"), ""); @@ -64,7 +64,7 @@ public void testSimpleTopLevelCompletion() { } @Test - public void testUniqueTopLevelCompletion() { + public void testUniqueTopLevelCompletion() throws Throwable { setRules("rule_one", "rule_two"); BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "rule_o"); @@ -77,7 +77,7 @@ public void testUniqueTopLevelCompletion() { } @Test - public void testSkylarkNativeCompletion() { + public void testSkylarkNativeCompletion() throws Throwable { setRules("rule_one", "rule_two"); BuildFile file = @@ -94,7 +94,7 @@ public void testSkylarkNativeCompletion() { } @Test - public void testNoCompletionInsideRule() { + public void testNoCompletionInsideRule() throws Throwable { ServiceHelper.unregisterLanguageExtensionPoint( "com.intellij.completion.contributor", BuiltInSymbolCompletionContributor.class, @@ -115,7 +115,7 @@ public void testNoCompletionInsideRule() { } @Test - public void testNoCompletionInComment() { + public void testNoCompletionInComment() throws Throwable { setRules("rule_one", "rule_two"); BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "#rule"); @@ -127,7 +127,7 @@ public void testNoCompletionInComment() { } @Test - public void testNoCompletionAfterInteger() { + public void testNoCompletionAfterInteger() throws Throwable { setRules("rule_one", "rule_two"); BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "1"); @@ -139,7 +139,7 @@ public void testNoCompletionAfterInteger() { } @Test - public void testGlobalFunctions() { + public void testGlobalFunctions() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "licen"); Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuiltInSymbolCompletionContributorTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuiltInSymbolCompletionContributorTest.java index 20155ba1d32..497be5ecbfd 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuiltInSymbolCompletionContributorTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/BuiltInSymbolCompletionContributorTest.java @@ -49,7 +49,7 @@ public BuildLanguageSpec getLanguageSpec(Project project) { } @Test - public void testSimpleTopLevelCompletion() { + public void testSimpleTopLevelCompletion() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), ""); Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); @@ -61,7 +61,7 @@ public void testSimpleTopLevelCompletion() { } @Test - public void testUniqueTopLevelCompletion() { + public void testUniqueTopLevelCompletion() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "PACKAGE_N"); Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); @@ -75,7 +75,7 @@ public void testUniqueTopLevelCompletion() { } @Test - public void testNoCompletionInComment() { + public void testNoCompletionInComment() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "#PACK"); Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); @@ -85,7 +85,7 @@ public void testNoCompletionInComment() { } @Test - public void testNoCompletionAfterInteger() { + public void testNoCompletionAfterInteger() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "123"); Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); @@ -95,7 +95,7 @@ public void testNoCompletionAfterInteger() { } @Test - public void testNoCompletionInFuncall() { + public void testNoCompletionInFuncall() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "java_library()"); Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/CommonMacroCompletionContributorTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/CommonMacroCompletionContributorTest.java index ab5089f7258..23a22fdc3ed 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/CommonMacroCompletionContributorTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/CommonMacroCompletionContributorTest.java @@ -49,14 +49,14 @@ public final void after() { macros.clear(); } - private String[] getCompletionItems(BuildFile file, int line, int column) { + private String[] getCompletionItems(BuildFile file, int line, int column) throws Throwable { Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); editorTest.setCaretPosition(editor, line, column); return editorTest.getCompletionItemsAsStrings(); } @Test - public void completionResults_trivialExample_containsMacro() { + public void completionResults_trivialExample_containsMacro() throws Throwable { macros.add( CommonMacros.builder() .setLocation("//foo/bar.bzl") @@ -68,7 +68,7 @@ public void completionResults_trivialExample_containsMacro() { } @Test - public void completionResults_ignoreExistingSymbols() { + public void completionResults_ignoreExistingSymbols() throws Throwable { macros.add( CommonMacros.builder() .setLocation("//foo/bar.bzl") diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/FilePathCompletionTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/FilePathCompletionTest.java index e4ca57d32b3..fef488b4073 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/FilePathCompletionTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/FilePathCompletionTest.java @@ -32,7 +32,7 @@ public class FilePathCompletionTest extends BuildFileIntegrationTestCase { @Test - public void testUniqueDirectoryCompleted() { + public void testUniqueDirectoryCompleted() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("java/BUILD"), "'//'"); Editor editor = editorTest.openFileInEditor(file); @@ -45,7 +45,7 @@ public void testUniqueDirectoryCompleted() { } @Test - public void testInsertPairQuoteOptionRespected() { + public void testInsertPairQuoteOptionRespected() throws Throwable { boolean old = CodeInsightSettings.getInstance().AUTOINSERT_PAIR_QUOTE; try { CodeInsightSettings.getInstance().AUTOINSERT_PAIR_QUOTE = false; @@ -69,7 +69,7 @@ public void testInsertPairQuoteOptionRespected() { } @Test - public void testUniqueMultiSegmentDirectoryCompleted() { + public void testUniqueMultiSegmentDirectoryCompleted() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "'//'"); Editor editor = editorTest.openFileInEditor(file); @@ -80,7 +80,7 @@ public void testUniqueMultiSegmentDirectoryCompleted() { } @Test - public void testStopDirectoryTraversalAtBuildPackage() { + public void testStopDirectoryTraversalAtBuildPackage() throws Throwable { workspace.createFile(new WorkspacePath("foo/bar/BUILD")); workspace.createFile(new WorkspacePath("foo/bar/baz/BUILD")); @@ -96,7 +96,7 @@ public void testStopDirectoryTraversalAtBuildPackage() { // get the possibilities, then start typing // next segment and complete again @Test - public void testMultiStageCompletion() { + public void testMultiStageCompletion() throws Throwable { workspace.createDirectory(new WorkspacePath("foo")); workspace.createDirectory(new WorkspacePath("bar")); workspace.createDirectory(new WorkspacePath("other")); diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/ParameterCompletionContributorTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/ParameterCompletionContributorTest.java index 6b8e85c81df..21ae9ca24cd 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/ParameterCompletionContributorTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/ParameterCompletionContributorTest.java @@ -31,7 +31,7 @@ public class ParameterCompletionContributorTest extends BuildFileIntegrationTestCase { @Test - public void testArgsCompletion() { + public void testArgsCompletion() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "def function(arg1, *"); Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); @@ -44,7 +44,7 @@ public void testArgsCompletion() { } @Test - public void testKwargsCompletion() { + public void testKwargsCompletion() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "def function(arg1, **"); Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/RuleTargetCompletionTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/RuleTargetCompletionTest.java index ce2388b3f2b..dc0851906ac 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/RuleTargetCompletionTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/completion/RuleTargetCompletionTest.java @@ -37,7 +37,7 @@ public class RuleTargetCompletionTest extends BuildFileIntegrationTestCase { @Test - public void testLocalTarget() { + public void testLocalTarget() throws Throwable { BuildFile file = createBuildFile( new WorkspacePath("java/com/google/BUILD"), @@ -55,7 +55,7 @@ public void testLocalTarget() { } @Test - public void testCustomRuleCompletion() { + public void testCustomRuleCompletion() throws Throwable { MockBuildLanguageSpecProvider specProvider = new MockBuildLanguageSpecProvider(); setBuildLanguageSpecRules(specProvider, "java_library"); registerApplicationService(BuildLanguageSpecProvider.class, specProvider); @@ -77,7 +77,7 @@ public void testCustomRuleCompletion() { } @Test - public void testIgnoreContainingTarget() { + public void testIgnoreContainingTarget() throws Throwable { BuildFile file = createBuildFile( new WorkspacePath("java/com/google/BUILD"), @@ -93,7 +93,7 @@ public void testIgnoreContainingTarget() { } @Test - public void testNotCodeCompletionInNameField() { + public void testNotCodeCompletionInNameField() throws Throwable { BuildFile file = createBuildFile( new WorkspacePath("java/com/google/BUILD"), @@ -110,7 +110,7 @@ public void testNotCodeCompletionInNameField() { } @Test - public void testNonLocalTarget() { + public void testNonLocalTarget() throws Throwable { createBuildFile( new WorkspacePath("java/com/google/foo/BUILD"), "java_library(name = 'foo_lib')"); @@ -129,7 +129,7 @@ public void testNonLocalTarget() { } @Test - public void testNonLocalRulesNotCompletedWithoutColon() { + public void testNonLocalRulesNotCompletedWithoutColon() throws Throwable { createBuildFile( new WorkspacePath("java/com/google/foo/BUILD"), "java_library(name = 'foo_lib')"); @@ -148,7 +148,7 @@ public void testNonLocalRulesNotCompletedWithoutColon() { } @Test - public void testPackageLocalRulesCompletedWithoutColon() { + public void testPackageLocalRulesCompletedWithoutColon() throws Throwable { BuildFile file = createBuildFile( new WorkspacePath("java/com/google/BUILD"), @@ -170,7 +170,7 @@ public void testPackageLocalRulesCompletedWithoutColon() { } @Test - public void testLocalPathIgnoredForNonLocalLabels() { + public void testLocalPathIgnoredForNonLocalLabels() throws Throwable { createBuildFile(new WorkspacePath("java/BUILD"), "java_library(name = 'root_rule')"); BuildFile otherPackage = diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/editor/BuildQuoteHandlerTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/editor/BuildQuoteHandlerTest.java index 214d775afb0..91a64d41a63 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/editor/BuildQuoteHandlerTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/editor/BuildQuoteHandlerTest.java @@ -28,7 +28,7 @@ public class BuildQuoteHandlerTest extends BuildFileIntegrationTestCase { @Test - public void testClosingQuoteInserted() { + public void testClosingQuoteInserted() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), ""); editorTest.performTypingAction(file, '"'); @@ -36,7 +36,7 @@ public void testClosingQuoteInserted() { } @Test - public void testClosingSingleQuoteInserted() { + public void testClosingSingleQuoteInserted() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), ""); editorTest.performTypingAction(file, '\''); @@ -44,7 +44,7 @@ public void testClosingSingleQuoteInserted() { } @Test - public void testClosingTripleQuoteInserted() { + public void testClosingTripleQuoteInserted() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), ""); editorTest.performTypingAction(file, '"'); @@ -54,7 +54,7 @@ public void testClosingTripleQuoteInserted() { } @Test - public void testClosingTripleSingleQuoteInserted() { + public void testClosingTripleSingleQuoteInserted() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), ""); editorTest.performTypingAction(file, '\''); @@ -64,7 +64,7 @@ public void testClosingTripleSingleQuoteInserted() { } @Test - public void testOnlyCaretMovedWhenCompletingExistingClosingQuotes() { + public void testOnlyCaretMovedWhenCompletingExistingClosingQuotes() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "'text'", "laterContents"); testFixture.configureFromExistingVirtualFile(file.getVirtualFile()); @@ -75,7 +75,7 @@ public void testOnlyCaretMovedWhenCompletingExistingClosingQuotes() { } @Test - public void testOnlyCaretMovedWhenCompletingExistingClosingTripleQuotes() { + public void testOnlyCaretMovedWhenCompletingExistingClosingTripleQuotes() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "'''text'''", "laterContents"); @@ -95,7 +95,7 @@ public void testOnlyCaretMovedWhenCompletingExistingClosingTripleQuotes() { } @Test - public void testAdditionalTripleQuotesNotInsertedWhenClosingQuotes() { + public void testAdditionalTripleQuotesNotInsertedWhenClosingQuotes() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "'''text''", "laterContents"); @@ -107,7 +107,7 @@ public void testAdditionalTripleQuotesNotInsertedWhenClosingQuotes() { } @Test - public void testAdditionalQuoteNotInsertedWhenClosingQuotes() { + public void testAdditionalQuoteNotInsertedWhenClosingQuotes() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "'text", "laterContents"); testFixture.configureFromExistingVirtualFile(file.getVirtualFile()); diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/editor/EnterInLineCommentTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/editor/EnterInLineCommentTest.java index abb47d107b2..67f1990b506 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/editor/EnterInLineCommentTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/editor/EnterInLineCommentTest.java @@ -28,7 +28,7 @@ public class EnterInLineCommentTest extends BuildFileIntegrationTestCase { @Test - public void testInternalNewlineCommented() { + public void testInternalNewlineCommented() throws Throwable { BuildFile file = createBuildFile( new WorkspacePath("BUILD"), "# first line comment", "# second line comment"); @@ -41,7 +41,7 @@ public void testInternalNewlineCommented() { } @Test - public void testNewlineAtEndOfComment() { + public void testNewlineAtEndOfComment() throws Throwable { BuildFile file = createBuildFile( new WorkspacePath("BUILD"), "# first line comment", "# second line comment"); diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/formatting/BuildFileFoldingBuilderTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/formatting/BuildFileFoldingBuilderTest.java index 44726b95c74..6115c379f15 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/formatting/BuildFileFoldingBuilderTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/formatting/BuildFileFoldingBuilderTest.java @@ -33,7 +33,7 @@ public class BuildFileFoldingBuilderTest extends BuildFileIntegrationTestCase { @Test - public void testEndOfFileFunctionDelcaration() { + public void testEndOfFileFunctionDelcaration() throws Throwable { // bug 28618935: test no NPE in the case where there's no // statement list following the func-def colon BuildFile file = createBuildFile(new WorkspacePath("java/com/google/BUILD"), "def function():"); @@ -42,7 +42,7 @@ public void testEndOfFileFunctionDelcaration() { } @Test - public void testMultilineCommentFolded() { + public void testMultilineCommentFolded() throws Throwable { BuildFile file = createBuildFile( new WorkspacePath("java/com/google/BUILD"), @@ -61,7 +61,7 @@ public void testMultilineCommentFolded() { } @Test - public void testMultilineCommentIncludingBlankLinesIsFolded() { + public void testMultilineCommentIncludingBlankLinesIsFolded() throws Throwable { BuildFile file = createBuildFile( new WorkspacePath("java/com/google/BUILD"), @@ -75,7 +75,7 @@ public void testMultilineCommentIncludingBlankLinesIsFolded() { } @Test - public void testMultilineStringFoldedToFirstLine() { + public void testMultilineStringFoldedToFirstLine() throws Throwable { BuildFile file = createBuildFile( new WorkspacePath("java/com/google/BUILD"), @@ -89,7 +89,7 @@ public void testMultilineStringFoldedToFirstLine() { } @Test - public void testFuncDefStatementsFolded() { + public void testFuncDefStatementsFolded() throws Throwable { BuildFile file = createBuildFile( new WorkspacePath("java/com/google/BUILD"), @@ -108,7 +108,7 @@ public void testFuncDefStatementsFolded() { } @Test - public void testRulesFolded() { + public void testRulesFolded() throws Throwable { BuildFile file = createBuildFile( new WorkspacePath("java/com/google/BUILD"), @@ -123,7 +123,7 @@ public void testRulesFolded() { } @Test - public void testLoadStatementFolded() { + public void testLoadStatementFolded() throws Throwable { BuildFile file = createBuildFile( new WorkspacePath("java/com/google/BUILD"), @@ -139,7 +139,7 @@ public void testLoadStatementFolded() { .isEqualTo(file.findChildByClass(LoadStatement.class)); } - private FoldingDescriptor[] getFoldingRegions(BuildFile file) { + private FoldingDescriptor[] getFoldingRegions(BuildFile file) throws Throwable { Editor editor = editorTest.openFileInEditor(file.getVirtualFile()); return new BuildFileFoldingBuilder().buildFoldRegions(file.getNode(), editor.getDocument()); } diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/highlighting/HighlightingAnnotatorTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/highlighting/HighlightingAnnotatorTest.java index 4a38fdf897b..fb0ba970d20 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/highlighting/HighlightingAnnotatorTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/highlighting/HighlightingAnnotatorTest.java @@ -33,7 +33,7 @@ public class HighlightingAnnotatorTest extends BuildFileIntegrationTestCase { @Test - public void testBuiltInNamesSimple() { + public void testBuiltInNamesSimple() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "None"); ReferenceExpression ref = file.findChildByClass(ReferenceExpression.class); @@ -48,7 +48,7 @@ public void testBuiltInNamesSimple() { } @Test - public void testBuiltInNames() { + public void testBuiltInNames() throws Throwable { BuildFile file = createBuildFile(new WorkspacePath("BUILD"), "a = True", "b = False", "type(a)"); diff --git a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/references/LabelReferenceTest.java b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/references/LabelReferenceTest.java index 0db5f0e3270..7a068b0772e 100644 --- a/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/references/LabelReferenceTest.java +++ b/base/tests/integrationtests/com/google/idea/blaze/base/lang/buildfile/references/LabelReferenceTest.java @@ -185,7 +185,7 @@ public void testRulePreferredOverFile() { } @Test - public void testNoTargetFoundFromNameAttributeLabel() { + public void testNoTargetFoundFromNameAttributeLabel() throws Throwable { // we want 'GoToDeclaration' to trigger 'find usages' from a name attribute, which won't happen // if it's pointing to a target element different from the 'find usages target' BuildFile file = diff --git a/base/tests/utils/integration/com/google/idea/blaze/base/BlazeIntegrationTestCase.java b/base/tests/utils/integration/com/google/idea/blaze/base/BlazeIntegrationTestCase.java index b0e9721d3b5..c8dc9a2be25 100644 --- a/base/tests/utils/integration/com/google/idea/blaze/base/BlazeIntegrationTestCase.java +++ b/base/tests/utils/integration/com/google/idea/blaze/base/BlazeIntegrationTestCase.java @@ -26,6 +26,7 @@ import com.google.idea.blaze.base.settings.BlazeImportSettingsManager; import com.google.idea.blaze.base.settings.BuildSystem; import com.google.idea.blaze.base.sync.SyncCache; +import com.google.idea.sdkcompat.testframework.EdtTestUtilWrapper; import com.google.idea.testing.EdtRule; import com.google.idea.testing.IntellijTestSetupRule; import com.google.idea.testing.ServiceHelper; @@ -40,7 +41,6 @@ import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.newvfs.RefreshQueue; import com.intellij.openapi.vfs.newvfs.RefreshSession; -import com.intellij.testFramework.EdtTestUtil; import com.intellij.testFramework.IdeaTestUtil; import com.intellij.testFramework.UsefulTestCase; import com.intellij.testFramework.fixtures.CodeInsightTestFixture; @@ -94,7 +94,7 @@ public void evaluate() throws Throwable { protected WorkspaceFileSystem workspace; @Before - public final void setUp() throws Exception { + public final void setUp() throws Throwable { testFixture = createTestFixture(); testFixture.setUp(); fileSystem = @@ -153,7 +153,7 @@ public BufferedInputStream forOutputArtifact(BlazeArtifact output) throws IOExce } @After - public final void tearDown() throws Exception { + public final void tearDown() throws Throwable { if (!isLightTestCase()) { // Workaround to avoid a platform race condition that occurs when we delete a VirtualDirectory // whose children were affected by external file system events that RefreshQueue is still @@ -176,8 +176,8 @@ public final void tearDown() throws Exception { testFixture = null; } - private static void runWriteAction(Runnable writeAction) { - EdtTestUtil.runInEdtAndWait( + private static void runWriteAction(Runnable writeAction) throws Throwable { + EdtTestUtilWrapper.runInEdtAndWait( () -> ApplicationManager.getApplication().runWriteAction(writeAction)); } diff --git a/base/tests/utils/integration/com/google/idea/blaze/base/EditorTestHelper.java b/base/tests/utils/integration/com/google/idea/blaze/base/EditorTestHelper.java index d286124484b..75bd0b78d40 100644 --- a/base/tests/utils/integration/com/google/idea/blaze/base/EditorTestHelper.java +++ b/base/tests/utils/integration/com/google/idea/blaze/base/EditorTestHelper.java @@ -18,6 +18,7 @@ import com.google.common.collect.ImmutableList; import com.google.idea.blaze.base.lang.buildfile.psi.StringLiteral; import com.google.idea.blaze.base.lang.buildfile.psi.util.PsiUtils; +import com.google.idea.sdkcompat.testframework.EdtTestUtilWrapper; import com.intellij.codeInsight.lookup.Lookup; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementPresentation; @@ -34,9 +35,7 @@ import com.intellij.testFramework.EditorTestUtil; import com.intellij.testFramework.EditorTestUtil.CaretAndSelectionState; import com.intellij.testFramework.EditorTestUtil.CaretInfo; -import com.intellij.testFramework.EdtTestUtil; import com.intellij.testFramework.fixtures.CodeInsightTestFixture; -import com.intellij.util.ThrowableRunnable; import java.util.Arrays; import javax.annotation.Nullable; @@ -50,13 +49,12 @@ public EditorTestHelper(Project project, CodeInsightTestFixture testFixture) { this.testFixture = testFixture; } - public Editor openFileInEditor(PsiFile file) { + public Editor openFileInEditor(PsiFile file) throws Throwable { return openFileInEditor(file.getVirtualFile()); } - public Editor openFileInEditor(VirtualFile file) { - EdtTestUtil.runInEdtAndWait( - (ThrowableRunnable) () -> testFixture.openFileInEditor(file)); + public Editor openFileInEditor(VirtualFile file) throws Throwable { + EdtTestUtilWrapper.runInEdtAndWait(() -> testFixture.openFileInEditor(file)); return testFixture.getEditor(); } @@ -103,7 +101,7 @@ public boolean completeIfUnique() { } /** Simulates a user typing action, at current caret position of file. */ - public void performTypingAction(PsiFile file, char typedChar) { + public void performTypingAction(PsiFile file, char typedChar) throws Throwable { performTypingAction(openFileInEditor(file.getVirtualFile()), typedChar); } @@ -124,13 +122,12 @@ public final void pressButton(final String action) { .executeCommand(project, () -> testFixture.performEditorAction(action), "", null); } - public void setCaretPosition(Editor editor, int lineNumber, int columnNumber) { + public void setCaretPosition(Editor editor, int lineNumber, int columnNumber) throws Throwable { final CaretInfo info = new CaretInfo(new LogicalPosition(lineNumber, columnNumber), null); - EdtTestUtil.runInEdtAndWait( - (ThrowableRunnable) - () -> - EditorTestUtil.setCaretsAndSelection( - editor, new CaretAndSelectionState(ImmutableList.of(info), null))); + EdtTestUtilWrapper.runInEdtAndWait( + () -> + EditorTestUtil.setCaretsAndSelection( + editor, new CaretAndSelectionState(ImmutableList.of(info), null))); } public void assertCaretPosition(Editor editor, int lineNumber, int columnNumber) { diff --git a/base/tests/utils/integration/com/google/idea/blaze/base/run/producer/BlazeRunConfigurationProducerTestCase.java b/base/tests/utils/integration/com/google/idea/blaze/base/run/producer/BlazeRunConfigurationProducerTestCase.java index 08ce5b76202..f3a80172ed1 100644 --- a/base/tests/utils/integration/com/google/idea/blaze/base/run/producer/BlazeRunConfigurationProducerTestCase.java +++ b/base/tests/utils/integration/com/google/idea/blaze/base/run/producer/BlazeRunConfigurationProducerTestCase.java @@ -76,7 +76,7 @@ public final void doTeardown() { IconManager.deactivate(); } - protected PsiFile createAndIndexFile(WorkspacePath path, String... contents) { + protected PsiFile createAndIndexFile(WorkspacePath path, String... contents) throws Throwable { PsiFile file = workspace.createPsiFile(path, contents); editorTest.openFileInEditor(file); // open file to trigger update of indices return file; diff --git a/golang/tests/integrationtests/com/google/idea/blaze/golang/run/producers/BlazeGoTestConfigurationProducerTest.java b/golang/tests/integrationtests/com/google/idea/blaze/golang/run/producers/BlazeGoTestConfigurationProducerTest.java index f25b170520c..1fd73d76302 100644 --- a/golang/tests/integrationtests/com/google/idea/blaze/golang/run/producers/BlazeGoTestConfigurationProducerTest.java +++ b/golang/tests/integrationtests/com/google/idea/blaze/golang/run/producers/BlazeGoTestConfigurationProducerTest.java @@ -50,7 +50,7 @@ public final void suppressNativeProducers() { } @Test - public void testProducedFromGoFile() { + public void testProducedFromGoFile() throws Throwable { PsiFile goFile = createAndIndexFile( new WorkspacePath("foo/bar/foo_test.go"), @@ -89,7 +89,7 @@ public void testProducedFromGoFile() { } @Test - public void testProducedFromTestCase() { + public void testProducedFromTestCase() throws Throwable { PsiFile goFile = createAndIndexFile( new WorkspacePath("foo/bar/foo_test.go"), diff --git a/golang/tests/integrationtests/com/google/idea/blaze/golang/run/producers/GoBinaryContextProviderTest.java b/golang/tests/integrationtests/com/google/idea/blaze/golang/run/producers/GoBinaryContextProviderTest.java index 7c7e1562d4a..2b02356dc5e 100644 --- a/golang/tests/integrationtests/com/google/idea/blaze/golang/run/producers/GoBinaryContextProviderTest.java +++ b/golang/tests/integrationtests/com/google/idea/blaze/golang/run/producers/GoBinaryContextProviderTest.java @@ -41,7 +41,7 @@ public class GoBinaryContextProviderTest extends BlazeRunConfigurationProducerTestCase { @Test - public void contextProducedFromBinaryGoFileIsBinaryTarget() { + public void contextProducedFromBinaryGoFileIsBinaryTarget() throws Throwable { PsiFile goFile = createAndIndexFile(new WorkspacePath("foo/bar/main.go"), "package main", "func main() {}"); @@ -75,7 +75,7 @@ public void contextProducedFromBinaryGoFileIsBinaryTarget() { } @Test - public void contextProducedFromLibraryGoFileIsBinaryTarget() { + public void contextProducedFromLibraryGoFileIsBinaryTarget() throws Throwable { PsiFile goFile = createAndIndexFile(new WorkspacePath("foo/bar/main.go"), "package main", "func main() {}"); diff --git a/java/tests/integrationtests/com/google/idea/blaze/java/lang/build/completion/JavaClassQualifiedNameCompletionTest.java b/java/tests/integrationtests/com/google/idea/blaze/java/lang/build/completion/JavaClassQualifiedNameCompletionTest.java index 62a826e85c0..726383879d4 100644 --- a/java/tests/integrationtests/com/google/idea/blaze/java/lang/build/completion/JavaClassQualifiedNameCompletionTest.java +++ b/java/tests/integrationtests/com/google/idea/blaze/java/lang/build/completion/JavaClassQualifiedNameCompletionTest.java @@ -32,7 +32,7 @@ public class JavaClassQualifiedNameCompletionTest extends BuildFileIntegrationTestCase { @Test - public void testCompleteClassName() { + public void testCompleteClassName() throws Throwable { workspace.createPsiFile( new WorkspacePath("java/com/google/bin/Main.java"), "package com.google.bin;", @@ -61,7 +61,7 @@ public void testCompleteClassName() { } @Test - public void testNoCompletionForOtherAttributes() { + public void testNoCompletionForOtherAttributes() throws Throwable { workspace.createPsiFile( new WorkspacePath("java/com/google/bin/Main.java"), "package com.google.bin;", diff --git a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaAbstractTestCaseConfigurationProducerTest.java b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaAbstractTestCaseConfigurationProducerTest.java index ecbcac12acc..2b6f3dea637 100644 --- a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaAbstractTestCaseConfigurationProducerTest.java +++ b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaAbstractTestCaseConfigurationProducerTest.java @@ -67,7 +67,7 @@ public final void setup() { } @Test - public void testIgnoreTestClassWithNoTestSubclasses() { + public void testIgnoreTestClassWithNoTestSubclasses() throws Throwable { PsiFile javaFile = createAndIndexFile( new WorkspacePath("java/com/google/test/TestClass.java"), @@ -91,7 +91,7 @@ public void testIgnoreTestClassWithNoTestSubclasses() { } @Test - public void testIgnoreAbstractTestClassWithNoTestSubclasses() { + public void testIgnoreAbstractTestClassWithNoTestSubclasses() throws Throwable { PsiFile javaFile = createAndIndexFile( new WorkspacePath("java/com/google/test/TestClass.java"), @@ -115,7 +115,7 @@ public void testIgnoreAbstractTestClassWithNoTestSubclasses() { } @Test - public void testHandlesNonAbstractClassWithTestSubclass() { + public void testHandlesNonAbstractClassWithTestSubclass() throws Throwable { workspace.createPsiDirectory(new WorkspacePath("java/com/google/test")); PsiFile superClassFile = createAndIndexFile( @@ -158,7 +158,7 @@ public void testHandlesNonAbstractClassWithTestSubclass() { } @Test - public void testConfigurationCreatedFromAbstractClass() { + public void testConfigurationCreatedFromAbstractClass() throws Throwable { workspace.createPsiDirectory(new WorkspacePath("java/com/google/test")); PsiFile abstractClassFile = createAndIndexFile( @@ -219,7 +219,7 @@ public void testConfigurationCreatedFromAbstractClass() { } @Test - public void testConfigurationCreatedFromMethodInAbstractClass() { + public void testConfigurationCreatedFromMethodInAbstractClass() throws Throwable { PsiFile abstractClassFile = createAndIndexFile( new WorkspacePath("java/com/google/test/AbstractTestCase.java"), diff --git a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaTestClassConfigurationProducerTest.java b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaTestClassConfigurationProducerTest.java index 80c7c91e0b0..d29c2a5c331 100644 --- a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaTestClassConfigurationProducerTest.java +++ b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaTestClassConfigurationProducerTest.java @@ -68,7 +68,7 @@ public final void setup() { } @Test - public void testProducedFromPsiFile() { + public void testProducedFromPsiFile() throws Throwable { PsiFile javaFile = createAndIndexFile( new WorkspacePath("java/com/google/test/TestClass.java"), @@ -112,7 +112,7 @@ public void testProducedFromPsiFile() { } @Test - public void testProducedFromPsiClass() { + public void testProducedFromPsiClass() throws Throwable { PsiFile javaFile = createAndIndexFile( new WorkspacePath("java/com/google/test/TestClass.java"), @@ -159,7 +159,7 @@ public void testProducedFromPsiClass() { } @Test - public void testProducedFromPsiClassWithInnerTestClass() { + public void testProducedFromPsiClassWithInnerTestClass() throws Throwable { PsiFile javaFile = createAndIndexFile( new WorkspacePath("java/com/google/test/OuterClass.java"), @@ -212,7 +212,7 @@ public void testProducedFromPsiClassWithInnerTestClass() { } @Test - public void testConfigFromContextRecognizesItsOwnConfig() { + public void testConfigFromContextRecognizesItsOwnConfig() throws Throwable { PsiFile javaFile = createAndIndexFile( new WorkspacePath("java/com/google/test/TestClass.java"), @@ -246,7 +246,7 @@ public void testConfigFromContextRecognizesItsOwnConfig() { } @Test - public void testConfigWithDifferentLabelIgnored() { + public void testConfigWithDifferentLabelIgnored() throws Throwable { PsiFile javaFile = createAndIndexFile( new WorkspacePath("java/com/google/test/TestClass.java"), @@ -283,7 +283,7 @@ public void testConfigWithDifferentLabelIgnored() { } @Test - public void testConfigWithDifferentFilterIgnored() { + public void testConfigWithDifferentFilterIgnored() throws Throwable { PsiFile javaFile = createAndIndexFile( new WorkspacePath("java/com/google/test/TestClass.java"), diff --git a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaTestMethodConfigurationProducerTest.java b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaTestMethodConfigurationProducerTest.java index caad99ea29f..3865793738c 100644 --- a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaTestMethodConfigurationProducerTest.java +++ b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/BlazeJavaTestMethodConfigurationProducerTest.java @@ -68,7 +68,7 @@ public final void setup() { } @Test - public void testProducedFromPsiMethod() { + public void testProducedFromPsiMethod() throws Throwable { // Arrange PsiFile javaFile = createAndIndexFile( @@ -119,7 +119,7 @@ public void testProducedFromPsiMethod() { } @Test - public void testConfigFromContextRecognizesItsOwnConfig() { + public void testConfigFromContextRecognizesItsOwnConfig() throws Throwable { PsiMethod method = setupGenericJunitTestClassAndBlazeTarget(); ConfigurationContext context = createContextFromPsi(method); BlazeCommandRunConfiguration config = @@ -132,7 +132,7 @@ public void testConfigFromContextRecognizesItsOwnConfig() { } @Test - public void testConfigWithDifferentLabelIsIgnored() { + public void testConfigWithDifferentLabelIsIgnored() throws Throwable { // Arrange PsiMethod method = setupGenericJunitTestClassAndBlazeTarget(); ConfigurationContext context = createContextFromPsi(method); @@ -150,7 +150,7 @@ public void testConfigWithDifferentLabelIsIgnored() { } @Test - public void testConfigWithDifferentFilterIgnored() { + public void testConfigWithDifferentFilterIgnored() throws Throwable { // Arrange PsiMethod method = setupGenericJunitTestClassAndBlazeTarget(); ConfigurationContext context = createContextFromPsi(method); @@ -178,7 +178,7 @@ public void testConfigWithDifferentFilterIgnored() { * class. Used when the implementation details (class name, target string, etc.) aren't relevant * to the test. */ - private PsiMethod setupGenericJunitTestClassAndBlazeTarget() { + private PsiMethod setupGenericJunitTestClassAndBlazeTarget() throws Throwable { PsiFile javaFile = createAndIndexFile( new WorkspacePath("java/com/google/test/TestClass.java"), diff --git a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/JavaBinaryContextProviderTest.java b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/JavaBinaryContextProviderTest.java index 24785841555..1dfb450106a 100644 --- a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/JavaBinaryContextProviderTest.java +++ b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/JavaBinaryContextProviderTest.java @@ -38,7 +38,7 @@ public class JavaBinaryContextProviderTest extends BlazeRunConfigurationProducerTestCase { @Test - public void testUniqueJavaBinaryChosen() { + public void testUniqueJavaBinaryChosen() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -70,7 +70,7 @@ public void testUniqueJavaBinaryChosen() { } @Test - public void testNoJavaBinaryChosenIfNotInRDeps() { + public void testNoJavaBinaryChosenIfNotInRDeps() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -98,7 +98,7 @@ public void testNoJavaBinaryChosenIfNotInRDeps() { } @Test - public void testNoResultForClassWithoutMainMethod() { + public void testNoResultForClassWithoutMainMethod() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -123,7 +123,7 @@ public void testNoResultForClassWithoutMainMethod() { } @Test - public void testJavaBinaryWithMatchingNameChosen() { + public void testJavaBinaryWithMatchingNameChosen() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -160,7 +160,7 @@ public void testJavaBinaryWithMatchingNameChosen() { } @Test - public void testJavaBinaryWithMatchingMainClassChosen() { + public void testJavaBinaryWithMatchingMainClassChosen() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() diff --git a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/MultipleJavaClassesTestContextProviderTest.java b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/MultipleJavaClassesTestContextProviderTest.java index 2a31424b953..dc4223a7f01 100644 --- a/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/MultipleJavaClassesTestContextProviderTest.java +++ b/java/tests/integrationtests/com/google/idea/blaze/java/run/producers/MultipleJavaClassesTestContextProviderTest.java @@ -106,7 +106,7 @@ public final void removeSourceFolder() { } @Test - public void testProducedFromDirectory() throws Exception { + public void testProducedFromDirectory() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -149,7 +149,7 @@ public void testProducedFromDirectory() throws Exception { } @Test - public void testProducedFromDirectoryWithNestedTests() throws Exception { + public void testProducedFromDirectoryWithNestedTests() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -192,7 +192,7 @@ public void testProducedFromDirectoryWithNestedTests() throws Exception { } @Test - public void testNotProducedForDirectoryNotUnderTestRoots() { + public void testNotProducedForDirectoryNotUnderTestRoots() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -244,7 +244,7 @@ public void testNotProducedFromDirectoryWithoutTests() { } @Test - public void testProducedFromTestFiles() { + public void testProducedFromTestFiles() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -297,7 +297,7 @@ public void testProducedFromTestFiles() { } @Test - public void testNotProducedFromTestFilesInDifferentTestTargets() { + public void testNotProducedFromTestFilesInDifferentTestTargets() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -347,7 +347,7 @@ public void testNotProducedFromTestFilesInDifferentTestTargets() { } @Test - public void testNotProducedFromNonTestFiles() { + public void testNotProducedFromNonTestFiles() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() diff --git a/javascript/tests/integrationtests/com/google/idea/blaze/javascript/run/producers/BlazeJavaScriptTestRunLineMarkerContributorTest.java b/javascript/tests/integrationtests/com/google/idea/blaze/javascript/run/producers/BlazeJavaScriptTestRunLineMarkerContributorTest.java index 7c1f7c10cd5..e32da4d2507 100644 --- a/javascript/tests/integrationtests/com/google/idea/blaze/javascript/run/producers/BlazeJavaScriptTestRunLineMarkerContributorTest.java +++ b/javascript/tests/integrationtests/com/google/idea/blaze/javascript/run/producers/BlazeJavaScriptTestRunLineMarkerContributorTest.java @@ -56,7 +56,7 @@ public void setup() { } @Test - public void testGetClosureTestInfo() { + public void testGetClosureTestInfo() throws Throwable { TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder() .addTarget( @@ -101,7 +101,7 @@ public void testGetClosureTestInfo() { } @Test - public void testGetClosureTestSuiteInfo() { + public void testGetClosureTestSuiteInfo() throws Throwable { TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder() .addTarget( @@ -151,7 +151,7 @@ public void testGetClosureTestSuiteInfo() { } @Test - public void testGetJasmineTestInfo() { + public void testGetJasmineTestInfo() throws Throwable { TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder() .addTarget( diff --git a/javascript/tests/integrationtests/com/google/idea/blaze/javascript/run/producers/JavascriptTestContextProviderTest.java b/javascript/tests/integrationtests/com/google/idea/blaze/javascript/run/producers/JavascriptTestContextProviderTest.java index ccfd48d6bf1..43682ec6ec8 100644 --- a/javascript/tests/integrationtests/com/google/idea/blaze/javascript/run/producers/JavascriptTestContextProviderTest.java +++ b/javascript/tests/integrationtests/com/google/idea/blaze/javascript/run/producers/JavascriptTestContextProviderTest.java @@ -44,7 +44,7 @@ @RunWith(JUnit4.class) public class JavascriptTestContextProviderTest extends BlazeRunConfigurationProducerTestCase { @Test - public void testClosureTestSuite() { + public void testClosureTestSuite() throws Throwable { PsiFile jsTestFile = configure( ImmutableList.of("chrome-linux"), @@ -65,7 +65,7 @@ public void testClosureTestSuite() { } @Test - public void testOldStyleClosureTestSuite() { + public void testOldStyleClosureTestSuite() throws Throwable { createAndIndexFile( WorkspacePath.createIfValid("javascript/closure/testing/testsuite.js"), "goog.provide('goog.testing.testSuite');", @@ -90,7 +90,7 @@ public void testOldStyleClosureTestSuite() { } @Test - public void testTopLevelFunctions() { + public void testTopLevelFunctions() throws Throwable { PsiFile jsTestFile = configure(ImmutableList.of("chrome-linux"), "function testFoo() {}"); ConfigurationContext context = createContextFromPsi(jsTestFile); @@ -103,7 +103,7 @@ public void testTopLevelFunctions() { } @Test - public void testMultipleBrowsers() { + public void testMultipleBrowsers() throws Throwable { PsiFile jsTestFile = configure(ImmutableList.of("chrome-linux", "firefox-linux"), "function testFoo() {}"); @@ -126,7 +126,7 @@ public void testMultipleBrowsers() { } @Test - public void testNoTests() { + public void testNoTests() throws Throwable { PsiFile jsTestFile = configure(ImmutableList.of("chrome-linux"), "function foo() {}"); ConfigurationContext context = createContextFromPsi(jsTestFile); @@ -134,7 +134,7 @@ public void testNoTests() { } @Test - public void testClosureTestSuiteImportedButUnused() { + public void testClosureTestSuiteImportedButUnused() throws Throwable { PsiFile jsTestFile = configure( ImmutableList.of("chrome-linux"), @@ -147,7 +147,7 @@ public void testClosureTestSuiteImportedButUnused() { } @Test - public void testClosureTestSuiteImportedWrongSymbol() { + public void testClosureTestSuiteImportedWrongSymbol() throws Throwable { PsiFile jsTestFile = configure( ImmutableList.of("chrome-linux"), @@ -162,7 +162,8 @@ public void testClosureTestSuiteImportedWrongSymbol() { assertThat(context.getConfigurationsFromContext()).isNull(); } - private PsiFile configure(ImmutableList browsers, String... filesContents) { + private PsiFile configure(ImmutableList browsers, String... filesContents) + throws Throwable { TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder() .addTarget( diff --git a/javascript/tests/integrationtests/com/google/idea/blaze/javascript/run/producers/OldJavascriptTestContextProviderTest.java b/javascript/tests/integrationtests/com/google/idea/blaze/javascript/run/producers/OldJavascriptTestContextProviderTest.java index 3fc6fa56c29..d95ce9b06bc 100644 --- a/javascript/tests/integrationtests/com/google/idea/blaze/javascript/run/producers/OldJavascriptTestContextProviderTest.java +++ b/javascript/tests/integrationtests/com/google/idea/blaze/javascript/run/producers/OldJavascriptTestContextProviderTest.java @@ -49,7 +49,7 @@ @RunWith(JUnit4.class) public class OldJavascriptTestContextProviderTest extends BlazeRunConfigurationProducerTestCase { @Test - public void testClosureTestSuite() { + public void testClosureTestSuite() throws Throwable { PsiFile jsTestFile = configure( ImmutableList.of("chrome-linux"), @@ -70,7 +70,7 @@ public void testClosureTestSuite() { } @Test - public void testOldStyleClosureTestSuite() { + public void testOldStyleClosureTestSuite() throws Throwable { createAndIndexFile( WorkspacePath.createIfValid("javascript/closure/testing/testsuite.js"), "goog.provide('goog.testing.testSuite');", @@ -95,7 +95,7 @@ public void testOldStyleClosureTestSuite() { } @Test - public void testTopLevelFunctions() { + public void testTopLevelFunctions() throws Throwable { PsiFile jsTestFile = configure(ImmutableList.of("chrome-linux"), "function testFoo() {}"); ConfigurationContext context = createContextFromPsi(jsTestFile); @@ -108,7 +108,7 @@ public void testTopLevelFunctions() { } @Test - public void testMultipleBrowsers() { + public void testMultipleBrowsers() throws Throwable { PsiFile jsTestFile = configure(ImmutableList.of("chrome-linux", "firefox-linux"), "function testFoo() {}"); @@ -131,7 +131,7 @@ public void testMultipleBrowsers() { } @Test - public void testNoTests() { + public void testNoTests() throws Throwable { PsiFile jsTestFile = configure(ImmutableList.of("chrome-linux"), "function foo() {}"); ConfigurationContext context = createContextFromPsi(jsTestFile); @@ -139,7 +139,7 @@ public void testNoTests() { } @Test - public void testClosureTestSuiteImportedButUnused() { + public void testClosureTestSuiteImportedButUnused() throws Throwable { PsiFile jsTestFile = configure( ImmutableList.of("chrome-linux"), @@ -152,7 +152,7 @@ public void testClosureTestSuiteImportedButUnused() { } @Test - public void testClosureTestSuiteImportedWrongSymbol() { + public void testClosureTestSuiteImportedWrongSymbol() throws Throwable { PsiFile jsTestFile = configure( ImmutableList.of("chrome-linux"), @@ -167,7 +167,8 @@ public void testClosureTestSuiteImportedWrongSymbol() { assertThat(context.getConfigurationsFromContext()).isNull(); } - private PsiFile configure(ImmutableList browsers, String... filesContents) { + private PsiFile configure(ImmutableList browsers, String... filesContents) + throws Throwable { TargetMapBuilder targetMapBuilder = TargetMapBuilder.builder() .addTarget( diff --git a/kotlin/tests/integrationtests/com/google/idea/blaze/kotlin/run/producers/KotlinBinaryContextProviderTest.java b/kotlin/tests/integrationtests/com/google/idea/blaze/kotlin/run/producers/KotlinBinaryContextProviderTest.java index 6ed2a7853f0..265705148b1 100644 --- a/kotlin/tests/integrationtests/com/google/idea/blaze/kotlin/run/producers/KotlinBinaryContextProviderTest.java +++ b/kotlin/tests/integrationtests/com/google/idea/blaze/kotlin/run/producers/KotlinBinaryContextProviderTest.java @@ -36,7 +36,7 @@ @RunWith(JUnit4.class) public class KotlinBinaryContextProviderTest extends BlazeRunConfigurationProducerTestCase { @Test - public void testMainMethodIsRunnable() { + public void testMainMethodIsRunnable() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -69,7 +69,7 @@ public void testMainMethodIsRunnable() { } @Test - public void testMainClassInterpretedCorrectly() { + public void testMainClassInterpretedCorrectly() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() diff --git a/python/tests/integrationtests/com/google/idea/blaze/python/run/producers/BlazePyTestConfigurationProducerTest.java b/python/tests/integrationtests/com/google/idea/blaze/python/run/producers/BlazePyTestConfigurationProducerTest.java index 687fac76b28..943ccc623be 100644 --- a/python/tests/integrationtests/com/google/idea/blaze/python/run/producers/BlazePyTestConfigurationProducerTest.java +++ b/python/tests/integrationtests/com/google/idea/blaze/python/run/producers/BlazePyTestConfigurationProducerTest.java @@ -51,7 +51,7 @@ public final void suppressNativeProducers() { } @Test - public void testProducedFromPyFile() { + public void testProducedFromPyFile() throws Throwable { PsiFile pyFile = createAndIndexFile( new WorkspacePath("py/test/unittest.py"), @@ -90,7 +90,7 @@ public void testProducedFromPyFile() { } @Test - public void testProducedFromPyClass() { + public void testProducedFromPyClass() throws Throwable { PsiFile pyFile = createAndIndexFile( new WorkspacePath("py/test/unittest.py"), @@ -132,7 +132,7 @@ public void testProducedFromPyClass() { } @Test - public void testProducedFromTestCase() { + public void testProducedFromTestCase() throws Throwable { PsiFile pyFile = createAndIndexFile( new WorkspacePath("py/test/unittest.py"), @@ -174,7 +174,7 @@ public void testProducedFromTestCase() { } @Test - public void testProducedFromTestCaseWithParameters() { + public void testProducedFromTestCaseWithParameters() throws Throwable { PsiFile pyFile = createAndIndexFile( new WorkspacePath("py/test/unittest.py"), @@ -218,7 +218,7 @@ public void testProducedFromTestCaseWithParameters() { } @Test - public void testProducedFromTestCaseWithNamedParametersDict() { + public void testProducedFromTestCaseWithNamedParametersDict() throws Throwable { PsiFile pyFile = createAndIndexFile( new WorkspacePath("py/test/unittest.py"), @@ -265,7 +265,7 @@ public void testProducedFromTestCaseWithNamedParametersDict() { } @Test - public void testProducedFromTestCaseWithNamedParametersTuple() { + public void testProducedFromTestCaseWithNamedParametersTuple() throws Throwable { PsiFile pyFile = createAndIndexFile( new WorkspacePath("py/test/unittest.py"), @@ -312,7 +312,7 @@ public void testProducedFromTestCaseWithNamedParametersTuple() { } @Test - public void testProducedFromTestCaseWithNamedParametersTupleAndUnderscores() { + public void testProducedFromTestCaseWithNamedParametersTupleAndUnderscores() throws Throwable { PsiFile pyFile = createAndIndexFile( new WorkspacePath("py/test/unittest.py"), @@ -360,7 +360,7 @@ public void testProducedFromTestCaseWithNamedParametersTupleAndUnderscores() { } @Test - public void testProducedFromTestCaseWithParametersList() { + public void testProducedFromTestCaseWithParametersList() throws Throwable { PsiFile pyFile = createAndIndexFile( new WorkspacePath("py/test/unittest.py"), @@ -404,7 +404,7 @@ public void testProducedFromTestCaseWithParametersList() { } @Test - public void testProducedFromTestCaseWithNamedParametersDictList() { + public void testProducedFromTestCaseWithNamedParametersDictList() throws Throwable { PsiFile pyFile = createAndIndexFile( new WorkspacePath("py/test/unittest.py"), @@ -451,7 +451,7 @@ public void testProducedFromTestCaseWithNamedParametersDictList() { } @Test - public void testProducedFromTestCaseWithEmptyParametersList() { + public void testProducedFromTestCaseWithEmptyParametersList() throws Throwable { PsiFile pyFile = createAndIndexFile( new WorkspacePath("py/test/unittest.py"), diff --git a/python/tests/integrationtests/com/google/idea/blaze/python/run/producers/PyBinaryContextProviderTest.java b/python/tests/integrationtests/com/google/idea/blaze/python/run/producers/PyBinaryContextProviderTest.java index 79b868b8901..792f8e931ab 100644 --- a/python/tests/integrationtests/com/google/idea/blaze/python/run/producers/PyBinaryContextProviderTest.java +++ b/python/tests/integrationtests/com/google/idea/blaze/python/run/producers/PyBinaryContextProviderTest.java @@ -41,7 +41,7 @@ public class PyBinaryContextProviderTest extends BlazeRunConfigurationProducerTestCase { @Test - public void testProducedFromPyFile() { + public void testProducedFromPyFile() throws Throwable { PsiFile pyFile = createAndIndexFile( new WorkspacePath("py/bin/main.py"), diff --git a/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/BlazeScalaRunLineMarkerContributorTest.java b/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/BlazeScalaRunLineMarkerContributorTest.java index f64a2695433..ee537f75a41 100644 --- a/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/BlazeScalaRunLineMarkerContributorTest.java +++ b/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/BlazeScalaRunLineMarkerContributorTest.java @@ -36,7 +36,7 @@ public class BlazeScalaRunLineMarkerContributorTest extends BlazeRunConfigurationProducerTestCase { @Test - public void testGetMainInfo() { + public void testGetMainInfo() throws Throwable { BlazeScalaRunLineMarkerContributor markerContributor = new BlazeScalaRunLineMarkerContributor(); ScalaRunLineMarkerContributor replacedContributor = new ScalaRunLineMarkerContributor(); @@ -54,8 +54,7 @@ public void testGetMainInfo() { List elements = PsiUtils.findAllChildrenOfClassRecursive(scalaFile, LeafPsiElement.class); LeafPsiElement objectIdentifier = - elements - .stream() + elements.stream() .filter(e -> Objects.equal(e.getText(), "MainClass")) .findFirst() .orElse(null); @@ -69,7 +68,6 @@ public void testGetMainInfo() { assertThat(objectInfo).isNotNull(); assertThat(objectInfo.icon).isEqualTo(AllIcons.RunConfigurations.TestState.Run); - // Main object info replaces the one from the scala plugin Info replacedObjectInfo = replacedContributor.getInfo(objectIdentifier); assertThat(replacedObjectInfo).isNotNull(); @@ -86,8 +84,7 @@ public void testGetMainInfo() { assertThat(methodInfo.shouldReplace(replacedMethodInfo)).isTrue(); // No other element should get an info - elements - .stream() + elements.stream() .filter(e -> !Objects.equal(e, objectIdentifier) && !Objects.equal(e, methodIdentifier)) .forEach(e -> assertThat(markerContributor.getInfo(e)).isNull()); } diff --git a/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/BlazeScalaTestClassConfigurationProducerTest.java b/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/BlazeScalaTestClassConfigurationProducerTest.java index 711729b6324..a9c8a79c403 100644 --- a/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/BlazeScalaTestClassConfigurationProducerTest.java +++ b/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/BlazeScalaTestClassConfigurationProducerTest.java @@ -44,7 +44,7 @@ public class BlazeScalaTestClassConfigurationProducerTest extends BlazeRunConfigurationProducerTestCase { @Test - public void testJunitTestProducedFromPsiClass() { + public void testJunitTestProducedFromPsiClass() throws Throwable { PsiFile file = createAndIndexFile( new WorkspacePath("scala/com/google/test/TestClass.scala"), @@ -92,7 +92,7 @@ public void testJunitTestProducedFromPsiClass() { } @Test - public void testScalaTestProducedFromPsiClass() { + public void testScalaTestProducedFromPsiClass() throws Throwable { PsiFile file = createAndIndexFile( WorkspacePath.createIfValid("scala/com/google/test/TestClass.scala"), diff --git a/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/BlazeScalaTestRunLineMarkerContributorTest.java b/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/BlazeScalaTestRunLineMarkerContributorTest.java index bd33ba670df..5fe9037924a 100644 --- a/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/BlazeScalaTestRunLineMarkerContributorTest.java +++ b/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/BlazeScalaTestRunLineMarkerContributorTest.java @@ -38,7 +38,7 @@ public class BlazeScalaTestRunLineMarkerContributorTest new BlazeScalaTestRunLineMarkerContributor(); @Test - public void testIgnoreNonTest() { + public void testIgnoreNonTest() throws Throwable { PsiFile scalaFile = createAndIndexFile( WorkspacePath.createIfValid("src/main/scala/com/google/library/Library.scala"), @@ -52,7 +52,7 @@ public void testIgnoreNonTest() { } @Test - public void testGetJunitTestInfo() { + public void testGetJunitTestInfo() throws Throwable { PsiFile junitTestFile = createAndIndexFile( WorkspacePath.createIfValid("src/test/scala/com/google/test/JunitTest.scala"), @@ -66,14 +66,12 @@ public void testGetJunitTestInfo() { List elements = PsiUtils.findAllChildrenOfClassRecursive(junitTestFile, LeafPsiElement.class); LeafPsiElement classIdentifier = - elements - .stream() + elements.stream() .filter(e -> Objects.equal(e.getText(), "JunitTest")) .findFirst() .orElse(null); LeafPsiElement methodIdentifier = - elements - .stream() + elements.stream() .filter(e -> Objects.equal(e.getText(), "testMethod")) .findFirst() .orElse(null); @@ -88,14 +86,13 @@ public void testGetJunitTestInfo() { assertThat(methodInfo).isNotNull(); assertThat(methodInfo.icon).isEqualTo(AllIcons.RunConfigurations.TestState.Run); - elements - .stream() + elements.stream() .filter(e -> !Objects.equal(e, classIdentifier) && !Objects.equal(e, methodIdentifier)) .forEach(e -> assertThat(markerContributor.getInfo(e)).isNull()); } @Test - public void testGetSpecs2TestInfo() { + public void testGetSpecs2TestInfo() throws Throwable { createAndIndexFile( WorkspacePath.createIfValid("scala/org/junit/runner/RunWith.scala"), "package org.junit.runner", @@ -138,8 +135,7 @@ public void testGetSpecs2TestInfo() { List elements = PsiUtils.findAllChildrenOfClassRecursive(specs2TestFile, LeafPsiElement.class); LeafPsiElement classIdentifier = - elements - .stream() + elements.stream() .filter(e -> Objects.equal(e.getText(), "Specs2Test")) .findFirst() .orElse(null); @@ -149,14 +145,13 @@ public void testGetSpecs2TestInfo() { assertThat(info).isNotNull(); assertThat(info.icon).isEqualTo(AllIcons.RunConfigurations.TestState.Run_run); - elements - .stream() + elements.stream() .filter(e -> !Objects.equal(e, classIdentifier)) .forEach(e -> assertThat(markerContributor.getInfo(e)).isNull()); } @Test - public void testGetScalaTestInfo() { + public void testGetScalaTestInfo() throws Throwable { PsiFile scalaTestFile = createAndIndexFile( WorkspacePath.createIfValid("src/test/scala/com/google/test/ScalaTest.scala"), @@ -172,8 +167,7 @@ public void testGetScalaTestInfo() { List elements = PsiUtils.findAllChildrenOfClassRecursive(scalaTestFile, LeafPsiElement.class); LeafPsiElement classIdentifier = - elements - .stream() + elements.stream() .filter(e -> Objects.equal(e.getText(), "ScalaTest")) .findFirst() .orElse(null); @@ -183,8 +177,7 @@ public void testGetScalaTestInfo() { assertThat(info).isNotNull(); assertThat(info.icon).isEqualTo(AllIcons.RunConfigurations.TestState.Run_run); - elements - .stream() + elements.stream() .filter(e -> !Objects.equal(e, classIdentifier)) .forEach(e -> assertThat(markerContributor.getInfo(e)).isNull()); } diff --git a/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/DeployableJarRunConfigurationProducerTest.java b/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/DeployableJarRunConfigurationProducerTest.java index 1cc7e4a28e6..f300fb950b4 100644 --- a/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/DeployableJarRunConfigurationProducerTest.java +++ b/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/DeployableJarRunConfigurationProducerTest.java @@ -45,7 +45,7 @@ protected BuildSystem buildSystem() { } @Test - public void testCorrectMainAppAndTargetChosen() { + public void testCorrectMainAppAndTargetChosen() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() diff --git a/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/ScalaBinaryContextProviderTest.java b/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/ScalaBinaryContextProviderTest.java index 97e0b7d210f..452c5de7d47 100644 --- a/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/ScalaBinaryContextProviderTest.java +++ b/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/ScalaBinaryContextProviderTest.java @@ -38,7 +38,7 @@ public class ScalaBinaryContextProviderTest extends BlazeRunConfigurationProducerTestCase { @Test - public void testUniqueScalaBinaryChosen() { + public void testUniqueScalaBinaryChosen() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -73,7 +73,7 @@ public void testUniqueScalaBinaryChosen() { } @Test - public void testNoScalaBinaryChosenIfNotInRDeps() { + public void testNoScalaBinaryChosenIfNotInRDeps() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -103,7 +103,7 @@ public void testNoScalaBinaryChosenIfNotInRDeps() { } @Test - public void testNoResultForObjectWithoutMainMethod() { + public void testNoResultForObjectWithoutMainMethod() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -129,7 +129,7 @@ public void testNoResultForObjectWithoutMainMethod() { } @Test - public void testScalaBinaryWithMatchingNameChosen() { + public void testScalaBinaryWithMatchingNameChosen() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() @@ -169,7 +169,7 @@ public void testScalaBinaryWithMatchingNameChosen() { } @Test - public void testScalaBinaryWithMatchingMainClassChosen() { + public void testScalaBinaryWithMatchingMainClassChosen() throws Throwable { MockBlazeProjectDataBuilder builder = MockBlazeProjectDataBuilder.builder(workspaceRoot); builder.setTargetMap( TargetMapBuilder.builder() diff --git a/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/ScalaSpecs2TestContextProviderTest.java b/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/ScalaSpecs2TestContextProviderTest.java index 2aa347da6b2..adc25c54580 100644 --- a/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/ScalaSpecs2TestContextProviderTest.java +++ b/scala/tests/integrationtests/com/google/idea/blaze/scala/run/producers/ScalaSpecs2TestContextProviderTest.java @@ -43,7 +43,7 @@ public class ScalaSpecs2TestContextProviderTest extends BlazeRunConfigurationProducerTestCase { @Test - public void testSpecs2TestProducedFromPsiClass() { + public void testSpecs2TestProducedFromPsiClass() throws Throwable { PsiFile file = createTestPsiFile(); assertThat(file).isInstanceOf(ScalaFile.class); @@ -84,7 +84,7 @@ public void testSpecs2TestProducedFromPsiClass() { // TODO: also test BlazeScalaTestEventsHandler } - private PsiFile createTestPsiFile() { + private PsiFile createTestPsiFile() throws Throwable { createAndIndexFile( WorkspacePath.createIfValid("scala/org/junit/Test.scala"), "package org.junit", diff --git a/testing/BUILD b/testing/BUILD index d5444e9f704..a8272857085 100644 --- a/testing/BUILD +++ b/testing/BUILD @@ -35,9 +35,9 @@ java_library( "intellij-ue-2020.1": glob(["testcompat/v201/com/google/idea/sdkcompat/**/*.java"]), "intellij-2020.2": glob(["testcompat/v202/com/google/idea/sdkcompat/**/*.java"]), "intellij-ue-2020.2": glob(["testcompat/v202/com/google/idea/sdkcompat/**/*.java"]), - "intellij-2020.3": glob(["testcompat/v202/com/google/idea/sdkcompat/**/*.java"]), - "intellij-ue-2020.3": glob(["testcompat/v202/com/google/idea/sdkcompat/**/*.java"]), - "default": [], + "intellij-2020.3": glob(["testcompat/v203/com/google/idea/sdkcompat/**/*.java"]), + "intellij-ue-2020.3": glob(["testcompat/v203/com/google/idea/sdkcompat/**/*.java"]), + "default": glob(["testcompat/v203/com/google/idea/sdkcompat/**/*.java"]), }), deps = [ "//common/experiments", diff --git a/testing/src/com/google/idea/testing/EdtRule.java b/testing/src/com/google/idea/testing/EdtRule.java index 4f374d27d26..c71f1ed004d 100644 --- a/testing/src/com/google/idea/testing/EdtRule.java +++ b/testing/src/com/google/idea/testing/EdtRule.java @@ -15,9 +15,8 @@ */ package com.google.idea.testing; -import com.intellij.testFramework.EdtTestUtil; +import com.google.idea.sdkcompat.testframework.EdtTestUtilWrapper; import com.intellij.testFramework.TestRunnerUtil; -import com.intellij.util.ThrowableRunnable; import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; @@ -31,7 +30,7 @@ public Statement apply(Statement base, Description description) { @Override public void evaluate() throws Throwable { TestRunnerUtil.replaceIdeEventQueueSafely(); - EdtTestUtil.runInEdtAndWait((ThrowableRunnable) base::evaluate); + EdtTestUtilWrapper.runInEdtAndWait(base::evaluate); } }; } diff --git a/testing/testcompat/v201/com/google/idea/sdkcompat/testframework/EdtTestUtilWrapper.java b/testing/testcompat/v201/com/google/idea/sdkcompat/testframework/EdtTestUtilWrapper.java new file mode 100644 index 00000000000..b57640e5ed1 --- /dev/null +++ b/testing/testcompat/v201/com/google/idea/sdkcompat/testframework/EdtTestUtilWrapper.java @@ -0,0 +1,33 @@ +/* + * Copyright 2021 The Bazel Authors. All rights reserved. + * + * 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. + */ +package com.google.idea.sdkcompat.testframework; + +import com.intellij.testFramework.EdtTestUtil; +import com.intellij.util.ThrowableRunnable; + +/** + * #api202 {@link EdtTestUtil#runInEdtAndWait} uses {@link ThrowableRunnable} instead of {@link + * Runnable} since 2020.3 + */ +public final class EdtTestUtilWrapper { + + private EdtTestUtilWrapper() {} + + @SuppressWarnings({"RedundantThrows", "CheckedExceptionNotThrown"}) + public static void runInEdtAndWait(ThrowableRunnable r) throws Throwable { + EdtTestUtil.runInEdtAndWait(r); + } +} diff --git a/testing/testcompat/v201/com/google/idea/sdkcompat/testframework/fixtures/CompletionAutoPopupTesterAdapter.java b/testing/testcompat/v201/com/google/idea/sdkcompat/testframework/fixtures/CompletionAutoPopupTesterAdapter.java new file mode 100644 index 00000000000..5d07d599a83 --- /dev/null +++ b/testing/testcompat/v201/com/google/idea/sdkcompat/testframework/fixtures/CompletionAutoPopupTesterAdapter.java @@ -0,0 +1,43 @@ +/* + * Copyright 2021 The Bazel Authors. All rights reserved. + * + * 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. + */ +package com.google.idea.sdkcompat.testframework.fixtures; + +import com.intellij.testFramework.fixtures.CodeInsightTestFixture; +import com.intellij.testFramework.fixtures.CompletionAutoPopupTester; +import com.intellij.util.ThrowableRunnable; + +/** + * #api202 {@link CompletionAutoPopupTester#runWithAutoPopupEnabled} now accepts {@link + * ThrowableRunnable} instead of {@link Runnable} and can throw an exception + */ +public class CompletionAutoPopupTesterAdapter extends CompletionAutoPopupTester { + + public CompletionAutoPopupTesterAdapter(CodeInsightTestFixture fixture) { + super(fixture); + } + + @SuppressWarnings({"RedundantThrows", "FunctionalInterfaceClash"}) + public void runWithAutoPopupEnabled(ThrowableRunnable r) throws Throwable { + super.runWithAutoPopupEnabled( + () -> { + try { + r.run(); + } catch (Throwable throwable) { + // the run cannot throw an exception, this is to satisfy the compiler + } + }); + } +} diff --git a/testing/testcompat/v202/com/google/idea/sdkcompat/testframework/EdtTestUtilWrapper.java b/testing/testcompat/v202/com/google/idea/sdkcompat/testframework/EdtTestUtilWrapper.java new file mode 100644 index 00000000000..b57640e5ed1 --- /dev/null +++ b/testing/testcompat/v202/com/google/idea/sdkcompat/testframework/EdtTestUtilWrapper.java @@ -0,0 +1,33 @@ +/* + * Copyright 2021 The Bazel Authors. All rights reserved. + * + * 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. + */ +package com.google.idea.sdkcompat.testframework; + +import com.intellij.testFramework.EdtTestUtil; +import com.intellij.util.ThrowableRunnable; + +/** + * #api202 {@link EdtTestUtil#runInEdtAndWait} uses {@link ThrowableRunnable} instead of {@link + * Runnable} since 2020.3 + */ +public final class EdtTestUtilWrapper { + + private EdtTestUtilWrapper() {} + + @SuppressWarnings({"RedundantThrows", "CheckedExceptionNotThrown"}) + public static void runInEdtAndWait(ThrowableRunnable r) throws Throwable { + EdtTestUtil.runInEdtAndWait(r); + } +} diff --git a/testing/testcompat/v202/com/google/idea/sdkcompat/testframework/fixtures/CompletionAutoPopupTesterAdapter.java b/testing/testcompat/v202/com/google/idea/sdkcompat/testframework/fixtures/CompletionAutoPopupTesterAdapter.java new file mode 100644 index 00000000000..5d07d599a83 --- /dev/null +++ b/testing/testcompat/v202/com/google/idea/sdkcompat/testframework/fixtures/CompletionAutoPopupTesterAdapter.java @@ -0,0 +1,43 @@ +/* + * Copyright 2021 The Bazel Authors. All rights reserved. + * + * 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. + */ +package com.google.idea.sdkcompat.testframework.fixtures; + +import com.intellij.testFramework.fixtures.CodeInsightTestFixture; +import com.intellij.testFramework.fixtures.CompletionAutoPopupTester; +import com.intellij.util.ThrowableRunnable; + +/** + * #api202 {@link CompletionAutoPopupTester#runWithAutoPopupEnabled} now accepts {@link + * ThrowableRunnable} instead of {@link Runnable} and can throw an exception + */ +public class CompletionAutoPopupTesterAdapter extends CompletionAutoPopupTester { + + public CompletionAutoPopupTesterAdapter(CodeInsightTestFixture fixture) { + super(fixture); + } + + @SuppressWarnings({"RedundantThrows", "FunctionalInterfaceClash"}) + public void runWithAutoPopupEnabled(ThrowableRunnable r) throws Throwable { + super.runWithAutoPopupEnabled( + () -> { + try { + r.run(); + } catch (Throwable throwable) { + // the run cannot throw an exception, this is to satisfy the compiler + } + }); + } +} diff --git a/testing/testcompat/v203/com/google/idea/sdkcompat/codeinsight/navigation/CtrlMouseHandlerCompat.java b/testing/testcompat/v203/com/google/idea/sdkcompat/codeinsight/navigation/CtrlMouseHandlerCompat.java new file mode 100644 index 00000000000..b43ea53b699 --- /dev/null +++ b/testing/testcompat/v203/com/google/idea/sdkcompat/codeinsight/navigation/CtrlMouseHandlerCompat.java @@ -0,0 +1,32 @@ +/* + * Copyright 2020 The Bazel Authors. All rights reserved. + * + * 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. + */ +package com.google.idea.sdkcompat.codeinsight.navigation; + +import com.intellij.codeInsight.navigation.CtrlMouseHandler; +import com.intellij.openapi.editor.Editor; +import javax.annotation.Nullable; + +/** Compat class for {@link CtrlMouseHandler}. */ +public class CtrlMouseHandlerCompat { + + private CtrlMouseHandlerCompat() {} + + /** #api201: CtrlMouseHandler.BrowseMode.Declaration replaced with dedicated method in 2020.2 */ + @Nullable + public static String getGoToDeclarationOrUsagesText(Editor editor) { + return CtrlMouseHandler.getGoToDeclarationOrUsagesText(editor); + } +} diff --git a/testing/testcompat/v203/com/google/idea/sdkcompat/testframework/EdtTestUtilWrapper.java b/testing/testcompat/v203/com/google/idea/sdkcompat/testframework/EdtTestUtilWrapper.java new file mode 100644 index 00000000000..5a6595b03f7 --- /dev/null +++ b/testing/testcompat/v203/com/google/idea/sdkcompat/testframework/EdtTestUtilWrapper.java @@ -0,0 +1,31 @@ +/* + * Copyright 2021 The Bazel Authors. All rights reserved. + * + * 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. + */ +package com.google.idea.sdkcompat.testframework; + +import com.intellij.testFramework.EdtTestUtil; +import com.intellij.util.ThrowableRunnable; + +/** + * #api202 {@link EdtTestUtil#runInEdtAndWait} uses {@link ThrowableRunnable} instead of {@link + * Runnable} since 2020.3 + */ +public final class EdtTestUtilWrapper { + private EdtTestUtilWrapper() {} + + public static void runInEdtAndWait(ThrowableRunnable r) throws Throwable { + EdtTestUtil.runInEdtAndWait(r); + } +} diff --git a/testing/testcompat/v203/com/google/idea/sdkcompat/testframework/fixtures/CompletionAutoPopupTesterAdapter.java b/testing/testcompat/v203/com/google/idea/sdkcompat/testframework/fixtures/CompletionAutoPopupTesterAdapter.java new file mode 100644 index 00000000000..13344fdfbc0 --- /dev/null +++ b/testing/testcompat/v203/com/google/idea/sdkcompat/testframework/fixtures/CompletionAutoPopupTesterAdapter.java @@ -0,0 +1,30 @@ +/* + * Copyright 2021 The Bazel Authors. All rights reserved. + * + * 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. + */ +package com.google.idea.sdkcompat.testframework.fixtures; + +import com.intellij.testFramework.fixtures.CodeInsightTestFixture; +import com.intellij.testFramework.fixtures.CompletionAutoPopupTester; +import com.intellij.util.ThrowableRunnable; + +/** + * #api202 {@link CompletionAutoPopupTester#runWithAutoPopupEnabled} uses {@link ThrowableRunnable} + * instead of {@link Runnable} since 2020.3 + */ +public class CompletionAutoPopupTesterAdapter extends CompletionAutoPopupTester { + public CompletionAutoPopupTesterAdapter(CodeInsightTestFixture fixture) { + super(fixture); + } +} diff --git a/testing/testcompat/v203/com/google/idea/testing/cidr/StubOCResolveConfiguration.java b/testing/testcompat/v203/com/google/idea/testing/cidr/StubOCResolveConfiguration.java new file mode 100644 index 00000000000..34cb328b8ba --- /dev/null +++ b/testing/testcompat/v203/com/google/idea/testing/cidr/StubOCResolveConfiguration.java @@ -0,0 +1,36 @@ +/* + * Copyright 2020 The Bazel Authors. All rights reserved. + * + * 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. + */ +package com.google.idea.testing.cidr; + +import com.intellij.openapi.project.Project; +import com.jetbrains.cidr.lang.toolchains.CidrFileSeparators; +import com.jetbrains.cidr.lang.workspace.OCResolveConfiguration; + +/** + * Stub {@link OCResolveConfiguration} for testing. + * + *

#api201 + */ +public class StubOCResolveConfiguration extends StubOCResolveConfigurationBase { + public StubOCResolveConfiguration(Project project) { + super(project); + } + + @Override + public CidrFileSeparators getFileSeparators() { + return CidrFileSeparators.UNIX; + } +}