diff --git a/annotations/com/intellij/testFramework/fixtures/annotations.xml b/annotations/com/intellij/testFramework/fixtures/annotations.xml
index d9c8ac57348..409755505e2 100644
--- a/annotations/com/intellij/testFramework/fixtures/annotations.xml
+++ b/annotations/com/intellij/testFramework/fixtures/annotations.xml
@@ -2,4 +2,9 @@
-
-
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/compiler/tests/org/jetbrains/jet/InTextDirectivesUtils.java b/compiler/tests/org/jetbrains/jet/InTextDirectivesUtils.java
index d1abb001b1d..c8b116f4cec 100644
--- a/compiler/tests/org/jetbrains/jet/InTextDirectivesUtils.java
+++ b/compiler/tests/org/jetbrains/jet/InTextDirectivesUtils.java
@@ -45,12 +45,12 @@ public final class InTextDirectivesUtils {
}
@NotNull
- public static String[] findArrayWithPrefixes(String fileText, String... prefixes) {
+ public static String[] findArrayWithPrefixes(@NotNull String fileText, @NotNull String... prefixes) {
return ArrayUtil.toStringArray(findListWithPrefixes(fileText, prefixes));
}
@NotNull
- public static List findListWithPrefixes(String fileText, String... prefixes) {
+ public static List findListWithPrefixes(@NotNull String fileText, @NotNull String... prefixes) {
List result = new ArrayList();
for (String line : findLinesWithPrefixesRemoved(fileText, prefixes)) {
diff --git a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java
index 03953c2fb15..25bcd4483c3 100644
--- a/generators/org/jetbrains/jet/generators/tests/GenerateTests.java
+++ b/generators/org/jetbrains/jet/generators/tests/GenerateTests.java
@@ -31,6 +31,7 @@ import org.jetbrains.jet.completion.AbstractJavaCompletionTest;
import org.jetbrains.jet.completion.AbstractJavaWithLibCompletionTest;
import org.jetbrains.jet.completion.AbstractJetJSCompletionTest;
import org.jetbrains.jet.completion.AbstractKeywordCompletionTest;
+import org.jetbrains.jet.completion.weighers.AbstractCompletionWeigherTest;
import org.jetbrains.jet.descriptors.serialization.AbstractDescriptorSerializationTest;
import org.jetbrains.jet.editor.quickDoc.AbstractJetQuickDocProviderTest;
import org.jetbrains.jet.findUsages.AbstractJetFindUsagesTest;
@@ -460,6 +461,13 @@ public class GenerateTests {
testModelWithPattern("idea/testData/findUsages", "^(.+).0.kt$", "doTest")
);
+ generateTest(
+ "idea/tests",
+ "CompletionWeigherTestGenerated",
+ AbstractCompletionWeigherTest.class,
+ testModel("idea/testData/completion/weighers", true, "doTest")
+ );
+
generateTest(
"idea/tests/",
"ConfigureProjectByChangingFileTestGenerated",
diff --git a/idea/testData/completion/weighers/DeprecatedFun.kt b/idea/testData/completion/weighers/DeprecatedFun.kt
index 14e5243af3d..de6492b6c4a 100644
--- a/idea/testData/completion/weighers/DeprecatedFun.kt
+++ b/idea/testData/completion/weighers/DeprecatedFun.kt
@@ -1,7 +1,9 @@
fun foo1() {}
deprecated("Use foo3 instead") fun foo2() {}
-fun foo3 {}
+fun foo3() {}
fun test() {
-
-}
\ No newline at end of file
+ foo
+}
+
+// ORDER: foo1, foo3, foo2
\ No newline at end of file
diff --git a/idea/testData/completion/weighers/LocalValuesAndParams.kt b/idea/testData/completion/weighers/LocalValuesAndParams.kt
index dc3d4ca6ecf..e8d20d8f61d 100644
--- a/idea/testData/completion/weighers/LocalValuesAndParams.kt
+++ b/idea/testData/completion/weighers/LocalValuesAndParams.kt
@@ -2,5 +2,7 @@ val initGlobal = 12
fun test(initParam : Int) {
val initLocal = "Test"
-
-}
\ No newline at end of file
+ init
+}
+
+// ORDER: initLocal, initParam, initGlobal
\ No newline at end of file
diff --git a/idea/testData/completion/weighers/LocalsBeforeKeywords.kt b/idea/testData/completion/weighers/LocalsBeforeKeywords.kt
index e6ff31110c6..ad72690a83c 100644
--- a/idea/testData/completion/weighers/LocalsBeforeKeywords.kt
+++ b/idea/testData/completion/weighers/LocalsBeforeKeywords.kt
@@ -1,4 +1,6 @@
fun test() {
val a = 12
-
-}
\ No newline at end of file
+ a
+}
+
+// ORDER: a, as
\ No newline at end of file
diff --git a/idea/testData/completion/weighers/LocalsPropertiesKeywords.kt b/idea/testData/completion/weighers/LocalsPropertiesKeywords.kt
index 80f1f572d25..4dae3796958 100644
--- a/idea/testData/completion/weighers/LocalsPropertiesKeywords.kt
+++ b/idea/testData/completion/weighers/LocalsPropertiesKeywords.kt
@@ -1,4 +1,6 @@
fun test(fals: Int) {
val falt = 111
- f
-}
\ No newline at end of file
+ fa
+}
+
+// ORDER: fals, falt, false
\ No newline at end of file
diff --git a/idea/testData/completion/weighers/ParametersBeforeKeywords.kt b/idea/testData/completion/weighers/ParametersBeforeKeywords.kt
index 4d0df5ffac9..e6850e53c6d 100644
--- a/idea/testData/completion/weighers/ParametersBeforeKeywords.kt
+++ b/idea/testData/completion/weighers/ParametersBeforeKeywords.kt
@@ -1,3 +1,5 @@
-fun bar(fo: Int) {
-
-}
\ No newline at end of file
+fun bar(fop: Int) {
+ fo
+}
+
+// ORDER: fop, for (... in ...) {...}
\ No newline at end of file
diff --git a/idea/testData/completion/weighers/TemplatesAndKeywordsLast.kt b/idea/testData/completion/weighers/TemplatesAndKeywordsLast.kt
index 98d92ebcf7f..e707565edb7 100644
--- a/idea/testData/completion/weighers/TemplatesAndKeywordsLast.kt
+++ b/idea/testData/completion/weighers/TemplatesAndKeywordsLast.kt
@@ -1,4 +1,6 @@
fun main(variables: Array) {
val values = ""
-
-}
\ No newline at end of file
+ va
+}
+
+// ORDER: values, variables, val ... = ..., var ... = ..., vararg
\ No newline at end of file
diff --git a/idea/tests/org/jetbrains/jet/completion/weighers/AbstractCompletionWeigherTest.kt b/idea/tests/org/jetbrains/jet/completion/weighers/AbstractCompletionWeigherTest.kt
new file mode 100644
index 00000000000..2286e6a7b60
--- /dev/null
+++ b/idea/tests/org/jetbrains/jet/completion/weighers/AbstractCompletionWeigherTest.kt
@@ -0,0 +1,44 @@
+/*
+ * 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.weighers
+
+import com.intellij.codeInsight.completion.CompletionType
+import org.jetbrains.jet.InTextDirectivesUtils
+import java.io.File
+import org.jetbrains.jet.plugin.PluginTestCaseBase
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
+import org.testng.Assert
+
+public abstract class AbstractCompletionWeigherTest() : LightCodeInsightFixtureTestCase() {
+ fun doTest(path: String) {
+ val fixture = myFixture!!
+
+ fixture.configureByFile(path)
+ val text = fixture.getEditor()!!.getDocument().getText()
+
+ val items = InTextDirectivesUtils.findArrayWithPrefixes(text, "// ORDER:")
+ Assert.assertTrue(!items.isEmpty(), """Some items should be defined with "// ORDER:" directive""")
+
+ fixture.complete(CompletionType.BASIC, 1)
+ fixture.assertPreferredCompletionItems(0, *items)
+ }
+
+ protected override fun getTestDataPath() : String? {
+ return File(PluginTestCaseBase.getTestDataPathBase(), "/completion/weighers").getPath() + File.separator
+ }
+}
+
diff --git a/idea/tests/org/jetbrains/jet/completion/weighers/CompletionWeigherTest.java b/idea/tests/org/jetbrains/jet/completion/weighers/CompletionWeigherTest.java
deleted file mode 100644
index e79aadc9966..00000000000
--- a/idea/tests/org/jetbrains/jet/completion/weighers/CompletionWeigherTest.java
+++ /dev/null
@@ -1,62 +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.weighers;
-
-import com.intellij.codeInsight.completion.CompletionAutoPopupTestCase;
-import com.intellij.openapi.application.Result;
-import com.intellij.openapi.command.WriteCommandAction;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.jet.plugin.PluginTestCaseBase;
-
-public class CompletionWeigherTest extends CompletionAutoPopupTestCase {
- public void testLocalValuesAndParams() {
- doTest("init", "initLocal", "initParam", "initGlobal");
- }
-
- public void testTemplatesAndKeywordsLast() {
- doTest("va", "values", "variables", "val ... = ...", "var ... = ...", "vararg");
- }
-
- public void testDeprecatedFun() {
- doTest("foo", "foo1", "foo3", "foo2");
- }
-
- public void testLocalsBeforeKeywords() {
- doTest("a", "a", "as");
- }
-
- public void testParametersBeforeKeywords() {
- doTest("fo", "fo", "for (... in ...) {...}");
- }
-
- public void testLocalsPropertiesKeywords() {
- doTest("a", "fals", "falt", "false");
- }
-
- public void doTest(String type, @NonNls String... expected) {
- new WriteCommandAction(myFixture.getProject(), myFixture.getFile()) {
- @Override
- protected void run(Result result) throws Throwable {
- myFixture.setTestDataPath(PluginTestCaseBase.getTestDataPathBase() + "/completion/weighers/");
- myFixture.configureByFile(getTestName(false) + ".kt");
- }
- }.execute();
-
- type(type);
- myFixture.assertPreferredCompletionItems(0, expected);
- }
-}
diff --git a/idea/tests/org/jetbrains/jet/completion/weighers/CompletionWeigherTestGenerated.java b/idea/tests/org/jetbrains/jet/completion/weighers/CompletionWeigherTestGenerated.java
new file mode 100644
index 00000000000..8ab8a40329e
--- /dev/null
+++ b/idea/tests/org/jetbrains/jet/completion/weighers/CompletionWeigherTestGenerated.java
@@ -0,0 +1,63 @@
+/*
+ * 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.weighers;
+
+import org.jetbrains.jet.JetTestUtils;
+import org.jetbrains.jet.test.TestMetadata;
+
+import java.io.File;
+import java.util.regex.Pattern;
+
+/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
+@SuppressWarnings("all")
+@TestMetadata("idea/testData/completion/weighers")
+public class CompletionWeigherTestGenerated extends AbstractCompletionWeigherTest {
+ public void testAllFilesPresentInWeighers() throws Exception {
+ JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/completion/weighers"), Pattern.compile("^(.+)\\.kt$"), true);
+ }
+
+ @TestMetadata("DeprecatedFun.kt")
+ public void testDeprecatedFun() throws Exception {
+ doTest("idea/testData/completion/weighers/DeprecatedFun.kt");
+ }
+
+ @TestMetadata("LocalValuesAndParams.kt")
+ public void testLocalValuesAndParams() throws Exception {
+ doTest("idea/testData/completion/weighers/LocalValuesAndParams.kt");
+ }
+
+ @TestMetadata("LocalsBeforeKeywords.kt")
+ public void testLocalsBeforeKeywords() throws Exception {
+ doTest("idea/testData/completion/weighers/LocalsBeforeKeywords.kt");
+ }
+
+ @TestMetadata("LocalsPropertiesKeywords.kt")
+ public void testLocalsPropertiesKeywords() throws Exception {
+ doTest("idea/testData/completion/weighers/LocalsPropertiesKeywords.kt");
+ }
+
+ @TestMetadata("ParametersBeforeKeywords.kt")
+ public void testParametersBeforeKeywords() throws Exception {
+ doTest("idea/testData/completion/weighers/ParametersBeforeKeywords.kt");
+ }
+
+ @TestMetadata("TemplatesAndKeywordsLast.kt")
+ public void testTemplatesAndKeywordsLast() throws Exception {
+ doTest("idea/testData/completion/weighers/TemplatesAndKeywordsLast.kt");
+ }
+
+}