Insert empty lines after functions and properties (KT-4002)

#KT-4002 Fixed
This commit is contained in:
Nikolay Krasko
2014-10-10 17:50:37 +04:00
parent 22d33a5afa
commit b06b3ab4c4
54 changed files with 764 additions and 121 deletions
@@ -1,117 +1,121 @@
<root>
<item name='com.intellij.formatting.Spacing com.intellij.formatting.Spacing createKeepingFirstColumnSpacing(int, int, boolean, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.Spacing com.intellij.formatting.Spacing createSpacing(int, int, int, boolean, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder append(com.intellij.formatting.SpacingBuilder)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder after(com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder around(com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder around(com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder before(com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder beforeInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder beforeInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder betweenInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder betweenInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder withinPair(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder withinPairInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder blankLines(int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder lineBreakInCode()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder lineBreakInCodeIf(boolean)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder none()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spaceIf(boolean)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spaces(int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spacing(int, int, int, boolean, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.DependentSpacingRule com.intellij.formatting.DependentSpacingRule registerData(com.intellij.formatting.DependentSpacingRule.Anchor, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.Spacing com.intellij.formatting.Spacing createKeepingFirstColumnSpacing(int, int, boolean, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.Spacing com.intellij.formatting.Spacing createSpacing(int, int, int, boolean, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder append(com.intellij.formatting.SpacingBuilder)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder after(com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder afterInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder around(com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder around(com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder aroundInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder before(com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder beforeInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder beforeInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder between(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder betweenInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder betweenInside(com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.TokenSet, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder withinPair(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder com.intellij.formatting.SpacingBuilder.RuleBuilder withinPairInside(com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType, com.intellij.psi.tree.IElementType)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder blankLines(int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder lineBreakInCode()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder lineBreakInCodeIf(boolean)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder none()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spaceIf(boolean)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spaces(int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item
name='com.intellij.formatting.SpacingBuilder.RuleBuilder com.intellij.formatting.SpacingBuilder spacing(int, int, int, boolean, int)'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>
@@ -29,6 +29,11 @@ import com.intellij.formatting.ASTBlock
import org.jetbrains.jet.plugin.formatter.KotlinSpacingBuilder.CustomSpacingBuilder
import com.intellij.formatting.SpacingBuilder
import com.intellij.formatting.SpacingBuilder.RuleBuilder
import com.intellij.formatting.DependentSpacingRule
import com.intellij.formatting.DependentSpacingRule.Trigger
import com.intellij.formatting.DependentSpacingRule.Anchor
import com.intellij.openapi.util.TextRange
import com.intellij.formatting.DependantSpacingImpl
val MODIFIERS_LIST_ENTRIES = TokenSet.orSet(TokenSet.create(ANNOTATION_ENTRY, ANNOTATION), MODIFIER_KEYWORDS)
@@ -43,7 +48,31 @@ fun SpacingBuilder.afterInside(element: IElementType, tokenSet: TokenSet, spacin
fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
val jetSettings = settings.getCustomSettings(javaClass<JetCodeStyleSettings>())!!
val jetCommonSettings = settings.getCommonSettings(JetLanguage.INSTANCE)!!
return rules(settings) {
custom {
val emptyLineIfLeftMultiline = { (parent: ASTBlock, left: ASTBlock, right: ASTBlock) ->
val multilineLF = 2
val singleLineLF = 1
val dependentSpacingRule = DependentSpacingRule(Trigger.HAS_LINE_FEEDS).registerData(Anchor.MIN_LINE_FEEDS, multilineLF)
LineFeedDependantSpacing(
0, 0,
minimumLineFeeds = singleLineLF,
keepLineBreaks = settings.KEEP_LINE_BREAKS,
keepBlankLines = settings.KEEP_BLANK_LINES_IN_DECLARATIONS,
dependency = left.getTextRange(), rule = dependentSpacingRule)
}
inPosition(left = CLASS, right = CLASS).customRule(emptyLineIfLeftMultiline)
inPosition(left = FUN, right = FUN).customRule(emptyLineIfLeftMultiline)
inPosition(left = PROPERTY, right = FUN).customRule(emptyLineIfLeftMultiline)
inPosition(left = FUN, right = PROPERTY).customRule(emptyLineIfLeftMultiline)
// Case left for alternative constructors
inPosition(left = FUN, right = CLASS).customRule(emptyLineIfLeftMultiline)
}
simple {
// ============ Line breaks ==============
after(PACKAGE_DIRECTIVE).blankLines(1)
@@ -51,10 +80,15 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
after(IMPORT_LIST).blankLines(1)
before(DOC_COMMENT).lineBreakInCode()
between(PROPERTY, PROPERTY).lineBreakInCode()
between(CLASS, FUN).blankLines(1)
between(CLASS, PROPERTY).blankLines(1)
between(PROPERTY, CLASS).blankLines(1)
before(FUN).lineBreakInCode()
before(PROPERTY).lineBreakInCode()
between(FUN, FUN).blankLines(1)
between(FUN, PROPERTY).blankLines(1)
// =============== Spacing ================
betweenInside(LBRACE, RBRACE, CLASS_BODY).spaces(0)
@@ -269,3 +303,17 @@ fun createSpacingBuilder(settings: CodeStyleSettings): KotlinSpacingBuilder {
}
}
}
public class LineFeedDependantSpacing(
minSpaces: Int,
maxSpaces: Int,
val minimumLineFeeds: Int,
keepLineBreaks: Boolean,
keepBlankLines: Int,
dependency: TextRange,
rule: DependentSpacingRule) : DependantSpacingImpl(minSpaces, maxSpaces, dependency, keepLineBreaks, keepBlankLines, rule) {
override fun getMinLineFeeds(): Int {
val superMin = super.getMinLineFeeds()
return if (superMin == 0) minimumLineFeeds else superMin
}
}
@@ -8,15 +8,19 @@ class C : Base<String, C, Unit>() {
override fun bar(value: () -> Unit): (String) -> Unit {
<selection><caret>return super<Base>.bar(value)</selection>
}
override fun equals(other: Any?): Boolean {
return super<Base>.equals(other)
}
override fun foo(value: C): C {
return super<Base>.foo(value)
}
override fun hashCode(): Int {
return super<Base>.hashCode()
}
override val method: (String?) -> String = ?
override fun toString(): String {
return super<Base>.toString()
@@ -7,15 +7,19 @@ class C(t :T) : T by t {
override fun bar() {
<selection><caret>throw UnsupportedOperationException()</selection>
}
override fun equals(other: Any?): Boolean {
return super<T>.equals(other)
}
override fun foo() {
throw UnsupportedOperationException()
}
override fun hashCode(): Int {
return super<T>.hashCode()
}
override fun toString(): String {
return super<T>.toString()
}
@@ -10,9 +10,11 @@ class SomeOther<S> : Some<S> {
override fun someFoo() {
<selection><caret>throw UnsupportedOperationException()</selection>
}
override fun someGenericFoo(): S {
throw UnsupportedOperationException()
}
override fun someOtherFoo(): Int {
throw UnsupportedOperationException()
}
@@ -14,20 +14,25 @@ class C : A(), B {
override fun equals(other: Any?): Boolean {
<selection><caret>return super<A>.equals(other)</selection>
}
override fun hashCode(): Int {
return super<A>.hashCode()
}
override fun internalFun() {
super<A>.internalFun()
}
override val internalProperty: Int = 0
override fun protectedFun() {
super<A>.protectedFun()
}
override val protectedProperty: Int = 0
override fun publicFun() {
super<A>.publicFun()
}
override val publicProperty: Int = 0
override fun toString(): String {
return super<A>.toString()
@@ -7,15 +7,19 @@ class C : A {
override fun bar(): String {
<selection><caret>return super<A>.bar()</selection>
}
override fun equals(other: Any?): Boolean {
return super<A>.equals(other)
}
override fun foo(value: String): Int {
return super<A>.foo(value)
}
override fun hashCode(): Int {
return super<A>.hashCode()
}
override fun toString(): String {
return super<A>.toString()
}
@@ -6,16 +6,20 @@ class Other {
override fun equals(other: Any?): Boolean {
<selection><caret>return super<Any>.equals(other)</selection>
}
override fun hashCode(): Int {
return super<Any>.hashCode()
}
override fun toString(): String {
return super<Any>.toString()
}
fun test() {
val a = 1
}
fun otherTest() {
}
}
}
@@ -6,16 +6,21 @@ class Other {
fun test() {
val a = 1
}
override fun equals(other: Any?): Boolean {
<selection><caret>return super<Any>.equals(other)</selection>
}
override fun hashCode(): Int {
return super<Any>.hashCode()
}
override fun toString(): String {
return super<Any>.toString()
}
fun otherTest() {
}
}
}
@@ -6,16 +6,20 @@ class Other {
override fun equals(other: Any?): Boolean {
<selection><caret>return super<Any>.equals(other)</selection>
}
override fun hashCode(): Int {
return super<Any>.hashCode()
}
override fun toString(): String {
return super<Any>.toString()
}
fun test() {
val a = 1
}
fun otherTest() {
}
}
}
@@ -10,12 +10,15 @@ class C : A() {
override fun equals(other: Any?): Boolean {
return super<A>.equals(other)
}
override fun foo(value: Int) {
super<A>.foo(value)
}
override fun hashCode(): Int {
return super<A>.hashCode()
}
override fun toString(): String {
return super<A>.toString()
}
@@ -8,6 +8,7 @@ class SomeTest : Test {
override fun test() {
<selection><caret>throw UnsupportedOperationException()</selection>
}
override val testProp: Int = 0
/**
* test
@@ -2,6 +2,7 @@ fun foo() {
class A {
fun test() {}
}
val d: A
if (<caret>) {
d = A()
@@ -0,0 +1,9 @@
trait Some {
fun f1()
fun f2()
}
abstract class Abstract() {
abstract fun f1()
abstract fun f2()
}
@@ -0,0 +1,9 @@
trait Some {
fun f1()
fun f2()
}
abstract class Abstract() {
abstract fun f1()
abstract fun f2()
}
@@ -0,0 +1,48 @@
fun f1() {
}
class C1 {}
// -----
fun f2() {
}
class C2
// -----
fun f3 = 1
class C3 {}
// -----
fun f4 = 2
class C4
// -----
class C5 {}
fun f5() {
}
// -----
class C6
fun f6() {
}
// -----
class C7 {}
fun f7 = 1
// -----
class C8
fun f8 = 1
@@ -0,0 +1,38 @@
fun f1() {}
class C1 {}
// -----
fun f2() {}
class C2
// -----
fun f3 = 1
class C3 {}
// -----
fun f4 = 2
class C4
// -----
class C5 {}
fun f5() {}
// -----
class C6
fun f6() {}
// -----
class C7 {}
fun f7 = 1
// -----
class C8
fun f8 = 1
@@ -0,0 +1,25 @@
class A
class B
class C {
}
class D {
}
class E
: Some
class F
fun some() = 1
class G
fun some() = 1
val a = 1
class H
val b = 1
@@ -0,0 +1,19 @@
class A
class B
class C {
}
class D {
}
class E
: Some
class F
fun some() = 1
class G
fun some() = 1
val a = 1
class H
val b = 1
@@ -0,0 +1,76 @@
// No lines
fun f1() {
}
val p1 = 1
fun f2() {
}
fun f3() = 1
val p2 = 1
fun f4() = 1
fun f4() {
}
val p3: Int
get() = 1
fun f5() = 1
class OneLine {
fun f1() {
}
val p1 = 1
fun f2() {
}
fun f3() = 1
val p2 = 1
fun f4() = 1
fun f4() {
}
val p3: Int
get() = 1
fun f5() = 1
}
class TwoLines {
fun f1() {
}
val p1 = 1
fun f2() {
}
fun f3() = 1
val p2 = 1
fun f4() = 1
fun f4() {
}
val p3: Int
get() = 1
fun f5() = 1
}
@@ -0,0 +1,64 @@
// No lines
fun f1() {}
val p1 = 1
fun f2() {}
fun f3() = 1
val p2 = 1
fun f4() = 1
fun f4() {}
val p3: Int
get() = 1
fun f5() = 1
class OneLine {
fun f1() {}
val p1 = 1
fun f2() {}
fun f3() = 1
val p2 = 1
fun f4() = 1
fun f4() {}
val p3: Int
get() = 1
fun f5() = 1
}
class TwoLines {
fun f1() {}
val p1 = 1
fun f2() {}
fun f3() = 1
val p2 = 1
fun f4() = 1
fun f4() {}
val p3: Int
get() = 1
fun f5() = 1
}
@@ -0,0 +1,66 @@
// No lines between
fun f2() {
}
fun f1() {
}
fun f3() = 1
fun f4() {
}
fun f5() {
}
fun f6() = 1
fun f7() = 8
// One line
fun f2() {
}
fun f1() {
}
fun f3() = 1
fun f4() {
}
fun f5() {
}
fun f6() = 1
fun f7() = 8
// Two lines between
fun l1() {
}
fun l2() {
}
fun l3() = 1
fun l4() {
}
fun l5() {
}
fun l6() = 1
fun l7() = 8
@@ -0,0 +1,53 @@
// No lines between
fun f2() {}
fun f1() {}
fun f3() = 1
fun f4() {}
fun f5() {
}
fun f6() = 1
fun f7() = 8
// One line
fun f2() {}
fun f1() {}
fun f3() = 1
fun f4() {}
fun f5() {
}
fun f6() = 1
fun f7() = 8
// Two lines between
fun l1() {}
fun l2() {}
fun l3() = 1
fun l4() {}
fun l5() {
}
fun l6() = 1
fun l7() = 8
@@ -0,0 +1,42 @@
val p1 by Some
val p2 = 1
val p3: Int get() = 3
val p4: Int
get() {
return 1
}
val p5: Int
class OneLine {
val p1 by Some
val p2 = 1
val p3: Int get() = 3
val p4: Int
get() {
return 1
}
val p5: Int
}
class TwoLines {
val p1 by Some
val p2 = 1
val p3: Int get() = 3
val p4: Int
get() {
return 1
}
val p5: Int
}
@@ -0,0 +1,36 @@
val p1 by Some
val p2 = 1
val p3: Int get() = 3
val p4: Int
get() { return 1 }
val p5: Int
class OneLine {
val p1 by Some
val p2 = 1
val p3: Int get() = 3
val p4: Int
get() { return 1 }
val p5: Int
}
class TwoLines {
val p1 by Some
val p2 = 1
val p3: Int get() = 3
val p4: Int
get() { return 1 }
val p5: Int
}
@@ -4,6 +4,7 @@ class Foo<T> {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
fun <T> x (y: Foo<List<T>>, w: java.util.ArrayList<T>) {
val z: Iterable<T> = y["", w]
}
@@ -4,6 +4,7 @@ class Foo<T> {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
fun <T> x (y: Foo<List<T>>, w: java.util.ArrayList<T>) {
val z = y["", w]
}
@@ -5,6 +5,7 @@ class A<T>(val n: T) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
class B<T>(val m: T)
fun test(): B<String> {
@@ -5,6 +5,7 @@ class A<T>(val n: T) {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
class B<T>(val m: T)
fun test<U, V>(u: U): B<V> {
@@ -4,6 +4,7 @@ class Foo<T> {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
fun foo() {
for (i: Int in Foo<Int>()) { }
}
@@ -4,6 +4,7 @@ class Foo<T> {
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
fun foo() {
for (i in Foo<Int>()) {
bar(i)
@@ -156,6 +156,42 @@ public class JetFormatterTestGenerated extends AbstractJetFormatterTest {
doTest(fileName);
}
@TestMetadata("EmptyLineBetweeAbstractFunctions.after.kt")
public void testEmptyLineBetweeAbstractFunctions() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/EmptyLineBetweeAbstractFunctions.after.kt");
doTest(fileName);
}
@TestMetadata("EmptyLineBetweenClassAndFunction.after.kt")
public void testEmptyLineBetweenClassAndFunction() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/EmptyLineBetweenClassAndFunction.after.kt");
doTest(fileName);
}
@TestMetadata("EmptyLineBetweenClasses.after.kt")
public void testEmptyLineBetweenClasses() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/EmptyLineBetweenClasses.after.kt");
doTest(fileName);
}
@TestMetadata("EmptyLineBetweenFunAndProperty.after.kt")
public void testEmptyLineBetweenFunAndProperty() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/EmptyLineBetweenFunAndProperty.after.kt");
doTest(fileName);
}
@TestMetadata("EmptyLineBetweenFunctions.after.kt")
public void testEmptyLineBetweenFunctions() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/EmptyLineBetweenFunctions.after.kt");
doTest(fileName);
}
@TestMetadata("EmptyLineBetweenProperties.after.kt")
public void testEmptyLineBetweenProperties() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/EmptyLineBetweenProperties.after.kt");
doTest(fileName);
}
@TestMetadata("ForLineBreak.after.kt")
public void testForLineBreak() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/formatter/ForLineBreak.after.kt");
@@ -938,10 +938,12 @@ class SmartEnterTest : JetLightCodeInsightFixtureTestCase() {
fun testFunBody7() = doFileTest(
"""
trait T
fun <U> other() where U: T<caret>
""",
"""
trait T
fun <U> other() where U : T {
<caret>
}
@@ -3,8 +3,10 @@ abstract class Shape {
public fun setColor(c: String) {
color = c
}
public fun getColor(): String {
return color
}
public abstract fun area(): Double
}
@@ -1,8 +1,10 @@
class T {
fun main() {
}
fun i(): Int {
}
fun s(): String {
}
}
+1
View File
@@ -5,6 +5,7 @@ import java.util.HashMap
fun Test(): Test {
return Test()
}
fun Test(s: String): Test {
return Test()
}
@@ -3,6 +3,7 @@ class S {
fun sB(): Boolean {
return true
}
fun sI(): Int {
return 1
}
@@ -17,6 +17,7 @@ class Customer(public val _firstName: String, public val _lastName: String) {
private fun doSmthBefore() {
}
private fun doSmthAfter() {
}
}
@@ -9,6 +9,7 @@ class C(private val arg1: Int, private val arg2: Int, private val arg3: Int) {
fun foo(p: Int): Int {
return p
}
private fun staticFoo(p: Int): Int {
return p
}
@@ -6,6 +6,7 @@ class F {
fun f2() {
}
var i: Int? = 0
fun f3() {
@@ -17,6 +17,7 @@ class F {
fun f2() {
}
var i: Int? = 0
fun f3() {
@@ -25,6 +25,7 @@ class F {
fun f1() {
}
var i: Int? = 0
//c5
@@ -18,6 +18,7 @@ class F {
fun f2() {
}
var i: Int? = 0
fun f3() {
@@ -2,6 +2,7 @@ class A {
fun a() {
}
}
class B : A() {
override fun a() {
}
+1
View File
@@ -7,6 +7,7 @@ public class Java {
val m = HashMap()
m.put(1, 1)
}
fun test2() {
val m = HashMap()
val g = G("")
@@ -15,6 +15,7 @@ class StringContainer(s: String)
class Test {
fun putString(s: String) {
}
fun test() {
putString(One.myContainer.myString)
StringContainer(One.myContainer.myString)
+1
View File
@@ -15,6 +15,7 @@ class IntContainer(i: Int)
class Test {
fun putInt(i: Int) {
}
fun test() {
putInt(One.myContainer.myInt)
IntContainer(One.myContainer.myInt)
+2
View File
@@ -13,6 +13,7 @@ public class Language(protected var code: String) : Serializable {
class Base {
fun test() {
}
override fun toString(): String {
return "BASE"
}
@@ -21,6 +22,7 @@ class Base {
class Child : Base() {
override fun test() {
}
override fun toString(): String {
return "Child"
}
@@ -3,8 +3,10 @@
open class A {
open fun foo1() {
}
private fun foo2() {
}
fun foo3() {
}
}
@@ -31,4 +33,4 @@ enum class E {
fun foo(): Int {
return 0
}
}
}
@@ -10,6 +10,7 @@ class A {
private fun privateStatic1() {
}
private fun privateStatic2() {
}
}
@@ -6,6 +6,7 @@ class A {
private fun privateStatic1() {
}
private fun privateStatic2() {
}
}
@@ -12,6 +12,7 @@ class A {
private fun privateStatic1() {
}
private fun privateStatic2() {
}
}
@@ -13,6 +13,7 @@ class A {
private fun privateStatic1() {
}
private fun privateStatic2() {
}
}
@@ -11,6 +11,7 @@ class A {
private fun privateStatic1() {
}
private fun privateStatic2() {
}
}