diff --git a/idea/idea-completion/testData/weighers/basic/expectedType/ifConditionQualified.kt b/idea/idea-completion/testData/weighers/basic/expectedType/ifConditionQualified.kt new file mode 100644 index 00000000000..67d548e7b90 --- /dev/null +++ b/idea/idea-completion/testData/weighers/basic/expectedType/ifConditionQualified.kt @@ -0,0 +1,18 @@ +// FIR_COMPARISON + +object x { + val b: Boolean = true + val c: String = "true" + val d: Int = 1 + val e: Long = 1L + val f: Boolean = true + + fun foo(): Boolean = true +} + + +fun test() { + if(x.){ +} + +// ORDER: b, f, foo \ No newline at end of file diff --git a/idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunction.kt b/idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunction.kt new file mode 100644 index 00000000000..3ce0a0dce4b --- /dev/null +++ b/idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunction.kt @@ -0,0 +1,13 @@ +val b: Boolean = true +val c: String = "true" +val d: Int = 1 +val e: Long = 1L +val f: Boolean = true + +fun foo(): Boolean + +fun test(): Int { + return +} + +//ORDER: test, d \ No newline at end of file diff --git a/idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunctionQualifiedSelector.kt b/idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunctionQualifiedSelector.kt new file mode 100644 index 00000000000..df342ebe47d --- /dev/null +++ b/idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunctionQualifiedSelector.kt @@ -0,0 +1,17 @@ +// FIR_COMPARISON + +object x { + val b: Boolean = true + val c: String = "true" + val d: Int = 1 + val e: Long = 1L + val f: Boolean = true + + fun foo(): Int +} + +fun test(): Int { + return x. +} + +//ORDER: d, foo, f \ No newline at end of file diff --git a/idea/idea-completion/testData/weighers/basic/expectedType/returnFromLambda.kt b/idea/idea-completion/testData/weighers/basic/expectedType/returnFromLambda.kt new file mode 100644 index 00000000000..289e1935ed5 --- /dev/null +++ b/idea/idea-completion/testData/weighers/basic/expectedType/returnFromLambda.kt @@ -0,0 +1,17 @@ +// FIR_COMPARISON + +val a: Int +val b: String +val c: Long +val d: Int + +fun test(): Int { + receiveLambda { + return@receiveLambda + } + return 2 +} + +fun receiveLambda(x: () -> Int){} + +// ORDER: a, d, test \ No newline at end of file diff --git a/idea/idea-completion/testData/weighers/basic/expectedType/whileConditionQualified.kt b/idea/idea-completion/testData/weighers/basic/expectedType/whileConditionQualified.kt new file mode 100644 index 00000000000..bd75fcaa56c --- /dev/null +++ b/idea/idea-completion/testData/weighers/basic/expectedType/whileConditionQualified.kt @@ -0,0 +1,18 @@ +// FIR_COMPARISON + +object x { + val b: Boolean = true + val c: String = "true" + val d: Int = 1 + val e: Long = 1L + val f: Boolean = true + + fun foo(): Boolean = true +} + + +fun x() { + while(x.){ +} + +// ORDER: b, f, foo \ No newline at end of file diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/weighers/BasicCompletionWeigherTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/weighers/BasicCompletionWeigherTestGenerated.java index 471eb610940..161db59f2cb 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/weighers/BasicCompletionWeigherTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/weighers/BasicCompletionWeigherTestGenerated.java @@ -485,6 +485,44 @@ public class BasicCompletionWeigherTestGenerated extends AbstractBasicCompletion } } + @TestMetadata("idea/idea-completion/testData/weighers/basic/expectedType") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ExpectedType extends AbstractBasicCompletionWeigherTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInExpectedType() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-completion/testData/weighers/basic/expectedType"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true); + } + + @TestMetadata("ifConditionQualified.kt") + public void testIfConditionQualified() throws Exception { + runTest("idea/idea-completion/testData/weighers/basic/expectedType/ifConditionQualified.kt"); + } + + @TestMetadata("returnFromFunction.kt") + public void testReturnFromFunction() throws Exception { + runTest("idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunction.kt"); + } + + @TestMetadata("returnFromFunctionQualifiedSelector.kt") + public void testReturnFromFunctionQualifiedSelector() throws Exception { + runTest("idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunctionQualifiedSelector.kt"); + } + + @TestMetadata("returnFromLambda.kt") + public void testReturnFromLambda() throws Exception { + runTest("idea/idea-completion/testData/weighers/basic/expectedType/returnFromLambda.kt"); + } + + @TestMetadata("whileConditionQualified.kt") + public void testWhileConditionQualified() throws Exception { + runTest("idea/idea-completion/testData/weighers/basic/expectedType/whileConditionQualified.kt"); + } + } + @TestMetadata("idea/idea-completion/testData/weighers/basic/parameterNameAndType") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/completion/wheigher/HighLevelWeigherTestGenerated.java b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/completion/wheigher/HighLevelWeigherTestGenerated.java index 1db3ed5d37a..cce33472ca0 100644 --- a/idea/idea-fir/tests/org/jetbrains/kotlin/idea/completion/wheigher/HighLevelWeigherTestGenerated.java +++ b/idea/idea-fir/tests/org/jetbrains/kotlin/idea/completion/wheigher/HighLevelWeigherTestGenerated.java @@ -485,6 +485,44 @@ public class HighLevelWeigherTestGenerated extends AbstractHighLevelWeigherTest } } + @TestMetadata("idea/idea-completion/testData/weighers/basic/expectedType") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ExpectedType extends AbstractHighLevelWeigherTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInExpectedType() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/idea-completion/testData/weighers/basic/expectedType"), Pattern.compile("^([^.]+)\\.(kt|kts)$"), null, true); + } + + @TestMetadata("ifConditionQualified.kt") + public void testIfConditionQualified() throws Exception { + runTest("idea/idea-completion/testData/weighers/basic/expectedType/ifConditionQualified.kt"); + } + + @TestMetadata("returnFromFunction.kt") + public void testReturnFromFunction() throws Exception { + runTest("idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunction.kt"); + } + + @TestMetadata("returnFromFunctionQualifiedSelector.kt") + public void testReturnFromFunctionQualifiedSelector() throws Exception { + runTest("idea/idea-completion/testData/weighers/basic/expectedType/returnFromFunctionQualifiedSelector.kt"); + } + + @TestMetadata("returnFromLambda.kt") + public void testReturnFromLambda() throws Exception { + runTest("idea/idea-completion/testData/weighers/basic/expectedType/returnFromLambda.kt"); + } + + @TestMetadata("whileConditionQualified.kt") + public void testWhileConditionQualified() throws Exception { + runTest("idea/idea-completion/testData/weighers/basic/expectedType/whileConditionQualified.kt"); + } + } + @TestMetadata("idea/idea-completion/testData/weighers/basic/parameterNameAndType") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)