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 27e8037..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,8 +372,25 @@ 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);
+ int srcLen = scanner.source.length;
+ if (scanner.currentPosition < srcLen-1) {
+ newLine(1);
+ }
+ continue;
+ }
/*
* ## MODIFYING the indentation level before generating new lines and indentation in the output string
*/
@@ -1420,7 +1439,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
// |= (15.25.2)
return "|="; //$NON-NLS-1$
case TokenNameDOT_EQUAL:
- // .=
+ // .=
return ".="; //$NON-NLS-1$
case TokenNameDOT:
// .
@@ -1444,6 +1463,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.
@@ -1908,7 +1932,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter {
//return (currentToken == TokenNameCOMMA || currentToken ==
// TokenNameSEMICOLON);
return currentToken != TokenNameif && currentToken != TokenNameLPAREN && currentToken != TokenNameNOT
- && currentToken != TokenNamewhile && currentToken != TokenNamefor && currentToken != TokenNameforeach
+ && currentToken != TokenNamewhile && currentToken != TokenNamefor && currentToken != TokenNameforeach
&& currentToken != TokenNameswitch;
}