KT-20591: Show annotations in parameter info (#1358)

Show annotations in parameter info

 #KT-20591 Fixed
This commit is contained in:
Yoshinori Isogai
2017-10-28 04:59:04 +09:00
committed by Simon Ogorodnik
parent 2c4e023cba
commit 11f9c055fd
6 changed files with 68 additions and 1 deletions
@@ -254,6 +254,10 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
return buildString {
if (named) append("[")
parameter.annotations.getAllAnnotations().forEach {
it.annotation.fqName?.let { append("@${it.shortName().asString()} ") }
}
if (parameter.varargElementType != null) {
append("vararg ")
}
@@ -0,0 +1,11 @@
annotation class Fancy
class Foo(@Fancy foo: Int)
fun bar() {
Foo(<caret>)
}
/*
Text: (<highlight>@Fancy foo: Int</highlight>), Disabled: false, Strikeout: false, Green: true
*/
@@ -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(<caret>)
}
/*
Text: (<highlight>foo: Int</highlight>, @Fancy foo1: Int, foo2: Int), Disabled: false, Strikeout: false, Green: true
*/
+12
View File
@@ -0,0 +1,12 @@
annotation class Fancy
private fun abc(@Fancy foo: Int) {
}
fun foo() {
abc(<caret>)
}
/*
Text: (<highlight>@Fancy foo: Int</highlight>), Disabled: false, Strikeout: false, Green: true
*/
+1 -1
View File
@@ -3,4 +3,4 @@ fun foo(@Suppress("UNCHECKED_CAST") p: () -> Unit){}
fun bar() {
foo(<caret>)
}
//Text: (<highlight>p: () -> Unit</highlight>), Disabled: false, Strikeout: false, Green: true
//Text: (<highlight>@Suppress p: () -> Unit</highlight>), Disabled: false, Strikeout: false, Green: true
@@ -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)