Lines 133-139
Link Here
|
133 |
private boolean isMethodInvocationShifted; // is continual indentation already included ? |
133 |
private boolean isMethodInvocationShifted; // is continual indentation already included ? |
134 |
private boolean isFirstUseStatementPart; |
134 |
private boolean isFirstUseStatementPart; |
135 |
private boolean isFirstUseTraitStatementPart; |
135 |
private boolean isFirstUseTraitStatementPart; |
136 |
private boolean inArray; |
136 |
private int inArrayBalance; |
137 |
|
137 |
|
138 |
public FormatVisitor(BaseDocument document, DocumentOptions documentOptions, final int caretOffset, final int startOffset, final int endOffset) { |
138 |
public FormatVisitor(BaseDocument document, DocumentOptions documentOptions, final int caretOffset, final int startOffset, final int endOffset) { |
139 |
this.document = document; |
139 |
this.document = document; |
Lines 148-153
Link Here
|
148 |
formatTokens.add(new FormatToken.InitToken()); |
148 |
formatTokens.add(new FormatToken.InitToken()); |
149 |
isMethodInvocationShifted = false; |
149 |
isMethodInvocationShifted = false; |
150 |
groupAlignmentTokenHolders = new Stack<>(); |
150 |
groupAlignmentTokenHolders = new Stack<>(); |
|
|
151 |
inArrayBalance = 0; |
151 |
} |
152 |
} |
152 |
|
153 |
|
153 |
public List<FormatToken> getFormatTokens() { |
154 |
public List<FormatToken> getFormatTokens() { |
Lines 256-262
Link Here
|
256 |
|
257 |
|
257 |
@Override |
258 |
@Override |
258 |
public void visit(ArrayCreation node) { |
259 |
public void visit(ArrayCreation node) { |
259 |
inArray = true; |
260 |
inArrayBalance++; |
260 |
int delta = options.indentArrayItems - options.continualIndentSize; |
261 |
int delta = options.indentArrayItems - options.continualIndentSize; |
261 |
if (ts.token().id() != PHPTokenId.PHP_ARRAY && lastIndex <= ts.index() // it's possible that the expression starts with array |
262 |
if (ts.token().id() != PHPTokenId.PHP_ARRAY && lastIndex <= ts.index() // it's possible that the expression starts with array |
262 |
&& !ts.token().text().toString().equals("[")) { //NOI18N |
263 |
&& !ts.token().text().toString().equals("[")) { //NOI18N |
Lines 305-311
Link Here
|
305 |
formatTokens.add(new FormatToken.IndentToken(ts.offset() + ts.token().length(), -1 * delta)); |
306 |
formatTokens.add(new FormatToken.IndentToken(ts.offset() + ts.token().length(), -1 * delta)); |
306 |
addAllUntilOffset(node.getEndOffset()); |
307 |
addAllUntilOffset(node.getEndOffset()); |
307 |
resetGroupAlignment(); |
308 |
resetGroupAlignment(); |
308 |
inArray = false; |
309 |
inArrayBalance--; |
309 |
} |
310 |
} |
310 |
|
311 |
|
311 |
private int modifyDeltaForEnclosingFunctionInvocations(int delta) { |
312 |
private int modifyDeltaForEnclosingFunctionInvocations(int delta) { |
Lines 1077-1087
Link Here
|
1077 |
Block body = node.getBody(); |
1078 |
Block body = node.getBody(); |
1078 |
if (body != null) { |
1079 |
if (body != null) { |
1079 |
addAllUntilOffset(body.getStartOffset()); |
1080 |
addAllUntilOffset(body.getStartOffset()); |
1080 |
if (!inArray) { |
1081 |
if (inArrayBalance == 0) { |
1081 |
formatTokens.add(new FormatToken.IndentToken(body.getStartOffset(), -1 * options.continualIndentSize)); |
1082 |
formatTokens.add(new FormatToken.IndentToken(body.getStartOffset(), -1 * options.continualIndentSize)); |
1082 |
} |
1083 |
} |
1083 |
scan(body); |
1084 |
scan(body); |
1084 |
if (!inArray) { |
1085 |
if (inArrayBalance == 0) { |
1085 |
formatTokens.add(new FormatToken.IndentToken(body.getEndOffset(), options.continualIndentSize)); |
1086 |
formatTokens.add(new FormatToken.IndentToken(body.getEndOffset(), options.continualIndentSize)); |
1086 |
} |
1087 |
} |
1087 |
} |
1088 |
} |