From 5bbcebd072a22e69270f963f6accbefa66efd074 Mon Sep 17 00:00:00 2001 From: durel_b Date: Wed, 22 Oct 2003 17:45:20 +0000 Subject: [PATCH] compact the dereferencing operator in the formatter ($c->m stay as this insted of being break in $c -> m) --- .../phpdt/internal/formatter/CodeFormatter.java | 6 ++++++ .../internal/formatter/impl/FormatterOptions.java | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletions(-) 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 3d70337..30ed629 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 @@ -890,6 +890,8 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { // (eg: ++, --, +, -) and the identifier being modified. if (previousToken == TokenNamePLUS_PLUS || previousToken == TokenNameMINUS_MINUS + || (previousToken == TokenNameMINUS_GREATER && + options.compactDereferencingMode) // -> || (previousToken == TokenNamePLUS && unarySignModifier > 0) || (previousToken == TokenNameMINUS && unarySignModifier > 0)) { pendingSpace = false; @@ -912,7 +914,11 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { 7) in an assignment statement, if the previous token is an open brace or the current token is a close brace 8) previous token is a single line comment + 9) current token is a '->' */ + if (token == TokenNameMINUS_GREATER && + options.compactDereferencingMode) pendingSpace = false; + boolean openAndCloseBrace = previousCompilableToken == TokenNameLBRACE && token == TokenNameRBRACE; if (pendingSpace diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/impl/FormatterOptions.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/impl/FormatterOptions.java index 3b9f9b7..b8f8626 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/impl/FormatterOptions.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/formatter/impl/FormatterOptions.java @@ -26,7 +26,9 @@ public class FormatterOptions { public static final String OPTION_CompactAssignment = "net.sourceforge.phpeclipse.core.formatter.style.assignment"; //$NON-NLS-1$ public static final String OPTION_TabulationChar = "net.sourceforge.phpeclipse.core.formatter.tabulation.char"; //$NON-NLS-1$ public static final String OPTION_TabulationSize = "net.sourceforge.phpeclipse.core.formatter.tabulation.size"; //$NON-NLS-1$ - + public static final String OPTION_CompactDereferencing = "net.sourceforge.phpeclipse.core.formatter.style.assignment"; + // TODO: add the checkbox in the preferences panel ; load/save + public static final String INSERT = "insert"; //$NON-NLS-1$ public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$ public static final String PRESERVE_ONE = "preserve one"; //$NON-NLS-1$ @@ -50,6 +52,8 @@ public class FormatterOptions { public boolean compactAssignmentMode = false; // if isTrue, assignments look like x= 12 (not like x = 12); + public boolean compactDereferencingMode = true; + // if isTrue, dereferencing look like $obj->method (not like $obj -> method); //number of consecutive spaces used to replace the tab char public int tabSize = 4; // n spaces for one tab @@ -184,6 +188,9 @@ public class FormatterOptions { public boolean isCompactingAssignment() { return compactAssignmentMode; } + public boolean isCompactingDereferencing() { + return compactDereferencingMode; + } // public boolean isCompactingElseIf() { // return compactElseIfMode; // } -- 1.7.1