From: khartlage Date: Mon, 31 Mar 2003 20:02:18 +0000 (+0000) Subject: Codeformatter preferences should work now X-Git-Url: http://secure.phpeclipse.com Codeformatter preferences should work now --- 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 98f4f2c..8d764c4 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 @@ -445,17 +445,17 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { */ // Do not add a new line between ELSE and IF, if the option elseIfOnSameLine is true. // Fix for 1ETLWPZ: IVJCOM:ALL - incorrect "else if" formatting - if (pendingNewlineAfterParen - && previousCompilableToken == TokenNameelse - && token == TokenNameif - && options.compactElseIfMode) { - pendingNewlineAfterParen = false; - pendingNewLines = 0; - indentationLevel += pop(TokenNameelse); - // because else if is now one single statement, - // the indentation level after it is increased by one and not by 2 - // (else = 1 indent, if = 1 indent, but else if = 1 indent, not 2). - } +// if (pendingNewlineAfterParen +// && previousCompilableToken == TokenNameelse +// && token == TokenNameif +// && options.compactElseIfMode) { +// pendingNewlineAfterParen = false; +// pendingNewLines = 0; +// indentationLevel += pop(TokenNameelse); +// // because else if is now one single statement, +// // the indentation level after it is increased by one and not by 2 +// // (else = 1 indent, if = 1 indent, but else if = 1 indent, not 2). +// } // Add a newline & indent to the formatted source string if // a for/if-else/while statement was scanned and there is no block // following it. @@ -1121,7 +1121,7 @@ public class CodeFormatter implements ITerminalSymbols, ICodeFormatter { return new ConfigurableOption[] { new ConfigurableOption(componentName, "newline.openingBrace", locale, options.newLineBeforeOpeningBraceMode ? 0 : 1), //$NON-NLS-1$ new ConfigurableOption(componentName, "newline.controlStatement", locale, options.newlineInControlStatementMode ? 0 : 1), //$NON-NLS-1$ new ConfigurableOption(componentName, "newline.clearAll", locale, options.clearAllBlankLinesMode ? 0 : 1), //$NON-NLS-1$ - new ConfigurableOption(componentName, "newline.elseIf", locale, options.compactElseIfMode ? 0 : 1), //$NON-NLS-1$ +// new ConfigurableOption(componentName, "newline.elseIf", locale, options.compactElseIfMode ? 0 : 1), //$NON-NLS-1$ new ConfigurableOption(componentName, "newline.emptyBlock", locale, options.newLineInEmptyBlockMode ? 0 : 1), //$NON-NLS-1$ new ConfigurableOption(componentName, "line.split", locale, options.maxLineLength), //$NON-NLS-1$ new ConfigurableOption(componentName, "style.compactAssignment", locale, options.compactAssignmentMode ? 0 : 1), //$NON-NLS-1$ 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 ba4127f..3b9f9b7 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 @@ -17,15 +17,15 @@ public class FormatterOptions { /** * Option IDs */ - public static final String OPTION_InsertNewlineBeforeOpeningBrace = "net.sourceforge.phpdt.core.formatter.newline.openingBrace"; //$NON-NLS-1$ - public static final String OPTION_InsertNewlineInControlStatement = "net.sourceforge.phpdt.core.formatter.newline.controlStatement"; //$NON-NLS-1$ - public static final String OPTION_InsertNewLineBetweenElseAndIf = "net.sourceforge.phpdt.core.formatter.newline.elseIf"; //$NON-NLS-1$ - public static final String OPTION_InsertNewLineInEmptyBlock = "net.sourceforge.phpdt.core.formatter.newline.emptyBlock"; //$NON-NLS-1$ - public static final String OPTION_ClearAllBlankLines = "net.sourceforge.phpdt.core.formatter.newline.clearAll"; //$NON-NLS-1$ - public static final String OPTION_SplitLineExceedingLength = "net.sourceforge.phpdt.core.formatter.lineSplit"; //$NON-NLS-1$ - public static final String OPTION_CompactAssignment = "net.sourceforge.phpdt.core.formatter.style.assignment"; //$NON-NLS-1$ - public static final String OPTION_TabulationChar = "net.sourceforge.phpdt.core.formatter.tabulation.char"; //$NON-NLS-1$ - public static final String OPTION_TabulationSize = "net.sourceforge.phpdt.core.formatter.tabulation.size"; //$NON-NLS-1$ + public static final String OPTION_InsertNewlineBeforeOpeningBrace = "net.sourceforge.phpeclipse.core.formatter.newline.openingBrace"; //$NON-NLS-1$ + public static final String OPTION_InsertNewlineInControlStatement = "net.sourceforge.phpeclipse.core.formatter.newline.controlStatement"; //$NON-NLS-1$ + // public static final String OPTION_InsertNewLineBetweenElseAndIf = "net.sourceforge.phpeclipse.core.formatter.newline.elseIf"; //$NON-NLS-1$ + public static final String OPTION_InsertNewLineInEmptyBlock = "net.sourceforge.phpeclipse.core.formatter.newline.emptyBlock"; //$NON-NLS-1$ + public static final String OPTION_ClearAllBlankLines = "net.sourceforge.phpeclipse.core.formatter.newline.clearAll"; //$NON-NLS-1$ + public static final String OPTION_SplitLineExceedingLength = "net.sourceforge.phpeclipse.core.formatter.lineSplit"; //$NON-NLS-1$ + 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 INSERT = "insert"; //$NON-NLS-1$ public static final String DO_NOT_INSERT = "do not insert"; //$NON-NLS-1$ @@ -55,7 +55,7 @@ public class FormatterOptions { public int tabSize = 4; // n spaces for one tab public boolean indentWithTab = true; - public boolean compactElseIfMode = true; + //public boolean compactElseIfMode = true; // if true, else and if are kept on the same line. public boolean newLineInEmptyBlockMode = true; // if false, no new line in {} if it's empty. @@ -108,14 +108,14 @@ public class FormatterOptions { } continue; } - if (optionID.equals(OPTION_InsertNewLineBetweenElseAndIf)) { - if (optionValue.equals(INSERT)) { - this.compactElseIfMode = false; - } else if (optionValue.equals(DO_NOT_INSERT)) { - this.compactElseIfMode = true; - } - continue; - } +// if (optionID.equals(OPTION_InsertNewLineBetweenElseAndIf)) { +// if (optionValue.equals(INSERT)) { +// this.compactElseIfMode = false; +// } else if (optionValue.equals(DO_NOT_INSERT)) { +// this.compactElseIfMode = true; +// } +// continue; +// } if (optionID.equals(OPTION_InsertNewLineInEmptyBlock)) { if (optionValue.equals(INSERT)) { this.newLineInEmptyBlockMode = true; @@ -184,9 +184,9 @@ public class FormatterOptions { public boolean isCompactingAssignment() { return compactAssignmentMode; } - public boolean isCompactingElseIf() { - return compactElseIfMode; - } +// public boolean isCompactingElseIf() { +// return compactElseIfMode; +// } public boolean isUsingTabForIndenting() { return indentWithTab; } @@ -202,8 +202,8 @@ public class FormatterOptions { /** * @deprecated - should use a Map when creating the options. */ - public void setCompactElseIfMode(boolean flag) { - compactElseIfMode = flag; - } +// public void setCompactElseIfMode(boolean flag) { +// compactElseIfMode = flag; +// } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeFormatterPreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeFormatterPreferencePage.java index bd714b3..7250029 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeFormatterPreferencePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/preferences/CodeFormatterPreferencePage.java @@ -52,7 +52,7 @@ public class CodeFormatterPreferencePage extends PreferencePage implements IWork private static final String PREF_NEWLINE_OPENING_BRACES= PHPCore.FORMATTER_NEWLINE_OPENING_BRACE; private static final String PREF_NEWLINE_CONTROL_STATEMENT= PHPCore.FORMATTER_NEWLINE_CONTROL; private static final String PREF_NEWLINE_CLEAR_ALL= PHPCore.FORMATTER_CLEAR_BLANK_LINES; - private static final String PREF_NEWLINE_ELSE_IF= PHPCore.FORMATTER_NEWLINE_ELSE_IF; + // private static final String PREF_NEWLINE_ELSE_IF= PHPCore.FORMATTER_NEWLINE_ELSE_IF; private static final String PREF_NEWLINE_EMPTY_BLOCK= PHPCore.FORMATTER_NEWLINE_EMPTY_BLOCK; private static final String PREF_LINE_SPLIT= PHPCore.FORMATTER_LINE_SPLIT; private static final String PREF_STYLE_COMPACT_ASSIGNEMENT= PHPCore.FORMATTER_COMPACT_ASSIGNMENT; @@ -76,7 +76,8 @@ public class CodeFormatterPreferencePage extends PreferencePage implements IWork private static String[] getAllKeys() { return new String[] { PREF_NEWLINE_OPENING_BRACES, PREF_NEWLINE_CONTROL_STATEMENT, PREF_NEWLINE_CLEAR_ALL, - PREF_NEWLINE_ELSE_IF, PREF_NEWLINE_EMPTY_BLOCK, PREF_LINE_SPLIT, + // PREF_NEWLINE_ELSE_IF, + PREF_NEWLINE_EMPTY_BLOCK, PREF_LINE_SPLIT, PREF_STYLE_COMPACT_ASSIGNEMENT, PREF_TAB_CHAR, PREF_TAB_SIZE }; } @@ -243,8 +244,8 @@ public class CodeFormatterPreferencePage extends PreferencePage implements IWork label= PHPUIMessages.getString("CodeFormatterPreferencePage.newline_clear_lines"); //$NON-NLS-1$ addCheckBox(newlineComposite, label, PREF_NEWLINE_CLEAR_ALL, new String[] { CLEAR_ALL, PRESERVE_ONE } ); - label= PHPUIMessages.getString("CodeFormatterPreferencePage.newline_else_if.label"); //$NON-NLS-1$ - addCheckBox(newlineComposite, label, PREF_NEWLINE_ELSE_IF, insertNotInsert); +// label= PHPUIMessages.getString("CodeFormatterPreferencePage.newline_else_if.label"); //$NON-NLS-1$ +// addCheckBox(newlineComposite, label, PREF_NEWLINE_ELSE_IF, insertNotInsert); label= PHPUIMessages.getString("CodeFormatterPreferencePage.newline_empty_block.label"); //$NON-NLS-1$ addCheckBox(newlineComposite, label, PREF_NEWLINE_EMPTY_BLOCK, insertNotInsert);