*/
public static final String FORMATTER_COMPACT_ASSIGNMENT = PLUGIN_ID
+ ".formatter.style.assignment"; //$NON-NLS-1$
+
+ /**
+ * Possible configurable option ID.
+ *
+ * @see #getDefaultOptions
+ * @since 2.0
+ */
+ public static final String FORMATTER_COMPACT_STRING_CONCATENATION = PLUGIN_ID
+ + ".formatter.style.compactStringConcatenation"; //$NON-NLS-1$
+ /**
+ * Possible configurable option ID.
+ *
+ * @see #getDefaultOptions
+ * @since 2.0
+ */
+ public static final String FORMATTER_COMPACT_ARRAYS = PLUGIN_ID
+ + ".formatter.style.compactArrays"; //$NON-NLS-1$
/**
* Possible configurable option ID.
preferences.setDefault(FORMATTER_COMPACT_ASSIGNMENT, NORMAL);
optionNames.add(FORMATTER_COMPACT_ASSIGNMENT);
+
+ preferences.setDefault(FORMATTER_COMPACT_ARRAYS, NORMAL);
+ optionNames.add(FORMATTER_COMPACT_ARRAYS);
+
+ preferences.setDefault(FORMATTER_COMPACT_STRING_CONCATENATION, NORMAL);
+ optionNames.add(FORMATTER_COMPACT_STRING_CONCATENATION);
preferences.setDefault(FORMATTER_TAB_CHAR, TAB);
optionNames.add(FORMATTER_TAB_CHAR);
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;
&& previousToken != TokenNameRBRACE
&& previousToken != TokenNamesuper) {
// && previousToken != TokenNamethis) {
- space();
+ if (!options.compactArrays) {
+ space();
+ }
}
// If in a for/if/while statement, increase the parenthesis
// count
if (previousCompilableToken == TokenNamearray) {
arrayDeclarationCount++;
arrayDeclarationParenthesis[arrayDeclarationCount] = openParenthesis[openParenthesisCount - 1];
- indentationLevel++;
- pendingNewLines = 1;
+ if (!options.compactArrays) {
+ indentationLevel++;
+ pendingNewLines = 1;
+ }
}
// S }
break;
if (arrayDeclarationCount > 0) {
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)
- newLine(1);
+ if (!options.compactArrays) {
+ newLine(1);
+ }
+ }
+ if (!options.compactArrays) {
+ indentationLevel--;
+
}
- indentationLevel--;
currentLineIndentationLevel = indentationLevel;
pendingNewLines = 0;
arrayDeclarationCount--;
if (arrayDeclarationCount > 0) {
if (arrayDeclarationParenthesis[arrayDeclarationCount] == openParenthesis[openParenthesisCount - 1]) {
// there is no left parenthesis to close in current array declaration (#1475484)
- pendingNewLines = 1;
+ if (!options.compactArrays) {
+ pendingNewLines = 1;
+ }
}
}
break;
case TokenNameDOT:
- space();
+ if (!options.compactStringConcatenation) {
+ space();
+ }
pendingSpace = false;
break;
case TokenNameSEMICOLON:
case TokenNameDOLLAR:
case Scanner.TokenNameCOMMENT_LINE:
return false;
+ case TokenNameDOT:
+ return !options.compactStringConcatenation;
default:
return true;
}
public static final String OPTION_CompactAssignment = "net.sourceforge.phpeclipse.formatter.style.assignment"; //$NON-NLS-1$
+ public static final String OPTION_CompactStringConcatenation = "net.sourceforge.phpeclipse.formatter.style.compactStringConcatenation"; //$NON-NLS-1$
+
+ public static final String OPTION_CompactArrays = "net.sourceforge.phpeclipse.formatter.style.compactArrays"; //$NON-NLS-1$
+
public static final String OPTION_TabulationChar = "net.sourceforge.phpeclipse.formatter.tabulation.char"; //$NON-NLS-1$
public static final String OPTION_TabulationSize = "net.sourceforge.phpeclipse.formatter.tabulation.size"; //$NON-NLS-1$
public int maxLineLength = 80;
public boolean compactAssignmentMode = false;
+
+ public boolean compactStringConcatenation = false;
+ public boolean compactArrays = false;
+
// if isTrue, assignments look like x= 12 (not like x = 12);
public boolean compactDereferencingMode = true;
}
continue;
}
+ if (optionID.equals(OPTION_CompactArrays)) {
+ if (optionValue.equals(COMPACT)) {
+ this.compactArrays = true;
+ } else if (optionValue.equals(NORMAL)) {
+ this.compactArrays = false;
+ }
+ continue;
+ }
+ if (optionID.equals(OPTION_CompactStringConcatenation)) {
+ if (optionValue.equals(COMPACT)) {
+ this.compactStringConcatenation = true;
+ } else if (optionValue.equals(NORMAL)) {
+ this.compactStringConcatenation = false;
+ }
+ continue;
+ }
if (optionID.equals(OPTION_TabulationChar)) {
if (optionValue.equals(TAB)) {
this.indentWithTab = true;
CodeFormatterPreferencePage.newline_empty_block.label=In&sert a new line inside an empty block
CodeFormatterPreferencePage.split_line.label=Ma&ximum line length:
CodeFormatterPreferencePage.style_compact_assignement.label=&Compact assignment
+CodeFormatterPreferencePage.style_compact_arrays.label=Compact &arrays
+CodeFormatterPreferencePage.style_compact_string_concatenation.label=Compact &string concatenation
CodeFormatterPreferencePage.tab_char.label=Indentation is represented by a &tab
CodeFormatterPreferencePage.tab_size.label=&Number of spaces representing a tab:
private static final String PREF_STYLE_COMPACT_ASSIGNEMENT = JavaCore.FORMATTER_COMPACT_ASSIGNMENT;
+ private static final String PREF_STYLE_COMPACT_STRING_CONCATENATION = JavaCore.FORMATTER_COMPACT_STRING_CONCATENATION;
+
+ private static final String PREF_STYLE_COMPACT_ARRAYS = JavaCore.FORMATTER_COMPACT_ARRAYS;
+
private static final String PREF_TAB_CHAR = JavaCore.FORMATTER_TAB_CHAR;
private static final String PREF_TAB_SIZE = JavaCore.FORMATTER_TAB_SIZE;
PREF_NEWLINE_CONTROL_STATEMENT, PREF_NEWLINE_CLEAR_ALL,
// PREF_NEWLINE_ELSE_IF,
PREF_NEWLINE_EMPTY_BLOCK, PREF_LINE_SPLIT,
- PREF_STYLE_COMPACT_ASSIGNEMENT, PREF_TAB_CHAR, PREF_TAB_SIZE };
+ PREF_STYLE_COMPACT_ASSIGNEMENT, PREF_STYLE_COMPACT_STRING_CONCATENATION,
+ PREF_STYLE_COMPACT_ARRAYS,
+ PREF_TAB_CHAR, PREF_TAB_SIZE };
}
/**
.getString("CodeFormatterPreferencePage.style_compact_assignement.label"); //$NON-NLS-1$
addCheckBox(styleComposite, label, PREF_STYLE_COMPACT_ASSIGNEMENT,
new String[] { COMPACT, NORMAL });
+
+ label = PHPUIMessages
+ .getString("CodeFormatterPreferencePage.style_compact_string_concatenation.label"); //$NON-NLS-1$
+ addCheckBox(styleComposite, label, PREF_STYLE_COMPACT_STRING_CONCATENATION,
+ new String[] { COMPACT, NORMAL });
+
+ label = PHPUIMessages
+ .getString("CodeFormatterPreferencePage.style_compact_arrays.label"); //$NON-NLS-1$
+ addCheckBox(styleComposite, label, PREF_STYLE_COMPACT_ARRAYS,
+ new String[] { COMPACT, NORMAL });
label = PHPUIMessages
.getString("CodeFormatterPreferencePage.tab_char.label"); //$NON-NLS-1$