X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/CodeFormatter.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/CodeFormatter.java index 5d8db07..30e0110 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/CodeFormatter.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/CodeFormatter.java @@ -332,6 +332,8 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { currentLineIndentationLevel += constructionsCount; // An InvalidInputException exception might cause the termination of this // loop. + int arrayDeclarationCount=0; + int[] arrayDeclarationParenthesis=new int[10]; try { while (true) { // Get the next token. Catch invalid input and output it @@ -675,9 +677,26 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { else openParenthesis[0]++; pendingSpace = false; + // recognize array declaration for nice output + if (previousCompilableToken == TokenNamearray) { + arrayDeclarationCount++; + arrayDeclarationParenthesis[arrayDeclarationCount]=openParenthesis[openParenthesisCount]; + indentationLevel++; + pendingNewLines=1; + } //S } break; case TokenNameRPAREN: + // check for closing array declaration + if (arrayDeclarationCount>0) { + if (arrayDeclarationParenthesis[arrayDeclarationCount]==openParenthesis[openParenthesisCount]) { + newLine(1); + indentationLevel--; + currentLineIndentationLevel = indentationLevel; + pendingNewLines = 0; + arrayDeclarationCount--; + } + } // Decrease the parenthesis count // if there is no more unclosed parenthesis, // a new line and indent may be append (depending on the next @@ -766,6 +785,11 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { pendingSpace = false; break; case TokenNameCOMMA: + pendingSpace = false; + if (arrayDeclarationCount>0) { + pendingNewLines=1; + } + break; case TokenNameDOT: pendingSpace = false; break;