mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
in fixture-based tests dispose things earlier to not treat them as leaks
This commit is contained in:
@@ -81,7 +81,7 @@ public class GenerateConstructorTest extends LightCodeInsightFixtureTestCase {
|
||||
myFixture.addClass("package foo;\n\nimport java.lang.annotation.*;\n\n@Target(ElementType.TYPE_USE) public @interface TestNotNull { }");
|
||||
NullableNotNullManager manager = NullableNotNullManager.getInstance(getProject());
|
||||
manager.setNotNulls("foo.TestNotNull");
|
||||
Disposer.register(getTestRootDisposable(), manager::setNotNulls);
|
||||
Disposer.register(myFixture.getTestRootDisposable(), manager::setNotNulls);
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ class JavaDocumentationTest extends LightCodeInsightFixtureTestCase {
|
||||
JavaPsiFacade.getInstance(project).findClass('Foo', it.resolveScope)?.findMethodBySignature(it, false)
|
||||
}
|
||||
}
|
||||
PlatformTestUtil.registerExtension DocumentationDelegateProvider.EP_NAME, provider, testRootDisposable
|
||||
PlatformTestUtil.registerExtension DocumentationDelegateProvider.EP_NAME, provider, myFixture.testRootDisposable
|
||||
|
||||
configure '''\
|
||||
class Foo {
|
||||
|
||||
@@ -262,7 +262,7 @@ class Test implements A {
|
||||
String[] getAnnotations(Project project) {
|
||||
return ["a.A"]
|
||||
}
|
||||
}, getTestRootDisposable())
|
||||
}, myFixture.getTestRootDisposable())
|
||||
myFixture.configureByText "test.java", """\
|
||||
import java.util.*;
|
||||
import a.*;
|
||||
|
||||
@@ -239,7 +239,7 @@ public class ParameterInfoTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
public void testHighlightConstructorJustChosenInCompletion() {
|
||||
Registry.get("java.completion.show.constructors").setValue(true);
|
||||
Disposer.register(getTestRootDisposable(), () -> Registry.get("java.completion.show.constructors").setValue(false));
|
||||
Disposer.register(myFixture.getTestRootDisposable(), () -> Registry.get("java.completion.show.constructors").setValue(false));
|
||||
|
||||
myFixture.addClass("class Bar {" +
|
||||
"Bar(boolean a);" +
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RegExpHighlightingTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
public void testBoundaries() {
|
||||
doTest("\\b <error descr=\"This boundary is not supported in this regex dialect\">\\b{g}</error> \\B \\A \\z \\Z \\G");
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_9, myFixture.getModule(), getTestRootDisposable());
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_9, myFixture.getModule(), myFixture.getTestRootDisposable());
|
||||
doTest("\\b \\b{g} \\B \\A \\z \\Z \\G");
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ public class RegExpHighlightingTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
public void testUnicodeGrapheme() {
|
||||
doTest("<error descr=\"Illegal/unsupported escape sequence\">\\X</error>");
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_9, myFixture.getModule(), getTestRootDisposable());
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_9, myFixture.getModule(), myFixture.getTestRootDisposable());
|
||||
doTest("\\X");
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public class RegExpHighlightingTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
|
||||
public void testIllegalCharacterRange4() {
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_9, myFixture.getModule(), getTestRootDisposable());
|
||||
IdeaTestUtil.setTestVersion(JavaSdkVersion.JDK_1_9, myFixture.getModule(), myFixture.getTestRootDisposable());
|
||||
doTest("[<error descr=\"Illegal character range (to < from)\">\\N{LATIN SMALL LETTER Z}-\\N{LATIN SMALL LETTER A}</error>]");
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class ClassNameCompletionTest extends LightFixtureCompletionTestCase {
|
||||
|
||||
String path = "/template";
|
||||
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), myFixture.getTestRootDisposable());
|
||||
configureByFile(path + "/before1.java");
|
||||
selectItem(myItems[0]);
|
||||
TemplateState state = TemplateManagerImpl.getTemplateState(myFixture.getEditor());
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public abstract class CompletionSortingTestCase extends LightFixtureCompletionTe
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
((StatisticsManagerImpl)StatisticsManager.getInstance()).enableStatistics(getTestRootDisposable());
|
||||
((StatisticsManagerImpl)StatisticsManager.getInstance()).enableStatistics(myFixture.getTestRootDisposable());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -138,7 +138,7 @@ class Bar {{ abcmethod(); anotherMethod(<caret>) }}"""
|
||||
}
|
||||
""")
|
||||
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, testRootDisposable, "foo.Excl")
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, myFixture.testRootDisposable, "foo.Excl")
|
||||
|
||||
doTest "class Bar {{ abcm<caret> }}", true, """import static foo.Foo.abcmethod;
|
||||
|
||||
@@ -153,7 +153,7 @@ class Bar {{ abcmethod()<caret> }}"""
|
||||
}
|
||||
""")
|
||||
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, testRootDisposable, "foo.Foo.abcmethodExcluded")
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, myFixture.testRootDisposable, "foo.Foo.abcmethodExcluded")
|
||||
|
||||
doTest "class Bar {{ abcm<caret> }}", true, """import static foo.Foo.abcmethod1;
|
||||
|
||||
|
||||
+2
-2
@@ -122,7 +122,7 @@ class HeavyCompletionTest extends JavaCodeInsightFixtureTestCase {
|
||||
}
|
||||
|
||||
void testMapsInvalidation() throws Exception {
|
||||
JavaAutoPopupTest.registerCompletionContributor(CacheVerifyingContributor, testRootDisposable, LoadingOrder.FIRST)
|
||||
JavaAutoPopupTest.registerCompletionContributor(CacheVerifyingContributor, myFixture.testRootDisposable, LoadingOrder.FIRST)
|
||||
myFixture.configureByFile("/codeInsight/completion/normal/" + getTestName(false) + ".java")
|
||||
assertInstanceOf(myFixture.getFile().getVirtualFile().getFileSystem(), LocalFileSystem.class) // otherwise the completion copy won't be preserved which is critical here
|
||||
myFixture.completeBasic()
|
||||
@@ -229,7 +229,7 @@ class Foo {{ Books.Test.v1<caret> }}
|
||||
}
|
||||
|
||||
void "test different jdks in different modules"() {
|
||||
(StatisticsManager.instance as StatisticsManagerImpl).enableStatistics(testRootDisposable)
|
||||
(StatisticsManager.instance as StatisticsManagerImpl).enableStatistics(myFixture.testRootDisposable)
|
||||
|
||||
def anotherModule = PsiTestUtil.addModule(project, StdModuleTypes.JAVA, 'another', myFixture.tempDirFixture.findOrCreateDir('another'))
|
||||
ModuleRootModificationUtil.setModuleSdk(anotherModule, IdeaTestUtil.mockJdk17)
|
||||
|
||||
+12
-12
@@ -315,7 +315,7 @@ class Foo {
|
||||
}
|
||||
|
||||
void "test no autopopup at the end of line comment"() {
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, getTestRootDisposable())
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, myFixture.getTestRootDisposable())
|
||||
myFixture.configureByText "a.java", """
|
||||
class Foo {
|
||||
// foo bar <caret>
|
||||
@@ -648,7 +648,7 @@ public interface Test {
|
||||
}
|
||||
|
||||
private def registerContributor(final Class contributor, LoadingOrder order = LoadingOrder.LAST) {
|
||||
registerCompletionContributor(contributor, testRootDisposable, order)
|
||||
registerCompletionContributor(contributor, myFixture.testRootDisposable, order)
|
||||
}
|
||||
static def registerCompletionContributor(final Class contributor, Disposable parentDisposable, LoadingOrder order) {
|
||||
def ep = Extensions.rootArea.getExtensionPoint("com.intellij.completion.contributor")
|
||||
@@ -1088,7 +1088,7 @@ class Foo {
|
||||
}
|
||||
|
||||
void testCompletionWhenLiveTemplateAreNotSufficient() {
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable())
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), myFixture.getTestRootDisposable())
|
||||
myFixture.configureByText("a.java", """
|
||||
class Foo {
|
||||
{
|
||||
@@ -1216,7 +1216,7 @@ public class UTest {
|
||||
}
|
||||
|
||||
void testExactMatchesTemplateFirst() {
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, getTestRootDisposable())
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, myFixture.getTestRootDisposable())
|
||||
myFixture.configureByText("a.java", """
|
||||
public class Test {
|
||||
void itar() {}
|
||||
@@ -1235,9 +1235,9 @@ public class Test {
|
||||
Template template = manager.createTemplate("itar", "myGroup", null)
|
||||
JavaCodeContextType contextType = ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), JavaCodeContextType.Statement)
|
||||
((TemplateImpl)template).templateContext.setEnabled(contextType, true)
|
||||
CodeInsightTestUtil.addTemplate(template, testRootDisposable)
|
||||
CodeInsightTestUtil.addTemplate(template, myFixture.testRootDisposable)
|
||||
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, testRootDisposable)
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, myFixture.testRootDisposable)
|
||||
myFixture.configureByText("a.java", """
|
||||
public class Test {
|
||||
void foo() {
|
||||
@@ -1421,7 +1421,7 @@ class Foo extends Abcdefg <caret>'''
|
||||
}
|
||||
|
||||
void testSoutvTemplate() {
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable())
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), myFixture.getTestRootDisposable())
|
||||
myFixture.configureByText 'a.java', 'class Foo {{ <caret> }}'
|
||||
type 'soutv\tgetcl.'
|
||||
myFixture.checkResult '''\
|
||||
@@ -1534,7 +1534,7 @@ class Foo {
|
||||
}
|
||||
|
||||
void testReplaceTypedPrefixPart() {
|
||||
((StatisticsManagerImpl)StatisticsManager.getInstance()).enableStatistics(getTestRootDisposable())
|
||||
((StatisticsManagerImpl)StatisticsManager.getInstance()).enableStatistics(myFixture.getTestRootDisposable())
|
||||
myFixture.configureByText 'a.java', 'class Foo{ { <caret> }}'
|
||||
for (i in 0..StatisticsManager.OBLIVION_THRESHOLD) {
|
||||
type 'System.out.printl\n\n'
|
||||
@@ -1668,7 +1668,7 @@ class Foo {
|
||||
}
|
||||
|
||||
void "test no name autopopup in live template"() {
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable())
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), myFixture.getTestRootDisposable())
|
||||
myFixture.configureByText 'a.java', '''class F {
|
||||
String nameContainingIdentifier;
|
||||
<caret>
|
||||
@@ -1751,7 +1751,7 @@ class Cls {
|
||||
final JavaCodeContextType contextType =
|
||||
ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), JavaCodeContextType.Statement)
|
||||
((TemplateImpl)template).getTemplateContext().setEnabled(contextType, true)
|
||||
CodeInsightTestUtil.addTemplate(template, testRootDisposable)
|
||||
CodeInsightTestUtil.addTemplate(template, myFixture.testRootDisposable)
|
||||
|
||||
myFixture.configureByText 'a.java', '''
|
||||
class Foo {
|
||||
@@ -1792,7 +1792,7 @@ class Foo {{
|
||||
}
|
||||
|
||||
void "test show popup with single live template if show_live_tempate_in_completion option is enabled"() {
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(false, getTestRootDisposable())
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(false, myFixture.getTestRootDisposable())
|
||||
myFixture.configureByText "a.java", """
|
||||
class Foo {{
|
||||
ita<caret>
|
||||
@@ -1800,7 +1800,7 @@ ita<caret>
|
||||
type 'r'
|
||||
assert lookup == null
|
||||
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, getTestRootDisposable())
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, myFixture.getTestRootDisposable())
|
||||
type '\br'
|
||||
assert lookup
|
||||
assert myFixture.lookupElementStrings == ['itar']
|
||||
|
||||
+1
-1
@@ -621,7 +621,7 @@ interface TxANotAnno {}
|
||||
}
|
||||
|
||||
void testLiveTemplateOrdering() {
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, getTestRootDisposable())
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, myFixture.getTestRootDisposable())
|
||||
checkPreferredItems(0, 'return')
|
||||
assert lookup.items.find { it.lookupString == 'ritar'} != null
|
||||
}
|
||||
|
||||
+7
-7
@@ -421,12 +421,12 @@ class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
void testExcludeStringBuffer() throws Throwable {
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, testRootDisposable, StringBuffer.name)
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, myFixture.testRootDisposable, StringBuffer.name)
|
||||
doAntiTest()
|
||||
}
|
||||
|
||||
void testExcludeInstanceInnerClasses() throws Throwable {
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, testRootDisposable, "foo")
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, myFixture.testRootDisposable, "foo")
|
||||
myFixture.addClass 'package foo; public class Outer { public class Inner {} }'
|
||||
myFixture.addClass 'package bar; public class Inner {}'
|
||||
configure()
|
||||
@@ -435,7 +435,7 @@ class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
void testExcludedInstanceInnerClassCreation() throws Throwable {
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, testRootDisposable, "foo")
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, myFixture.testRootDisposable, "foo")
|
||||
myFixture.addClass 'package foo; public class Outer { public class Inner {} }'
|
||||
myFixture.addClass 'package bar; public class Inner {}'
|
||||
configure()
|
||||
@@ -444,7 +444,7 @@ class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
void testExcludedInstanceInnerClassQualifiedReference() throws Throwable {
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, testRootDisposable, "foo")
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, myFixture.testRootDisposable, "foo")
|
||||
myFixture.addClass 'package foo; public class Outer { public class Inner {} }'
|
||||
myFixture.addClass 'package bar; public class Inner {}'
|
||||
configure()
|
||||
@@ -453,14 +453,14 @@ class NormalCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
void testStaticMethodOfExcludedClass() {
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, testRootDisposable, "foo")
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, myFixture.testRootDisposable, "foo")
|
||||
myFixture.addClass 'package foo; public class Outer { public static void method() {} }'
|
||||
configure()
|
||||
assert myFixture.lookupElementStrings == ['method']
|
||||
}
|
||||
|
||||
void testExcludeWildcards() {
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, testRootDisposable, "foo.Outer.*1*")
|
||||
JavaProjectCodeInsightSettings.setExcludedNames(project, myFixture.testRootDisposable, "foo.Outer.*1*")
|
||||
myFixture.addClass '''
|
||||
package foo;
|
||||
public class Outer {
|
||||
@@ -1684,7 +1684,7 @@ class Bar {
|
||||
void testIndentingForSwitchCase() { doTest() }
|
||||
|
||||
void testIncrementalCopyReparse() {
|
||||
((PsiDocumentManagerBase)PsiDocumentManager.getInstance(project)).disableBackgroundCommit(testRootDisposable)
|
||||
((PsiDocumentManagerBase)PsiDocumentManager.getInstance(project)).disableBackgroundCommit(myFixture.testRootDisposable)
|
||||
|
||||
myFixture.configureByText('a.java', 'class Fooxxxxxxxxxx { Fooxxxxx<caret>a f;\n' + 'public void foo() {}\n' * 10000 + '}')
|
||||
def items = myFixture.completeBasic()
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ class SignatureCompletionTest extends LightFixtureCompletionTestCase {
|
||||
super.setUp()
|
||||
Registry.get("java.completion.argument.live.template").value = true
|
||||
Registry.get("java.completion.show.constructors").value = true
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable())
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), myFixture.getTestRootDisposable())
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,7 +88,7 @@ class SignatureCompletionTest extends LightFixtureCompletionTestCase {
|
||||
}
|
||||
|
||||
void testCollectStatisticsOnMethods() {
|
||||
((StatisticsManagerImpl)StatisticsManager.instance).enableStatistics(testRootDisposable)
|
||||
((StatisticsManagerImpl)StatisticsManager.instance).enableStatistics(myFixture.testRootDisposable)
|
||||
configureByTestName()
|
||||
myFixture.assertPreferredCompletionItems 0, 'test1', 'test2'
|
||||
myFixture.lookup.currentItem = myFixture.lookupElements[1]
|
||||
|
||||
+1
-1
@@ -669,7 +669,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
|
||||
final SmartCompletionContextType completionContextType =
|
||||
ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), SmartCompletionContextType.class);
|
||||
((TemplateImpl)template).getTemplateContext().setEnabled(completionContextType, true);
|
||||
CodeInsightTestUtil.addTemplate(template, getTestRootDisposable());
|
||||
CodeInsightTestUtil.addTemplate(template, myFixture.getTestRootDisposable());
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ class JavadocHtmlLintInspectionTest : LightCodeInsightFixtureTestCase() {
|
||||
|
||||
val javaHome = System.getProperty("java.home")
|
||||
val jdkHome = if (javaHome.endsWith("jre")) PathUtil.getParentPath(javaHome) else javaHome
|
||||
VfsRootAccess.allowRootAccess(testRootDisposable, jdkHome)
|
||||
VfsRootAccess.allowRootAccess(myFixture.testRootDisposable, jdkHome)
|
||||
}
|
||||
|
||||
fun testNoComment() = doTest("class C { }")
|
||||
|
||||
@@ -39,7 +39,7 @@ public class PsiAugmentProviderTest extends LightCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
PlatformTestUtil.registerExtension(PsiAugmentProvider.EP_NAME, new TestAugmentProvider(), getTestRootDisposable());
|
||||
PlatformTestUtil.registerExtension(PsiAugmentProvider.EP_NAME, new TestAugmentProvider(), myFixture.getTestRootDisposable());
|
||||
myFixture.addClass("package lombok;\npublic @interface val { }");
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -22,7 +22,7 @@ import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
class CreateConstantFieldFromUsageTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
void "test add import when there is a single type variant"() {
|
||||
TemplateManagerImpl.setTemplateTesting(project, testRootDisposable)
|
||||
TemplateManagerImpl.setTemplateTesting(project, myFixture.testRootDisposable)
|
||||
myFixture.addClass "package foo; public class Foo { public void someMethod() {} }"
|
||||
myFixture.configureByText "a.java", '''
|
||||
class Test {
|
||||
@@ -42,7 +42,7 @@ class Test {
|
||||
}
|
||||
|
||||
void "test inside annotation argument with braces"() {
|
||||
TemplateManagerImpl.setTemplateTesting(project, testRootDisposable)
|
||||
TemplateManagerImpl.setTemplateTesting(project, myFixture.testRootDisposable)
|
||||
myFixture.configureByText "a.java", '''
|
||||
interface A {}
|
||||
@SuppressWarnings({A.CON<caret>ST})
|
||||
@@ -59,7 +59,7 @@ class Test {}
|
||||
}
|
||||
|
||||
void "test inside annotation argument no braces"() {
|
||||
TemplateManagerImpl.setTemplateTesting(project, testRootDisposable)
|
||||
TemplateManagerImpl.setTemplateTesting(project, myFixture.testRootDisposable)
|
||||
myFixture.configureByText "a.java", '''
|
||||
interface A {}
|
||||
@SuppressWarnings(A.CON<caret>ST)
|
||||
@@ -76,7 +76,7 @@ class Test {}
|
||||
}
|
||||
|
||||
void "test insert presentable name when showing type lookup"() {
|
||||
TemplateManagerImpl.setTemplateTesting(project, testRootDisposable)
|
||||
TemplateManagerImpl.setTemplateTesting(project, myFixture.testRootDisposable)
|
||||
myFixture.addClass "package foo; public class Foo { public void someMethod() {} }"
|
||||
myFixture.addClass "package bar; public class Bar { public void someMethod() {} }"
|
||||
myFixture.configureByText "a.java", '''
|
||||
|
||||
+1
-1
@@ -547,7 +547,7 @@ public class Foo {
|
||||
}
|
||||
|
||||
void "test remember chosen variants"() {
|
||||
((StatisticsManagerImpl)StatisticsManager.getInstance()).enableStatistics(getTestRootDisposable())
|
||||
((StatisticsManagerImpl)StatisticsManager.getInstance()).enableStatistics(myFixture.getTestRootDisposable())
|
||||
myFixture.addClass 'package foo; public class Log {}'
|
||||
myFixture.addClass 'package bar; public class Log {}'
|
||||
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ public class ListTemplateActionTest extends LightCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), myFixture.getTestRootDisposable());
|
||||
addTemplate("simple", "simple template text", "description", "test");
|
||||
addTemplate("complex key", "complex template text", "", "test");
|
||||
addTemplate("template.with.desc", "template with description", "desc", "test");
|
||||
@@ -46,7 +46,7 @@ public class ListTemplateActionTest extends LightCodeInsightFixtureTestCase {
|
||||
template.setDescription(description);
|
||||
TemplateContextType contextType = ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), JavaCodeContextType.class);
|
||||
template.getTemplateContext().setEnabled(contextType, true);
|
||||
CodeInsightTestUtil.addTemplate(template, getTestRootDisposable());
|
||||
CodeInsightTestUtil.addTemplate(template, myFixture.getTestRootDisposable());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@ public class LiveTemplateEditorActionsTest extends LightCodeInsightFixtureTestCa
|
||||
}
|
||||
|
||||
private void expendTemplate() {
|
||||
TemplateManagerImpl.setTemplateTesting(myFixture.getProject(), getTestRootDisposable());
|
||||
TemplateManagerImpl.setTemplateTesting(myFixture.getProject(), myFixture.getTestRootDisposable());
|
||||
myFixture.configureByFile("BeforeTestData.java");
|
||||
|
||||
final TemplateManager manager = TemplateManager.getInstance(getProject());
|
||||
|
||||
@@ -54,7 +54,7 @@ class LiveTemplateTest extends LightCodeInsightFixtureTestCase {
|
||||
@Override
|
||||
protected void setUp() {
|
||||
super.setUp()
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable())
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), myFixture.getTestRootDisposable())
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +80,7 @@ class LiveTemplateTest extends LightCodeInsightFixtureTestCase {
|
||||
template.addVariable("ARG", "", "", false)
|
||||
TemplateContextType contextType = contextType(JavaCodeContextType.class)
|
||||
((TemplateImpl)template).getTemplateContext().setEnabled(contextType, true)
|
||||
CodeInsightTestUtil.addTemplate(template, testRootDisposable)
|
||||
CodeInsightTestUtil.addTemplate(template, myFixture.testRootDisposable)
|
||||
|
||||
writeCommand { manager.startTemplate(editor, (char)'\t') }
|
||||
UIUtil.dispatchAllInvocationEvents()
|
||||
@@ -853,7 +853,7 @@ class A {{
|
||||
|
||||
myFixture.configureByText("a.java", "class A { void f() { Stri<selection>ng s = \"tpl</selection><caret>\"; } }")
|
||||
|
||||
CodeInsightTestUtil.addTemplate(template, testRootDisposable)
|
||||
CodeInsightTestUtil.addTemplate(template, myFixture.testRootDisposable)
|
||||
myFixture.type '\t'
|
||||
myFixture.checkResult 'class A { void f() { Stri "; } }'
|
||||
}
|
||||
@@ -1099,7 +1099,7 @@ class Foo {
|
||||
template.addVariable("VAR1", "", "", true)
|
||||
template.addVariable("VAR2", new MacroCallNode(new FileNameMacro()), new ConstantNode("default"), true)
|
||||
((TemplateImpl)template).templateContext.setEnabled(contextType(JavaCodeContextType.class), true)
|
||||
CodeInsightTestUtil.addTemplate(template, testRootDisposable)
|
||||
CodeInsightTestUtil.addTemplate(template, myFixture.testRootDisposable)
|
||||
|
||||
startTemplate(template)
|
||||
myFixture.checkResult """\
|
||||
@@ -1133,7 +1133,7 @@ class Foo {
|
||||
template.addVariable("VAR1", "", "", true)
|
||||
template.addVariable("VAR2", new MacroCallNode(new MyMirrorMacro("VAR1")), null, true)
|
||||
((TemplateImpl)template).templateContext.setEnabled(contextType(JavaCodeContextType.class), true)
|
||||
CodeInsightTestUtil.addTemplate(template, testRootDisposable)
|
||||
CodeInsightTestUtil.addTemplate(template, myFixture.testRootDisposable)
|
||||
|
||||
startTemplate(template)
|
||||
myFixture.checkResult """\
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
|
||||
public class TemplateBuilderTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testRunInlineTemplate() throws Throwable {
|
||||
TemplateManagerImpl.setTemplateTesting(myFixture.getProject(), getTestRootDisposable());
|
||||
TemplateManagerImpl.setTemplateTesting(myFixture.getProject(), myFixture.getTestRootDisposable());
|
||||
myFixture.configureByText("a.java", "class A {\n" +
|
||||
" public String tes<caret>t() {\n" +
|
||||
" }\n" +
|
||||
|
||||
+6
-6
@@ -33,7 +33,7 @@ public class TemplatesCompletionTest extends CompletionAutoPopupTestCase {
|
||||
@Override
|
||||
public void setUp() {
|
||||
super.setUp();
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(false, getTestRootDisposable());
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(false, myFixture.getTestRootDisposable());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,12 +51,12 @@ public class TemplatesCompletionTest extends CompletionAutoPopupTestCase {
|
||||
}
|
||||
|
||||
public void testSimpleCompletionList() {
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, getTestRootDisposable());
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, myFixture.getTestRootDisposable());
|
||||
doAutoPopupTest("ins", InstanceofExpressionPostfixTemplate.class);
|
||||
}
|
||||
|
||||
public void testAutopopupWithEnabledLiveTemplatesInCompletion() {
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(false, getTestRootDisposable());
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(false, myFixture.getTestRootDisposable());
|
||||
|
||||
configureByFile();
|
||||
type("instanceof");
|
||||
@@ -124,14 +124,14 @@ public class TemplatesCompletionTest extends CompletionAutoPopupTestCase {
|
||||
}
|
||||
|
||||
public void testDoNotAutoCompleteCompletionElementIfTemplateUnique() {
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, getTestRootDisposable());
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, myFixture.getTestRootDisposable());
|
||||
configureByFile();
|
||||
myFixture.completeBasic();
|
||||
checkResultByFile();
|
||||
}
|
||||
|
||||
public void testDoNotCompleteTemplateInMultiCaretMode() {
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, getTestRootDisposable());
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, myFixture.getTestRootDisposable());
|
||||
configureByFile();
|
||||
assertEmpty(myFixture.complete(CompletionType.BASIC));
|
||||
checkResultByFile();
|
||||
@@ -187,7 +187,7 @@ public class TemplatesCompletionTest extends CompletionAutoPopupTestCase {
|
||||
}
|
||||
|
||||
public void testTabCompletionWithTemplatesInAutopopup() {
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, getTestRootDisposable());
|
||||
LiveTemplateCompletionContributor.setShowTemplatesInTests(true, myFixture.getTestRootDisposable());
|
||||
|
||||
configureByFile();
|
||||
type(".");
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ public class InstanceofPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
}
|
||||
|
||||
public void testSingleExpressionTemplate() {
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), myFixture.getTestRootDisposable());
|
||||
|
||||
myFixture.configureByFile(getTestName(true) + ".java");
|
||||
myFixture.type('\t');
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class LambdaPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
}
|
||||
|
||||
public void testDoNotExpandOnJavaLess8() {
|
||||
IdeaTestUtil.setModuleLanguageLevel(myModule, LanguageLevel.JDK_1_6, getTestRootDisposable());
|
||||
IdeaTestUtil.setModuleLanguageLevel(myModule, LanguageLevel.JDK_1_6, myFixture.getTestRootDisposable());
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class OptionalPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
}
|
||||
|
||||
public void testDoNotExpandOnJavaLess8() {
|
||||
IdeaTestUtil.setModuleLanguageLevel(myModule, LanguageLevel.JDK_1_6, getTestRootDisposable());
|
||||
IdeaTestUtil.setModuleLanguageLevel(myModule, LanguageLevel.JDK_1_6, myFixture.getTestRootDisposable());
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ public class StreamPostfixTemplateTest extends PostfixTemplateTestCase {
|
||||
}
|
||||
|
||||
public void testDoNotExpandOnJavaLess8() {
|
||||
IdeaTestUtil.setModuleLanguageLevel(myModule, LanguageLevel.JDK_1_6, getTestRootDisposable());
|
||||
IdeaTestUtil.setModuleLanguageLevel(myModule, LanguageLevel.JDK_1_6, myFixture.getTestRootDisposable());
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class DataFlowInspection8Test extends DataFlowInspectionTestCase {
|
||||
private void setupCustomAnnotations() {
|
||||
myFixture.addClass("package foo;\n\nimport java.lang.annotation.*;\n\n@Target({ElementType.TYPE_USE}) public @interface Nullable { }");
|
||||
myFixture.addClass("package foo;\n\nimport java.lang.annotation.*;\n\n@Target({ElementType.TYPE_USE}) public @interface NotNull { }");
|
||||
setCustomAnnotations(getProject(), getTestRootDisposable(), "foo.NotNull", "foo.Nullable");
|
||||
setCustomAnnotations(getProject(), myFixture.getTestRootDisposable(), "foo.NotNull", "foo.Nullable");
|
||||
}
|
||||
|
||||
static void setCustomAnnotations(Project project, Disposable parentDisposable, String notNull, String nullable) {
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ class DataFlowInspectionHeavyTest extends JavaCodeInsightFixtureTestCase {
|
||||
'''
|
||||
|
||||
myFixture.addFileToProject 'annos/annos.java', annotationsText("ElementType.TYPE_USE")
|
||||
DataFlowInspection8Test.setCustomAnnotations(project, testRootDisposable, 'annos.NotNull', 'annos.Nullable')
|
||||
DataFlowInspection8Test.setCustomAnnotations(project, myFixture.testRootDisposable, 'annos.NotNull', 'annos.Nullable')
|
||||
|
||||
def testFile = myFixture.addFileToProject 'test.java', '''
|
||||
class Zoo {
|
||||
|
||||
@@ -444,7 +444,7 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public boolean isImplicitWrite(PsiElement element) {
|
||||
return element instanceof PsiField && ((PsiField)element).getName().startsWith("field");
|
||||
}
|
||||
}, getTestRootDisposable());
|
||||
}, myFixture.getTestRootDisposable());
|
||||
doTest();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -153,7 +153,7 @@ public class NullableStuffInspectionTest extends LightCodeInsightFixtureTestCase
|
||||
|
||||
final NullableNotNullManager nnnManager = NullableNotNullManager.getInstance(getProject());
|
||||
nnnManager.setNullables("custom.CheckForNull");
|
||||
Disposer.register(getTestRootDisposable(), new Disposable() {
|
||||
Disposer.register(myFixture.getTestRootDisposable(), new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
nnnManager.setNullables();
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ public class EmbeddedLiveTemplatesTest extends LightPlatformCodeInsightFixtureTe
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
myFixture.configureByText(PlainTextFileType.INSTANCE, ""); // enable editor action context
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), myFixture.getTestRootDisposable());
|
||||
}
|
||||
|
||||
private static class TestAction extends CreateFromTemplateActionBase {
|
||||
|
||||
@@ -620,7 +620,7 @@ class IndexTest extends JavaCodeInsightFixtureTestCase {
|
||||
void testIndexedFilesListener() throws Throwable {
|
||||
def listener = new RecordingVfsListener()
|
||||
|
||||
ApplicationManager.getApplication().getMessageBus().connect(getTestRootDisposable()).subscribe(
|
||||
ApplicationManager.getApplication().getMessageBus().connect(myFixture.getTestRootDisposable()).subscribe(
|
||||
VirtualFileManager.VFS_CHANGES,
|
||||
listener
|
||||
)
|
||||
|
||||
@@ -25,10 +25,8 @@ import com.intellij.openapi.application.ReadAction
|
||||
import com.intellij.openapi.util.Computable
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.psi.CommonClassNames
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.search.ProjectScope
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
|
||||
import com.intellij.util.Consumer
|
||||
@@ -39,7 +37,6 @@ import org.jetbrains.plugins.groovy.lang.psi.GroovyFile
|
||||
import javax.swing.*
|
||||
|
||||
import static com.intellij.testFramework.EdtTestUtil.runInEdtAndWait
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
@@ -383,7 +380,7 @@ class Intf {
|
||||
|
||||
runInEdtAndWait {
|
||||
def popup = myPopup = ChooseByNamePopup.createPopup(project, model, (PsiElement)context, "")
|
||||
Disposer.register(testRootDisposable, { popup.close(false) } as Disposable)
|
||||
Disposer.register(myFixture.testRootDisposable, { popup.close(false) } as Disposable)
|
||||
}
|
||||
myPopup
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ public class ClassChooserTest extends LightCodeInsightFixtureTestCase {
|
||||
return new JRootPane();
|
||||
}
|
||||
};
|
||||
Disposer.register(getTestRootDisposable(), dialog.getDisposable());
|
||||
Disposer.register(myFixture.getTestRootDisposable(), dialog.getDisposable());
|
||||
|
||||
ChooseByNameModelEx model = (ChooseByNameModelEx)ref.get();
|
||||
CommonProcessors.CollectProcessor<String> processor = new CommonProcessors.CollectProcessor<>();
|
||||
|
||||
@@ -38,7 +38,7 @@ public class PsiAnchorTest extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
|
||||
public void testInjectedAnchor() {
|
||||
new MyTestInjector(getPsiManager()).injectAll(getTestRootDisposable());
|
||||
new MyTestInjector(getPsiManager()).injectAll(myFixture.getTestRootDisposable());
|
||||
myFixture.configureByText("a.java", "class X { String java=\"class <caret>Foo {}\"}");
|
||||
PsiClass cls = (PsiClass)myFixture.getElementAtCaret();
|
||||
assertEquals("Foo", cls.getName());
|
||||
|
||||
Reference in New Issue
Block a user