diff --git a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java index 3e1cc6b5a01..b29d80c050d 100644 --- a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java +++ b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java @@ -27,6 +27,8 @@ import org.jetbrains.jet.codegen.AbstractTopLevelMembersInvocationTest; import org.jetbrains.jet.codegen.defaultConstructor.AbstractDefaultConstructorCodegenTest; import org.jetbrains.jet.codegen.flags.AbstractWriteFlagsTest; import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest; +import org.jetbrains.jet.completion.AbstractJavaCompletionTest; +import org.jetbrains.jet.completion.AbstractJetJSCompletionTest; import org.jetbrains.jet.jvm.compiler.*; import org.jetbrains.jet.lang.resolve.lazy.AbstractLazyResolveDescriptorRendererTest; import org.jetbrains.jet.lang.resolve.lazy.AbstractLazyResolveNamespaceComparingTest; @@ -223,6 +225,22 @@ public class GenerateTests { new SimpleTestClassModel(new File("idea/testData/quickfix"), true, Pattern.compile("^before(\\w+)\\.kt$"), "doTest") ); + generateTest( + "idea/tests/", + "JetBasicJSCompletionTest", + AbstractJetJSCompletionTest.class, + testModel("idea/testData/completion/basic", false, "doTest"), + testModel("idea/testData/completion/basic/js", false, "doTest") + ); + + generateTest( + "idea/tests/", + "JetBasicJavaCompletionTest", + AbstractJavaCompletionTest.class, + testModel("idea/testData/completion/basic", false, "doTest"), + testModel("idea/testData/completion/basic/java", false, "doTest") + ); + generateTest( "idea/tests/", "QuickFixMultiFileTestGenerated", @@ -286,6 +304,10 @@ public class GenerateTests { return testModel(rootPath, true, "kt", methodName); } + private static SimpleTestClassModel testModel(@NotNull String rootPath, boolean recursive, @NotNull String methodName) { + return testModel(rootPath, recursive, "kt", methodName); + } + private static SimpleTestClassModel testModelWithDirectories(@NotNull String rootPath, @NotNull String methodName) { return new SimpleTestClassModel(new File(rootPath), false, Pattern.compile("^(.+)$"), methodName); } diff --git a/idea/testData/completion/basic/DoNotCompleteForErrorReceivers.kt b/idea/testData/completion/basic/DoNotCompleteForErrorReceivers.kt index d5036432850..19006b4d1f8 100644 --- a/idea/testData/completion/basic/DoNotCompleteForErrorReceivers.kt +++ b/idea/testData/completion/basic/DoNotCompleteForErrorReceivers.kt @@ -1,4 +1,4 @@ -// KT-1187 Wrong unnecessary completion +/// KT-1187 Wrong unnecessary completion fun anyfun() { a.b.c.d.e.f. diff --git a/idea/testData/completion/basic/ExtensionForProperty.kt b/idea/testData/completion/basic/ExtensionForProperty.kt index 9cd78b02333..d89b58a6a81 100644 --- a/idea/testData/completion/basic/ExtensionForProperty.kt +++ b/idea/testData/completion/basic/ExtensionForProperty.kt @@ -4,4 +4,5 @@ class Test { // TIME: 1 // EXIST: String~(jet) -// EXIST: StringBuffer \ No newline at end of file +// EXIST: StringBuilder +// EXIST_JAVA_ONLY: StringBuffer diff --git a/idea/testData/completion/basic/ExtensionFunReceiver.kt b/idea/testData/completion/basic/ExtensionFunReceiver.kt index 250177fc0fa..d92e9701351 100644 --- a/idea/testData/completion/basic/ExtensionFunReceiver.kt +++ b/idea/testData/completion/basic/ExtensionFunReceiver.kt @@ -5,7 +5,7 @@ fun S // Should complete types for receiver after explicit basic completion call // TIME: 1 // EXIST: String -// EXIST: StringBuffer +// EXIST_JAVA_ONLY: StringBuffer // EXIST: Set // ABSENT: testing diff --git a/idea/testData/completion/basic/FromImports.kt b/idea/testData/completion/basic/FromImports.kt index 440ab53b49c..c1d0a18ae53 100644 --- a/idea/testData/completion/basic/FromImports.kt +++ b/idea/testData/completion/basic/FromImports.kt @@ -6,4 +6,6 @@ fun hello() { val a = So } -// EXIST: SortedSet, SortedMap +// EXIST: SortedSet +// EXIST_JAVA_ONLY: SortedMap +// EXIST_JS_ONLY: JSON diff --git a/idea/testData/completion/basic/InEmptyImport.kt b/idea/testData/completion/basic/InEmptyImport.kt index 258a362f416..164153c0bc0 100644 --- a/idea/testData/completion/basic/InEmptyImport.kt +++ b/idea/testData/completion/basic/InEmptyImport.kt @@ -2,5 +2,7 @@ package Test import -// EXIST: java, javax +// EXIST: java, +// EXIST_JAVA_ONLY: javax +// EXIST_JS_ONLY: js // ABSENT: Array, Integer \ No newline at end of file diff --git a/idea/testData/completion/basic/InImport.kt b/idea/testData/completion/basic/InImport.kt index b2e02557987..c3d655f475c 100644 --- a/idea/testData/completion/basic/InImport.kt +++ b/idea/testData/completion/basic/InImport.kt @@ -6,4 +6,5 @@ class Test { } -// EXIST: AbstractList, Date, Random, concurrent \ No newline at end of file +// EXIST: AbstractList, Date +// EXIST_JAVA_ONLY: Random, concurrent \ No newline at end of file diff --git a/idea/testData/completion/basic/NoObjectInTypePosition.kt b/idea/testData/completion/basic/NoObjectInTypePosition.kt index a2ad7955995..4b790d52618 100644 --- a/idea/testData/completion/basic/NoObjectInTypePosition.kt +++ b/idea/testData/completion/basic/NoObjectInTypePosition.kt @@ -4,5 +4,5 @@ fun test() { val a : Named } -// TIMES: 2 +// TIME: 2 // ABSENT: NamedObject diff --git a/idea/testData/completion/basic/OnlyScopedClassesWithoutExplicit.kt b/idea/testData/completion/basic/OnlyScopedClassesWithoutExplicit.kt index 80dd034f048..f6ce087c2ae 100644 --- a/idea/testData/completion/basic/OnlyScopedClassesWithoutExplicit.kt +++ b/idea/testData/completion/basic/OnlyScopedClassesWithoutExplicit.kt @@ -4,7 +4,6 @@ fun firstFun() { val a = In } -// RUNTIME: 1 // TIME: 0 // EXIST: Int~(jet) // ABSENT: Int~(jet.runtime.SharedVar) \ No newline at end of file diff --git a/idea/testData/completion/basic/ShortClassNamesInTypePosition.kt b/idea/testData/completion/basic/ShortClassNamesInTypePosition.kt new file mode 100644 index 00000000000..55b7749f0ed --- /dev/null +++ b/idea/testData/completion/basic/ShortClassNamesInTypePosition.kt @@ -0,0 +1,10 @@ +package testing + +class Hello() { + fun test() { + val a : S + } +} + +// EXIST: Set, Short, ShortArray +// ABSENT: toString diff --git a/idea/testData/completion/basic/StandardJetArrayFirst.kt b/idea/testData/completion/basic/StandardJetArrayFirst.kt index af30eafbab2..3975218b443 100644 --- a/idea/testData/completion/basic/StandardJetArrayFirst.kt +++ b/idea/testData/completion/basic/StandardJetArrayFirst.kt @@ -2,11 +2,12 @@ fun main(args: Array) { Array } -// COMPLETE: 2 +// TIME: 2 // WITH_ORDER: 1 // EXIST: Array~(jet) -// EXIST: Array~(java.sql) - +// EXIST_JAVA_ONLY: Array~(java.sql) +// EXIST_JAVA_ONLY: ArrayList~ (java.util) +// EXIST_JS_ONLY: ArrayList~(java.util) diff --git a/idea/testData/completion/basic/StandardJetDoubleFirst.kt b/idea/testData/completion/basic/StandardJetDoubleFirst.kt index 71d4e6eb6da..49aaa47e695 100644 --- a/idea/testData/completion/basic/StandardJetDoubleFirst.kt +++ b/idea/testData/completion/basic/StandardJetDoubleFirst.kt @@ -1,7 +1,8 @@ fun some(a: Double) { } -// COMPLETE: 2 +// TIME: 2 // WITH_ORDER: 1 // EXIST: Double~(jet) -// EXIST: Double~(java.lang) \ No newline at end of file +// EXIST_JAVA_ONLY: Double~(java.lang) +// EXIST: DoubleArray~(jet) diff --git a/idea/testData/completion/basic/TopLevelNonImportedExtFun.jar b/idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.jar similarity index 100% rename from idea/testData/completion/basic/TopLevelNonImportedExtFun.jar rename to idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.jar diff --git a/idea/testData/completion/basic/TopLevelNonImportedExtFun.kt b/idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.kt similarity index 100% rename from idea/testData/completion/basic/TopLevelNonImportedExtFun.kt rename to idea/testData/completion/basic/custom/TopLevelNonImportedExtFun.kt diff --git a/idea/testData/completion/basic/TopLevelNonImportedFun.jar b/idea/testData/completion/basic/custom/TopLevelNonImportedFun.jar similarity index 100% rename from idea/testData/completion/basic/TopLevelNonImportedFun.jar rename to idea/testData/completion/basic/custom/TopLevelNonImportedFun.jar diff --git a/idea/testData/completion/basic/TopLevelNonImportedFun.kt b/idea/testData/completion/basic/custom/TopLevelNonImportedFun.kt similarity index 100% rename from idea/testData/completion/basic/TopLevelNonImportedFun.kt rename to idea/testData/completion/basic/custom/TopLevelNonImportedFun.kt diff --git a/idea/testData/completion/basic/ExtensionFromStandardLibrary.kt b/idea/testData/completion/basic/java/ExtensionFromStandardLibrary.kt similarity index 93% rename from idea/testData/completion/basic/ExtensionFromStandardLibrary.kt rename to idea/testData/completion/basic/java/ExtensionFromStandardLibrary.kt index 898d674715a..f28da6dbde1 100644 --- a/idea/testData/completion/basic/ExtensionFromStandardLibrary.kt +++ b/idea/testData/completion/basic/java/ExtensionFromStandardLibrary.kt @@ -7,7 +7,6 @@ fun firstFun() { a.toLinke } -// RUNTIME: 1 // TIME: 1 // EXIST: toLinkedList@toLinkedList()~for jet.Iterable in kotlin // NUMBER: 1 diff --git a/idea/testData/completion/basic/InPackage.kt b/idea/testData/completion/basic/java/InPackage.kt similarity index 100% rename from idea/testData/completion/basic/InPackage.kt rename to idea/testData/completion/basic/java/InPackage.kt diff --git a/idea/testData/completion/basic/JavaClassNames.kt b/idea/testData/completion/basic/java/JavaClassNames.kt similarity index 64% rename from idea/testData/completion/basic/JavaClassNames.kt rename to idea/testData/completion/basic/java/JavaClassNames.kt index 554921794bc..82d4f9010c1 100644 --- a/idea/testData/completion/basic/JavaClassNames.kt +++ b/idea/testData/completion/basic/java/JavaClassNames.kt @@ -7,4 +7,6 @@ class Hello() { } } -// EXIST: SortedMap, Short, Socket \ No newline at end of file +// TIME: 2 +// EXIST: SortedMap, Short, Socket +// ABSENT: hashSetOf \ No newline at end of file diff --git a/idea/testData/completion/basic/NoClassNameDuplicationForRuntimeClass.kt b/idea/testData/completion/basic/java/NoClassNameDuplicationForRuntimeClass.kt similarity index 58% rename from idea/testData/completion/basic/NoClassNameDuplicationForRuntimeClass.kt rename to idea/testData/completion/basic/java/NoClassNameDuplicationForRuntimeClass.kt index 10e828f8f85..4b9d2114d1c 100644 --- a/idea/testData/completion/basic/NoClassNameDuplicationForRuntimeClass.kt +++ b/idea/testData/completion/basic/java/NoClassNameDuplicationForRuntimeClass.kt @@ -1,6 +1,5 @@ val x = LineIterator -// RUNTIME: 1 // TIME: 1 -// EXIST: LineIterator +// EXIST: LineIterator~(kotlin.io) // NUMBER: 1 diff --git a/idea/testData/completion/basic/NoImportedJavaClassDuplication.kt b/idea/testData/completion/basic/java/NoImportedJavaClassDuplication.kt similarity index 70% rename from idea/testData/completion/basic/NoImportedJavaClassDuplication.kt rename to idea/testData/completion/basic/java/NoImportedJavaClassDuplication.kt index 05139ad47c7..fddd4bd02fc 100644 --- a/idea/testData/completion/basic/NoImportedJavaClassDuplication.kt +++ b/idea/testData/completion/basic/java/NoImportedJavaClassDuplication.kt @@ -3,5 +3,5 @@ import java.io.InputStreamReader val x = InputStreamReader // TIME: 1 -// EXIST: InputStreamReader +// EXIST: InputStreamReader~(java.io) // NUMBER: 1 \ No newline at end of file diff --git a/idea/testData/completion/basic/TopLevelFromStandardLibrary.kt b/idea/testData/completion/basic/java/TopLevelFromStandardLibrary.kt similarity index 94% rename from idea/testData/completion/basic/TopLevelFromStandardLibrary.kt rename to idea/testData/completion/basic/java/TopLevelFromStandardLibrary.kt index d8fc717363c..8c00b0e6d85 100644 --- a/idea/testData/completion/basic/TopLevelFromStandardLibrary.kt +++ b/idea/testData/completion/basic/java/TopLevelFromStandardLibrary.kt @@ -7,5 +7,4 @@ fun someFun() { // Important: This test checks that completion will find top level functions from jars. // If you going to update it make sure that methods are not auto-imported -// RUNTIME: 1 // EXIST: measureTimeNano, measureTimeMillis \ No newline at end of file diff --git a/idea/testData/completion/basic/TopLevelFromStandardLibraryWithoutParam.kt b/idea/testData/completion/basic/java/TopLevelFromStandardLibraryWithoutParam.kt similarity index 95% rename from idea/testData/completion/basic/TopLevelFromStandardLibraryWithoutParam.kt rename to idea/testData/completion/basic/java/TopLevelFromStandardLibraryWithoutParam.kt index 30079d1d389..f13e4fd0173 100644 --- a/idea/testData/completion/basic/TopLevelFromStandardLibraryWithoutParam.kt +++ b/idea/testData/completion/basic/java/TopLevelFromStandardLibraryWithoutParam.kt @@ -7,5 +7,4 @@ fun someFun() { // Important: This test checks that completion will find top level functions from jars. // If you going to update it make sure that methods are not auto-imported -// RUNTIME: 1 // EXIST: defaultDocumentBuilderFactory \ No newline at end of file diff --git a/idea/testData/completion/basic/js/InPackage.kt b/idea/testData/completion/basic/js/InPackage.kt new file mode 100644 index 00000000000..d81f8c666f1 --- /dev/null +++ b/idea/testData/completion/basic/js/InPackage.kt @@ -0,0 +1,4 @@ +package js. + +// EXIST: dom +// ABSENT: Date, JSON, capitalize \ No newline at end of file diff --git a/idea/testData/completion/basic/js/JSStd.kt b/idea/testData/completion/basic/js/JSStd.kt new file mode 100644 index 00000000000..a4209d746fa --- /dev/null +++ b/idea/testData/completion/basic/js/JSStd.kt @@ -0,0 +1,4 @@ +val test = JSON. + +// EXIST: stringify +// EXIST: parse diff --git a/idea/tests/org/jetbrains/jet/completion/AbstractJavaCompletionTest.java b/idea/tests/org/jetbrains/jet/completion/AbstractJavaCompletionTest.java new file mode 100644 index 00000000000..f09c22ec88d --- /dev/null +++ b/idea/tests/org/jetbrains/jet/completion/AbstractJavaCompletionTest.java @@ -0,0 +1,34 @@ +/* + * 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; + +import com.intellij.testFramework.LightProjectDescriptor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.plugin.JetWithJdkAndRuntimeLightProjectDescriptor; + +public abstract class AbstractJavaCompletionTest extends JetFixtureCompletionBaseTestCase { + @NotNull + @Override + protected LightProjectDescriptor getProjectDescriptor() { + return JetWithJdkAndRuntimeLightProjectDescriptor.INSTANCE; + } + + @Override + public ExpectedCompletionUtils.Platform getPlatform() { + return ExpectedCompletionUtils.Platform.JAVA; + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/completion/AbstractJetJSCompletionTest.java b/idea/tests/org/jetbrains/jet/completion/AbstractJetJSCompletionTest.java new file mode 100644 index 00000000000..8196389426d --- /dev/null +++ b/idea/tests/org/jetbrains/jet/completion/AbstractJetJSCompletionTest.java @@ -0,0 +1,34 @@ +/* + * 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; + +import com.intellij.testFramework.LightProjectDescriptor; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.plugin.JetStdJSProjectDescriptor; + +public abstract class AbstractJetJSCompletionTest extends JetFixtureCompletionBaseTestCase { + @NotNull + @Override + protected LightProjectDescriptor getProjectDescriptor() { + return JetStdJSProjectDescriptor.INSTANCE; + } + + @Override + public ExpectedCompletionUtils.Platform getPlatform() { + return ExpectedCompletionUtils.Platform.JS; + } +} diff --git a/idea/tests/org/jetbrains/jet/completion/ExpectedCompletionUtils.java b/idea/tests/org/jetbrains/jet/completion/ExpectedCompletionUtils.java index d30a29ea997..263dcc98e05 100644 --- a/idea/tests/org/jetbrains/jet/completion/ExpectedCompletionUtils.java +++ b/idea/tests/org/jetbrains/jet/completion/ExpectedCompletionUtils.java @@ -18,6 +18,7 @@ package org.jetbrains.jet.completion; import com.google.common.base.Function; import com.google.common.collect.Collections2; +import com.google.common.collect.ImmutableList; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementPresentation; import com.intellij.openapi.util.text.StringUtil; @@ -97,30 +98,44 @@ public class ExpectedCompletionUtils { } } - public static final String EXIST_LINE_PREFIX = "// EXIST:"; - public static final String EXIST_JS_LINE_PREFIX = "// EXIST_JS:"; - public static final String EXIST_JAVA_LINE_PREFIX = "// EXIST_JAVA:"; + private static final String EXIST_LINE_PREFIX = "EXIST:"; - public static final String ABSENT_LINE_PREFIX = "// ABSENT:"; - public static final String ABSENT_JS_LINE_PREFIX = "// ABSENT_JS:"; - public static final String ABSENT_JAVA_LINE_PREFIX = "// ABSENT_JAVA:"; + private static final String ABSENT_LINE_PREFIX = "ABSENT:"; + private static final String ABSENT_JS_LINE_PREFIX = "ABSENT_JS:"; + private static final String ABSENT_JAVA_LINE_PREFIX = "ABSENT_JAVA:"; - public static final String NUMBER_LINE_PREFIX = "// NUMBER:"; - public static final String NUMBER_JS_LINE_PREFIX = "// NUMBER_JS:"; - public static final String NUMBER_JAVA_LINE_PREFIX = "// NUMBER_JAVA:"; + private static final String EXIST_JAVA_ONLY_LINE_PREFIX = "EXIST_JAVA_ONLY:"; + private static final String EXIST_JS_ONLY_LINE_PREFIX = "EXIST_JS_ONLY:"; - public static final String EXECUTION_TIME_PREFIX = "// TIME:"; - public static final String WITH_ORDER_PREFIX = "// WITH_ORDER:"; + private static final String NUMBER_LINE_PREFIX = "NUMBER:"; + private static final String NUMBER_JS_LINE_PREFIX = "NUMBER_JS:"; + private static final String NUMBER_JAVA_LINE_PREFIX = "NUMBER_JAVA:"; + + private static final String EXECUTION_TIME_PREFIX = "TIME:"; + private static final String WITH_ORDER_PREFIX = "WITH_ORDER:"; + + public static final List KNOWN_PREFIXES = ImmutableList.of( + EXIST_LINE_PREFIX, + ABSENT_LINE_PREFIX, + ABSENT_JS_LINE_PREFIX, + ABSENT_JAVA_LINE_PREFIX, + EXIST_JAVA_ONLY_LINE_PREFIX, + EXIST_JS_ONLY_LINE_PREFIX, + NUMBER_LINE_PREFIX, + NUMBER_JS_LINE_PREFIX, + NUMBER_JAVA_LINE_PREFIX, + EXECUTION_TIME_PREFIX, + WITH_ORDER_PREFIX); @NotNull public static CompletionProposal[] itemsShouldExist(String fileText, Platform platform) { switch (platform) { case ALL: - return processProposalAssertions(fileText, EXIST_LINE_PREFIX, EXIST_JAVA_LINE_PREFIX, EXIST_JS_LINE_PREFIX); + return processProposalAssertions(fileText, EXIST_LINE_PREFIX); case JAVA: - return processProposalAssertions(fileText, EXIST_LINE_PREFIX, EXIST_JAVA_LINE_PREFIX); + return processProposalAssertions(fileText, EXIST_LINE_PREFIX, EXIST_JAVA_ONLY_LINE_PREFIX); case JS: - return processProposalAssertions(fileText, EXIST_LINE_PREFIX, EXIST_JS_LINE_PREFIX); + return processProposalAssertions(fileText, EXIST_LINE_PREFIX, EXIST_JS_ONLY_LINE_PREFIX); } throw new IllegalArgumentException("platform"); @@ -130,11 +145,11 @@ public class ExpectedCompletionUtils { public static CompletionProposal[] itemsShouldAbsent(String fileText, Platform platform) { switch (platform) { case ALL: - return processProposalAssertions(fileText, ABSENT_LINE_PREFIX, EXIST_JAVA_LINE_PREFIX, EXIST_JS_LINE_PREFIX); + return processProposalAssertions(fileText, ABSENT_LINE_PREFIX); case JAVA: - return processProposalAssertions(fileText, ABSENT_LINE_PREFIX, ABSENT_JAVA_LINE_PREFIX); + return processProposalAssertions(fileText, ABSENT_LINE_PREFIX, ABSENT_JAVA_LINE_PREFIX, EXIST_JS_ONLY_LINE_PREFIX); case JS: - return processProposalAssertions(fileText, ABSENT_LINE_PREFIX, ABSENT_JS_LINE_PREFIX); + return processProposalAssertions(fileText, ABSENT_LINE_PREFIX, ABSENT_JS_LINE_PREFIX, EXIST_JAVA_ONLY_LINE_PREFIX); } throw new IllegalArgumentException("platform"); @@ -191,7 +206,11 @@ public class ExpectedCompletionUtils { return InTextDirectivesUtils.getPrefixedInt(fileText, WITH_ORDER_PREFIX) != null; } - protected static void assertContainsRenderedItems(CompletionProposal[] expected, LookupElement[] items, boolean checkOrder) { + public static void assertDirectivesValid(String fileText) { + InTextDirectivesUtils.assertHasUnknownPrefixes(fileText, KNOWN_PREFIXES); + } + + public static void assertContainsRenderedItems(CompletionProposal[] expected, LookupElement[] items, boolean checkOrder) { List itemsInformation = getItemsInformation(items); String allItemsString = listToString(itemsInformation); @@ -230,7 +249,7 @@ public class ExpectedCompletionUtils { return InTextDirectivesUtils.getPrefixedInt(fileText, NUMBER_LINE_PREFIX); } - protected static void assertNotContainsRenderedItems(CompletionProposal[] unexpected,LookupElement[] items) { + public static void assertNotContainsRenderedItems(CompletionProposal[] unexpected,LookupElement[] items) { List itemsInformation = getItemsInformation(items); String allItemsString = listToString(itemsInformation); @@ -242,7 +261,7 @@ public class ExpectedCompletionUtils { } } - protected static List getItemsInformation(LookupElement[] items) { + public static List getItemsInformation(LookupElement[] items) { LookupElementPresentation presentation = new LookupElementPresentation(); List result = new ArrayList(); @@ -257,7 +276,7 @@ public class ExpectedCompletionUtils { return result; } - protected static String listToString(Collection items) { + public static String listToString(Collection items) { return StringUtil.join( Collections2.transform(items, new Function() { @Override diff --git a/idea/tests/org/jetbrains/jet/completion/JetBasicCompletionTest.java b/idea/tests/org/jetbrains/jet/completion/JetBasicCompletionTest.java deleted file mode 100644 index 30dc77acc66..00000000000 --- a/idea/tests/org/jetbrains/jet/completion/JetBasicCompletionTest.java +++ /dev/null @@ -1,321 +0,0 @@ -/* - * 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; - -import com.intellij.openapi.roots.OrderRootType; -import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor; -import com.intellij.openapi.vfs.VfsUtil; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.plugin.PluginTestCaseBase; -import org.jetbrains.jet.testing.ConfigLibraryUtil; - -import java.io.File; - -public class JetBasicCompletionTest extends JetCompletionTestBase { - public void testAutoCastAfterIf() { - doTest(); - } - - public void testAutoCastAfterIfMethod() { - doTest(); - } - - public void testAutoCastForThis() { - doTest(); - } - - public void testAutoCastInWhen() { - doTest(); - } - - public void testBasicAny() { - doTest(); - } - - public void testBasicInt() { - doTest(); - } - - public void testBeforeDotInCall() { - doTest(); - } - - public void testCallLocalLambda() { - doTest(); - } - - public void testDoNotCompleteForErrorReceivers() { - doTest(); - } - - public void testExtendClassName() { - doTest(); - } - - public void testExtendQualifiedClassName() { - doTest(); - } - - public void testExtensionFromStandardLibrary() { - doTest(); - } - - public void testExtensionFunReceiver() { - doTest(); - } - - public void testExtensionWithAdditionalTypeParameters() { - doTest(); - } - - public void testExtensionWithGenericParamInReceiver() { - doTest(); - } - - public void testExtensionWithGenericReceiver() { - doTest(); - } - - public void testExtensionWithInternalGenericParameters() { - doTest(); - } - - public void testExtensionWithManyTypeParamsInReceiver() { - doTest(); - } - - public void testExtensionForProperty() { - doTest(); - } - - public void testFromImports() { - doTest(); - } - - public void testFunctionCompletionFormatting() { - doTest(); - } - - public void testInCallExpression() { - doTest(); - } - - public void testInClassInitializer() { - doTest(); - } - - public void testInClassPropertyAccessor() { - doTest(); - } - - public void testInEmptyImport() { - doTest(); - } - - public void testInFileWithMultiDeclaration() { - doTest(); - } - - public void testInFileWithTypedef() { - doTest(); - } - - public void testInFunInClassInitializer() { - doTest(); - } - - public void testInGlobalPropertyInitializer() { - doTest(); - } - - public void testInImport() { - doTest(); - } - - public void testInInitializerInPropertyAccessor() { - doTest(); - } - - public void testInLocalObjectDeclaration() { - doTest(); - } - - public void testInLongDotQualifiedExpression() { - doTest(); - } - - public void testInMiddleOfNamespace() { - doTest(); - } - - public void testInMiddleOfPackage() { - doTest(); - } - - public void testInObjectInDelegationSpecifier() { - doTest(); - } - - public void testInPackage() { - doTest(); - } - - public void testInPackageBegin() { - doTest(); - } - - public void testInTypeAnnotation() { - doTest(); - } - - public void testJavaClassNames() { - doTest(); - } - - public void testJavaPackage() { - doTest(); - } - - public void testLocalMultideclarationValues() { - doTest(); - } - - public void testNamedObject() { - doTest(); - } - - public void testNoClassNameDuplication() { - doTest(); - } - - public void testNoClassNameDuplicationForRuntimeClass() { - doTest(); - } - - public void testNoEmptyNamespace() { - doTest(); - } - - public void testNoImportedJavaClassDuplication() { - doTest(); - } - - public void testNoObjectInTypePosition() { - doTest(); - } - - public void testNoTopLevelCompletionInQualifiedUserTypes() { - doTest(); - } - - public void testOnlyScopedClassesWithoutExplicit() { - doTest(); - } - - public void testOverloadFunctions() { - doTest(); - } - - public void testStandardJetArrayFirst() { - doTest(); - } - - public void testStandardJetDoubleFirst() { - doTest(); - } - - public void testSubpackageInFun() { - doTest(); - } - - public void testTopLevelFromStandardLibrary() { - doTest(); - } - - public void testTopLevelFromStandardLibraryWithoutParam() { - doTest(); - } - - public void testVariableClassName() { - doTest(); - } - - public void testVisibilityClassMembersFromExternal() { - doTest(); - } - - public void testVisibilityClassMembersFromExternalForce() { - doTest(); - } - - public void testVisibilityInSubclass() { - doTest(); - } - - public void testVisibilityInSubclassForce() { - doTest(); - } - - public void testCompletionInSetter() { - doTest(); - } - - public void testClassRedeclaration1() { - doTest(); - } - - public void testClassRedeclaration2() { - doTest(); - } - - public void testObjectRedeclaration1() { - doTest(); - } - - public void testObjectRedeclaration2() { - doTest(); - } - - public void testTopLevelNonImportedFun() { - doTestWithJar(); - } - - public void testTopLevelNonImportedExtFun() { - doTestWithJar(); - } - - public void doTestWithJar() { - NewLibraryEditor editor = new NewLibraryEditor(null, null); - editor.setName("doTestWithJarLib"); - editor.addRoot(VfsUtil.getUrlForLibraryRoot(new File(getTestDataPath() + "/" + getTestName(false) + ".jar")), OrderRootType.CLASSES); - - try { - ConfigLibraryUtil.configureLibrary(getModule(), getFullJavaJDK(), editor); - doTest(); - } - finally { - ConfigLibraryUtil.unConfigureLibrary(getModule(), getFullJavaJDK(), editor.getName()); - } - } - - @NotNull - @Override - protected String getTestDataPath() { - return new File(PluginTestCaseBase.getTestDataPathBase(), "/completion/basic").getPath() + - File.separator; - } -} diff --git a/idea/tests/org/jetbrains/jet/completion/JetBasicJSCompletionTest.java b/idea/tests/org/jetbrains/jet/completion/JetBasicJSCompletionTest.java new file mode 100644 index 00000000000..c37c9186192 --- /dev/null +++ b/idea/tests/org/jetbrains/jet/completion/JetBasicJSCompletionTest.java @@ -0,0 +1,367 @@ +/* + * 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; + +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.AbstractJetJSCompletionTest; + +/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@InnerTestClasses({JetBasicJSCompletionTest.Basic.class, JetBasicJSCompletionTest.Js.class}) +public class JetBasicJSCompletionTest extends AbstractJetJSCompletionTest { + @TestMetadata("idea/testData/completion/basic") + public static class Basic extends AbstractJetJSCompletionTest { + public void testAllFilesPresentInBasic() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/basic"), Pattern.compile("^(.+)\\.kt$"), false); + } + + @TestMetadata("AutoCastAfterIf.kt") + public void testAutoCastAfterIf() throws Exception { + doTest("idea/testData/completion/basic/AutoCastAfterIf.kt"); + } + + @TestMetadata("AutoCastAfterIfMethod.kt") + public void testAutoCastAfterIfMethod() throws Exception { + doTest("idea/testData/completion/basic/AutoCastAfterIfMethod.kt"); + } + + @TestMetadata("AutoCastForThis.kt") + public void testAutoCastForThis() throws Exception { + doTest("idea/testData/completion/basic/AutoCastForThis.kt"); + } + + @TestMetadata("AutoCastInWhen.kt") + public void testAutoCastInWhen() throws Exception { + doTest("idea/testData/completion/basic/AutoCastInWhen.kt"); + } + + @TestMetadata("BasicAny.kt") + public void testBasicAny() throws Exception { + doTest("idea/testData/completion/basic/BasicAny.kt"); + } + + @TestMetadata("BasicInt.kt") + public void testBasicInt() throws Exception { + doTest("idea/testData/completion/basic/BasicInt.kt"); + } + + @TestMetadata("BeforeDotInCall.kt") + public void testBeforeDotInCall() throws Exception { + doTest("idea/testData/completion/basic/BeforeDotInCall.kt"); + } + + @TestMetadata("CallLocalLambda.kt") + public void testCallLocalLambda() throws Exception { + doTest("idea/testData/completion/basic/CallLocalLambda.kt"); + } + + @TestMetadata("ClassRedeclaration1.kt") + public void testClassRedeclaration1() throws Exception { + doTest("idea/testData/completion/basic/ClassRedeclaration1.kt"); + } + + @TestMetadata("ClassRedeclaration2.kt") + public void testClassRedeclaration2() throws Exception { + doTest("idea/testData/completion/basic/ClassRedeclaration2.kt"); + } + + @TestMetadata("CompletionInSetter.kt") + public void testCompletionInSetter() throws Exception { + doTest("idea/testData/completion/basic/CompletionInSetter.kt"); + } + + @TestMetadata("DoNotCompleteForErrorReceivers.kt") + public void testDoNotCompleteForErrorReceivers() throws Exception { + doTest("idea/testData/completion/basic/DoNotCompleteForErrorReceivers.kt"); + } + + @TestMetadata("ExtendClassName.kt") + public void testExtendClassName() throws Exception { + doTest("idea/testData/completion/basic/ExtendClassName.kt"); + } + + @TestMetadata("ExtendQualifiedClassName.kt") + public void testExtendQualifiedClassName() throws Exception { + doTest("idea/testData/completion/basic/ExtendQualifiedClassName.kt"); + } + + @TestMetadata("ExtensionForProperty.kt") + public void testExtensionForProperty() throws Exception { + doTest("idea/testData/completion/basic/ExtensionForProperty.kt"); + } + + @TestMetadata("ExtensionFunReceiver.kt") + public void testExtensionFunReceiver() throws Exception { + doTest("idea/testData/completion/basic/ExtensionFunReceiver.kt"); + } + + @TestMetadata("ExtensionWithAdditionalTypeParameters.kt") + public void testExtensionWithAdditionalTypeParameters() throws Exception { + doTest("idea/testData/completion/basic/ExtensionWithAdditionalTypeParameters.kt"); + } + + @TestMetadata("ExtensionWithGenericParamInReceiver.kt") + public void testExtensionWithGenericParamInReceiver() throws Exception { + doTest("idea/testData/completion/basic/ExtensionWithGenericParamInReceiver.kt"); + } + + @TestMetadata("ExtensionWithGenericReceiver.kt") + public void testExtensionWithGenericReceiver() throws Exception { + doTest("idea/testData/completion/basic/ExtensionWithGenericReceiver.kt"); + } + + @TestMetadata("ExtensionWithInternalGenericParameters.kt") + public void testExtensionWithInternalGenericParameters() throws Exception { + doTest("idea/testData/completion/basic/ExtensionWithInternalGenericParameters.kt"); + } + + @TestMetadata("ExtensionWithManyTypeParamsInReceiver.kt") + public void testExtensionWithManyTypeParamsInReceiver() throws Exception { + doTest("idea/testData/completion/basic/ExtensionWithManyTypeParamsInReceiver.kt"); + } + + @TestMetadata("FromImports.kt") + public void testFromImports() throws Exception { + doTest("idea/testData/completion/basic/FromImports.kt"); + } + + @TestMetadata("FunctionCompletionFormatting.kt") + public void testFunctionCompletionFormatting() throws Exception { + doTest("idea/testData/completion/basic/FunctionCompletionFormatting.kt"); + } + + @TestMetadata("InCallExpression.kt") + public void testInCallExpression() throws Exception { + doTest("idea/testData/completion/basic/InCallExpression.kt"); + } + + @TestMetadata("InClassInitializer.kt") + public void testInClassInitializer() throws Exception { + doTest("idea/testData/completion/basic/InClassInitializer.kt"); + } + + @TestMetadata("InClassPropertyAccessor.kt") + public void testInClassPropertyAccessor() throws Exception { + doTest("idea/testData/completion/basic/InClassPropertyAccessor.kt"); + } + + @TestMetadata("InEmptyImport.kt") + public void testInEmptyImport() throws Exception { + doTest("idea/testData/completion/basic/InEmptyImport.kt"); + } + + @TestMetadata("InFileWithMultiDeclaration.kt") + public void testInFileWithMultiDeclaration() throws Exception { + doTest("idea/testData/completion/basic/InFileWithMultiDeclaration.kt"); + } + + @TestMetadata("InFileWithTypedef.kt") + public void testInFileWithTypedef() throws Exception { + doTest("idea/testData/completion/basic/InFileWithTypedef.kt"); + } + + @TestMetadata("InFunInClassInitializer.kt") + public void testInFunInClassInitializer() throws Exception { + doTest("idea/testData/completion/basic/InFunInClassInitializer.kt"); + } + + @TestMetadata("InGlobalPropertyInitializer.kt") + public void testInGlobalPropertyInitializer() throws Exception { + doTest("idea/testData/completion/basic/InGlobalPropertyInitializer.kt"); + } + + @TestMetadata("InImport.kt") + public void testInImport() throws Exception { + doTest("idea/testData/completion/basic/InImport.kt"); + } + + @TestMetadata("InInitializerInPropertyAccessor.kt") + public void testInInitializerInPropertyAccessor() throws Exception { + doTest("idea/testData/completion/basic/InInitializerInPropertyAccessor.kt"); + } + + @TestMetadata("InLocalObjectDeclaration.kt") + public void testInLocalObjectDeclaration() throws Exception { + doTest("idea/testData/completion/basic/InLocalObjectDeclaration.kt"); + } + + @TestMetadata("InLongDotQualifiedExpression.kt") + public void testInLongDotQualifiedExpression() throws Exception { + doTest("idea/testData/completion/basic/InLongDotQualifiedExpression.kt"); + } + + @TestMetadata("InMiddleOfNamespace.kt") + public void testInMiddleOfNamespace() throws Exception { + doTest("idea/testData/completion/basic/InMiddleOfNamespace.kt"); + } + + @TestMetadata("InMiddleOfPackage.kt") + public void testInMiddleOfPackage() throws Exception { + doTest("idea/testData/completion/basic/InMiddleOfPackage.kt"); + } + + @TestMetadata("InObjectInDelegationSpecifier.kt") + public void testInObjectInDelegationSpecifier() throws Exception { + doTest("idea/testData/completion/basic/InObjectInDelegationSpecifier.kt"); + } + + @TestMetadata("InPackageBegin.kt") + public void testInPackageBegin() throws Exception { + doTest("idea/testData/completion/basic/InPackageBegin.kt"); + } + + @TestMetadata("InTypeAnnotation.kt") + public void testInTypeAnnotation() throws Exception { + doTest("idea/testData/completion/basic/InTypeAnnotation.kt"); + } + + @TestMetadata("JavaPackage.kt") + public void testJavaPackage() throws Exception { + doTest("idea/testData/completion/basic/JavaPackage.kt"); + } + + @TestMetadata("LocalMultideclarationValues.kt") + public void testLocalMultideclarationValues() throws Exception { + doTest("idea/testData/completion/basic/LocalMultideclarationValues.kt"); + } + + @TestMetadata("NamedObject.kt") + public void testNamedObject() throws Exception { + doTest("idea/testData/completion/basic/NamedObject.kt"); + } + + @TestMetadata("NoClassNameDuplication.kt") + public void testNoClassNameDuplication() throws Exception { + doTest("idea/testData/completion/basic/NoClassNameDuplication.kt"); + } + + @TestMetadata("NoEmptyNamespace.kt") + public void testNoEmptyNamespace() throws Exception { + doTest("idea/testData/completion/basic/NoEmptyNamespace.kt"); + } + + @TestMetadata("NoObjectInTypePosition.kt") + public void testNoObjectInTypePosition() throws Exception { + doTest("idea/testData/completion/basic/NoObjectInTypePosition.kt"); + } + + @TestMetadata("NoTopLevelCompletionInQualifiedUserTypes.kt") + public void testNoTopLevelCompletionInQualifiedUserTypes() throws Exception { + doTest("idea/testData/completion/basic/NoTopLevelCompletionInQualifiedUserTypes.kt"); + } + + @TestMetadata("ObjectRedeclaration1.kt") + public void testObjectRedeclaration1() throws Exception { + doTest("idea/testData/completion/basic/ObjectRedeclaration1.kt"); + } + + @TestMetadata("ObjectRedeclaration2.kt") + public void testObjectRedeclaration2() throws Exception { + doTest("idea/testData/completion/basic/ObjectRedeclaration2.kt"); + } + + @TestMetadata("OnlyScopedClassesWithoutExplicit.kt") + public void testOnlyScopedClassesWithoutExplicit() throws Exception { + doTest("idea/testData/completion/basic/OnlyScopedClassesWithoutExplicit.kt"); + } + + @TestMetadata("OverloadFunctions.kt") + public void testOverloadFunctions() throws Exception { + doTest("idea/testData/completion/basic/OverloadFunctions.kt"); + } + + @TestMetadata("ShortClassNamesInTypePosition.kt") + public void testShortClassNamesInTypePosition() throws Exception { + doTest("idea/testData/completion/basic/ShortClassNamesInTypePosition.kt"); + } + + @TestMetadata("StandardJetArrayFirst.kt") + public void testStandardJetArrayFirst() throws Exception { + doTest("idea/testData/completion/basic/StandardJetArrayFirst.kt"); + } + + @TestMetadata("StandardJetDoubleFirst.kt") + public void testStandardJetDoubleFirst() throws Exception { + doTest("idea/testData/completion/basic/StandardJetDoubleFirst.kt"); + } + + @TestMetadata("SubpackageInFun.kt") + public void testSubpackageInFun() throws Exception { + doTest("idea/testData/completion/basic/SubpackageInFun.kt"); + } + + @TestMetadata("VariableClassName.kt") + public void testVariableClassName() throws Exception { + doTest("idea/testData/completion/basic/VariableClassName.kt"); + } + + @TestMetadata("VisibilityClassMembersFromExternal.kt") + public void testVisibilityClassMembersFromExternal() throws Exception { + doTest("idea/testData/completion/basic/VisibilityClassMembersFromExternal.kt"); + } + + @TestMetadata("VisibilityClassMembersFromExternalForce.kt") + public void testVisibilityClassMembersFromExternalForce() throws Exception { + doTest("idea/testData/completion/basic/VisibilityClassMembersFromExternalForce.kt"); + } + + @TestMetadata("VisibilityInSubclass.kt") + public void testVisibilityInSubclass() throws Exception { + doTest("idea/testData/completion/basic/VisibilityInSubclass.kt"); + } + + @TestMetadata("VisibilityInSubclassForce.kt") + public void testVisibilityInSubclassForce() throws Exception { + doTest("idea/testData/completion/basic/VisibilityInSubclassForce.kt"); + } + + } + + @TestMetadata("idea/testData/completion/basic/js") + public static class Js extends AbstractJetJSCompletionTest { + public void testAllFilesPresentInJs() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/basic/js"), Pattern.compile("^(.+)\\.kt$"), false); + } + + @TestMetadata("InPackage.kt") + public void testInPackage() throws Exception { + doTest("idea/testData/completion/basic/js/InPackage.kt"); + } + + @TestMetadata("JSStd.kt") + public void testJSStd() throws Exception { + doTest("idea/testData/completion/basic/js/JSStd.kt"); + } + + } + + public static Test suite() { + TestSuite suite = new TestSuite("JetBasicJSCompletionTest"); + suite.addTestSuite(Basic.class); + suite.addTestSuite(Js.class); + return suite; + } +} diff --git a/idea/tests/org/jetbrains/jet/completion/JetBasicJavaCompletionTest.java b/idea/tests/org/jetbrains/jet/completion/JetBasicJavaCompletionTest.java new file mode 100644 index 00000000000..fdc6f187cab --- /dev/null +++ b/idea/tests/org/jetbrains/jet/completion/JetBasicJavaCompletionTest.java @@ -0,0 +1,392 @@ +/* + * 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; + +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.AbstractJavaCompletionTest; + +/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@InnerTestClasses({JetBasicJavaCompletionTest.Basic.class, JetBasicJavaCompletionTest.Java.class}) +public class JetBasicJavaCompletionTest extends AbstractJavaCompletionTest { + @TestMetadata("idea/testData/completion/basic") + public static class Basic extends AbstractJavaCompletionTest { + public void testAllFilesPresentInBasic() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/basic"), Pattern.compile("^(.+)\\.kt$"), false); + } + + @TestMetadata("AutoCastAfterIf.kt") + public void testAutoCastAfterIf() throws Exception { + doTest("idea/testData/completion/basic/AutoCastAfterIf.kt"); + } + + @TestMetadata("AutoCastAfterIfMethod.kt") + public void testAutoCastAfterIfMethod() throws Exception { + doTest("idea/testData/completion/basic/AutoCastAfterIfMethod.kt"); + } + + @TestMetadata("AutoCastForThis.kt") + public void testAutoCastForThis() throws Exception { + doTest("idea/testData/completion/basic/AutoCastForThis.kt"); + } + + @TestMetadata("AutoCastInWhen.kt") + public void testAutoCastInWhen() throws Exception { + doTest("idea/testData/completion/basic/AutoCastInWhen.kt"); + } + + @TestMetadata("BasicAny.kt") + public void testBasicAny() throws Exception { + doTest("idea/testData/completion/basic/BasicAny.kt"); + } + + @TestMetadata("BasicInt.kt") + public void testBasicInt() throws Exception { + doTest("idea/testData/completion/basic/BasicInt.kt"); + } + + @TestMetadata("BeforeDotInCall.kt") + public void testBeforeDotInCall() throws Exception { + doTest("idea/testData/completion/basic/BeforeDotInCall.kt"); + } + + @TestMetadata("CallLocalLambda.kt") + public void testCallLocalLambda() throws Exception { + doTest("idea/testData/completion/basic/CallLocalLambda.kt"); + } + + @TestMetadata("ClassRedeclaration1.kt") + public void testClassRedeclaration1() throws Exception { + doTest("idea/testData/completion/basic/ClassRedeclaration1.kt"); + } + + @TestMetadata("ClassRedeclaration2.kt") + public void testClassRedeclaration2() throws Exception { + doTest("idea/testData/completion/basic/ClassRedeclaration2.kt"); + } + + @TestMetadata("CompletionInSetter.kt") + public void testCompletionInSetter() throws Exception { + doTest("idea/testData/completion/basic/CompletionInSetter.kt"); + } + + @TestMetadata("DoNotCompleteForErrorReceivers.kt") + public void testDoNotCompleteForErrorReceivers() throws Exception { + doTest("idea/testData/completion/basic/DoNotCompleteForErrorReceivers.kt"); + } + + @TestMetadata("ExtendClassName.kt") + public void testExtendClassName() throws Exception { + doTest("idea/testData/completion/basic/ExtendClassName.kt"); + } + + @TestMetadata("ExtendQualifiedClassName.kt") + public void testExtendQualifiedClassName() throws Exception { + doTest("idea/testData/completion/basic/ExtendQualifiedClassName.kt"); + } + + @TestMetadata("ExtensionForProperty.kt") + public void testExtensionForProperty() throws Exception { + doTest("idea/testData/completion/basic/ExtensionForProperty.kt"); + } + + @TestMetadata("ExtensionFunReceiver.kt") + public void testExtensionFunReceiver() throws Exception { + doTest("idea/testData/completion/basic/ExtensionFunReceiver.kt"); + } + + @TestMetadata("ExtensionWithAdditionalTypeParameters.kt") + public void testExtensionWithAdditionalTypeParameters() throws Exception { + doTest("idea/testData/completion/basic/ExtensionWithAdditionalTypeParameters.kt"); + } + + @TestMetadata("ExtensionWithGenericParamInReceiver.kt") + public void testExtensionWithGenericParamInReceiver() throws Exception { + doTest("idea/testData/completion/basic/ExtensionWithGenericParamInReceiver.kt"); + } + + @TestMetadata("ExtensionWithGenericReceiver.kt") + public void testExtensionWithGenericReceiver() throws Exception { + doTest("idea/testData/completion/basic/ExtensionWithGenericReceiver.kt"); + } + + @TestMetadata("ExtensionWithInternalGenericParameters.kt") + public void testExtensionWithInternalGenericParameters() throws Exception { + doTest("idea/testData/completion/basic/ExtensionWithInternalGenericParameters.kt"); + } + + @TestMetadata("ExtensionWithManyTypeParamsInReceiver.kt") + public void testExtensionWithManyTypeParamsInReceiver() throws Exception { + doTest("idea/testData/completion/basic/ExtensionWithManyTypeParamsInReceiver.kt"); + } + + @TestMetadata("FromImports.kt") + public void testFromImports() throws Exception { + doTest("idea/testData/completion/basic/FromImports.kt"); + } + + @TestMetadata("FunctionCompletionFormatting.kt") + public void testFunctionCompletionFormatting() throws Exception { + doTest("idea/testData/completion/basic/FunctionCompletionFormatting.kt"); + } + + @TestMetadata("InCallExpression.kt") + public void testInCallExpression() throws Exception { + doTest("idea/testData/completion/basic/InCallExpression.kt"); + } + + @TestMetadata("InClassInitializer.kt") + public void testInClassInitializer() throws Exception { + doTest("idea/testData/completion/basic/InClassInitializer.kt"); + } + + @TestMetadata("InClassPropertyAccessor.kt") + public void testInClassPropertyAccessor() throws Exception { + doTest("idea/testData/completion/basic/InClassPropertyAccessor.kt"); + } + + @TestMetadata("InEmptyImport.kt") + public void testInEmptyImport() throws Exception { + doTest("idea/testData/completion/basic/InEmptyImport.kt"); + } + + @TestMetadata("InFileWithMultiDeclaration.kt") + public void testInFileWithMultiDeclaration() throws Exception { + doTest("idea/testData/completion/basic/InFileWithMultiDeclaration.kt"); + } + + @TestMetadata("InFileWithTypedef.kt") + public void testInFileWithTypedef() throws Exception { + doTest("idea/testData/completion/basic/InFileWithTypedef.kt"); + } + + @TestMetadata("InFunInClassInitializer.kt") + public void testInFunInClassInitializer() throws Exception { + doTest("idea/testData/completion/basic/InFunInClassInitializer.kt"); + } + + @TestMetadata("InGlobalPropertyInitializer.kt") + public void testInGlobalPropertyInitializer() throws Exception { + doTest("idea/testData/completion/basic/InGlobalPropertyInitializer.kt"); + } + + @TestMetadata("InImport.kt") + public void testInImport() throws Exception { + doTest("idea/testData/completion/basic/InImport.kt"); + } + + @TestMetadata("InInitializerInPropertyAccessor.kt") + public void testInInitializerInPropertyAccessor() throws Exception { + doTest("idea/testData/completion/basic/InInitializerInPropertyAccessor.kt"); + } + + @TestMetadata("InLocalObjectDeclaration.kt") + public void testInLocalObjectDeclaration() throws Exception { + doTest("idea/testData/completion/basic/InLocalObjectDeclaration.kt"); + } + + @TestMetadata("InLongDotQualifiedExpression.kt") + public void testInLongDotQualifiedExpression() throws Exception { + doTest("idea/testData/completion/basic/InLongDotQualifiedExpression.kt"); + } + + @TestMetadata("InMiddleOfNamespace.kt") + public void testInMiddleOfNamespace() throws Exception { + doTest("idea/testData/completion/basic/InMiddleOfNamespace.kt"); + } + + @TestMetadata("InMiddleOfPackage.kt") + public void testInMiddleOfPackage() throws Exception { + doTest("idea/testData/completion/basic/InMiddleOfPackage.kt"); + } + + @TestMetadata("InObjectInDelegationSpecifier.kt") + public void testInObjectInDelegationSpecifier() throws Exception { + doTest("idea/testData/completion/basic/InObjectInDelegationSpecifier.kt"); + } + + @TestMetadata("InPackageBegin.kt") + public void testInPackageBegin() throws Exception { + doTest("idea/testData/completion/basic/InPackageBegin.kt"); + } + + @TestMetadata("InTypeAnnotation.kt") + public void testInTypeAnnotation() throws Exception { + doTest("idea/testData/completion/basic/InTypeAnnotation.kt"); + } + + @TestMetadata("JavaPackage.kt") + public void testJavaPackage() throws Exception { + doTest("idea/testData/completion/basic/JavaPackage.kt"); + } + + @TestMetadata("LocalMultideclarationValues.kt") + public void testLocalMultideclarationValues() throws Exception { + doTest("idea/testData/completion/basic/LocalMultideclarationValues.kt"); + } + + @TestMetadata("NamedObject.kt") + public void testNamedObject() throws Exception { + doTest("idea/testData/completion/basic/NamedObject.kt"); + } + + @TestMetadata("NoClassNameDuplication.kt") + public void testNoClassNameDuplication() throws Exception { + doTest("idea/testData/completion/basic/NoClassNameDuplication.kt"); + } + + @TestMetadata("NoEmptyNamespace.kt") + public void testNoEmptyNamespace() throws Exception { + doTest("idea/testData/completion/basic/NoEmptyNamespace.kt"); + } + + @TestMetadata("NoObjectInTypePosition.kt") + public void testNoObjectInTypePosition() throws Exception { + doTest("idea/testData/completion/basic/NoObjectInTypePosition.kt"); + } + + @TestMetadata("NoTopLevelCompletionInQualifiedUserTypes.kt") + public void testNoTopLevelCompletionInQualifiedUserTypes() throws Exception { + doTest("idea/testData/completion/basic/NoTopLevelCompletionInQualifiedUserTypes.kt"); + } + + @TestMetadata("ObjectRedeclaration1.kt") + public void testObjectRedeclaration1() throws Exception { + doTest("idea/testData/completion/basic/ObjectRedeclaration1.kt"); + } + + @TestMetadata("ObjectRedeclaration2.kt") + public void testObjectRedeclaration2() throws Exception { + doTest("idea/testData/completion/basic/ObjectRedeclaration2.kt"); + } + + @TestMetadata("OnlyScopedClassesWithoutExplicit.kt") + public void testOnlyScopedClassesWithoutExplicit() throws Exception { + doTest("idea/testData/completion/basic/OnlyScopedClassesWithoutExplicit.kt"); + } + + @TestMetadata("OverloadFunctions.kt") + public void testOverloadFunctions() throws Exception { + doTest("idea/testData/completion/basic/OverloadFunctions.kt"); + } + + @TestMetadata("ShortClassNamesInTypePosition.kt") + public void testShortClassNamesInTypePosition() throws Exception { + doTest("idea/testData/completion/basic/ShortClassNamesInTypePosition.kt"); + } + + @TestMetadata("StandardJetArrayFirst.kt") + public void testStandardJetArrayFirst() throws Exception { + doTest("idea/testData/completion/basic/StandardJetArrayFirst.kt"); + } + + @TestMetadata("StandardJetDoubleFirst.kt") + public void testStandardJetDoubleFirst() throws Exception { + doTest("idea/testData/completion/basic/StandardJetDoubleFirst.kt"); + } + + @TestMetadata("SubpackageInFun.kt") + public void testSubpackageInFun() throws Exception { + doTest("idea/testData/completion/basic/SubpackageInFun.kt"); + } + + @TestMetadata("VariableClassName.kt") + public void testVariableClassName() throws Exception { + doTest("idea/testData/completion/basic/VariableClassName.kt"); + } + + @TestMetadata("VisibilityClassMembersFromExternal.kt") + public void testVisibilityClassMembersFromExternal() throws Exception { + doTest("idea/testData/completion/basic/VisibilityClassMembersFromExternal.kt"); + } + + @TestMetadata("VisibilityClassMembersFromExternalForce.kt") + public void testVisibilityClassMembersFromExternalForce() throws Exception { + doTest("idea/testData/completion/basic/VisibilityClassMembersFromExternalForce.kt"); + } + + @TestMetadata("VisibilityInSubclass.kt") + public void testVisibilityInSubclass() throws Exception { + doTest("idea/testData/completion/basic/VisibilityInSubclass.kt"); + } + + @TestMetadata("VisibilityInSubclassForce.kt") + public void testVisibilityInSubclassForce() throws Exception { + doTest("idea/testData/completion/basic/VisibilityInSubclassForce.kt"); + } + + } + + @TestMetadata("idea/testData/completion/basic/java") + public static class Java extends AbstractJavaCompletionTest { + public void testAllFilesPresentInJava() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/basic/java"), Pattern.compile("^(.+)\\.kt$"), false); + } + + @TestMetadata("ExtensionFromStandardLibrary.kt") + public void testExtensionFromStandardLibrary() throws Exception { + doTest("idea/testData/completion/basic/java/ExtensionFromStandardLibrary.kt"); + } + + @TestMetadata("InPackage.kt") + public void testInPackage() throws Exception { + doTest("idea/testData/completion/basic/java/InPackage.kt"); + } + + @TestMetadata("JavaClassNames.kt") + public void testJavaClassNames() throws Exception { + doTest("idea/testData/completion/basic/java/JavaClassNames.kt"); + } + + @TestMetadata("NoClassNameDuplicationForRuntimeClass.kt") + public void testNoClassNameDuplicationForRuntimeClass() throws Exception { + doTest("idea/testData/completion/basic/java/NoClassNameDuplicationForRuntimeClass.kt"); + } + + @TestMetadata("NoImportedJavaClassDuplication.kt") + public void testNoImportedJavaClassDuplication() throws Exception { + doTest("idea/testData/completion/basic/java/NoImportedJavaClassDuplication.kt"); + } + + @TestMetadata("TopLevelFromStandardLibrary.kt") + public void testTopLevelFromStandardLibrary() throws Exception { + doTest("idea/testData/completion/basic/java/TopLevelFromStandardLibrary.kt"); + } + + @TestMetadata("TopLevelFromStandardLibraryWithoutParam.kt") + public void testTopLevelFromStandardLibraryWithoutParam() throws Exception { + doTest("idea/testData/completion/basic/java/TopLevelFromStandardLibraryWithoutParam.kt"); + } + + } + + public static Test suite() { + TestSuite suite = new TestSuite("JetBasicJavaCompletionTest"); + suite.addTestSuite(Basic.class); + suite.addTestSuite(Java.class); + return suite; + } +} diff --git a/idea/tests/org/jetbrains/jet/completion/JetFixtureCompletionBaseTestCase.java b/idea/tests/org/jetbrains/jet/completion/JetFixtureCompletionBaseTestCase.java new file mode 100644 index 00000000000..24141d98b8d --- /dev/null +++ b/idea/tests/org/jetbrains/jet/completion/JetFixtureCompletionBaseTestCase.java @@ -0,0 +1,88 @@ +/* + * 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; + +import com.intellij.codeInsight.CodeInsightSettings; +import com.intellij.codeInsight.completion.CompletionType; +import com.intellij.codeInsight.lookup.LookupElement; +import com.intellij.testFramework.LightProjectDescriptor; +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.plugin.JetStdJSProjectDescriptor; + +public abstract class JetFixtureCompletionBaseTestCase extends LightCodeInsightFixtureTestCase { + private boolean autocompleteSetting; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + autocompleteSetting = CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION; + CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = false; + } + + @Override + protected void tearDown() throws Exception { + CodeInsightSettings.getInstance().AUTOCOMPLETE_ON_CODE_COMPLETION = autocompleteSetting; + + super.tearDown(); + } + + public abstract ExpectedCompletionUtils.Platform getPlatform(); + + public void doTest(String testPath) { + myFixture.configureByFile(testPath); + + String fileText = myFixture.getFile().getText(); + + Integer completionTime = ExpectedCompletionUtils.getExecutionTime(fileText); + + myFixture.complete(CompletionType.BASIC, completionTime == null ? 0 : completionTime); + + ExpectedCompletionUtils.assertDirectivesValid(fileText); + + ExpectedCompletionUtils.CompletionProposal[] expected = ExpectedCompletionUtils.itemsShouldExist(fileText, getPlatform()); + ExpectedCompletionUtils.CompletionProposal[] unexpected = ExpectedCompletionUtils.itemsShouldAbsent(fileText, getPlatform()); + Integer itemsNumber = ExpectedCompletionUtils.getExpectedNumber(fileText, getPlatform()); + + assertTrue("Should be some assertions about completion", + expected.length != 0 || unexpected.length != 0 || itemsNumber != null); + + LookupElement[] items = myFixture.getLookupElements(); + + if (items == null) { + items = new LookupElement[0]; + } + + ExpectedCompletionUtils.assertContainsRenderedItems(expected, items, ExpectedCompletionUtils.isWithOrder(fileText)); + ExpectedCompletionUtils.assertNotContainsRenderedItems(unexpected, items); + + if (itemsNumber != null) { + assertEquals( + String.format( + "Invalid number of completion items: %s", + ExpectedCompletionUtils.listToString(ExpectedCompletionUtils.getItemsInformation(items))), + itemsNumber.intValue(), items.length); + } + } + + @NotNull + @Override + protected LightProjectDescriptor getProjectDescriptor() { + return JetStdJSProjectDescriptor.INSTANCE; + } +}