Fix scripting formatter to avoid extra indent in invisible block node.

This commit is contained in:
Ilya Ryzhenkov
2014-03-19 09:15:54 +04:00
committed by Andrey Breslav
parent 480dd6767c
commit 64b4c2d49b
3 changed files with 25 additions and 1 deletions
@@ -267,7 +267,7 @@ public class JetBlock extends AbstractBlock {
.forType(PROPERTY_ACCESSOR)
.set(Indent.getNormalIndent()),
ASTIndentStrategy.forNode("For a single statement if 'for'")
ASTIndentStrategy.forNode("For a single statement in 'for'")
.in(BODY)
.notForType(BLOCK)
.set(Indent.getNormalIndent()),
@@ -302,6 +302,13 @@ public class JetBlock extends AbstractBlock {
ASTNode childParent = child.getTreeParent();
IElementType childType = child.getElementType();
// SCRIPT: Avoid indenting script top BLOCK contents
if (childParent != null && childParent.getTreeParent() != null) {
if (childParent.getElementType() == BLOCK && childParent.getTreeParent().getElementType() == SCRIPT) {
return Indent.getNoneIndent();
}
}
for (ASTIndentStrategy strategy : INDENT_RULES) {
Indent indent = strategy.getIndent(child);
if (indent != null) {
+9
View File
@@ -0,0 +1,9 @@
import a.b.c
val x = 0
fun fn() {
println(x)
}
var y = fn()
y = y + 1
+8
View File
@@ -0,0 +1,8 @@
import a.b.c
val x = 0
fun fn() {
println(x)
}
var y = fn()
y = y+1