KT-2572 Cursor position on Enter after 'try'

#KT-2575 Fixed
This commit is contained in:
Nikolay Krasko
2012-08-20 19:50:04 +04:00
parent 99ab76c8fd
commit b85300d90a
9 changed files with 58 additions and 5 deletions
@@ -58,12 +58,12 @@ public abstract class ASTIndentStrategy {
public static class PositionStrategy extends ASTIndentStrategy {
private Indent defaultIndent = Indent.getNoneIndent();
private List<IElementType> in = new ArrayList<IElementType>();
private List<IElementType> notIn = new ArrayList<IElementType>();
private List<IElementType> forElement = new ArrayList<IElementType>();
private List<IElementType> notForElement = new ArrayList<IElementType>();
private final List<IElementType> in = new ArrayList<IElementType>();
private final List<IElementType> notIn = new ArrayList<IElementType>();
private final List<IElementType> forElement = new ArrayList<IElementType>();
private final List<IElementType> notForElement = new ArrayList<IElementType>();
private String debugInfo;
private final String debugInfo;
public PositionStrategy(@Nullable String debugInfo) {
this.debugInfo = debugInfo;
@@ -145,6 +145,10 @@ public class JetBlock extends AbstractBlock {
return new ChildAttributes(Indent.getNormalIndent(), null);
}
else if (type == JetNodeTypes.TRY) {
// In try - try BLOCK catch BLOCK finally BLOCK
return new ChildAttributes(Indent.getNoneIndent(), null);
}
else if (type == JetNodeTypes.DOT_QUALIFIED_EXPRESSION) {
return new ChildAttributes(Indent.getContinuationWithoutFirstIndent(), null);
}
@@ -0,0 +1,6 @@
fun some(): Int {
try {
}
catch () {
}<caret>
}
@@ -0,0 +1,7 @@
fun some(): Int {
try {
}
catch () {
}
<caret>
}
@@ -0,0 +1,7 @@
fun some(): Int {
try {
}
catch () {
}
finally {}<caret>
}
@@ -0,0 +1,8 @@
fun some(): Int {
try {
}
catch () {
}
finally {}
<caret>
}
@@ -0,0 +1,4 @@
fun some(): Int {
try {
}<caret>
}
@@ -0,0 +1,5 @@
fun some(): Int {
try {
}
<caret>
}
@@ -29,10 +29,22 @@ import java.io.File;
*/
public class JetTypingIndentationTest extends LightCodeInsightTestCase {
public void testAfterCatch() {
doFileNewlineTest();
}
public void testAfterFinally() {
doFileNewlineTest();
}
public void testAfterImport() {
doFileNewlineTest();
}
public void testAfterTry() {
doFileNewlineTest();
}
public void testConsecutiveCallsAfterDot() {
doFileNewlineTest();
}