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 986398f..d209db0 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 @@ -18,6 +18,8 @@ import java.util.Hashtable; import java.util.Locale; import java.util.Map; +//import javax.swing.text.html.Option; + import net.sourceforge.phpdt.core.ICodeFormatter; import net.sourceforge.phpdt.core.compiler.CharOperation; import net.sourceforge.phpdt.core.compiler.ITerminalSymbols; @@ -781,7 +783,9 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { && previousToken != TokenNameRBRACE && previousToken != TokenNamesuper) { // && previousToken != TokenNamethis) { - space(); + if (!options.compactArrays) { + space(); + } } // If in a for/if/while statement, increase the parenthesis // count @@ -795,20 +799,34 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { // recognize array declaration for nice output if (previousCompilableToken == TokenNamearray) { arrayDeclarationCount++; - arrayDeclarationParenthesis[arrayDeclarationCount] = openParenthesis[openParenthesisCount]; - indentationLevel++; - pendingNewLines = 1; + arrayDeclarationParenthesis[arrayDeclarationCount] = openParenthesis[openParenthesisCount - 1]; + if (!options.compactArrays) { + indentationLevel++; + pendingNewLines = 1; + } } // S } break; case TokenNameRPAREN: // check for closing array declaration if (arrayDeclarationCount > 0) { - if (arrayDeclarationParenthesis[arrayDeclarationCount] == openParenthesis[openParenthesisCount]) { + if (arrayDeclarationParenthesis[arrayDeclarationCount] == openParenthesis[openParenthesisCount - 1]) { if (previousCompilableToken != TokenNameLPAREN) { - newLine(1); + if (!options.compactArrays) { + newLine(1); + } + } else if (previousToken == TokenNameCOMMENT_LINE + || previousToken == TokenNameCOMMENT_BLOCK + || previousToken == TokenNameCOMMENT_PHPDOC) { + // prevent to combine comment line and statement line (#1475484) + if (!options.compactArrays) { + newLine(1); + } + } + if (!options.compactArrays) { + indentationLevel--; + } - indentationLevel--; currentLineIndentationLevel = indentationLevel; pendingNewLines = 0; arrayDeclarationCount--; @@ -913,11 +931,18 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { case TokenNameCOMMA: pendingSpace = false; if (arrayDeclarationCount > 0) { - pendingNewLines = 1; + if (arrayDeclarationParenthesis[arrayDeclarationCount] == openParenthesis[openParenthesisCount - 1]) { + // there is no left parenthesis to close in current array declaration (#1475484) + if (!options.compactArrays) { + pendingNewLines = 1; + } + } } break; case TokenNameDOT: - space(); + if (!options.compactStringConcatenation) { + space(); + } pendingSpace = false; break; case TokenNameSEMICOLON: @@ -975,9 +1000,9 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { break; case Scanner.TokenNameCOMMENT_LINE: pendingNewLines = 1; - if (inAssignment) { - currentLineIndentationLevel++; - } + //if (inAssignment) { + // currentLineIndentationLevel++; + //} break; // a line is always inserted after a one-line // comment case Scanner.TokenNameCOMMENT_PHPDOC: @@ -1439,6 +1464,8 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { case TokenNameDOLLAR: case Scanner.TokenNameCOMMENT_LINE: return false; + case TokenNameDOT: + return !options.compactStringConcatenation; default: return true; }