From 11f9c055fdca31d6136eba3c38ada8ed70bf6cd3 Mon Sep 17 00:00:00 2001 From: Yoshinori Isogai Date: Sat, 28 Oct 2017 04:59:04 +0900 Subject: [PATCH] KT-20591: Show annotations in parameter info (#1358) Show annotations in parameter info #KT-20591 Fixed --- .../KotlinFunctionParameterInfoHandler.kt | 4 +++ .../annotations/ConstructorCall.kt | 11 ++++++++ .../annotations/ConstructorCallWithUseSite.kt | 13 +++++++++ .../parameterInfo/annotations/FunctionCall.kt | 12 +++++++++ .../functionCall/NoAnnotations.kt | 2 +- .../ParameterInfoTestGenerated.java | 27 +++++++++++++++++++ 6 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 idea/testData/parameterInfo/annotations/ConstructorCall.kt create mode 100644 idea/testData/parameterInfo/annotations/ConstructorCallWithUseSite.kt create mode 100644 idea/testData/parameterInfo/annotations/FunctionCall.kt diff --git a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/KotlinFunctionParameterInfoHandler.kt b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/KotlinFunctionParameterInfoHandler.kt index 887a7472bac..f98b65cc2ad 100644 --- a/idea/src/org/jetbrains/kotlin/idea/parameterInfo/KotlinFunctionParameterInfoHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/parameterInfo/KotlinFunctionParameterInfoHandler.kt @@ -254,6 +254,10 @@ abstract class KotlinParameterInfoWithCallHandlerBase) +} + +/* +Text: (@Fancy foo: Int), Disabled: false, Strikeout: false, Green: true +*/ diff --git a/idea/testData/parameterInfo/annotations/ConstructorCallWithUseSite.kt b/idea/testData/parameterInfo/annotations/ConstructorCallWithUseSite.kt new file mode 100644 index 00000000000..f993eedc53a --- /dev/null +++ b/idea/testData/parameterInfo/annotations/ConstructorCallWithUseSite.kt @@ -0,0 +1,13 @@ +// WITH_RUNTIME + +annotation class Fancy + +class Foo(@get:Fancy val foo: Int, @param:Fancy val foo1: Int, @set:Fancy val foo2: Int) + +fun bar() { + Foo() +} + +/* +Text: (foo: Int, @Fancy foo1: Int, foo2: Int), Disabled: false, Strikeout: false, Green: true +*/ \ No newline at end of file diff --git a/idea/testData/parameterInfo/annotations/FunctionCall.kt b/idea/testData/parameterInfo/annotations/FunctionCall.kt new file mode 100644 index 00000000000..3d84737c12f --- /dev/null +++ b/idea/testData/parameterInfo/annotations/FunctionCall.kt @@ -0,0 +1,12 @@ +annotation class Fancy + +private fun abc(@Fancy foo: Int) { +} + +fun foo() { + abc() +} + +/* +Text: (@Fancy foo: Int), Disabled: false, Strikeout: false, Green: true +*/ diff --git a/idea/testData/parameterInfo/functionCall/NoAnnotations.kt b/idea/testData/parameterInfo/functionCall/NoAnnotations.kt index d8b6f8a32f1..690c4848c62 100644 --- a/idea/testData/parameterInfo/functionCall/NoAnnotations.kt +++ b/idea/testData/parameterInfo/functionCall/NoAnnotations.kt @@ -3,4 +3,4 @@ fun foo(@Suppress("UNCHECKED_CAST") p: () -> Unit){} fun bar() { foo() } -//Text: (p: () -> Unit), Disabled: false, Strikeout: false, Green: true \ No newline at end of file +//Text: (@Suppress p: () -> Unit), Disabled: false, Strikeout: false, Green: true \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/ParameterInfoTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/ParameterInfoTestGenerated.java index fac529d9101..1d266b9f71b 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/ParameterInfoTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/parameterInfo/ParameterInfoTestGenerated.java @@ -36,6 +36,33 @@ public class ParameterInfoTestGenerated extends AbstractParameterInfoTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true, "withLib1/sharedLib", "withLib2/sharedLib", "withLib3/sharedLib"); } + @TestMetadata("idea/testData/parameterInfo/annotations") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Annotations extends AbstractParameterInfoTest { + public void testAllFilesPresentInAnnotations() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo/annotations"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("ConstructorCall.kt") + public void testConstructorCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/parameterInfo/annotations/ConstructorCall.kt"); + doTest(fileName); + } + + @TestMetadata("ConstructorCallWithUseSite.kt") + public void testConstructorCallWithUseSite() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/parameterInfo/annotations/ConstructorCallWithUseSite.kt"); + doTest(fileName); + } + + @TestMetadata("FunctionCall.kt") + public void testFunctionCall() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/parameterInfo/annotations/FunctionCall.kt"); + doTest(fileName); + } + } + @TestMetadata("idea/testData/parameterInfo/arrayAccess") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)