outputLine(currentString, false, currentLineIndentationLevel, 0, -1, null, 0);
}
int scannerSourceLength = scanner.source.length;
- if (scannerSourceLength > 2) {
+ if ((scannerSourceLength > 2) && (scanner.startPosition < scannerSourceLength)) {
if (scanner.source[scannerSourceLength - 1] == '\n' && scanner.source[scannerSourceLength - 2] == '\r') {
formattedSource.append(options.lineSeparatorSequence);
increaseGlobalDelta(options.lineSeparatorSequence.length - 2);
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
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
pendingSpace = false;
break;
case TokenNameCOMMA:
+ pendingSpace = false;
+ if (arrayDeclarationCount>0) {
+ pendingNewLines=1;
+ }
+ break;
case TokenNameDOT:
pendingSpace = false;
break;
case TokenNameMINUS_MINUS:
// Do not put a space between a post-increment/decrement
// and the identifier being modified.
- if (previousToken == TokenNameIdentifier || previousToken == TokenNameRBRACKET) {
+ if (previousToken == TokenNameIdentifier || previousToken == TokenNameRBRACKET || previousToken == TokenNameVariable) {
pendingSpace = false;
}
break;