X-Git-Url: http://secure.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 420ed30..bfb0e3b 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 @@ -370,8 +370,21 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { } token = 0; } - if (token == Scanner.TokenNameEOF) + if (token == Scanner.TokenNameEOF) { break; + } else if (token == Scanner.TokenNameHEREDOC) { + // no indentation for heredocs and HTML ! + outputCurrentTokenWithoutIndent(Scanner.TokenNameHEREDOC, 0); + continue; + } else if (token == Scanner.TokenNameINLINE_HTML) { + // no indentation for heredocs and HTML ! + int newLineCount = 1; + if (scanner.startPosition==0) { + newLineCount = 0; + } + outputCurrentTokenWithoutIndent(Scanner.TokenNameINLINE_HTML, newLineCount); + continue; + } /* * ## MODIFYING the indentation level before generating new lines and indentation in the output string */ @@ -612,6 +625,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { break; case TokenNameswitch: case TokenNamefor: + case TokenNameforeach: case TokenNameif: case TokenNamewhile: if (openParenthesisCount == openParenthesis.length) { @@ -722,6 +736,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { if (constructionsCount > 0) { switch (constructions[constructionsCount - 1]) { case TokenNamefor: + case TokenNameforeach: //indentationLevel += popExclusiveUntilBlock(); //break; case TokenNameswitch: @@ -1418,7 +1433,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { // |= (15.25.2) return "|="; //$NON-NLS-1$ case TokenNameDOT_EQUAL: - // .= + // .= return ".="; //$NON-NLS-1$ case TokenNameDOT: // . @@ -1442,6 +1457,11 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { } } + private void outputCurrentTokenWithoutIndent(int token, int newLineCount) { + newLine(newLineCount); + formattedSource.append(scanner.source, scanner.startPosition, scanner.currentPosition - scanner.startPosition); + } + /** * Appends token to the formatted output.
* If it contains \n, append a LINE_SEPARATOR and indent after it. @@ -1906,7 +1926,8 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { //return (currentToken == TokenNameCOMMA || currentToken == // TokenNameSEMICOLON); return currentToken != TokenNameif && currentToken != TokenNameLPAREN && currentToken != TokenNameNOT - && currentToken != TokenNamewhile && currentToken != TokenNamefor && currentToken != TokenNameswitch; + && currentToken != TokenNamewhile && currentToken != TokenNamefor && currentToken != TokenNameforeach + && currentToken != TokenNameswitch; } /**