From 259d9fb891f0c0687e67dba135c181fcd23851e3 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 26 Dec 2013 16:17:49 +0400 Subject: [PATCH] Smart completion handlers tests made generated --- .../jet/generators/tests/GenerateTests.kt | 5 + .../handlers/smart/AnonymousObject1.kt | 2 + .../handlers/smart/AnonymousObject1.kt.after | 2 + .../handlers/smart/AnonymousObject2.kt | 2 + .../handlers/smart/AnonymousObject2.kt.after | 2 + .../handlers/smart/AnonymousObject3.kt | 2 + .../handlers/smart/AnonymousObject3.kt.after | 2 + .../smart/AnonymousObjectInsertsImport.kt | 4 +- .../AnonymousObjectInsertsImport.kt.after | 4 +- .../handlers/smart/ClassObjectMethod1.kt | 2 + .../smart/ClassObjectMethod1.kt.after | 2 + .../handlers/smart/ClassObjectMethod2.kt | 2 + .../smart/ClassObjectMethod2.kt.after | 2 + .../completion/handlers/smart/EnumMember.kt | 2 + .../handlers/smart/EnumMember.kt.after | 2 + .../smart/JavaEnumMemberInsertsImport.kt | 2 + .../JavaEnumMemberInsertsImport.kt.after | 2 + .../handlers/smart/JavaStaticField.kt | 2 + .../handlers/smart/JavaStaticField.kt.after | 2 + .../smart/JavaStaticFieldInsertImport.kt | 2 + .../JavaStaticFieldInsertImport.kt.after | 2 + .../handlers/smart/JavaStaticMethod.kt | 2 + .../handlers/smart/JavaStaticMethod.kt.after | 2 + .../smart/JavaStaticMethodInsertsImport.kt | 3 + .../JavaStaticMethodInsertsImport.kt.after | 3 + .../handlers/smart/TabReplaceExpression.kt | 3 + .../smart/TabReplaceExpression.kt.after | 3 + .../handlers/smart/TabReplaceExpression2.kt | 3 + .../smart/TabReplaceExpression2.kt.after | 3 + .../handlers/smart/TabReplaceExpression3.kt | 3 + .../smart/TabReplaceExpression3.kt.after | 3 + .../handlers/smart/TabReplaceIdentifier.kt | 3 + .../smart/TabReplaceIdentifier.kt.after | 3 + .../handlers/smart/TabReplaceOperand.kt | 3 + .../handlers/smart/TabReplaceOperand.kt.after | 3 + ... => AbstractSmartCompletionHandlerTest.kt} | 47 +++--- .../handlers/CompletionHandlerTestBase.kt | 6 +- .../SmartCompletionHandlerTestGenerated.java | 159 ++++++++++++++++++ .../JetLightCodeInsightFixtureTestCase.java | 22 +-- 39 files changed, 285 insertions(+), 38 deletions(-) rename idea/tests/org/jetbrains/jet/completion/handlers/{SmartCompletionHandlerTest.kt => AbstractSmartCompletionHandlerTest.kt} (50%) create mode 100644 idea/tests/org/jetbrains/jet/completion/handlers/SmartCompletionHandlerTestGenerated.java diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index 0250b1457fd..cecb559d0f0 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -82,6 +82,7 @@ import org.jetbrains.jet.j2k.test.AbstractJavaToKotlinConverterPluginTest import org.jetbrains.jet.j2k.test.AbstractJavaToKotlinConverterBasicTest import org.jetbrains.jet.plugin.conversion.copy.AbstractJavaToKotlinCopyPasteConversionTest import org.jetbrains.jet.shortenRefs.AbstractShortenRefsTest +import org.jetbrains.jet.completion.handlers.AbstractSmartCompletionHandlerTest fun main(args: Array) { System.setProperty("java.awt.headless", "true") @@ -268,6 +269,10 @@ fun main(args: Array) { model("completion/basic/custom", recursive = false) } + testClass(javaClass()) { + model("completion/handlers/smart") + } + testClass(javaClass()) { model("navigation/gotoSuper", extension = "test") } diff --git a/idea/testData/completion/handlers/smart/AnonymousObject1.kt b/idea/testData/completion/handlers/smart/AnonymousObject1.kt index e7b59ef3ae0..11668a02b22 100644 --- a/idea/testData/completion/handlers/smart/AnonymousObject1.kt +++ b/idea/testData/completion/handlers/smart/AnonymousObject1.kt @@ -1,3 +1,5 @@ trait Foo var a : Foo = + +//ELEMENT: object diff --git a/idea/testData/completion/handlers/smart/AnonymousObject1.kt.after b/idea/testData/completion/handlers/smart/AnonymousObject1.kt.after index e16a0ad3ec7..36afa6b9282 100644 --- a/idea/testData/completion/handlers/smart/AnonymousObject1.kt.after +++ b/idea/testData/completion/handlers/smart/AnonymousObject1.kt.after @@ -1,3 +1,5 @@ trait Foo var a : Foo = object: Foo {} + +//ELEMENT: object diff --git a/idea/testData/completion/handlers/smart/AnonymousObject2.kt b/idea/testData/completion/handlers/smart/AnonymousObject2.kt index 824e20a25de..6a88befe666 100644 --- a/idea/testData/completion/handlers/smart/AnonymousObject2.kt +++ b/idea/testData/completion/handlers/smart/AnonymousObject2.kt @@ -1,3 +1,5 @@ abstract class Foo var a : Foo = + +//ELEMENT: object diff --git a/idea/testData/completion/handlers/smart/AnonymousObject2.kt.after b/idea/testData/completion/handlers/smart/AnonymousObject2.kt.after index 3add17a6704..244e76ba86e 100644 --- a/idea/testData/completion/handlers/smart/AnonymousObject2.kt.after +++ b/idea/testData/completion/handlers/smart/AnonymousObject2.kt.after @@ -1,3 +1,5 @@ abstract class Foo var a : Foo = object: Foo() {} + +//ELEMENT: object diff --git a/idea/testData/completion/handlers/smart/AnonymousObject3.kt b/idea/testData/completion/handlers/smart/AnonymousObject3.kt index 8fcf46277a5..3629ac99331 100644 --- a/idea/testData/completion/handlers/smart/AnonymousObject3.kt +++ b/idea/testData/completion/handlers/smart/AnonymousObject3.kt @@ -1 +1,3 @@ var r : Runnable = + +//ELEMENT: object diff --git a/idea/testData/completion/handlers/smart/AnonymousObject3.kt.after b/idea/testData/completion/handlers/smart/AnonymousObject3.kt.after index 0598254f494..2b253a04b40 100644 --- a/idea/testData/completion/handlers/smart/AnonymousObject3.kt.after +++ b/idea/testData/completion/handlers/smart/AnonymousObject3.kt.after @@ -3,3 +3,5 @@ var r : Runnable = object: Runnable { throw UnsupportedOperationException() } } + +//ELEMENT: object diff --git a/idea/testData/completion/handlers/smart/AnonymousObjectInsertsImport.kt b/idea/testData/completion/handlers/smart/AnonymousObjectInsertsImport.kt index 592c57398f3..c5a3621dfa7 100644 --- a/idea/testData/completion/handlers/smart/AnonymousObjectInsertsImport.kt +++ b/idea/testData/completion/handlers/smart/AnonymousObjectInsertsImport.kt @@ -1 +1,3 @@ -val c: java.io.Closeable = \ No newline at end of file +val c: java.io.Closeable = + +//ELEMENT: object diff --git a/idea/testData/completion/handlers/smart/AnonymousObjectInsertsImport.kt.after b/idea/testData/completion/handlers/smart/AnonymousObjectInsertsImport.kt.after index 05bfc0a45db..dd45d717dbb 100644 --- a/idea/testData/completion/handlers/smart/AnonymousObjectInsertsImport.kt.after +++ b/idea/testData/completion/handlers/smart/AnonymousObjectInsertsImport.kt.after @@ -4,4 +4,6 @@ val c: java.io.Closeable = object: Closeable { override fun close() { throw UnsupportedOperationException() } -} \ No newline at end of file +} + +//ELEMENT: object diff --git a/idea/testData/completion/handlers/smart/ClassObjectMethod1.kt b/idea/testData/completion/handlers/smart/ClassObjectMethod1.kt index dfc201ce219..d22cb06034e 100644 --- a/idea/testData/completion/handlers/smart/ClassObjectMethod1.kt +++ b/idea/testData/completion/handlers/smart/ClassObjectMethod1.kt @@ -9,3 +9,5 @@ class K { fun foo(){ val k : K = } + +// ELEMENT: K.bar diff --git a/idea/testData/completion/handlers/smart/ClassObjectMethod1.kt.after b/idea/testData/completion/handlers/smart/ClassObjectMethod1.kt.after index fa8dd4357dd..7628ba55cd8 100644 --- a/idea/testData/completion/handlers/smart/ClassObjectMethod1.kt.after +++ b/idea/testData/completion/handlers/smart/ClassObjectMethod1.kt.after @@ -9,3 +9,5 @@ class K { fun foo(){ val k : K = K.bar() } + +// ELEMENT: K.bar diff --git a/idea/testData/completion/handlers/smart/ClassObjectMethod2.kt b/idea/testData/completion/handlers/smart/ClassObjectMethod2.kt index c6dd96c5070..d1940cb0329 100644 --- a/idea/testData/completion/handlers/smart/ClassObjectMethod2.kt +++ b/idea/testData/completion/handlers/smart/ClassObjectMethod2.kt @@ -9,3 +9,5 @@ class K { fun foo(){ val k : K = } + +// ELEMENT: K.bar diff --git a/idea/testData/completion/handlers/smart/ClassObjectMethod2.kt.after b/idea/testData/completion/handlers/smart/ClassObjectMethod2.kt.after index 369ec744e06..a321bbcaddc 100644 --- a/idea/testData/completion/handlers/smart/ClassObjectMethod2.kt.after +++ b/idea/testData/completion/handlers/smart/ClassObjectMethod2.kt.after @@ -9,3 +9,5 @@ class K { fun foo(){ val k : K = K.bar() } + +// ELEMENT: K.bar diff --git a/idea/testData/completion/handlers/smart/EnumMember.kt b/idea/testData/completion/handlers/smart/EnumMember.kt index ddc21f30e05..0834c5b4c79 100644 --- a/idea/testData/completion/handlers/smart/EnumMember.kt +++ b/idea/testData/completion/handlers/smart/EnumMember.kt @@ -6,3 +6,5 @@ enum class Foo { fun foo(){ val f : Foo = } + +// ELEMENT: Foo.X diff --git a/idea/testData/completion/handlers/smart/EnumMember.kt.after b/idea/testData/completion/handlers/smart/EnumMember.kt.after index 3cd00a17f3d..c77034e2c54 100644 --- a/idea/testData/completion/handlers/smart/EnumMember.kt.after +++ b/idea/testData/completion/handlers/smart/EnumMember.kt.after @@ -6,3 +6,5 @@ enum class Foo { fun foo(){ val f : Foo = Foo.X } + +// ELEMENT: Foo.X diff --git a/idea/testData/completion/handlers/smart/JavaEnumMemberInsertsImport.kt b/idea/testData/completion/handlers/smart/JavaEnumMemberInsertsImport.kt index 3e550180e1d..125cb9c7d7f 100644 --- a/idea/testData/completion/handlers/smart/JavaEnumMemberInsertsImport.kt +++ b/idea/testData/completion/handlers/smart/JavaEnumMemberInsertsImport.kt @@ -1,3 +1,5 @@ fun foo(){ val e : java.lang.annotation.ElementType = } + +// ELEMENT: ElementType.FIELD diff --git a/idea/testData/completion/handlers/smart/JavaEnumMemberInsertsImport.kt.after b/idea/testData/completion/handlers/smart/JavaEnumMemberInsertsImport.kt.after index 75c806d086e..7ce2f37dbdb 100644 --- a/idea/testData/completion/handlers/smart/JavaEnumMemberInsertsImport.kt.after +++ b/idea/testData/completion/handlers/smart/JavaEnumMemberInsertsImport.kt.after @@ -3,3 +3,5 @@ import java.lang.annotation.ElementType fun foo(){ val e : java.lang.annotation.ElementType = ElementType.FIELD } + +// ELEMENT: ElementType.FIELD diff --git a/idea/testData/completion/handlers/smart/JavaStaticField.kt b/idea/testData/completion/handlers/smart/JavaStaticField.kt index 7ffc3c7384f..bd1239d3871 100644 --- a/idea/testData/completion/handlers/smart/JavaStaticField.kt +++ b/idea/testData/completion/handlers/smart/JavaStaticField.kt @@ -3,3 +3,5 @@ import java.util.Locale fun foo(){ var l : Locale = } + +// ELEMENT: Locale.ENGLISH diff --git a/idea/testData/completion/handlers/smart/JavaStaticField.kt.after b/idea/testData/completion/handlers/smart/JavaStaticField.kt.after index 9fd249c66f2..98d1786fb19 100644 --- a/idea/testData/completion/handlers/smart/JavaStaticField.kt.after +++ b/idea/testData/completion/handlers/smart/JavaStaticField.kt.after @@ -3,3 +3,5 @@ import java.util.Locale fun foo(){ var l : Locale = Locale.ENGLISH } + +// ELEMENT: Locale.ENGLISH diff --git a/idea/testData/completion/handlers/smart/JavaStaticFieldInsertImport.kt b/idea/testData/completion/handlers/smart/JavaStaticFieldInsertImport.kt index 37592e3e6bb..c0349b1f437 100644 --- a/idea/testData/completion/handlers/smart/JavaStaticFieldInsertImport.kt +++ b/idea/testData/completion/handlers/smart/JavaStaticFieldInsertImport.kt @@ -1,3 +1,5 @@ fun foo(){ var l : java.util.Locale = } + +// ELEMENT: Locale.ENGLISH diff --git a/idea/testData/completion/handlers/smart/JavaStaticFieldInsertImport.kt.after b/idea/testData/completion/handlers/smart/JavaStaticFieldInsertImport.kt.after index fe5cbe1622b..58042f2eb61 100644 --- a/idea/testData/completion/handlers/smart/JavaStaticFieldInsertImport.kt.after +++ b/idea/testData/completion/handlers/smart/JavaStaticFieldInsertImport.kt.after @@ -3,3 +3,5 @@ import java.util.Locale fun foo(){ var l : java.util.Locale = Locale.ENGLISH } + +// ELEMENT: Locale.ENGLISH diff --git a/idea/testData/completion/handlers/smart/JavaStaticMethod.kt b/idea/testData/completion/handlers/smart/JavaStaticMethod.kt index 52ce3361f82..35e0875f7dc 100644 --- a/idea/testData/completion/handlers/smart/JavaStaticMethod.kt +++ b/idea/testData/completion/handlers/smart/JavaStaticMethod.kt @@ -1,3 +1,5 @@ fun foo(){ val l : java.lang.Thread = } + +// ELEMENT: Thread.currentThread diff --git a/idea/testData/completion/handlers/smart/JavaStaticMethod.kt.after b/idea/testData/completion/handlers/smart/JavaStaticMethod.kt.after index a5741b81458..18dfed987a3 100644 --- a/idea/testData/completion/handlers/smart/JavaStaticMethod.kt.after +++ b/idea/testData/completion/handlers/smart/JavaStaticMethod.kt.after @@ -1,3 +1,5 @@ fun foo(){ val l : java.lang.Thread = Thread.currentThread() } + +// ELEMENT: Thread.currentThread diff --git a/idea/testData/completion/handlers/smart/JavaStaticMethodInsertsImport.kt b/idea/testData/completion/handlers/smart/JavaStaticMethodInsertsImport.kt index c99016af90e..e232b1f211f 100644 --- a/idea/testData/completion/handlers/smart/JavaStaticMethodInsertsImport.kt +++ b/idea/testData/completion/handlers/smart/JavaStaticMethodInsertsImport.kt @@ -1,3 +1,6 @@ fun foo(){ val l : java.util.Calendar = } + +// ELEMENT: Calendar.getInstance +// TAIL_TEXT: (TimeZone) diff --git a/idea/testData/completion/handlers/smart/JavaStaticMethodInsertsImport.kt.after b/idea/testData/completion/handlers/smart/JavaStaticMethodInsertsImport.kt.after index 58a61d9b553..8aba94fc370 100644 --- a/idea/testData/completion/handlers/smart/JavaStaticMethodInsertsImport.kt.after +++ b/idea/testData/completion/handlers/smart/JavaStaticMethodInsertsImport.kt.after @@ -3,3 +3,6 @@ import java.util.Calendar fun foo(){ val l : java.util.Calendar = Calendar.getInstance() } + +// ELEMENT: Calendar.getInstance +// TAIL_TEXT: (TimeZone) diff --git a/idea/testData/completion/handlers/smart/TabReplaceExpression.kt b/idea/testData/completion/handlers/smart/TabReplaceExpression.kt index 9f105347112..bc8d93e9b48 100644 --- a/idea/testData/completion/handlers/smart/TabReplaceExpression.kt +++ b/idea/testData/completion/handlers/smart/TabReplaceExpression.kt @@ -3,3 +3,6 @@ fun foo(s: String){ } fun bar(sss: String) { foo(x.y()) } + +//ELEMENT: sss +//CHAR: \t diff --git a/idea/testData/completion/handlers/smart/TabReplaceExpression.kt.after b/idea/testData/completion/handlers/smart/TabReplaceExpression.kt.after index 9bfee2b8268..df7513962ff 100644 --- a/idea/testData/completion/handlers/smart/TabReplaceExpression.kt.after +++ b/idea/testData/completion/handlers/smart/TabReplaceExpression.kt.after @@ -3,3 +3,6 @@ fun foo(s: String){ } fun bar(sss: String) { foo(sss) } + +//ELEMENT: sss +//CHAR: \t diff --git a/idea/testData/completion/handlers/smart/TabReplaceExpression2.kt b/idea/testData/completion/handlers/smart/TabReplaceExpression2.kt index 46d56d72fbf..27003049d4d 100644 --- a/idea/testData/completion/handlers/smart/TabReplaceExpression2.kt +++ b/idea/testData/completion/handlers/smart/TabReplaceExpression2.kt @@ -3,3 +3,6 @@ fun foo(s: String){ } fun bar(sss: String) { foo(1 + x) } + +//ELEMENT: sss +//CHAR: \t diff --git a/idea/testData/completion/handlers/smart/TabReplaceExpression2.kt.after b/idea/testData/completion/handlers/smart/TabReplaceExpression2.kt.after index 9bfee2b8268..df7513962ff 100644 --- a/idea/testData/completion/handlers/smart/TabReplaceExpression2.kt.after +++ b/idea/testData/completion/handlers/smart/TabReplaceExpression2.kt.after @@ -3,3 +3,6 @@ fun foo(s: String){ } fun bar(sss: String) { foo(sss) } + +//ELEMENT: sss +//CHAR: \t diff --git a/idea/testData/completion/handlers/smart/TabReplaceExpression3.kt b/idea/testData/completion/handlers/smart/TabReplaceExpression3.kt index 62b624997cb..8314f6d952a 100644 --- a/idea/testData/completion/handlers/smart/TabReplaceExpression3.kt +++ b/idea/testData/completion/handlers/smart/TabReplaceExpression3.kt @@ -3,3 +3,6 @@ fun foo(s: String){ } fun bar(sss: String) { foo(x().y.z()) } + +//ELEMENT: sss +//CHAR: \t diff --git a/idea/testData/completion/handlers/smart/TabReplaceExpression3.kt.after b/idea/testData/completion/handlers/smart/TabReplaceExpression3.kt.after index 9bfee2b8268..df7513962ff 100644 --- a/idea/testData/completion/handlers/smart/TabReplaceExpression3.kt.after +++ b/idea/testData/completion/handlers/smart/TabReplaceExpression3.kt.after @@ -3,3 +3,6 @@ fun foo(s: String){ } fun bar(sss: String) { foo(sss) } + +//ELEMENT: sss +//CHAR: \t diff --git a/idea/testData/completion/handlers/smart/TabReplaceIdentifier.kt b/idea/testData/completion/handlers/smart/TabReplaceIdentifier.kt index f6688afec6f..898eebb979c 100644 --- a/idea/testData/completion/handlers/smart/TabReplaceIdentifier.kt +++ b/idea/testData/completion/handlers/smart/TabReplaceIdentifier.kt @@ -3,3 +3,6 @@ fun foo(s: String){ } fun bar(ss: String) { foo(xxx) } + +//ELEMENT: ss +//CHAR: \t diff --git a/idea/testData/completion/handlers/smart/TabReplaceIdentifier.kt.after b/idea/testData/completion/handlers/smart/TabReplaceIdentifier.kt.after index ec7e283ff0f..21932476662 100644 --- a/idea/testData/completion/handlers/smart/TabReplaceIdentifier.kt.after +++ b/idea/testData/completion/handlers/smart/TabReplaceIdentifier.kt.after @@ -3,3 +3,6 @@ fun foo(s: String){ } fun bar(ss: String) { foo(ss) } + +//ELEMENT: ss +//CHAR: \t diff --git a/idea/testData/completion/handlers/smart/TabReplaceOperand.kt b/idea/testData/completion/handlers/smart/TabReplaceOperand.kt index afbd9b2e9c5..91bbff9d8d9 100644 --- a/idea/testData/completion/handlers/smart/TabReplaceOperand.kt +++ b/idea/testData/completion/handlers/smart/TabReplaceOperand.kt @@ -6,3 +6,6 @@ val c: String = "" fun bar() { if (b1 && b2 && b3) {} } + +//ELEMENT: b3 +//CHAR: \t diff --git a/idea/testData/completion/handlers/smart/TabReplaceOperand.kt.after b/idea/testData/completion/handlers/smart/TabReplaceOperand.kt.after index 3f13f645f1a..83fc5b4c7bd 100644 --- a/idea/testData/completion/handlers/smart/TabReplaceOperand.kt.after +++ b/idea/testData/completion/handlers/smart/TabReplaceOperand.kt.after @@ -6,3 +6,6 @@ val c: String = "" fun bar() { if (b1 && b3 && b3) {} } + +//ELEMENT: b3 +//CHAR: \t diff --git a/idea/tests/org/jetbrains/jet/completion/handlers/SmartCompletionHandlerTest.kt b/idea/tests/org/jetbrains/jet/completion/handlers/AbstractSmartCompletionHandlerTest.kt similarity index 50% rename from idea/tests/org/jetbrains/jet/completion/handlers/SmartCompletionHandlerTest.kt rename to idea/tests/org/jetbrains/jet/completion/handlers/AbstractSmartCompletionHandlerTest.kt index 195d12a064b..85e7e3ca8bf 100644 --- a/idea/tests/org/jetbrains/jet/completion/handlers/SmartCompletionHandlerTest.kt +++ b/idea/tests/org/jetbrains/jet/completion/handlers/AbstractSmartCompletionHandlerTest.kt @@ -32,33 +32,30 @@ import org.junit.Assert import com.intellij.openapi.application.Result import com.intellij.testFramework.fixtures.JavaCodeInsightTestFixture import kotlin.properties.Delegates +import org.jetbrains.jet.InTextDirectivesUtils + +abstract class AbstractSmartCompletionHandlerTest() : CompletionHandlerTestBase() { + private val INVOCATION_COUNT_PREFIX = "INVOCATION_COUNT:" + private val LOOKUP_STRING_PREFIX = "ELEMENT:" + private val TAIL_TEXT_PREFIX = "TAIL_TEXT:" + private val COMPLETION_CHAR_PREFIX = "CHAR:" -public class SmartCompletionHandlerTest() : CompletionHandlerTestBase() { override val completionType: CompletionType = CompletionType.SMART override val testDataRelativePath: String = "/completion/handlers/smart" - fun testConstructor() = doTest() - fun testConstructorWithParameters() = doTest() - fun testConstructorForNullable() = doTest() - fun testConstructorForJavaClass() = doTest() - fun testConstructorForGenericType() = doTest() - fun testConstructorInsertsImport() = doTest() - fun testConstructorInsertsImport2() = doTest() - fun testJavaStaticMethod() = doTest(1, "Thread.currentThread", null, '\n') - fun testJavaStaticMethodInsertsImport() = doTest(1, "Calendar.getInstance", "(TimeZone)", '\n') - fun testClassObjectMethod1() = doTest(1, "K.bar", null, '\n') - fun testClassObjectMethod2() = doTest(1, "K.bar", null, '\n') - fun testEnumMember() = doTest(1, "Foo.X", null, '\n') - fun testJavaEnumMemberInsertsImport() = doTest(1, "ElementType.FIELD", null, '\n') - fun testJavaStaticField() = doTest(1, "Locale.ENGLISH", null, '\n') - fun testJavaStaticFieldInsertImport() = doTest(1, "Locale.ENGLISH", null, '\n') - fun testTabReplaceIdentifier() = doTest(1, "ss", null, '\t') - fun testTabReplaceExpression() = doTest(1, "sss", null, '\t') - fun testTabReplaceExpression2() = doTest(1, "sss", null, '\t') - fun testTabReplaceExpression3() = doTest(1, "sss", null, '\t') - fun testTabReplaceOperand() = doTest(1, "b3", null, '\t') - fun testAnonymousObject1() = doTest(1, "object", null, '\t') - fun testAnonymousObject2() = doTest(1, "object", null, '\t') - fun testAnonymousObject3() = doTest(1, "object", null, '\t') - fun testAnonymousObjectInsertsImport() = doTest(1, "object", null, '\t') + protected fun doTest(testPath: String) { + fixture.configureByFile(testPath) + + val fileText = fixture.getFile()!!.getText() + val invocationCount = InTextDirectivesUtils.getPrefixedInt(fileText, INVOCATION_COUNT_PREFIX) ?: 1 + val lookupString = InTextDirectivesUtils.findStringWithPrefixes(fileText, LOOKUP_STRING_PREFIX) + val tailText = InTextDirectivesUtils.findStringWithPrefixes(fileText, TAIL_TEXT_PREFIX) + val completionCharString = InTextDirectivesUtils.findStringWithPrefixes(fileText, COMPLETION_CHAR_PREFIX) + val completionChar = when(completionCharString) { + "\\n", null -> '\n' + "\\t" -> '\t' + else -> error("Uknown completion char") + } + doTestWithTextLoaded(invocationCount, lookupString, tailText, completionChar) + } } diff --git a/idea/tests/org/jetbrains/jet/completion/handlers/CompletionHandlerTestBase.kt b/idea/tests/org/jetbrains/jet/completion/handlers/CompletionHandlerTestBase.kt index 97d2090e32b..e7ad2a429c3 100644 --- a/idea/tests/org/jetbrains/jet/completion/handlers/CompletionHandlerTestBase.kt +++ b/idea/tests/org/jetbrains/jet/completion/handlers/CompletionHandlerTestBase.kt @@ -47,8 +47,12 @@ public abstract class CompletionHandlerTestBase() : JetLightCodeInsightFixtureTe protected fun doTest() : Unit = doTest(2, null, null, '\n') - protected fun doTest(time : Int, lookupString : String?, tailText : String?, completionChar : Char) : Unit { + protected fun doTest(time : Int, lookupString : String?, tailText : String?, completionChar : Char) { fixture.configureByFile(fileName()) + doTestWithTextLoaded(time, lookupString, tailText, completionChar) + } + + protected fun doTestWithTextLoaded(time : Int, lookupString : String?, tailText : String?, completionChar : Char) { if (lookupString != null || tailText != null) { fixture.complete(completionType, time) val item = getExistentLookupElement(lookupString, tailText) diff --git a/idea/tests/org/jetbrains/jet/completion/handlers/SmartCompletionHandlerTestGenerated.java b/idea/tests/org/jetbrains/jet/completion/handlers/SmartCompletionHandlerTestGenerated.java new file mode 100644 index 00000000000..02962cb7a9f --- /dev/null +++ b/idea/tests/org/jetbrains/jet/completion/handlers/SmartCompletionHandlerTestGenerated.java @@ -0,0 +1,159 @@ +/* + * Copyright 2010-2013 JetBrains s.r.o. + * + * 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 org.jetbrains.jet.completion.handlers; + +import junit.framework.Assert; +import junit.framework.Test; +import junit.framework.TestSuite; + +import java.io.File; +import java.util.regex.Pattern; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.test.InnerTestClasses; +import org.jetbrains.jet.test.TestMetadata; + +import org.jetbrains.jet.completion.handlers.AbstractSmartCompletionHandlerTest; + +/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("idea/testData/completion/handlers/smart") +public class SmartCompletionHandlerTestGenerated extends AbstractSmartCompletionHandlerTest { + public void testAllFilesPresentInSmart() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/completion/handlers/smart"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("AnonymousObject1.kt") + public void testAnonymousObject1() throws Exception { + doTest("idea/testData/completion/handlers/smart/AnonymousObject1.kt"); + } + + @TestMetadata("AnonymousObject2.kt") + public void testAnonymousObject2() throws Exception { + doTest("idea/testData/completion/handlers/smart/AnonymousObject2.kt"); + } + + @TestMetadata("AnonymousObject3.kt") + public void testAnonymousObject3() throws Exception { + doTest("idea/testData/completion/handlers/smart/AnonymousObject3.kt"); + } + + @TestMetadata("AnonymousObjectInsertsImport.kt") + public void testAnonymousObjectInsertsImport() throws Exception { + doTest("idea/testData/completion/handlers/smart/AnonymousObjectInsertsImport.kt"); + } + + @TestMetadata("ClassObjectMethod1.kt") + public void testClassObjectMethod1() throws Exception { + doTest("idea/testData/completion/handlers/smart/ClassObjectMethod1.kt"); + } + + @TestMetadata("ClassObjectMethod2.kt") + public void testClassObjectMethod2() throws Exception { + doTest("idea/testData/completion/handlers/smart/ClassObjectMethod2.kt"); + } + + @TestMetadata("Constructor.kt") + public void testConstructor() throws Exception { + doTest("idea/testData/completion/handlers/smart/Constructor.kt"); + } + + @TestMetadata("ConstructorForGenericType.kt") + public void testConstructorForGenericType() throws Exception { + doTest("idea/testData/completion/handlers/smart/ConstructorForGenericType.kt"); + } + + @TestMetadata("ConstructorForJavaClass.kt") + public void testConstructorForJavaClass() throws Exception { + doTest("idea/testData/completion/handlers/smart/ConstructorForJavaClass.kt"); + } + + @TestMetadata("ConstructorForNullable.kt") + public void testConstructorForNullable() throws Exception { + doTest("idea/testData/completion/handlers/smart/ConstructorForNullable.kt"); + } + + @TestMetadata("ConstructorInsertsImport.kt") + public void testConstructorInsertsImport() throws Exception { + doTest("idea/testData/completion/handlers/smart/ConstructorInsertsImport.kt"); + } + + @TestMetadata("ConstructorInsertsImport2.kt") + public void testConstructorInsertsImport2() throws Exception { + doTest("idea/testData/completion/handlers/smart/ConstructorInsertsImport2.kt"); + } + + @TestMetadata("ConstructorWithParameters.kt") + public void testConstructorWithParameters() throws Exception { + doTest("idea/testData/completion/handlers/smart/ConstructorWithParameters.kt"); + } + + @TestMetadata("EnumMember.kt") + public void testEnumMember() throws Exception { + doTest("idea/testData/completion/handlers/smart/EnumMember.kt"); + } + + @TestMetadata("JavaEnumMemberInsertsImport.kt") + public void testJavaEnumMemberInsertsImport() throws Exception { + doTest("idea/testData/completion/handlers/smart/JavaEnumMemberInsertsImport.kt"); + } + + @TestMetadata("JavaStaticField.kt") + public void testJavaStaticField() throws Exception { + doTest("idea/testData/completion/handlers/smart/JavaStaticField.kt"); + } + + @TestMetadata("JavaStaticFieldInsertImport.kt") + public void testJavaStaticFieldInsertImport() throws Exception { + doTest("idea/testData/completion/handlers/smart/JavaStaticFieldInsertImport.kt"); + } + + @TestMetadata("JavaStaticMethod.kt") + public void testJavaStaticMethod() throws Exception { + doTest("idea/testData/completion/handlers/smart/JavaStaticMethod.kt"); + } + + @TestMetadata("JavaStaticMethodInsertsImport.kt") + public void testJavaStaticMethodInsertsImport() throws Exception { + doTest("idea/testData/completion/handlers/smart/JavaStaticMethodInsertsImport.kt"); + } + + @TestMetadata("TabReplaceExpression.kt") + public void testTabReplaceExpression() throws Exception { + doTest("idea/testData/completion/handlers/smart/TabReplaceExpression.kt"); + } + + @TestMetadata("TabReplaceExpression2.kt") + public void testTabReplaceExpression2() throws Exception { + doTest("idea/testData/completion/handlers/smart/TabReplaceExpression2.kt"); + } + + @TestMetadata("TabReplaceExpression3.kt") + public void testTabReplaceExpression3() throws Exception { + doTest("idea/testData/completion/handlers/smart/TabReplaceExpression3.kt"); + } + + @TestMetadata("TabReplaceIdentifier.kt") + public void testTabReplaceIdentifier() throws Exception { + doTest("idea/testData/completion/handlers/smart/TabReplaceIdentifier.kt"); + } + + @TestMetadata("TabReplaceOperand.kt") + public void testTabReplaceOperand() throws Exception { + doTest("idea/testData/completion/handlers/smart/TabReplaceOperand.kt"); + } + +} diff --git a/idea/tests/org/jetbrains/jet/plugin/JetLightCodeInsightFixtureTestCase.java b/idea/tests/org/jetbrains/jet/plugin/JetLightCodeInsightFixtureTestCase.java index ae4309512ae..40144de9ce9 100644 --- a/idea/tests/org/jetbrains/jet/plugin/JetLightCodeInsightFixtureTestCase.java +++ b/idea/tests/org/jetbrains/jet/plugin/JetLightCodeInsightFixtureTestCase.java @@ -27,19 +27,21 @@ import org.jetbrains.jet.InTextDirectivesUtils; import java.io.File; public abstract class JetLightCodeInsightFixtureTestCase extends LightCodeInsightFixtureTestCase { - LightProjectDescriptor projectDescriptor = null; + LightProjectDescriptor projectDescriptor = JetLightProjectDescriptor.INSTANCE; @Override protected void setUp() throws Exception { - String fileText = FileUtil.loadFile(new File(getTestDataPath(), fileName())); - if (InTextDirectivesUtils.isDirectiveDefined(fileText, "RUNTIME")) { - projectDescriptor = JetWithJdkAndRuntimeLightProjectDescriptor.INSTANCE; - } - else if (InTextDirectivesUtils.isDirectiveDefined(fileText, "JS")) { - projectDescriptor = JetStdJSProjectDescriptor.INSTANCE; - } - else { - projectDescriptor = JetLightProjectDescriptor.INSTANCE; + if (!getTestName(false).startsWith("AllFilesPresentIn")) { + String fileText = FileUtil.loadFile(new File(getTestDataPath(), fileName())); + if (InTextDirectivesUtils.isDirectiveDefined(fileText, "RUNTIME")) { + projectDescriptor = JetWithJdkAndRuntimeLightProjectDescriptor.INSTANCE; + } + else if (InTextDirectivesUtils.isDirectiveDefined(fileText, "JS")) { + projectDescriptor = JetStdJSProjectDescriptor.INSTANCE; + } + else { + projectDescriptor = JetLightProjectDescriptor.INSTANCE; + } } super.setUp();