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 b272fbd..7caa523 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 @@ -168,6 +168,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { , true, /* tokenizeStrings */ null, null); // regular scanner for forming lines scanner.recordLineSeparator = true; + scanner.ignorePHPOneLiner = true; // to remind of the position of the beginning of the line. splitScanner = new Scanner(true /* comment */ , true /* whitespace */ @@ -175,6 +176,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { , false /* assert */ , true, /* tokenizeStrings */ null, null); + splitScanner.ignorePHPOneLiner = true; // secondary scanner to split long lines formed by primary scanning // initialize current line buffer currentLineBuffer = new StringBuffer(); @@ -370,11 +372,23 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { } token = 0; } - if (token == Scanner.TokenNameEOF) + if (token == Scanner.TokenNameEOF) { break; - if (token == Scanner.TokenNameHEREDOC || token == Scanner.TokenNameINLINE_HTML) { + } else if (token == Scanner.TokenNameHEREDOC) { // no indentation for heredocs and HTML ! - outputCurrentTokenWithoutIndent(Scanner.TokenNameHEREDOC); + 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); + int srcLen = scanner.source.length; + if (scanner.currentPosition < srcLen-1) { + newLine(1); + } continue; } /* @@ -1449,8 +1463,8 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { } } - private void outputCurrentTokenWithoutIndent(int token) { - newLine(0); + private void outputCurrentTokenWithoutIndent(int token, int newLineCount) { + newLine(newLineCount); formattedSource.append(scanner.source, scanner.startPosition, scanner.currentPosition - scanner.startPosition); }