Formatter: improve indentation rules for when entries
This commit is contained in:
@@ -290,6 +290,11 @@ public class JetBlock extends AbstractBlock {
|
|||||||
.in(DOC_COMMENT)
|
.in(DOC_COMMENT)
|
||||||
.forType(KDocTokens.LEADING_ASTERISK, KDocTokens.END)
|
.forType(KDocTokens.LEADING_ASTERISK, KDocTokens.END)
|
||||||
.set(Indent.getSpaceIndent(KDOC_COMMENT_INDENT)),
|
.set(Indent.getSpaceIndent(KDOC_COMMENT_INDENT)),
|
||||||
|
|
||||||
|
ASTIndentStrategy.forNode("Block in when entry")
|
||||||
|
.in(WHEN_ENTRY)
|
||||||
|
.notForType(BLOCK, WHEN_CONDITION_EXPRESSION, WHEN_CONDITION_IN_RANGE, WHEN_CONDITION_IS_PATTERN, ELSE_KEYWORD, ARROW)
|
||||||
|
.set(Indent.getNormalIndent()),
|
||||||
};
|
};
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -305,14 +310,6 @@ public class JetBlock extends AbstractBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Try to rewrite other rules to declarative style
|
// TODO: Try to rewrite other rules to declarative style
|
||||||
|
|
||||||
if (childParent != null && childParent.getElementType() == WHEN_ENTRY) {
|
|
||||||
ASTNode prev = getPrevWithoutWhitespace(child);
|
|
||||||
if (prev != null && prev.getText().equals("->")) {
|
|
||||||
return indentIfNotBrace(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (childParent != null && childParent.getElementType() == DOT_QUALIFIED_EXPRESSION) {
|
if (childParent != null && childParent.getElementType() == DOT_QUALIFIED_EXPRESSION) {
|
||||||
if (childParent.getFirstChildNode() != child && childParent.getLastChildNode() != child) {
|
if (childParent.getFirstChildNode() != child && childParent.getLastChildNode() != child) {
|
||||||
return Indent.getContinuationWithoutFirstIndent(false);
|
return Indent.getContinuationWithoutFirstIndent(false);
|
||||||
|
|||||||
@@ -2,8 +2,67 @@ fun some(x: Any) {
|
|||||||
when (x) {
|
when (x) {
|
||||||
is Int ->
|
is Int ->
|
||||||
0
|
0
|
||||||
|
3 ->
|
||||||
|
2
|
||||||
|
in 0..3 ->
|
||||||
|
2
|
||||||
|
else ->
|
||||||
|
1
|
||||||
|
}
|
||||||
|
when (x) {
|
||||||
|
is Int -> {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
3 -> {
|
||||||
|
2
|
||||||
|
}
|
||||||
|
in 0..3 -> {
|
||||||
|
2
|
||||||
|
}
|
||||||
else -> {
|
else -> {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
when (x) {
|
||||||
|
is Int ->
|
||||||
|
{
|
||||||
|
0
|
||||||
|
}
|
||||||
|
3 ->
|
||||||
|
{
|
||||||
|
2
|
||||||
|
}
|
||||||
|
in 0..3 ->
|
||||||
|
{
|
||||||
|
2
|
||||||
|
}
|
||||||
|
else ->
|
||||||
|
{
|
||||||
|
1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
when (x) {
|
||||||
|
is
|
||||||
|
Int
|
||||||
|
->
|
||||||
|
{
|
||||||
|
0
|
||||||
|
}
|
||||||
|
3
|
||||||
|
->
|
||||||
|
{
|
||||||
|
2
|
||||||
|
}
|
||||||
|
in
|
||||||
|
0..3
|
||||||
|
->
|
||||||
|
{
|
||||||
|
2
|
||||||
|
}
|
||||||
|
else
|
||||||
|
->
|
||||||
|
{
|
||||||
|
1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,67 @@ fun some(x : Any) {
|
|||||||
when (x) {
|
when (x) {
|
||||||
is Int ->
|
is Int ->
|
||||||
0
|
0
|
||||||
|
3 ->
|
||||||
|
2
|
||||||
|
in 0..3 ->
|
||||||
|
2
|
||||||
|
else ->
|
||||||
|
1
|
||||||
|
}
|
||||||
|
when (x) {
|
||||||
|
is Int -> {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
3 -> {
|
||||||
|
2
|
||||||
|
}
|
||||||
|
in 0..3 -> {
|
||||||
|
2
|
||||||
|
}
|
||||||
else -> {
|
else -> {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
when (x) {
|
||||||
|
is Int ->
|
||||||
|
{
|
||||||
|
0
|
||||||
|
}
|
||||||
|
3 ->
|
||||||
|
{
|
||||||
|
2
|
||||||
|
}
|
||||||
|
in 0..3 ->
|
||||||
|
{
|
||||||
|
2
|
||||||
|
}
|
||||||
|
else ->
|
||||||
|
{
|
||||||
|
1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
when (x) {
|
||||||
|
is
|
||||||
|
Int
|
||||||
|
->
|
||||||
|
{
|
||||||
|
0
|
||||||
|
}
|
||||||
|
3
|
||||||
|
->
|
||||||
|
{
|
||||||
|
2
|
||||||
|
}
|
||||||
|
in
|
||||||
|
0..3
|
||||||
|
->
|
||||||
|
{
|
||||||
|
2
|
||||||
|
}
|
||||||
|
else
|
||||||
|
->
|
||||||
|
{
|
||||||
|
1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user