diff --git a/src/org/intellij/erlang/formatter/ErlangFormattingBlock.java b/src/org/intellij/erlang/formatter/ErlangFormattingBlock.java index 27b840d0d..09af97a11 100644 --- a/src/org/intellij/erlang/formatter/ErlangFormattingBlock.java +++ b/src/org/intellij/erlang/formatter/ErlangFormattingBlock.java @@ -65,7 +65,7 @@ public class ErlangFormattingBlock extends AbstractBlock { ERL_PARENTHESIZED_EXPRESSION, ERL_ARGUMENT_LIST, ERL_ARGUMENT_DEFINITION_LIST, ERL_FUN_TYPE, ERL_FUN_TYPE_ARGUMENTS ); private static final TokenSet BRACKETS_CONTAINERS = TokenSet.create( - ERL_LIST_EXPRESSION, ERL_EXPORT_FUNCTIONS, ERL_EXPORT_TYPES, ERL_BINARY_EXPRESSION + ERL_LIST_EXPRESSION, ERL_IMPORT_FUNCTIONS, ERL_EXPORT_FUNCTIONS, ERL_EXPORT_TYPES, ERL_BINARY_EXPRESSION ); private static final TokenSet BINARY_EXPRESSIONS = TokenSet.create( ERL_LIST_OP_EXPRESSION, ERL_ASSIGNMENT_EXPRESSION, ERL_SEND_EXPRESSION, //right-assoc diff --git a/src/org/intellij/erlang/formatter/ErlangIndentProcessor.java b/src/org/intellij/erlang/formatter/ErlangIndentProcessor.java index 71ff1a28d..73ff20433 100644 --- a/src/org/intellij/erlang/formatter/ErlangIndentProcessor.java +++ b/src/org/intellij/erlang/formatter/ErlangIndentProcessor.java @@ -110,7 +110,7 @@ public Indent getChildIndent(ASTNode node, int binaryExpressionIndex) { return Indent.getNormalIndent(myErlangSettings.INDENT_RELATIVE); } } - if (ErlangParserDefinition.COMMENTS.contains(elementType) && parentType == ERL_TRY_EXPRESSION) { + if (ErlangParserDefinition.COMMENTS.contains(elementType) && (parentType == ERL_TRY_EXPRESSION || parentType == ERL_MAYBE_EXPRESSION)) { return Indent.getNormalIndent(); } if (needIndent(parentType)) { diff --git a/testData/formatter/alignedExport-after.erl b/testData/formatter/alignedExport-after.erl new file mode 100644 index 000000000..8b8d418ed --- /dev/null +++ b/testData/formatter/alignedExport-after.erl @@ -0,0 +1,15 @@ +%% Copyright (c) 2012. Sergey Ignatov. +-module(aaa). +-author("ignatov"). + +%% API +-export([ + foo/0, + bar/0 +]). + +foo() -> + bar. + +bar() -> + foo. \ No newline at end of file diff --git a/testData/formatter/alignedExport.erl b/testData/formatter/alignedExport.erl new file mode 100644 index 000000000..8032f1794 --- /dev/null +++ b/testData/formatter/alignedExport.erl @@ -0,0 +1,15 @@ +%% Copyright (c) 2012. Sergey Ignatov. +-module(aaa). +-author("ignatov"). + +%% API +-export([ +foo/0, + bar/0 +]). + +foo() -> + bar. + +bar() -> + foo. \ No newline at end of file diff --git a/testData/formatter/alignedImport-after.erl b/testData/formatter/alignedImport-after.erl new file mode 100644 index 000000000..28d9e098b --- /dev/null +++ b/testData/formatter/alignedImport-after.erl @@ -0,0 +1,12 @@ +%% Copyright (c) 2012. Sergey Ignatov. +-module(aaa). +-author("ignatov"). + +%% API +-import(lists, [ + nth/2, + all/2 +]). + +test() -> + nth(1, [1, 2, 3]). \ No newline at end of file diff --git a/testData/formatter/alignedImport.erl b/testData/formatter/alignedImport.erl new file mode 100644 index 000000000..9492a4050 --- /dev/null +++ b/testData/formatter/alignedImport.erl @@ -0,0 +1,12 @@ +%% Copyright (c) 2012. Sergey Ignatov. +-module(aaa). +-author("ignatov"). + +%% API +-import(lists,[ +nth/2, + all/2 +]). + +test() -> + nth(1, [1, 2, 3]). \ No newline at end of file diff --git a/testData/formatter/maybe6-after.erl b/testData/formatter/maybe6-after.erl new file mode 100644 index 000000000..375934db3 --- /dev/null +++ b/testData/formatter/maybe6-after.erl @@ -0,0 +1,4 @@ +test() -> + maybe + %% comment + end. \ No newline at end of file diff --git a/testData/formatter/maybe6.erl b/testData/formatter/maybe6.erl new file mode 100644 index 000000000..aa4a246fd --- /dev/null +++ b/testData/formatter/maybe6.erl @@ -0,0 +1,3 @@ +test() -> + maybe%% comment + end. \ No newline at end of file diff --git a/testData/formatter/try6-after.erl b/testData/formatter/try6-after.erl new file mode 100644 index 000000000..1e63db93a --- /dev/null +++ b/testData/formatter/try6-after.erl @@ -0,0 +1,4 @@ +test() -> + try + %% comment + end. \ No newline at end of file diff --git a/testData/formatter/try6.erl b/testData/formatter/try6.erl new file mode 100644 index 000000000..274b6edb7 --- /dev/null +++ b/testData/formatter/try6.erl @@ -0,0 +1,3 @@ +test() -> + try%% comment + end. \ No newline at end of file diff --git a/tests/org/intellij/erlang/formatting/ErlangFormattingTest.java b/tests/org/intellij/erlang/formatting/ErlangFormattingTest.java index d75f4f839..32acf2446 100644 --- a/tests/org/intellij/erlang/formatting/ErlangFormattingTest.java +++ b/tests/org/intellij/erlang/formatting/ErlangFormattingTest.java @@ -143,6 +143,16 @@ public void testAligned() throws Exception { doTest(); } + public void testAlignedImport() throws Exception { + alignBlocks(); + doTest(); + } + + public void testAlignedExport() throws Exception { + alignBlocks(); + doTest(); + } + public void testFunctionClausesAligned() throws Exception { getErlangSettings().ALIGN_FUNCTION_CLAUSES = true; doTest(); @@ -206,12 +216,14 @@ public void testUniformBinaryExpressionsStyle() throws Exception { public void testTry3() throws Exception { doEnterTest(); } public void testTry4() throws Exception { doEnterTest(); } public void testTry5() throws Exception { doEnterTest(); } + public void testTry6() throws Exception { doEnterTest(); } public void testTryParasite1() throws Exception { doEnterTest(); } public void testTryParasite2() throws Exception { doEnterTest(); } public void testTryParasite3() throws Exception { doEnterTest(); } public void testTryParasite4() throws Exception { doEnterTest(); } public void testTryParasite5() throws Exception { doEnterTest(); } + public void testTryParasite6() throws Exception { doEnterTest(); } public void testBindTry() throws Exception { doEnterTest(); } public void testBindTryExpr() throws Exception { doEnterTest(); } @@ -242,12 +254,14 @@ public void testUniformBinaryExpressionsStyle() throws Exception { public void testMaybe3() throws Exception { doEnterTest(); } public void testMaybe4() throws Exception { doEnterTest(); } public void testMaybe5() throws Exception { doEnterTest(); } + public void testMaybe6() throws Exception { doEnterTest(); } public void testMaybeParasite1() throws Exception { doEnterTest(); } public void testMaybeParasite2() throws Exception { doEnterTest(); } public void testMaybeParasite3() throws Exception { doEnterTest(); } public void testMaybeParasite4() throws Exception { doEnterTest(); } public void testMaybeParasite5() throws Exception { doEnterTest(); } + public void testMaybeParasite6() throws Exception { doEnterTest(); } public void testBindMaybe() throws Exception { doEnterTest(); } public void testBindMaybeElse() throws Exception { doEnterTest(); }