Implement option for wrapping method annotations
This commit is contained in:
@@ -359,6 +359,9 @@ abstract class KotlinCommonBlock(
|
||||
return getWrappingStrategyForItemList(commonSettings.CLASS_ANNOTATION_WRAP,
|
||||
KtNodeTypes.ANNOTATION_ENTRY)
|
||||
|
||||
is KtNamedFunction ->
|
||||
return getWrappingStrategyForItemList(commonSettings.METHOD_ANNOTATION_WRAP,
|
||||
KtNodeTypes.ANNOTATION_ENTRY)
|
||||
}
|
||||
|
||||
elementType === KtNodeTypes.VALUE_PARAMETER ->
|
||||
@@ -366,6 +369,9 @@ abstract class KotlinCommonBlock(
|
||||
|
||||
node.psi is KtClassOrObject ->
|
||||
return wrapAfterAnnotation(commonSettings.CLASS_ANNOTATION_WRAP)
|
||||
|
||||
node.psi is KtNamedFunction ->
|
||||
return wrapAfterAnnotation(commonSettings.METHOD_ANNOTATION_WRAP)
|
||||
}
|
||||
|
||||
return WrappingStrategy.NoWrapping
|
||||
|
||||
+2
-1
@@ -34,7 +34,7 @@ class KotlinLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvide
|
||||
val test =
|
||||
12
|
||||
|
||||
fun foo1(i1: Int, i2: Int, i3: Int) : Int {
|
||||
@Deprecated("Foo") fun foo1(i1: Int, i2: Int, i3: Int) : Int {
|
||||
when (i1) {
|
||||
is Number -> 0
|
||||
else -> 1
|
||||
@@ -236,6 +236,7 @@ class KotlinLanguageCodeStyleSettingsProvider : LanguageCodeStyleSettingsProvide
|
||||
"CALL_PARAMETERS_WRAP",
|
||||
"METHOD_PARAMETERS_WRAP",
|
||||
"EXTENDS_LIST_WRAP",
|
||||
"METHOD_ANNOTATION_WRAP",
|
||||
"CLASS_ANNOTATION_WRAP",
|
||||
"PARAMETER_ANNOTATION_WRAP",
|
||||
"METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE",
|
||||
|
||||
+3
-1
@@ -4,6 +4,8 @@ internal class C {
|
||||
private fun memberFun(file: File) {}
|
||||
|
||||
companion object {
|
||||
@JvmStatic fun main(args: Array<String>) {}
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
package to
|
||||
|
||||
object JavaClass {
|
||||
@JvmStatic fun main(args: Array<String>) {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
println("Hello, world!")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@Deprecated("Foo")
|
||||
@Deprecated("Bar")
|
||||
fun foo() {
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
@Deprecated("Foo") @Deprecated("Bar") fun foo() {
|
||||
}
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
@annot
|
||||
@foo fun foo() {
|
||||
@foo
|
||||
fun foo() {
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
annot()
|
||||
@foo fun foo() {
|
||||
@foo
|
||||
fun foo() {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
annot()
|
||||
@foo fun foo() {
|
||||
@foo
|
||||
fun foo() {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
public
|
||||
@foo fun foo() {
|
||||
@foo
|
||||
fun foo() {
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
public
|
||||
@foo fun foo() {
|
||||
@foo
|
||||
fun foo() {
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -3,7 +3,8 @@
|
||||
annotation class X(val s: String)
|
||||
|
||||
class A(val n: Int) {
|
||||
internal @X("1") fun <T : Number> T.getFoo(): Boolean = toInt() - n > 1
|
||||
internal @X("1")
|
||||
fun <T : Number> T.getFoo(): Boolean = toInt() - n > 1
|
||||
}
|
||||
|
||||
fun test() {
|
||||
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true"
|
||||
|
||||
@Suppress("REDUNDANT_NULLABLE") fun foo(): String?<caret>? = null
|
||||
@Suppress("REDUNDANT_NULLABLE")
|
||||
fun foo(): String?? = null
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
// "Suppress 'REDUNDANT_NULLABLE' for fun foo" "true"
|
||||
|
||||
@Suppress("REDUNDANT_NULLABLE") fun foo(): String?<caret>? = null
|
||||
@Suppress("REDUNDANT_NULLABLE")
|
||||
fun foo(): String?? = null
|
||||
@@ -42,7 +42,8 @@ class Variety<C> {
|
||||
private fun privateFun() = 0
|
||||
fun <T> genFunB(p: T): T = p
|
||||
fun <T> genFunC(p: T): C where T : C = p
|
||||
@MemAnn fun annotatedFun() = 0
|
||||
@MemAnn
|
||||
fun annotatedFun() = 0
|
||||
final fun finalFun() = 0
|
||||
// property
|
||||
var publicProp = 0
|
||||
|
||||
@@ -21,7 +21,8 @@ abstract class A {
|
||||
var X = "1" + "2"
|
||||
|
||||
// INFO: {"checked": "true"}
|
||||
@JvmStatic fun foo2(n: Int): String {
|
||||
@JvmStatic
|
||||
fun foo2(n: Int): String {
|
||||
return "_" + n + "_"
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -19,7 +19,8 @@ abstract class A {
|
||||
var X = "1" + "2"
|
||||
|
||||
// INFO: {"checked": "true", "toAbstract": "true"}
|
||||
@JvmStatic fun foo2(n: Int): String {
|
||||
@JvmStatic
|
||||
fun foo2(n: Int): String {
|
||||
return "_" + n + "_"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ interface A {
|
||||
var X = "1" + "2"
|
||||
|
||||
// INFO: {"checked": "true"}
|
||||
@JvmStatic fun foo2(n: Int): String {
|
||||
@JvmStatic
|
||||
fun foo2(n: Int): String {
|
||||
return "_" + n + "_"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ class T {
|
||||
var X = "1" + "2"
|
||||
|
||||
// INFO: {"checked": "true"}
|
||||
@JvmStatic fun foo2(n: Int): String {
|
||||
@JvmStatic
|
||||
fun foo2(n: Int): String {
|
||||
return "_" + n + "_"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,6 +494,12 @@ public class FormatterTestGenerated extends AbstractFormatterTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("MethodAnnotationWrapping.after.kt")
|
||||
public void testMethodAnnotationWrapping() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/MethodAnnotationWrapping.after.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("MethodCall.after.kt")
|
||||
public void testMethodCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/formatter/MethodCall.after.kt");
|
||||
|
||||
Reference in New Issue
Block a user