Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
15 changes: 15 additions & 0 deletions testData/formatter/alignedExport-after.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%% Copyright (c) 2012. Sergey Ignatov.
-module(aaa).
-author("ignatov").

%% API
-export([
foo/0,
bar/0
]).

foo() ->
bar.

bar() ->
foo.
15 changes: 15 additions & 0 deletions testData/formatter/alignedExport.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
%% Copyright (c) 2012. Sergey Ignatov.
-module(aaa).
-author("ignatov").

%% API
-export([
foo/0,
bar/0
]).

foo() ->
bar.

bar() ->
foo.
12 changes: 12 additions & 0 deletions testData/formatter/alignedImport-after.erl
Original file line number Diff line number Diff line change
@@ -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]).
12 changes: 12 additions & 0 deletions testData/formatter/alignedImport.erl
Original file line number Diff line number Diff line change
@@ -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]).
4 changes: 4 additions & 0 deletions testData/formatter/maybe6-after.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test() ->
maybe
<caret>%% comment
end.
3 changes: 3 additions & 0 deletions testData/formatter/maybe6.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test() ->
maybe<caret>%% comment
end.
4 changes: 4 additions & 0 deletions testData/formatter/try6-after.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test() ->
try
<caret>%% comment
end.
3 changes: 3 additions & 0 deletions testData/formatter/try6.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test() ->
try<caret>%% comment
end.
14 changes: 14 additions & 0 deletions tests/org/intellij/erlang/formatting/ErlangFormattingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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(); }
Expand Down Expand Up @@ -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(); }
Expand Down