View | Details | Raw Unified | Return to bug 148582 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/cdt/ui/tests/text/CAutoIndentTest.java (-4 / +46 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     Anton Leherbauer (Wind River Systems) - initial API and implementation
9
 *     Anton Leherbauer (Wind River Systems) - initial API and implementation
10
 *     Sergey Prigogin, Google
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.cdt.ui.tests.text;
13
package org.eclipse.cdt.ui.tests.text;
Lines 107-118 Link Here
107
		}
108
		}
108
109
109
		public void backspace(int n) throws BadLocationException {
110
		public void backspace(int n) throws BadLocationException {
110
			for (int i=0; i<n; ++i) {
111
			for (int i = 0; i < n; ++i) {
111
				backspace();
112
				backspace();
112
			}
113
			}
113
		}
114
		}
115
		
114
		public void backspace() throws BadLocationException {
116
		public void backspace() throws BadLocationException {
115
			TestDocumentCommand command = new TestDocumentCommand(fCaretOffset-1, 1, ""); //$NON-NLS-1$
117
			TestDocumentCommand command = new TestDocumentCommand(fCaretOffset - 1, 1, ""); //$NON-NLS-1$
116
			customizeDocumentCommand(command);
118
			customizeDocumentCommand(command);
117
			fCaretOffset = command.exec(fDoc);
119
			fCaretOffset = command.exec(fDoc);
118
		}
120
		}
Lines 139-144 Link Here
139
		public int moveCaret(int shift) {
141
		public int moveCaret(int shift) {
140
			return setCaretOffset(fCaretOffset + shift);
142
			return setCaretOffset(fCaretOffset + shift);
141
		}
143
		}
144
		
145
		public int goTo(int line) throws BadLocationException {
146
			fCaretOffset = fDoc.getLineOffset(line);
147
			return fCaretOffset;
148
		}
149
150
		public int goTo(int line, int column) throws BadLocationException {
151
			if (column < 0 || column > fDoc.getLineLength(line)) {
152
				throw new BadLocationException("No column " + column + " in line " + line); //$NON-NLS-1$ $NON-NLS-2$
153
			}
154
			fCaretOffset = fDoc.getLineOffset(line) + column;
155
			return fCaretOffset;
156
		}
142
157
143
		public int getCaretLine() throws BadLocationException {
158
		public int getCaretLine() throws BadLocationException {
144
			return fDoc.getLineOfOffset(fCaretOffset);
159
			return fDoc.getLineOfOffset(fCaretOffset);
Lines 162-168 Link Here
162
		}
177
		}
163
178
164
		public String getLine(int i) throws BadLocationException {
179
		public String getLine(int i) throws BadLocationException {
165
			IRegion region = fDoc.getLineInformation(getCaretLine()+i);
180
			IRegion region = fDoc.getLineInformation(getCaretLine() + i);
166
			return fDoc.get(region.getOffset(), region.getLength());
181
			return fDoc.get(region.getOffset(), region.getLength());
167
		}
182
		}
168
183
Lines 171-177 Link Here
171
		}
186
		}
172
187
173
		public String getContentType(int i) throws BadLocationException {
188
		public String getContentType(int i) throws BadLocationException {
174
			return TextUtilities.getContentType(fDoc, fPartitioning, fCaretOffset+i, false);
189
			return TextUtilities.getContentType(fDoc, fPartitioning, fCaretOffset + i, false);
175
		}
190
		}
176
	}
191
	}
177
192
Lines 271-276 Link Here
271
		assertEquals("\t\tint x = 5;", tester.getLine(1)); //$NON-NLS-1$
286
		assertEquals("\t\tint x = 5;", tester.getLine(1)); //$NON-NLS-1$
272
	}
287
	}
273
288
289
	public void testPasteAutoIndent() throws IOException, CoreException, BadLocationException {
290
		AutoEditTester tester = createAutoEditTester(); //$NON-NLS-1$
291
		tester.type("class A {\n"); //$NON-NLS-1$
292
		tester.goTo(1, 0);
293
		tester.paste("class B {\n" +
294
				     "protected:\n" +
295
				     "\tB();\n" +
296
				     "public:\n" +
297
				     "\tint getX() const {\n" +
298
				     "\t\treturn x_;\n" +
299
				     "\t}\n" +
300
				     "private:\n" +
301
				     "\tint x_;\n" +
302
				     "};\n"); //$NON-NLS-1$
303
		tester.goTo(1, 0);
304
		assertEquals("\tclass B {", tester.getLine(0)); //$NON-NLS-1$
305
		assertEquals("\tprotected:", tester.getLine(1)); //$NON-NLS-1$
306
		assertEquals("\t\tB();", tester.getLine(2)); //$NON-NLS-1$
307
		assertEquals("\tpublic:", tester.getLine(3)); //$NON-NLS-1$
308
		assertEquals("\t\tint getX() const {", tester.getLine(4)); //$NON-NLS-1$
309
		assertEquals("\t\t\treturn x_;", tester.getLine(5)); //$NON-NLS-1$
310
		assertEquals("\t\t}", tester.getLine(6)); //$NON-NLS-1$
311
		assertEquals("\tprivate:", tester.getLine(7)); //$NON-NLS-1$
312
		assertEquals("\t\tint x_;", tester.getLine(8)); //$NON-NLS-1$
313
		assertEquals("\t};", tester.getLine(9)); //$NON-NLS-1$
314
	}
315
274
	public void testDefaultAutoIndent() throws IOException, CoreException, BadLocationException {
316
	public void testDefaultAutoIndent() throws IOException, CoreException, BadLocationException {
275
		AutoEditTester tester = createAutoEditTester(); //$NON-NLS-1$
317
		AutoEditTester tester = createAutoEditTester(); //$NON-NLS-1$
276
		tester.type("   initial indent=3\n"); //$NON-NLS-1$
318
		tester.type("   initial indent=3\n"); //$NON-NLS-1$
(-)src/org/eclipse/cdt/core/formatter/CodeFormatter.java (+26 lines)
Lines 21-26 Link Here
21
 */
21
 */
22
public abstract class CodeFormatter {
22
public abstract class CodeFormatter {
23
23
24
  public static final String EMPTY_STRING = ""; //$NON-NLS-1$
25
24
	/**
26
	/**
25
	 * Unknown kind
27
	 * Unknown kind
26
	 */
28
	 */
Lines 46-51 Link Here
46
	 */
48
	 */
47
	public static final int K_COMPILATION_UNIT = 0x08;
49
	public static final int K_COMPILATION_UNIT = 0x08;
48
50
51
	/**
52
	 * Kind used to format a single-line comment
53
	 */
54
	public static final int K_SINGLE_LINE_COMMENT = 0x10;
55
	/**
56
	 * Kind used to format a multi-line comment
57
	 */
58
	public static final int K_MULTI_LINE_COMMENT = 0x20;
59
49
	/** 
60
	/** 
50
	 * Format <code>source</code>,
61
	 * Format <code>source</code>,
51
	 * and returns a text edit that correspond to the difference between the given string and the formatted string.
62
	 * and returns a text edit that correspond to the difference between the given string and the formatted string.
Lines 75-78 Link Here
75
	 * @param options - general formatter options
86
	 * @param options - general formatter options
76
	 */
87
	 */
77
	public abstract void setOptions(Map options);
88
	public abstract void setOptions(Map options);
89
  
90
  /**
91
   * Answers the string that corresponds to the indentation to the given indentation level or an empty string
92
   * if the indentation cannot be computed.
93
   * <p>This method needs to be overriden in a subclass.</p>
94
   * 
95
   * <p>The default implementation returns an empty string.</p>
96
   * 
97
   * @param indentationLevel the given indentation level
98
   * @return the string corresponding to the right indentation level
99
   * @exception IllegalArgumentException if the given indentation level is lower than zero
100
   */
101
  public String createIndentationString(int indentationLevel) {
102
    return EMPTY_STRING;
103
  }
78
}
104
}
(-)src/org/eclipse/cdt/core/formatter/CodeFormatterConstants.java (-3095 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 QNX Software Systems and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     QNX Software Systems - Initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.core.formatter;
13
14
import java.util.Map;
15
16
import org.eclipse.cdt.core.CCorePlugin;
17
import org.eclipse.cdt.internal.formatter.DefaultCodeFormatterOptions;
18
import org.eclipse.cdt.internal.formatter.align.Alignment;
19
20
/**
21
 */
22
public class CodeFormatterConstants {
23
24
	/**
25
	 * <pre>
26
	 * FORMATTER / Option for alignment of arguments in allocation expression
27
	 *     - option id:         "org.eclipse.cdt.core.formatter.language"
28
	 *     - possible values:   values proposed in class <code>ParserLanguage</code> 
29
	 *     - default:           ParserLanguage.CPP
30
	 * </pre>
31
	 */
32
	public static final String FORMATTER_LANGUAGE = CCorePlugin.PLUGIN_ID + ".formatter.language";	 //$NON-NLS-1$
33
	
34
	/**
35
	 * <pre>
36
	 * FORMATTER / Option for alignment of arguments in allocation expression
37
	 *     - option id:         "org.eclipse.cdt.core.formatter.current_file"
38
	 *     - possible values:   object of class <code>IFile</code> or <code>null</code> 
39
	 *     - default:           null
40
	 * </pre>
41
	 */
42
	public static final String FORMATTER_CURRENT_FILE = CCorePlugin.PLUGIN_ID + ".formatter.current_file";	 //$NON-NLS-1$
43
	
44
	/**
45
	 * <pre>
46
	 * FORMATTER / Value to set a brace location at the end of a line.
47
	 * </pre>
48
	 * @see #FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION
49
	 * @see #FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER
50
	 * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
51
	 * @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
52
 	 * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
53
 	 * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
54
	 * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
55
	 */
56
	public static final String END_OF_LINE = "end_of_line";	//$NON-NLS-1$
57
58
	/**
59
	 * <pre>
60
	 * FORMATTER / Value to set an option to false.
61
	 * </pre>
62
	 */
63
	public static final String FALSE = "false"; //$NON-NLS-1$
64
	
65
	/**
66
	 * <pre>
67
	 * FORMATTER / Option to align type members of a type declaration on column
68
	 *     - option id:         "org.eclipse.cdt.core.formatter.formatter.align_type_members_on_columns"
69
	 *     - possible values:   { TRUE, FALSE }
70
	 *     - default:           FALSE
71
	 * </pre>
72
	 * @see #TRUE
73
	 * @see #FALSE
74
	 */
75
	public static final String FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS = CCorePlugin.PLUGIN_ID + ".formatter.align_type_members_on_columns";	 //$NON-NLS-1$
76
77
	/**
78
	 * <pre>
79
	 * FORMATTER / Option for alignment of arguments in allocation expression
80
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_arguments_in_allocation_expression"
81
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
82
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
83
	 * </pre>
84
	 * @see #createAlignmentValue(boolean, int, int)
85
	 */
86
	public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_arguments_in_allocation_expression";	 //$NON-NLS-1$
87
	/**
88
	 * <pre>
89
	 * FORMATTER / Option for alignment of arguments in enum constant
90
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_arguments_in_enum_constant"
91
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
92
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
93
	 * </pre>
94
	 * @see #createAlignmentValue(boolean, int, int)
95
	 */
96
	public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_arguments_in_enum_constant";	 //$NON-NLS-1$
97
	/**
98
	 * <pre>
99
	 * FORMATTER / Option for alignment of arguments in explicit constructor call
100
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call"
101
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
102
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
103
	 * </pre>
104
	 * @see #createAlignmentValue(boolean, int, int)
105
	 */
106
	public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_arguments_in_explicit_constructor_call";	 //$NON-NLS-1$
107
	/**
108
	 * <pre>
109
	 * FORMATTER / Option for alignment of arguments in method invocation
110
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation"
111
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
112
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
113
	 * </pre>
114
	 * @see #createAlignmentValue(boolean, int, int)
115
	 */
116
	public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_arguments_in_method_invocation";	 //$NON-NLS-1$
117
	/**
118
	 * <pre>
119
	 * FORMATTER / Option for alignment of arguments in qualified allocation expression
120
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression"
121
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
122
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
123
	 * </pre>
124
	 * @see #createAlignmentValue(boolean, int, int)
125
	 */
126
	public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_arguments_in_qualified_allocation_expression";	 //$NON-NLS-1$
127
	/**
128
	 * <pre>
129
	 * FORMATTER / Option for alignment of assignment
130
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_assignment"
131
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
132
	 *     - default:           createAlignmentValue(false, M_NO_ALIGNMENT, INDENT_DEFAULT)
133
	 * </pre>
134
	 * @see #createAlignmentValue(boolean, int, int)
135
	 */
136
	public static final String FORMATTER_ALIGNMENT_FOR_ASSIGNMENT  = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_assignment";	 //$NON-NLS-1$
137
	/**
138
	 * <pre>
139
	 * FORMATTER / Option for alignment of binary expression
140
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_binary_expression"
141
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
142
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
143
	 * </pre>
144
	 * @see #createAlignmentValue(boolean, int, int)
145
	 */
146
	public static final String FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_binary_expression";	 //$NON-NLS-1$
147
	/**
148
	 * <pre>
149
	 * FORMATTER / Option for alignment of compact if
150
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_compact_if"
151
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
152
	 *     - default:           createAlignmentValue(false, WRAP_ONE_PER_LINE, INDENT_BY_ONE)
153
	 * </pre>
154
	 * @see #createAlignmentValue(boolean, int, int)
155
	 */
156
	public static final String FORMATTER_ALIGNMENT_FOR_COMPACT_IF = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_compact_if";	 //$NON-NLS-1$
157
	/**
158
	 * <pre>
159
	 * FORMATTER / Option for alignment of conditional expression
160
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_conditional_expression"
161
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
162
	 *     - default:           createAlignmentValue(false, WRAP_ONE_PER_LINE, INDENT_DEFAULT)
163
	 * </pre>
164
	 * @see #createAlignmentValue(boolean, int, int)
165
	 */
166
	public static final String FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_conditional_expression";	 //$NON-NLS-1$
167
	/**
168
	 * <pre>
169
	 * FORMATTER / Option for alignment of enum constants
170
	 *     - option id:        "org.eclipse.cdt.core.formatter.alignment_for_enum_constants"
171
	 *     - possible values:  values returned by <code>createAlignmentValue(boolean, int, int)</code> call
172
	 *     - default:          createAlignmentValue(false, WRAP_NO_SPLIT, INDENT_DEFAULT)
173
	 * </pre>
174
	 * @see #createAlignmentValue(boolean, int, int)
175
	 */
176
	public static final String FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_enum_constants";	 //$NON-NLS-1$
177
	/**
178
	 * <pre>
179
	 * FORMATTER / Option for alignment of expressions in array initializer
180
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer"
181
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
182
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
183
	 * </pre>
184
	 * @see #createAlignmentValue(boolean, int, int)
185
	 */
186
	public static final String FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_expressions_in_array_initializer";	 //$NON-NLS-1$
187
	/**
188
	 * <pre>
189
	 * FORMATTER / Option for alignment of multiple fields
190
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_multiple_fields"
191
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
192
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
193
	 * </pre>
194
	 * @see #createAlignmentValue(boolean, int, int)
195
	 */
196
	public static final String FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_multiple_fields";//$NON-NLS-1$	
197
	/**
198
	 * <pre>
199
	 * FORMATTER / Option for alignment of parameters in constructor declaration
200
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_parameters_in_constructor_declaration"
201
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
202
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
203
	 * </pre>
204
	 * @see #createAlignmentValue(boolean, int, int)
205
	 */
206
	public static final String FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_parameters_in_constructor_declaration";	 //$NON-NLS-1$
207
	/**
208
	 * <pre>
209
	 * FORMATTER / Option for alignment of parameters in method declaration
210
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration"
211
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
212
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
213
	 * </pre>
214
	 * @see #createAlignmentValue(boolean, int, int)
215
	 */
216
	public static final String FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_parameters_in_method_declaration";	 //$NON-NLS-1$
217
	/**
218
	 * <pre>
219
	 * FORMATTER / Option for alignment of selector in method invocation
220
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_selector_in_method_invocation"
221
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
222
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
223
	 * </pre>
224
	 * @see #createAlignmentValue(boolean, int, int)
225
	 */
226
	public static final String FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_selector_in_method_invocation";	 //$NON-NLS-1$
227
	/**
228
	 * <pre>
229
	 * FORMATTER / Option for alignment of superclass in type declaration
230
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_superclass_in_type_declaration"
231
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
232
	 *     - default:           createAlignmentValue(false, WRAP_NEXT_SHIFTED, INDENT_DEFAULT)
233
	 * </pre>
234
	 * @see #createAlignmentValue(boolean, int, int)
235
	 */
236
	public static final String FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_superclass_in_type_declaration";	 //$NON-NLS-1$
237
	/**
238
	 * <pre>
239
	 * FORMATTER / Option for alignment of superinterfaces in enum declaration
240
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration"
241
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
242
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
243
	 * </pre>
244
	 * @see #createAlignmentValue(boolean, int, int)
245
	 */
246
	public static final String FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_superinterfaces_in_enum_declaration";	 //$NON-NLS-1$
247
	/**
248
	 * <pre>
249
	 * FORMATTER / Option for alignment of superinterfaces in type declaration
250
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_superinterfaces_in_type_declaration"
251
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
252
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
253
	 * </pre>
254
	 * @see #createAlignmentValue(boolean, int, int)
255
	 */
256
	public static final String FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_superinterfaces_in_type_declaration";	 //$NON-NLS-1$
257
	/**
258
	 * <pre>
259
	 * FORMATTER / Option for alignment of throws clause in constructor declaration
260
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration"
261
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
262
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
263
	 * </pre>
264
	 * @see #createAlignmentValue(boolean, int, int)
265
	 */
266
	public static final String FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_throws_clause_in_constructor_declaration";	 //$NON-NLS-1$
267
	/**
268
	 * <pre>
269
	 * FORMATTER / Option for alignment of throws clause in method declaration
270
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration"
271
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
272
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
273
	 * </pre>
274
	 * @see #createAlignmentValue(boolean, int, int)
275
	 */
276
	public static final String FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_throws_clause_in_method_declaration";	 //$NON-NLS-1$
277
278
//	/**
279
//	 * <pre>
280
//	 * FORMATTER / Option to add blank lines after the imports declaration
281
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_after_imports"
282
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
283
//	 *     - default:           "0"
284
//	 * </pre>
285
//	 */
286
//	public static final String FORMATTER_BLANK_LINES_AFTER_IMPORTS = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_after_imports";	//$NON-NLS-1$
287
//	/**
288
//	 * <pre>
289
//	 * FORMATTER / Option to add blank lines after the package declaration
290
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_after_package"
291
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
292
//	 *     - default:           "0"
293
//	 * </pre>
294
//	 */
295
//	public static final String FORMATTER_BLANK_LINES_AFTER_PACKAGE = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_after_package";	//$NON-NLS-1$
296
//	/**
297
//	 * <pre>
298
//	 * FORMATTER / Option to add blank lines at the beginning of the method body
299
//	 *     - option id:         "org.eclipse.cdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body"
300
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
301
//	 *     - default:           "0"
302
//	 * </pre>
303
//	 */
304
//	public static final String FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY = CCorePlugin.PLUGIN_ID + ".formatter.number_of_blank_lines_at_beginning_of_method_body"; //$NON-NLS-1$
305
//	/**
306
//	 * <pre>
307
//	 * FORMATTER / Option to add blank lines before a field declaration
308
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_field"
309
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
310
//	 *     - default:           "0"
311
//	 * </pre>
312
//	 */
313
//	public static final String FORMATTER_BLANK_LINES_BEFORE_FIELD = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_field";	//$NON-NLS-1$
314
//	/**
315
//	 * <pre>
316
//	 * FORMATTER / Option to add blank lines before the first class body declaration
317
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_first_class_body_declaration"
318
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
319
//	 *     - default:           "0"
320
//	 * </pre>
321
//	 */
322
//	public static final String FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_first_class_body_declaration";	//$NON-NLS-1$
323
//	/**
324
//	 * <pre>
325
//	 * FORMATTER / Option to add blank lines before the imports declaration
326
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_imports"
327
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
328
//	 *     - default:           "0"
329
//	 * </pre>
330
//	 */
331
//	public static final String FORMATTER_BLANK_LINES_BEFORE_IMPORTS = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_imports";	//$NON-NLS-1$
332
//	/**
333
//	 * <pre>
334
//	 * FORMATTER / Option to add blank lines before a member type declaration
335
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_member_type"
336
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
337
//	 *     - default:           "0"
338
//	 * </pre>
339
//	 */
340
//	public static final String FORMATTER_BLANK_LINES_BEFORE_MEMBER_TYPE = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_member_type";	//$NON-NLS-1$
341
//	/**
342
//	 * <pre>
343
//	 * FORMATTER / Option to add blank lines before a method declaration
344
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_method"
345
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
346
//	 *     - default:           "0"
347
//	 * </pre>
348
//	 */
349
//	public static final String FORMATTER_BLANK_LINES_BEFORE_METHOD = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_method";	//$NON-NLS-1$
350
//	/**
351
//	 * <pre>
352
//	 * FORMATTER / Option to add blank lines before a new chunk
353
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_new_chunk"
354
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
355
//	 *     - default:           "0"
356
//	 * </pre>
357
//	 */
358
//	public static final String FORMATTER_BLANK_LINES_BEFORE_NEW_CHUNK = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_new_chunk";	//$NON-NLS-1$
359
//	/**
360
//	 * <pre>
361
//	 * FORMATTER / Option to add blank lines before the package declaration
362
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_package"
363
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
364
//	 *     - default:           "0"
365
//	 * </pre>
366
//	 */
367
//	public static final String FORMATTER_BLANK_LINES_BEFORE_PACKAGE = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_package";	//$NON-NLS-1$
368
//	/**
369
//	 * <pre>
370
//	 * FORMATTER / Option to add blank lines between type declarations
371
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_between_type_declarations"
372
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
373
//	 *     - default:           "0"
374
//	 * </pre>
375
//	 */
376
//	public static final String FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_between_type_declarations";	//$NON-NLS-1$
377
378
	/**
379
	 * <pre>
380
	 * FORMATTER / Option to position the braces of an annotation type declaration
381
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_annotation_type_declaration"
382
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
383
	 *     - default:           END_OF_LINE
384
	 * </pre>
385
	 * @see #END_OF_LINE
386
	 * @see #NEXT_LINE
387
	 * @see #NEXT_LINE_SHIFTED
388
	 * @see #NEXT_LINE_ON_WRAP
389
	 */
390
	public static final String FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_array_initializer";	//$NON-NLS-1$
391
	/**
392
	 * <pre>
393
	 * FORMATTER / Option to position the braces of a block
394
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_block"
395
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
396
	 *     - default:           END_OF_LINE
397
	 * </pre>
398
	 * @see #END_OF_LINE
399
	 * @see #NEXT_LINE
400
	 * @see #NEXT_LINE_SHIFTED
401
	 * @see #NEXT_LINE_ON_WRAP
402
	 */
403
	public static final String FORMATTER_BRACE_POSITION_FOR_BLOCK = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_block";	//$NON-NLS-1$
404
	/**
405
	 * <pre>
406
	 * FORMATTER / Option to position the braces of a block in a case statement when the block is the first statement following
407
	 *             the case
408
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_block_in_case"
409
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
410
	 *     - default:           END_OF_LINE
411
	 * </pre>
412
	 * @see #END_OF_LINE
413
	 * @see #NEXT_LINE
414
	 * @see #NEXT_LINE_SHIFTED
415
	 * @see #NEXT_LINE_ON_WRAP
416
	 */
417
	public static final String FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_block_in_case";	//$NON-NLS-1$
418
	/**
419
	 * <pre>
420
	 * FORMATTER / Option to position the braces of a constructor declaration
421
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_constructor_declaration"
422
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
423
	 *     - default:           END_OF_LINE
424
	 * </pre>
425
	 * @see #END_OF_LINE
426
	 * @see #NEXT_LINE
427
	 * @see #NEXT_LINE_SHIFTED
428
	 * @see #NEXT_LINE_ON_WRAP
429
	 */
430
	public static final String FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_constructor_declaration";	//$NON-NLS-1$
431
	/**
432
	 * <pre>
433
	 * FORMATTER / Option to position the braces of an enum constant
434
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_enum_constant"
435
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
436
	 *     - default:           END_OF_LINE
437
	 * </pre>
438
	 * @see #END_OF_LINE
439
	 * @see #NEXT_LINE
440
	 * @see #NEXT_LINE_SHIFTED
441
	 * @see #NEXT_LINE_ON_WRAP
442
	 */
443
	public static final String FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_enum_constant";	//$NON-NLS-1$
444
	/**
445
	 * <pre>
446
	 * FORMATTER / Option to position the braces of an enum declaration
447
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_enum_declaration"
448
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
449
	 *     - default:           END_OF_LINE
450
	 * </pre>
451
	 * @see #END_OF_LINE
452
	 * @see #NEXT_LINE
453
	 * @see #NEXT_LINE_SHIFTED
454
	 * @see #NEXT_LINE_ON_WRAP
455
	 */
456
	public static final String FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_enum_declaration";	//$NON-NLS-1$
457
	/**
458
	 * <pre>
459
	 * FORMATTER / Option to position the braces of a method declaration
460
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_method_declaration"
461
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
462
	 *     - default:           END_OF_LINE
463
	 * </pre>
464
	 * @see #END_OF_LINE
465
	 * @see #NEXT_LINE
466
	 * @see #NEXT_LINE_SHIFTED
467
	 * @see #NEXT_LINE_ON_WRAP
468
	 */
469
	public static final String FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_method_declaration";	//$NON-NLS-1$
470
	/**
471
	 * <pre>
472
	 * FORMATTER / Option to position the braces of a switch statement
473
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_switch"
474
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
475
	 *     - default:           END_OF_LINE
476
	 * </pre>
477
	 * @see #END_OF_LINE
478
	 * @see #NEXT_LINE
479
	 * @see #NEXT_LINE_SHIFTED
480
	 * @see #NEXT_LINE_ON_WRAP
481
	 */
482
	public static final String FORMATTER_BRACE_POSITION_FOR_SWITCH = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_switch";	//$NON-NLS-1$
483
	/**
484
	 * <pre>
485
	 * FORMATTER / Option to position the braces of a type declaration
486
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_type_declaration"
487
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
488
	 *     - default:           END_OF_LINE
489
	 * </pre>
490
	 * @see #END_OF_LINE
491
	 * @see #NEXT_LINE
492
	 * @see #NEXT_LINE_SHIFTED
493
	 * @see #NEXT_LINE_ON_WRAP
494
	 */
495
	public static final String FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_type_declaration";	//$NON-NLS-1$
496
497
//	/**
498
//	 * <pre>
499
//	 * FORMATTER / Option to control whether blank lines are cleared inside comments
500
//	 *     - option id:         "org.eclipse.cdt.core.formatter.comment.clear_blank_lines"
501
//	 *     - possible values:   { TRUE, FALSE }
502
//	 *     - default:           FALSE
503
//	 * </pre>
504
//	 * @see #TRUE
505
//	 * @see #FALSE
506
//	 */	
507
//	public final static String FORMATTER_COMMENT_CLEAR_BLANK_LINES = CCorePlugin.PLUGIN_ID + ".formatter.comment.clear_blank_lines"; //$NON-NLS-1$
508
	
509
//	/**
510
//	 * <pre>
511
//	 * FORMATTER / Option to control whether comments are formatted
512
//	 *     - option id:         "org.eclipse.cdt.core.formatter.comment.format_comments"
513
//	 *     - possible values:   { TRUE, FALSE }
514
//	 *     - default:           TRUE
515
//	 * </pre>
516
//	 * @see #TRUE
517
//	 * @see #FALSE
518
//	 */	
519
//	public final static String FORMATTER_COMMENT_FORMAT = CCorePlugin.PLUGIN_ID + ".formatter.comment.format_comments"; //$NON-NLS-1$
520
521
//	/**
522
//	 * <pre>
523
//	 * FORMATTER / Option to control whether the header comment of a C/C++ source file is formatted
524
//	 *     - option id:         "org.eclipse.cdt.core.formatter.comment.format_header"
525
//	 *     - possible values:   { TRUE, FALSE }
526
//	 *     - default:           FALSE
527
//	 * </pre>
528
//	 * @see #TRUE
529
//	 * @see #FALSE
530
//	 */	
531
//	public final static String FORMATTER_COMMENT_FORMAT_HEADER = CCorePlugin.PLUGIN_ID + ".formatter.comment.format_header"; //$NON-NLS-1$
532
533
//	/**
534
//	 * <pre>
535
//	 * FORMATTER / Option to control whether HTML tags are formatted.
536
//	 *     - option id:         "org.eclipse.cdt.core.formatter.comment.format_html"
537
//	 *     - possible values:   { TRUE, FALSE }
538
//	 *     - default:           TRUE
539
//	 * </pre>
540
//	 * @see #TRUE
541
//	 * @see #FALSE
542
//	 */	
543
//	public final static String FORMATTER_COMMENT_FORMAT_HTML = CCorePlugin.PLUGIN_ID + ".formatter.comment.format_html"; //$NON-NLS-1$
544
545
//	/**
546
//	 * <pre>
547
//	 * FORMATTER / Option to control whether code snippets are formatted in comments
548
//	 *     - option id:         "org.eclipse.cdt.core.formatter.comment.format_source_code"
549
//	 *     - possible values:   { TRUE, FALSE }
550
//	 *     - default:           TRUE
551
//	 * </pre>
552
//	 * @see #TRUE
553
//	 * @see #FALSE
554
//	 */	
555
//	public final static String FORMATTER_COMMENT_FORMAT_SOURCE = CCorePlugin.PLUGIN_ID + ".formatter.comment.format_source_code"; //$NON-NLS-1$
556
	
557
//	/**
558
//	 * <pre>
559
//	 * FORMATTER / Option to specify the line length for comments.
560
//	 *     - option id:         "org.eclipse.cdt.core.formatter.comment.line_length"
561
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
562
//	 *     - default:           "80"
563
//	 * </pre>
564
//	 */	
565
//	public final static String FORMATTER_COMMENT_LINE_LENGTH = CCorePlugin.PLUGIN_ID + ".formatter.comment.line_length"; //$NON-NLS-1$
566
567
//	/**
568
//	 * <pre>
569
//	 * FORMATTER / Option to compact else/if
570
//	 *     - option id:         "org.eclipse.cdt.core.formatter.compact_else_if"
571
//	 *     - possible values:   { TRUE, FALSE }
572
//	 *     - default:           TRUE
573
//	 * </pre>
574
//	 * @see #TRUE
575
//	 * @see #FALSE
576
//	 */
577
//	public static final String FORMATTER_COMPACT_ELSE_IF = CCorePlugin.PLUGIN_ID + ".formatter.compact_else_if";	//$NON-NLS-1$
578
579
	/**
580
	 * <pre>
581
	 * FORMATTER / Option to set the continuation indentation
582
	 *     - option id:         "org.eclipse.cdt.core.formatter.continuation_indentation"
583
	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
584
	 *     - default:           "2"
585
	 * </pre>
586
	 */
587
	public static final String FORMATTER_CONTINUATION_INDENTATION = CCorePlugin.PLUGIN_ID + ".formatter.continuation_indentation";	//$NON-NLS-1$
588
	/**
589
	 * <pre>
590
	 * FORMATTER / Option to set the continuation indentation inside array initializer
591
	 *     - option id:         "org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer"
592
	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
593
	 *     - default:           "2"
594
	 * </pre>
595
	 */
596
	public static final String FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.continuation_indentation_for_array_initializer";	//$NON-NLS-1$
597
	/**
598
	 * <pre>
599
	 * FORMATTER / Option to indent body declarations compare to its enclosing annotation declaration header
600
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header"
601
	 *     - possible values:   { TRUE, FALSE }
602
	 *     - default:           TRUE
603
	 * </pre>
604
	 * @see #TRUE
605
	 * @see #FALSE
606
	 */
607
	public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER = CCorePlugin.PLUGIN_ID + ".formatter.indent_body_declarations_compare_to_annotation_declaration_header";	//$NON-NLS-1$
608
	/**
609
	 * <pre>
610
	 * FORMATTER / Option to indent body declarations compare to its enclosing enum constant header
611
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header"
612
	 *     - possible values:   { TRUE, FALSE }
613
	 *     - default:           TRUE
614
	 * </pre>
615
	 * @see #TRUE
616
	 * @see #FALSE
617
	 */
618
	public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER = CCorePlugin.PLUGIN_ID + ".formatter.indent_body_declarations_compare_to_enum_constant_header";	//$NON-NLS-1$
619
	/**
620
	 * <pre>
621
	 * FORMATTER / Option to indent body declarations compare to its enclosing enum declaration header
622
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header"
623
	 *     - possible values:   { TRUE, FALSE }
624
	 *     - default:           TRUE
625
	 * </pre>
626
	 * @see #TRUE
627
	 * @see #FALSE
628
	 */
629
	public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER = CCorePlugin.PLUGIN_ID + ".formatter.indent_body_declarations_compare_to_enum_declaration_header";	//$NON-NLS-1$
630
	/**
631
	 * <pre>
632
	 * FORMATTER / Option to indent body declarations compare to its enclosing type header
633
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_type_header"
634
	 *     - possible values:   { TRUE, FALSE }
635
	 *     - default:           TRUE
636
	 * </pre>
637
	 * @see #TRUE
638
	 * @see #FALSE
639
	 */
640
	public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER = CCorePlugin.PLUGIN_ID + ".formatter.indent_body_declarations_compare_to_type_header";	//$NON-NLS-1$
641
	/**
642
	 * <pre>
643
	 * FORMATTER / Option to indent breaks compare to cases
644
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases"
645
	 *     - possible values:   { TRUE, FALSE }
646
	 *     - default:           TRUE
647
	 * </pre>
648
	 * @see #TRUE
649
	 * @see #FALSE
650
	 */
651
	public static final String FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES = CCorePlugin.PLUGIN_ID + ".formatter.indent_breaks_compare_to_cases";	//$NON-NLS-1$
652
	/**
653
	 * <pre>
654
	 * FORMATTER / Option to indent empty lines
655
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_empty_lines"
656
	 *     - possible values:   { TRUE, FALSE }
657
	 *     - default:           FALSE
658
	 * </pre>
659
	 * @see #TRUE
660
	 * @see #FALSE
661
	 */
662
	public static final String FORMATTER_INDENT_EMPTY_LINES = CCorePlugin.PLUGIN_ID + ".formatter.indent_empty_lines"; //$NON-NLS-1$	
663
	/**
664
	 * <pre>
665
	 * FORMATTER / Option to indent statements inside a block
666
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_statements_compare_to_block"
667
	 *     - possible values:   { TRUE, FALSE }
668
	 *     - default:           TRUE
669
	 * </pre>
670
	 * @see #TRUE
671
	 * @see #FALSE
672
	 */
673
	public static final String FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK = CCorePlugin.PLUGIN_ID + ".formatter.indent_statements_compare_to_block"; //$NON-NLS-1$
674
	/**
675
	 * <pre>
676
	 * FORMATTER / Option to indent statements inside the body of a method or a constructor
677
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_statements_compare_to_body"
678
	 *     - possible values:   { TRUE, FALSE }
679
	 *     - default:           TRUE
680
	 * </pre>
681
	 * @see #TRUE
682
	 * @see #FALSE
683
	 */
684
	public static final String FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY = CCorePlugin.PLUGIN_ID + ".formatter.indent_statements_compare_to_body"; //$NON-NLS-1$
685
	/**
686
	 * <pre>
687
	 * FORMATTER / Option to indent switch statements compare to cases
688
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases"
689
	 *     - possible values:   { TRUE, FALSE }
690
	 *     - default:           TRUE
691
	 * </pre>
692
	 * @see #TRUE
693
	 * @see #FALSE
694
	 */
695
	public static final String FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES = CCorePlugin.PLUGIN_ID + ".formatter.indent_switchstatements_compare_to_cases";	//$NON-NLS-1$
696
	/**
697
	 * <pre>
698
	 * FORMATTER / Option to indent switch statements compare to switch
699
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch"
700
	 *     - possible values:   { TRUE, FALSE }
701
	 *     - default:           TRUE
702
	 * </pre>
703
	 * @see #TRUE
704
	 * @see #FALSE
705
	 */
706
	public static final String FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH = CCorePlugin.PLUGIN_ID + ".formatter.indent_switchstatements_compare_to_switch";	//$NON-NLS-1$
707
708
	/**
709
	 * <pre>
710
	 * FORMATTER / Option to specify the equivalent number of spaces that represents one indentation 
711
	 *     - option id:         "org.eclipse.cdt.core.formatter.indentation.size"
712
	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
713
	 *     - default:           "4"
714
	 * </pre>
715
	 * <p>This option is used only if the tab char is set to MIXED.
716
	 * </p>
717
	 * @see #FORMATTER_TAB_CHAR
718
	 */
719
	public static final String FORMATTER_INDENTATION_SIZE = CCorePlugin.PLUGIN_ID + ".formatter.indentation.size"; //$NON-NLS-1$
720
721
//	/**
722
//	 * <pre>
723
//	 * FORMATTER / Option to insert a new line after an annotation
724
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_after_annotation"
725
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
726
//	 *     - default:           INSERT
727
//	 * </pre>
728
//	 * @see CCorePlugin#INSERT
729
//	 * @see CCorePlugin#DO_NOT_INSERT
730
//	 */
731
//	public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_after_annotation";//$NON-NLS-1$
732
//
733
//	/**
734
//	 * <pre>
735
//	 * FORMATTER / Option to insert a new line after the opening brace in an array initializer
736
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer"
737
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
738
//	 *     - default:           DO_NOT_INSERT
739
//	 * </pre>
740
//	 * @see CCorePlugin#INSERT
741
//	 * @see CCorePlugin#DO_NOT_INSERT
742
//	 */
743
//	public static final String FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_after_opening_brace_in_array_initializer";//$NON-NLS-1$
744
//
745
//	/**
746
//	 * <pre>
747
//	 * FORMATTER / Option to insert a new line at the end of the current file if missing
748
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing"
749
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
750
//	 *     - default:           DO_NOT_INSERT
751
//	 * </pre>
752
//	 * @see CCorePlugin#INSERT
753
//	 * @see CCorePlugin#DO_NOT_INSERT
754
//	 */
755
//	public static final String FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_at_end_of_file_if_missing";//$NON-NLS-1$
756
//	/**
757
//	 * <pre>
758
//	 * FORMATTER / Option to insert a new line before the catch keyword in try statement
759
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement"
760
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
761
//	 *     - default:           DO_NOT_INSERT
762
//	 * </pre>
763
//	 * @see CCorePlugin#INSERT
764
//	 * @see CCorePlugin#DO_NOT_INSERT
765
//	 */
766
//	public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_before_catch_in_try_statement";	//$NON-NLS-1$
767
//	/**
768
//	 * <pre>
769
//	 * FORMATTER / Option to insert a new line before the closing brace in an array initializer
770
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer"
771
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
772
//	 *     - default:           DO_NOT_INSERT
773
//	 * </pre>
774
//	 * @see CCorePlugin#INSERT
775
//	 * @see CCorePlugin#DO_NOT_INSERT
776
//	 */
777
//	public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_before_closing_brace_in_array_initializer";//$NON-NLS-1$
778
//	/**
779
//	 * <pre>
780
//	 * FORMATTER / Option to insert a new line before the else keyword in if statement
781
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement"
782
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
783
//	 *     - default:           DO_NOT_INSERT
784
//	 * </pre>
785
//	 * @see CCorePlugin#INSERT
786
//	 * @see CCorePlugin#DO_NOT_INSERT
787
//	 */
788
//	public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_before_else_in_if_statement";	//$NON-NLS-1$
789
//	/**
790
//	 * <pre>
791
//	 * FORMATTER / Option to insert a new line before the finally keyword in try statement
792
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_before_finally_in_try_statement"
793
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
794
//	 *     - default:           DO_NOT_INSERT
795
//	 * </pre>
796
//	 * @see CCorePlugin#INSERT
797
//	 * @see CCorePlugin#DO_NOT_INSERT
798
//	 */
799
//	public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_before_finally_in_try_statement";	//$NON-NLS-1$
800
//	/**
801
//	 * <pre>
802
//	 * FORMATTER / Option to insert a new line before while in do statement
803
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement"
804
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
805
//	 *     - default:           DO_NOT_INSERT
806
//	 * </pre>
807
//	 * @see CCorePlugin#INSERT
808
//	 * @see CCorePlugin#DO_NOT_INSERT
809
//	 */
810
//	public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_before_while_in_do_statement";	//$NON-NLS-1$
811
//	/**
812
//	 * <pre>
813
//	 * FORMATTER / Option to insert a new line in an empty annotation declaration
814
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_annotation_declaration"
815
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
816
//	 *     - default:           INSERT
817
//	 * </pre>
818
//	 * @see CCorePlugin#INSERT
819
//	 * @see CCorePlugin#DO_NOT_INSERT
820
//	 */
821
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_annotation_declaration";	//$NON-NLS-1$
822
//	/**
823
//	 * <pre>
824
//	 * FORMATTER / Option to insert a new line in an empty anonymous type declaration
825
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration"
826
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
827
//	 *     - default:           INSERT
828
//	 * </pre>
829
//	 * @see CCorePlugin#INSERT
830
//	 * @see CCorePlugin#DO_NOT_INSERT
831
//	 */
832
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_anonymous_type_declaration";	//$NON-NLS-1$
833
//	/**
834
//	 * <pre>
835
//	 * FORMATTER / Option to insert a new line in an empty block
836
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block"
837
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
838
//	 *     - default:           INSERT
839
//	 * </pre>
840
//	 * @see CCorePlugin#INSERT
841
//	 * @see CCorePlugin#DO_NOT_INSERT
842
//	 */
843
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_block";	//$NON-NLS-1$
844
//	/**
845
//	 * <pre>
846
//	 * FORMATTER / Option to insert a new line in an empty enum constant
847
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_enum_constant"
848
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
849
//	 *     - default:           INSERT
850
//	 * </pre>
851
//	 * @see CCorePlugin#INSERT
852
//	 * @see CCorePlugin#DO_NOT_INSERT
853
//	 */
854
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_enum_constant";	//$NON-NLS-1$
855
//	/**
856
//	 * <pre>
857
//	 * FORMATTER / Option to insert a new line in an empty enum declaration
858
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_enum_declaration"
859
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
860
//	 *     - default:           INSERT
861
//	 * </pre>
862
//	 * @see CCorePlugin#INSERT
863
//	 * @see CCorePlugin#DO_NOT_INSERT
864
//	 */
865
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_enum_declaration";	//$NON-NLS-1$
866
//	/**
867
//	 * <pre>
868
//	 * FORMATTER / Option to insert a new line in an empty method body
869
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_method_body"
870
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
871
//	 *     - default:           INSERT
872
//	 * </pre>
873
//	 * @see CCorePlugin#INSERT
874
//	 * @see CCorePlugin#DO_NOT_INSERT
875
//	 */
876
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_method_body";	//$NON-NLS-1$
877
//	/**
878
//	 * <pre>
879
//	 * FORMATTER / Option to insert a new line in an empty type declaration
880
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_type_declaration"
881
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
882
//	 *     - default:           INSERT
883
//	 * </pre>
884
//	 * @see CCorePlugin#INSERT
885
//	 * @see CCorePlugin#DO_NOT_INSERT
886
//	 */
887
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_type_declaration";	//$NON-NLS-1$
888
//	/**
889
//	 * <pre>
890
//	 * FORMATTER / Option to insert a space after and in wilcard
891
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_and_in_type_parameter"
892
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
893
//	 *     - default:           INSERT
894
//	 * </pre>
895
//	 * @see CCorePlugin#INSERT
896
//	 * @see CCorePlugin#DO_NOT_INSERT
897
//	 */
898
//	public static final String FORMATTER_INSERT_SPACE_AFTER_AND_IN_TYPE_PARAMETER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_and_in_type_parameter"; //$NON-NLS-1$
899
//	/**
900
//	 * <pre>
901
//	 * FORMATTER / Option to insert a space after an assignment operator
902
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator"
903
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
904
//	 *     - default:           INSERT
905
//	 * </pre>
906
//	 * @see CCorePlugin#INSERT
907
//	 * @see CCorePlugin#DO_NOT_INSERT
908
//	 */
909
//	public static final String FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_assignment_operator"; //$NON-NLS-1$
910
//	/**
911
//	 * <pre>
912
//	 * FORMATTER / Option to insert a space after at in annotation
913
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_at_in_annotation"
914
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
915
//	 *     - default:           INSERT
916
//	 * </pre>
917
//	 * @see CCorePlugin#INSERT
918
//	 * @see CCorePlugin#DO_NOT_INSERT
919
//	 */
920
//	public static final String FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_at_in_annotation"; //$NON-NLS-1$
921
//	/**
922
//	 * <pre>
923
//	 * FORMATTER / Option to insert a space after at in annotation type declaration
924
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_at_in_annotation_type_declaration"
925
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
926
//	 *     - default:           DO_NOT_INSERT
927
//	 * </pre>
928
//	 * @see CCorePlugin#INSERT
929
//	 * @see CCorePlugin#DO_NOT_INSERT
930
//	 */
931
//	public static final String FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_at_in_annotation_type_declaration"; //$NON-NLS-1$
932
//	/**
933
//	 * <pre>
934
//	 * FORMATTER / Option to insert a space after a binary operator
935
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_binary_operator"
936
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
937
//	 *     - default:           INSERT
938
//	 * </pre>
939
//	 * @see CCorePlugin#INSERT
940
//	 * @see CCorePlugin#DO_NOT_INSERT
941
//	 */
942
//	public static final String FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_binary_operator"; //$NON-NLS-1$
943
//	/**
944
//	 * <pre>
945
//	 * FORMATTER / Option to insert a space after the closing angle bracket in type arguments
946
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments"
947
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
948
//	 *     - default:           INSERT
949
//	 * </pre>
950
//	 * @see CCorePlugin#INSERT
951
//	 * @see CCorePlugin#DO_NOT_INSERT
952
//	 */
953
//	public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_closing_angle_bracket_in_type_arguments"; //$NON-NLS-1$
954
//	/**
955
//	 * <pre>
956
//	 * FORMATTER / Option to insert a space after the closing angle bracket in type parameters
957
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters"
958
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
959
//	 *     - default:           INSERT
960
//	 * </pre>
961
//	 * @see CCorePlugin#INSERT
962
//	 * @see CCorePlugin#DO_NOT_INSERT
963
//	 */
964
//	public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_closing_angle_bracket_in_type_parameters"; //$NON-NLS-1$
965
//	/**
966
//	 * <pre>
967
//	 * FORMATTER / Option to insert a space after the closing brace of a block
968
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block"
969
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
970
//	 *     - default:           INSERT
971
//	 * </pre>
972
//	 * @see CCorePlugin#INSERT
973
//	 * @see CCorePlugin#DO_NOT_INSERT
974
//	 */
975
//	public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_closing_brace_in_block"; //$NON-NLS-1$
976
//	/**
977
//	 * <pre>
978
//	 * FORMATTER / Option to insert a space after the closing parenthesis of a cast expression
979
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast"
980
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
981
//	 *     - default:           INSERT
982
//	 * </pre>
983
//	 * @see CCorePlugin#INSERT
984
//	 * @see CCorePlugin#DO_NOT_INSERT
985
//	 */
986
//	public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_closing_paren_in_cast"; //$NON-NLS-1$
987
//	/**
988
//	 * <pre>
989
//	 * FORMATTER / Option to insert a space after the colon in an assert statement
990
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_colon_in_assert"
991
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
992
//	 *     - default:           INSERT
993
//	 * </pre>
994
//	 * @see CCorePlugin#INSERT
995
//	 * @see CCorePlugin#DO_NOT_INSERT
996
//	 */
997
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_colon_in_assert"; //$NON-NLS-1$
998
//	/**
999
//	 * <pre>
1000
//	 * FORMATTER / Option to insert a space after colon in a case statement when a opening brace follows the colon
1001
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case"
1002
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1003
//	 *     - default:           INSERT
1004
//	 * </pre>
1005
//	 * @see CCorePlugin#INSERT
1006
//	 * @see CCorePlugin#DO_NOT_INSERT
1007
//	 */
1008
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CASE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_colon_in_case";	//$NON-NLS-1$
1009
//	/**
1010
//	 * <pre>
1011
//	 * FORMATTER / Option to insert a space after the colon in a conditional expression
1012
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional"
1013
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1014
//	 *     - default:           INSERT
1015
//	 * </pre>
1016
//	 * @see CCorePlugin#INSERT
1017
//	 * @see CCorePlugin#DO_NOT_INSERT
1018
//	 */
1019
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_colon_in_conditional"; //$NON-NLS-1$
1020
//	/**
1021
//	 * <pre>
1022
//	 * FORMATTER / Option to insert a space after colon in a for statement
1023
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_colon_in_for"
1024
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1025
//	 *     - default:           INSERT
1026
//	 * </pre>
1027
//	 * @see CCorePlugin#INSERT
1028
//	 * @see CCorePlugin#DO_NOT_INSERT
1029
//	 */
1030
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_colon_in_for";	//$NON-NLS-1$
1031
//	/**
1032
//	 * <pre>
1033
//	 * FORMATTER / Option to insert a space after the colon in a labeled statement
1034
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement"
1035
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1036
//	 *     - default:           INSERT
1037
//	 * </pre>
1038
//	 * @see CCorePlugin#INSERT
1039
//	 * @see CCorePlugin#DO_NOT_INSERT
1040
//	 */
1041
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_colon_in_labeled_statement"; //$NON-NLS-1$
1042
//	/**
1043
//	 * <pre>
1044
//	 * FORMATTER / Option to insert a space after the comma in an allocation expression
1045
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_allocation_expression"
1046
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1047
//	 *     - default:           INSERT
1048
//	 * </pre>
1049
//	 * @see CCorePlugin#INSERT
1050
//	 * @see CCorePlugin#DO_NOT_INSERT
1051
//	 */
1052
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_allocation_expression"; //$NON-NLS-1$
1053
//	/**
1054
//	 * <pre>
1055
//	 * FORMATTER / Option to insert a space after the comma in annotation
1056
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_annotation"
1057
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1058
//	 *     - default:           INSERT
1059
//	 * </pre>
1060
//	 * @see CCorePlugin#INSERT
1061
//	 * @see CCorePlugin#DO_NOT_INSERT
1062
//	 */
1063
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_annotation"; //$NON-NLS-1$
1064
//	/**
1065
//	 * <pre>
1066
//	 * FORMATTER / Option to insert a space after the comma in an array initializer
1067
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer"
1068
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1069
//	 *     - default:           INSERT
1070
//	 * </pre>
1071
//	 * @see CCorePlugin#INSERT
1072
//	 * @see CCorePlugin#DO_NOT_INSERT
1073
//	 */
1074
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_array_initializer"; //$NON-NLS-1$
1075
//	/**
1076
//	 * <pre>
1077
//	 * FORMATTER / Option to insert a space after the comma in the parameters of a constructor declaration
1078
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters"
1079
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1080
//	 *     - default:           INSERT
1081
//	 * </pre>
1082
//	 * @see CCorePlugin#INSERT
1083
//	 * @see CCorePlugin#DO_NOT_INSERT
1084
//	 */
1085
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_constructor_declaration_parameters"; //$NON-NLS-1$
1086
//	/**
1087
//	 * <pre>
1088
//	 * FORMATTER / Option to insert a space after the comma in the exception names in a throws clause of a constructor declaration
1089
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws"
1090
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1091
//	 *     - default:           INSERT
1092
//	 * </pre>
1093
//	 * @see CCorePlugin#INSERT
1094
//	 * @see CCorePlugin#DO_NOT_INSERT
1095
//	 */
1096
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_constructor_declaration_throws"; //$NON-NLS-1$
1097
//	/**
1098
//	 * <pre>
1099
//	 * FORMATTER / Option to insert a space after the comma in the arguments of an enum constant
1100
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments"
1101
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1102
//	 *     - default:           INSERT
1103
//	 * </pre>
1104
//	 * @see CCorePlugin#INSERT
1105
//	 * @see CCorePlugin#DO_NOT_INSERT
1106
//	 */
1107
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_CONSTANT_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_enum_constant_arguments"; //$NON-NLS-1$
1108
//	/**
1109
//	 * <pre>
1110
//	 * FORMATTER / Option to insert a space after the comma in enum declarations
1111
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations"
1112
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1113
//	 *     - default:           INSERT
1114
//	 * </pre>
1115
//	 * @see CCorePlugin#INSERT
1116
//	 * @see CCorePlugin#DO_NOT_INSERT
1117
//	 */
1118
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_enum_declarations"; //$NON-NLS-1$
1119
//	/**
1120
//	 * <pre>
1121
//	 * FORMATTER / Option to insert a space after the comma in the arguments of an explicit constructor call
1122
//	 *     - option id:         "org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments"
1123
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1124
//	 *     - default:           INSERT
1125
//	 * </pre>
1126
//	 * @see CCorePlugin#INSERT
1127
//	 * @see CCorePlugin#DO_NOT_INSERT
1128
//	 */
1129
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_explicitconstructorcall_arguments"; //$NON-NLS-1$
1130
//	/**
1131
//	 * <pre>
1132
//	 * FORMATTER / Option to insert a space after the comma in the increments of a for statement
1133
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_for_increments"
1134
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1135
//	 *     - default:           INSERT
1136
//	 * </pre>
1137
//	 * @see CCorePlugin#INSERT
1138
//	 * @see CCorePlugin#DO_NOT_INSERT
1139
//	 */
1140
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_for_increments"; //$NON-NLS-1$
1141
//	/**
1142
//	 * <pre>
1143
//	 * FORMATTER / Option to insert a space after the comma in the initializations of a for statement
1144
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_for_inits"
1145
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1146
//	 *     - default:           INSERT
1147
//	 * </pre>
1148
//	 * @see CCorePlugin#INSERT
1149
//	 * @see CCorePlugin#DO_NOT_INSERT
1150
//	 */
1151
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_for_inits"; //$NON-NLS-1$
1152
//	/**
1153
//	 * <pre>
1154
//	 * FORMATTER / Option to insert a space after the comma in the parameters of a method declaration
1155
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters"
1156
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1157
//	 *     - default:           INSERT
1158
//	 * </pre>
1159
//	 * @see CCorePlugin#INSERT
1160
//	 * @see CCorePlugin#DO_NOT_INSERT
1161
//	 */
1162
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_declaration_parameters"; //$NON-NLS-1$
1163
//	/**
1164
//	 * <pre>
1165
//	 * FORMATTER / Option to insert a space after the comma in the exception names in a throws clause of a method declaration
1166
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws"
1167
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1168
//	 *     - default:           INSERT
1169
//	 * </pre>
1170
//	 * @see CCorePlugin#INSERT
1171
//	 * @see CCorePlugin#DO_NOT_INSERT
1172
//	 */
1173
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_declaration_throws"; //$NON-NLS-1$
1174
//	/**
1175
//	 * <pre>
1176
//	 * FORMATTER / Option to insert a space after the comma in the arguments of a method invocation
1177
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments"
1178
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1179
//	 *     - default:           INSERT
1180
//	 * </pre>
1181
//	 * @see CCorePlugin#INSERT
1182
//	 * @see CCorePlugin#DO_NOT_INSERT
1183
//	 */
1184
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_invocation_arguments"; //$NON-NLS-1$
1185
//	/**
1186
//	 * <pre>
1187
//	 * FORMATTER / Option to insert a space after the comma in multiple field declaration
1188
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations"
1189
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1190
//	 *     - default:           INSERT
1191
//	 * </pre>
1192
//	 * @see CCorePlugin#INSERT
1193
//	 * @see CCorePlugin#DO_NOT_INSERT
1194
//	 */
1195
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_multiple_field_declarations"; //$NON-NLS-1$
1196
//	/**
1197
//	 * <pre>
1198
//	 * FORMATTER / Option to insert a space after the comma in multiple local declaration
1199
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations"
1200
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1201
//	 *     - default:           INSERT
1202
//	 * </pre>
1203
//	 * @see CCorePlugin#INSERT
1204
//	 * @see CCorePlugin#DO_NOT_INSERT
1205
//	 */
1206
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_multiple_local_declarations"; //$NON-NLS-1$
1207
//	/**
1208
//	 * <pre>
1209
//	 * FORMATTER / Option to insert a space after the comma in parameterized type reference
1210
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference"
1211
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1212
//	 *     - default:           INSERT
1213
//	 * </pre>
1214
//	 * @see CCorePlugin#INSERT
1215
//	 * @see CCorePlugin#DO_NOT_INSERT
1216
//	 */
1217
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_parameterized_type_reference"; //$NON-NLS-1$
1218
//	/**
1219
//	 * <pre>
1220
//	 * FORMATTER / Option to insert a space after the comma in superinterfaces names of a type header
1221
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_superinterfaces"
1222
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1223
//	 *     - default:           INSERT
1224
//	 * </pre>
1225
//	 * @see CCorePlugin#INSERT
1226
//	 * @see CCorePlugin#DO_NOT_INSERT
1227
//	 */
1228
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_superinterfaces"; //$NON-NLS-1$
1229
//	/**
1230
//	 * <pre>
1231
//	 * FORMATTER / Option to insert a space after the comma in type arguments
1232
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_type_arguments"
1233
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1234
//	 *     - default:           INSERT
1235
//	 * </pre>
1236
//	 * @see CCorePlugin#INSERT
1237
//	 * @see CCorePlugin#DO_NOT_INSERT
1238
//	 */
1239
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_type_arguments"; //$NON-NLS-1$
1240
//	/**
1241
//	 * <pre>
1242
//	 * FORMATTER / Option to insert a space after the comma in type parameters
1243
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_type_parameters"
1244
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1245
//	 *     - default:           INSERT
1246
//	 * </pre>
1247
//	 * @see CCorePlugin#INSERT
1248
//	 * @see CCorePlugin#DO_NOT_INSERT
1249
//	 */
1250
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_type_parameters"; //$NON-NLS-1$
1251
//	/**
1252
//	 * <pre>
1253
//	 * FORMATTER / Option to insert a space after ellipsis
1254
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_ellipsis"
1255
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1256
//	 *     - default:           INSERT
1257
//	 * </pre>
1258
//	 * @see CCorePlugin#INSERT
1259
//	 * @see CCorePlugin#DO_NOT_INSERT
1260
//	 */
1261
//	public static final String FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS  = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_ellipsis";	//$NON-NLS-1$
1262
//	/**
1263
//	 * <pre>
1264
//	 * FORMATTER / Option to insert a space after the opening angle bracket in parameterized type reference
1265
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference"
1266
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1267
//	 *     - default:           DO_NOT_INSERT
1268
//	 * </pre>
1269
//	 * @see CCorePlugin#INSERT
1270
//	 * @see CCorePlugin#DO_NOT_INSERT
1271
//	 */
1272
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference";//$NON-NLS-1$
1273
//	/**
1274
//	 * <pre>
1275
//	 * FORMATTER / Option to insert a space after the opening angle bracket in type arguments
1276
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments"
1277
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1278
//	 *     - default:           DO_NOT_INSERT
1279
//	 * </pre>
1280
//	 * @see CCorePlugin#INSERT
1281
//	 * @see CCorePlugin#DO_NOT_INSERT
1282
//	 */
1283
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_angle_bracket_in_type_arguments";//$NON-NLS-1$
1284
//	/**
1285
//	 * <pre>
1286
//	 * FORMATTER / Option to insert a space after the opening angle bracket in type parameters
1287
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters"
1288
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1289
//	 *     - default:           DO_NOT_INSERT
1290
//	 * </pre>
1291
//	 * @see CCorePlugin#INSERT
1292
//	 * @see CCorePlugin#DO_NOT_INSERT
1293
//	 */
1294
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_angle_bracket_in_type_parameters";//$NON-NLS-1$
1295
//	/**
1296
//	 * <pre>
1297
//	 * FORMATTER / Option to insert a space after the opening brace in an array initializer
1298
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer"
1299
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1300
//	 *     - default:           DO_NOT_INSERT
1301
//	 * </pre>
1302
//	 * @see CCorePlugin#INSERT
1303
//	 * @see CCorePlugin#DO_NOT_INSERT
1304
//	 */
1305
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_brace_in_array_initializer";	//$NON-NLS-1$
1306
//	/**
1307
//	 * <pre>
1308
//	 * FORMATTER / Option to insert a space after the opening bracket inside an array allocation expression
1309
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression"
1310
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1311
//	 *     - default:           DO_NOT_INSERT
1312
//	 * </pre>
1313
//	 * @see CCorePlugin#INSERT
1314
//	 * @see CCorePlugin#DO_NOT_INSERT
1315
//	 */
1316
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_bracket_in_array_allocation_expression";//$NON-NLS-1$
1317
//	/**
1318
//	 * <pre>
1319
//	 * FORMATTER / Option to insert a space after the opening bracket inside an array reference
1320
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket_in_array_reference"
1321
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1322
//	 *     - default:           DO_NOT_INSERT
1323
//	 * </pre>
1324
//	 * @see CCorePlugin#INSERT
1325
//	 * @see CCorePlugin#DO_NOT_INSERT
1326
//	 */
1327
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_bracket_in_array_reference";//$NON-NLS-1$
1328
//	/**
1329
//	 * <pre>
1330
//	 * FORMATTER / Option to insert a space after the opening parenthesis in annotation
1331
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_annotation"
1332
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1333
//	 *     - default:           DO_NOT_INSERT
1334
//	 * </pre>
1335
//	 * @see CCorePlugin#INSERT
1336
//	 * @see CCorePlugin#DO_NOT_INSERT
1337
//	 */
1338
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_annotation"; //$NON-NLS-1$
1339
//	/**
1340
//	 * <pre>
1341
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a cast expression
1342
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast"
1343
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1344
//	 *     - default:           DO_NOT_INSERT
1345
//	 * </pre>
1346
//	 * @see CCorePlugin#INSERT
1347
//	 * @see CCorePlugin#DO_NOT_INSERT
1348
//	 */
1349
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_cast"; //$NON-NLS-1$
1350
//	/**
1351
//	 * <pre>
1352
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a catch
1353
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch"
1354
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1355
//	 *     - default:           DO_NOT_INSERT
1356
//	 * </pre>
1357
//	 * @see CCorePlugin#INSERT
1358
//	 * @see CCorePlugin#DO_NOT_INSERT
1359
//	 */
1360
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_catch"; //$NON-NLS-1$
1361
//	/**
1362
//	 * <pre>
1363
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a constructor declaration
1364
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration"
1365
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1366
//	 *     - default:           DO_NOT_INSERT
1367
//	 * </pre>
1368
//	 * @see CCorePlugin#INSERT
1369
//	 * @see CCorePlugin#DO_NOT_INSERT
1370
//	 */
1371
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_constructor_declaration";	//$NON-NLS-1$
1372
//	/**
1373
//	 * <pre>
1374
//	 * FORMATTER / Option to insert a space after the opening parenthesis in enum constant
1375
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_enum_constant"
1376
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1377
//	 *     - default:           DO_NOT_INSERT
1378
//	 * </pre>
1379
//	 * @see CCorePlugin#INSERT
1380
//	 * @see CCorePlugin#DO_NOT_INSERT
1381
//	 */
1382
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_enum_constant"; //$NON-NLS-1$
1383
//	/**
1384
//	 * <pre>
1385
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a for statement
1386
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for"
1387
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1388
//	 *     - default:           DO_NOT_INSERT
1389
//	 * </pre>
1390
//	 * @see CCorePlugin#INSERT
1391
//	 * @see CCorePlugin#DO_NOT_INSERT
1392
//	 */
1393
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_for"; //$NON-NLS-1$
1394
//	/**
1395
//	 * <pre>
1396
//	 * FORMATTER / Option to insert a space after the opening parenthesis in an if statement
1397
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if"
1398
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1399
//	 *     - default:           DO_NOT_INSERT
1400
//	 * </pre>
1401
//	 * @see CCorePlugin#INSERT
1402
//	 * @see CCorePlugin#DO_NOT_INSERT
1403
//	 */
1404
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_if"; //$NON-NLS-1$
1405
//	/**
1406
//	 * <pre>
1407
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a method declaration
1408
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration"
1409
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1410
//	 *     - default:           DO_NOT_INSERT
1411
//	 * </pre>
1412
//	 * @see CCorePlugin#INSERT
1413
//	 * @see CCorePlugin#DO_NOT_INSERT
1414
//	 */
1415
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_method_declaration";	//$NON-NLS-1$
1416
//	/**
1417
//	 * <pre>
1418
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a method invocation
1419
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation"
1420
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1421
//	 *     - default:           DO_NOT_INSERT
1422
//	 * </pre>
1423
//	 * @see CCorePlugin#INSERT
1424
//	 * @see CCorePlugin#DO_NOT_INSERT
1425
//	 */
1426
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_method_invocation"; //$NON-NLS-1$
1427
//	/**
1428
//	 * <pre>
1429
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a parenthesized expression
1430
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression"
1431
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1432
//	 *     - default:           DO_NOT_INSERT
1433
//	 * </pre>
1434
//	 * @see CCorePlugin#INSERT
1435
//	 * @see CCorePlugin#DO_NOT_INSERT
1436
//	 */
1437
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_parenthesized_expression"; //$NON-NLS-1$
1438
//	/**
1439
//	 * <pre>
1440
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a switch statement
1441
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch"
1442
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1443
//	 *     - default:           DO_NOT_INSERT
1444
//	 * </pre>
1445
//	 * @see CCorePlugin#INSERT
1446
//	 * @see CCorePlugin#DO_NOT_INSERT
1447
//	 */
1448
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_switch"; //$NON-NLS-1$
1449
//	/**
1450
//	 * <pre>
1451
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a synchronized statement
1452
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_synchronized"
1453
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1454
//	 *     - default:           DO_NOT_INSERT
1455
//	 * </pre>
1456
//	 * @see CCorePlugin#INSERT
1457
//	 * @see CCorePlugin#DO_NOT_INSERT
1458
//	 */
1459
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_synchronized"; //$NON-NLS-1$
1460
//	/**
1461
//	 * <pre>
1462
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a while statement
1463
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while"
1464
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1465
//	 *     - default:           DO_NOT_INSERT
1466
//	 * </pre>
1467
//	 * @see CCorePlugin#INSERT
1468
//	 * @see CCorePlugin#DO_NOT_INSERT
1469
//	 */
1470
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_while"; //$NON-NLS-1$
1471
//	/**
1472
//	 * <pre>
1473
//	 * FORMATTER / Option to insert a space after a postfix operator
1474
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator"
1475
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1476
//	 *     - default:           DO_NOT_INSERT
1477
//	 * </pre>
1478
//	 * @see CCorePlugin#INSERT
1479
//	 * @see CCorePlugin#DO_NOT_INSERT
1480
//	 */
1481
//	public static final String FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_postfix_operator"; //$NON-NLS-1$
1482
//	/**
1483
//	 * <pre>
1484
//	 * FORMATTER / Option to insert a space after a prefix operator
1485
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator"
1486
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1487
//	 *     - default:           DO_NOT_INSERT
1488
//	 * </pre>
1489
//	 * @see CCorePlugin#INSERT
1490
//	 * @see CCorePlugin#DO_NOT_INSERT
1491
//	 */
1492
//	public static final String FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_prefix_operator"; //$NON-NLS-1$
1493
//	/**
1494
//	 * <pre>
1495
//	 * FORMATTER / Option to insert a space after question mark in a conditional expression
1496
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional"
1497
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1498
//	 *     - default:           DO_NOT_INSERT
1499
//	 * </pre>
1500
//	 * @see CCorePlugin#INSERT
1501
//	 * @see CCorePlugin#DO_NOT_INSERT
1502
//	 */
1503
//	public static final String FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_question_in_conditional"; //$NON-NLS-1$
1504
//	/**
1505
//	 * <pre>
1506
//	 * FORMATTER / Option to insert a space after question mark in a wildcard
1507
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_question_in_wildcard"
1508
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1509
//	 *     - default:           DO_NOT_INSERT
1510
//	 * </pre>
1511
//	 * @see CCorePlugin#INSERT
1512
//	 * @see CCorePlugin#DO_NOT_INSERT
1513
//	 */
1514
//	public static final String FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_WILDCARD = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_question_in_wildcard"; //$NON-NLS-1$
1515
//	/**
1516
//	 * <pre>
1517
//	 * FORMATTER / Option to insert a space after semicolon in a for statement
1518
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for"
1519
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1520
//	 *     - default:           INSERT
1521
//	 * </pre>
1522
//	 * @see CCorePlugin#INSERT
1523
//	 * @see CCorePlugin#DO_NOT_INSERT
1524
//	 */
1525
//	public static final String FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_semicolon_in_for"; //$NON-NLS-1$
1526
//	/**
1527
//	 * <pre>
1528
//	 * FORMATTER / Option to insert a space after an unary operator
1529
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_unary_operator"
1530
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1531
//	 *     - default:           DO_NOT_INSERT
1532
//	 * </pre>
1533
//	 * @see CCorePlugin#INSERT
1534
//	 * @see CCorePlugin#DO_NOT_INSERT
1535
//	 */
1536
//	public static final String FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_unary_operator"; //$NON-NLS-1$
1537
//	/**
1538
//	 * <pre>
1539
//	 * FORMATTER / Option to insert a space before and in wildcard
1540
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_and_in_type_parameter"
1541
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1542
//	 *     - default:           INSERT
1543
//	 * </pre>
1544
//	 * @see CCorePlugin#INSERT
1545
//	 * @see CCorePlugin#DO_NOT_INSERT
1546
//	 */
1547
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_AND_IN_TYPE_PARAMETER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_and_in_type_parameter";	//$NON-NLS-1$
1548
//	/**
1549
//	 * <pre>
1550
//	 * FORMATTER / Option to insert a space before an assignment operator
1551
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator"
1552
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1553
//	 *     - default:           INSERT
1554
//	 * </pre>
1555
//	 * @see CCorePlugin#INSERT
1556
//	 * @see CCorePlugin#DO_NOT_INSERT
1557
//	 */
1558
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_assignment_operator";	//$NON-NLS-1$
1559
//	/**
1560
//	 * <pre>
1561
//	 * FORMATTER / Option to insert a space before at in annotation type declaration
1562
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_at_in_annotation_type_declaration"
1563
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1564
//	 *     - default:           INSERT
1565
//	 * </pre>
1566
//	 * @see CCorePlugin#INSERT
1567
//	 * @see CCorePlugin#DO_NOT_INSERT
1568
//	 */
1569
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_AT_IN_ANNOTATION_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_at_in_annotation_type_declaration";	//$NON-NLS-1$
1570
//	/**
1571
//	 * <pre>
1572
//	 * FORMATTER / Option to insert a space before an binary operator
1573
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_binary_operator"
1574
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1575
//	 *     - default:           DO_NOT_INSERT
1576
//	 * </pre>
1577
//	 * @see CCorePlugin#INSERT
1578
//	 * @see CCorePlugin#DO_NOT_INSERT
1579
//	 */
1580
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_binary_operator";	//$NON-NLS-1$
1581
//	/**
1582
//	 * <pre>
1583
//	 * FORMATTER / Option to insert a space before the closing angle bracket in parameterized type reference
1584
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference"
1585
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1586
//	 *     - default:           DO_NOT_INSERT
1587
//	 * </pre>
1588
//	 * @see CCorePlugin#INSERT
1589
//	 * @see CCorePlugin#DO_NOT_INSERT
1590
//	 */
1591
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference";		//$NON-NLS-1$
1592
//	/**
1593
//	 * <pre>
1594
//	 * FORMATTER / Option to insert a space before the closing angle bracket in type arguments
1595
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments"
1596
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1597
//	 *     - default:           DO_NOT_INSERT
1598
//	 * </pre>
1599
//	 * @see CCorePlugin#INSERT
1600
//	 * @see CCorePlugin#DO_NOT_INSERT
1601
//	 */
1602
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_angle_bracket_in_type_arguments";		//$NON-NLS-1$
1603
//	/**
1604
//	 * <pre>
1605
//	 * FORMATTER / Option to insert a space before the closing angle bracket in type parameters
1606
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters"
1607
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1608
//	 *     - default:           DO_NOT_INSERT
1609
//	 * </pre>
1610
//	 * @see CCorePlugin#INSERT
1611
//	 * @see CCorePlugin#DO_NOT_INSERT
1612
//	 */
1613
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_angle_bracket_in_type_parameters";		//$NON-NLS-1$
1614
//	/**
1615
//	 * <pre>
1616
//	 * FORMATTER / Option to insert a space before the closing brace in an array initializer
1617
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer"
1618
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1619
//	 *     - default:           DO_NOT_INSERT
1620
//	 * </pre>
1621
//	 * @see CCorePlugin#INSERT
1622
//	 * @see CCorePlugin#DO_NOT_INSERT
1623
//	 */
1624
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_brace_in_array_initializer";		//$NON-NLS-1$
1625
//	/**
1626
//	 * <pre>
1627
//	 * FORMATTER / Option to insert a space before the closing bracket in an array allocation expression
1628
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression"
1629
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1630
//	 *     - default:           DO_NOT_INSERT
1631
//	 * </pre>
1632
//	 * @see CCorePlugin#INSERT
1633
//	 * @see CCorePlugin#DO_NOT_INSERT
1634
//	 */
1635
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_bracket_in_array_allocation_expression";//$NON-NLS-1$
1636
//	/**
1637
//	 * <pre>
1638
//	 * FORMATTER / Option to insert a space before the closing bracket in an array reference
1639
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket_in_array_reference"
1640
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1641
//	 *     - default:           DO_NOT_INSERT
1642
//	 * </pre>
1643
//	 * @see CCorePlugin#INSERT
1644
//	 * @see CCorePlugin#DO_NOT_INSERT
1645
//	 */
1646
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_bracket_in_array_reference";//$NON-NLS-1$
1647
//	/**
1648
//	 * <pre>
1649
//	 * FORMATTER / Option to insert a space before the closing parenthesis in annotation
1650
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_annotation"
1651
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1652
//	 *     - default:           DO_NOT_INSERT
1653
//	 * </pre>
1654
//	 * @see CCorePlugin#INSERT
1655
//	 * @see CCorePlugin#DO_NOT_INSERT
1656
//	 */
1657
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_annotation";	//$NON-NLS-1$
1658
//	/**
1659
//	 * <pre>
1660
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a cast expression
1661
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast"
1662
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1663
//	 *     - default:           DO_NOT_INSERT
1664
//	 * </pre>
1665
//	 * @see CCorePlugin#INSERT
1666
//	 * @see CCorePlugin#DO_NOT_INSERT
1667
//	 */
1668
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_cast";	//$NON-NLS-1$
1669
//	/**
1670
//	 * <pre>
1671
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a catch
1672
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch"
1673
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1674
//	 *     - default:           DO_NOT_INSERT
1675
//	 * </pre>
1676
//	 * @see CCorePlugin#INSERT
1677
//	 * @see CCorePlugin#DO_NOT_INSERT
1678
//	 */
1679
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_catch";	//$NON-NLS-1$
1680
//	/**
1681
//	 * <pre>
1682
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a constructor declaration
1683
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration"
1684
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1685
//	 *     - default:           DO_NOT_INSERT
1686
//	 * </pre>
1687
//	 * @see CCorePlugin#INSERT
1688
//	 * @see CCorePlugin#DO_NOT_INSERT
1689
//	 */
1690
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_constructor_declaration";	//$NON-NLS-1$
1691
//	/**
1692
//	 * <pre>
1693
//	 * FORMATTER / Option to insert a space before the closing parenthesis in enum constant
1694
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_enum_constant"
1695
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1696
//	 *     - default:           DO_NOT_INSERT
1697
//	 * </pre>
1698
//	 * @see CCorePlugin#INSERT
1699
//	 * @see CCorePlugin#DO_NOT_INSERT
1700
//	 */
1701
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_enum_constant";	//$NON-NLS-1$
1702
//	/**
1703
//	 * <pre>
1704
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a for statement
1705
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for"
1706
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1707
//	 *     - default:           DO_NOT_INSERT
1708
//	 * </pre>
1709
//	 * @see CCorePlugin#INSERT
1710
//	 * @see CCorePlugin#DO_NOT_INSERT
1711
//	 */
1712
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_for";	//$NON-NLS-1$
1713
//	/**
1714
//	 * <pre>
1715
//	 * FORMATTER / Option to insert a space before the closing parenthesis in an if statement
1716
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if"
1717
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1718
//	 *     - default:           DO_NOT_INSERT
1719
//	 * </pre>
1720
//	 * @see CCorePlugin#INSERT
1721
//	 * @see CCorePlugin#DO_NOT_INSERT
1722
//	 */
1723
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_if";	//$NON-NLS-1$
1724
//	/**
1725
//	 * <pre>
1726
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a method declaration
1727
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration"
1728
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1729
//	 *     - default:           DO_NOT_INSERT
1730
//	 * </pre>
1731
//	 * @see CCorePlugin#INSERT
1732
//	 * @see CCorePlugin#DO_NOT_INSERT
1733
//	 */
1734
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_method_declaration";	//$NON-NLS-1$
1735
//	/**
1736
//	 * <pre>
1737
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a method invocation
1738
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation"
1739
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1740
//	 *     - default:           DO_NOT_INSERT
1741
//	 * </pre>
1742
//	 * @see CCorePlugin#INSERT
1743
//	 * @see CCorePlugin#DO_NOT_INSERT
1744
//	 */
1745
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_method_invocation"; //$NON-NLS-1$
1746
//	/**
1747
//	 * <pre>
1748
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a parenthesized expression
1749
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression"
1750
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1751
//	 *     - default:           DO_NOT_INSERT
1752
//	 * </pre>
1753
//	 * @see CCorePlugin#INSERT
1754
//	 * @see CCorePlugin#DO_NOT_INSERT
1755
//	 */
1756
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_parenthesized_expression"; //$NON-NLS-1$
1757
//	/**
1758
//	 * <pre>
1759
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a switch statement
1760
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch"
1761
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1762
//	 *     - default:           DO_NOT_INSERT
1763
//	 * </pre>
1764
//	 * @see CCorePlugin#INSERT
1765
//	 * @see CCorePlugin#DO_NOT_INSERT
1766
//	 */
1767
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_switch";	//$NON-NLS-1$
1768
//	/**
1769
//	 * <pre>
1770
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a synchronized statement
1771
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_synchronized"
1772
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1773
//	 *     - default:           DO_NOT_INSERT
1774
//	 * </pre>
1775
//	 * @see CCorePlugin#INSERT
1776
//	 * @see CCorePlugin#DO_NOT_INSERT
1777
//	 */
1778
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_synchronized";	//$NON-NLS-1$
1779
//	/**
1780
//	 * <pre>
1781
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a while statement
1782
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while"
1783
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1784
//	 *     - default:           DO_NOT_INSERT
1785
//	 * </pre>
1786
//	 * @see CCorePlugin#INSERT
1787
//	 * @see CCorePlugin#DO_NOT_INSERT
1788
//	 */
1789
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_while";	//$NON-NLS-1$
1790
//	/**
1791
//	 * <pre>
1792
//	 * FORMATTER / Option to insert a space before colon in an assert statement
1793
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_colon_in_assert"
1794
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1795
//	 *     - default:           INSERT
1796
//	 * </pre>
1797
//	 * @see CCorePlugin#INSERT
1798
//	 * @see CCorePlugin#DO_NOT_INSERT
1799
//	 */
1800
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_colon_in_assert";	//$NON-NLS-1$
1801
//	/**
1802
//	 * <pre>
1803
//	 * FORMATTER / Option to insert a space before colon in a case statement
1804
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case"
1805
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1806
//	 *     - default:           INSERT
1807
//	 * </pre>
1808
//	 * @see CCorePlugin#INSERT
1809
//	 * @see CCorePlugin#DO_NOT_INSERT
1810
//	 */
1811
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_colon_in_case";	//$NON-NLS-1$
1812
//	/**
1813
//	 * <pre>
1814
//	 * FORMATTER / Option to insert a space before colon in a conditional expression
1815
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional"
1816
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1817
//	 *     - default:           INSERT
1818
//	 * </pre>
1819
//	 * @see CCorePlugin#INSERT
1820
//	 * @see CCorePlugin#DO_NOT_INSERT
1821
//	 */
1822
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_colon_in_conditional";	//$NON-NLS-1$
1823
//	/**
1824
//	 * <pre>
1825
//	 * FORMATTER / Option to insert a space before colon in a default statement
1826
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default"
1827
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1828
//	 *     - default:           INSERT
1829
//	 * </pre>
1830
//	 * @see CCorePlugin#INSERT
1831
//	 * @see CCorePlugin#DO_NOT_INSERT
1832
//	 */
1833
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_colon_in_default";	//$NON-NLS-1$
1834
//	/**
1835
//	 * <pre>
1836
//	 * FORMATTER / Option to insert a space before colon in a for statement
1837
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_colon_in_for"
1838
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1839
//	 *     - default:           INSERT
1840
//	 * </pre>
1841
//	 * @see CCorePlugin#INSERT
1842
//	 * @see CCorePlugin#DO_NOT_INSERT
1843
//	 */
1844
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_colon_in_for";	//$NON-NLS-1$
1845
//	/**
1846
//	 * <pre>
1847
//	 * FORMATTER / Option to insert a space before colon in a labeled statement
1848
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement"
1849
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1850
//	 *     - default:           INSERT
1851
//	 * </pre>
1852
//	 * @see CCorePlugin#INSERT
1853
//	 * @see CCorePlugin#DO_NOT_INSERT
1854
//	 */
1855
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_colon_in_labeled_statement";	//$NON-NLS-1$
1856
//	/**
1857
//	 * <pre>
1858
//	 * FORMATTER / Option to insert a space before comma in an allocation expression
1859
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_allocation_expression"
1860
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1861
//	 *     - default:           DO_NOT_INSERT
1862
//	 * </pre>
1863
//	 * @see CCorePlugin#INSERT
1864
//	 * @see CCorePlugin#DO_NOT_INSERT
1865
//	 */
1866
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_allocation_expression";	//$NON-NLS-1$
1867
//	/**
1868
//	 * <pre>
1869
//	 * FORMATTER / Option to insert a space before comma in annotation
1870
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_annotation"
1871
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1872
//	 *     - default:           DO_NOT_INSERT
1873
//	 * </pre>
1874
//	 * @see CCorePlugin#INSERT
1875
//	 * @see CCorePlugin#DO_NOT_INSERT
1876
//	 */
1877
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_annotation";	//$NON-NLS-1$
1878
//	/**
1879
//	 * <pre>
1880
//	 * FORMATTER / Option to insert a space before comma in an array initializer
1881
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer"
1882
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1883
//	 *     - default:           DO_NOT_INSERT
1884
//	 * </pre>
1885
//	 * @see CCorePlugin#INSERT
1886
//	 * @see CCorePlugin#DO_NOT_INSERT
1887
//	 */
1888
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_array_initializer";	//$NON-NLS-1$
1889
//	/**
1890
//	 * <pre>
1891
//	 * FORMATTER / Option to insert a space before comma in the parameters of a constructor declaration
1892
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters"
1893
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1894
//	 *     - default:           DO_NOT_INSERT
1895
//	 * </pre>
1896
//	 * @see CCorePlugin#INSERT
1897
//	 * @see CCorePlugin#DO_NOT_INSERT
1898
//	 */
1899
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_constructor_declaration_parameters";	//$NON-NLS-1$
1900
//	/**
1901
//	 * <pre>
1902
//	 * FORMATTER / Option to insert a space before comma in the exception names of the throws clause of a constructor declaration
1903
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws"
1904
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1905
//	 *     - default:           DO_NOT_INSERT
1906
//	 * </pre>
1907
//	 * @see CCorePlugin#INSERT
1908
//	 * @see CCorePlugin#DO_NOT_INSERT
1909
//	 */
1910
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_constructor_declaration_throws";	//$NON-NLS-1$
1911
//	/**
1912
//	 * <pre>
1913
//	 * FORMATTER / Option to insert a space before comma in the arguments of enum constant
1914
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments"
1915
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1916
//	 *     - default:           DO_NOT_INSERT
1917
//	 * </pre>
1918
//	 * @see CCorePlugin#INSERT
1919
//	 * @see CCorePlugin#DO_NOT_INSERT
1920
//	 */
1921
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_CONSTANT_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_enum_constant_arguments";	//$NON-NLS-1$
1922
//	/**
1923
//	 * <pre>
1924
//	 * FORMATTER / Option to insert a space before comma in enum declarations
1925
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations"
1926
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1927
//	 *     - default:           DO_NOT_INSERT
1928
//	 * </pre>
1929
//	 * @see CCorePlugin#INSERT
1930
//	 * @see CCorePlugin#DO_NOT_INSERT
1931
//	 */
1932
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_enum_declarations";	//$NON-NLS-1$
1933
//	/**
1934
//	 * <pre>
1935
//	 * FORMATTER / Option to insert a space before comma in the arguments of an explicit constructor call
1936
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments"
1937
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1938
//	 *     - default:           DO_NOT_INSERT
1939
//	 * </pre>
1940
//	 * @see CCorePlugin#INSERT
1941
//	 * @see CCorePlugin#DO_NOT_INSERT
1942
//	 */
1943
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_explicitconstructorcall_arguments";	//$NON-NLS-1$
1944
//	/**
1945
//	 * <pre>
1946
//	 * FORMATTER / Option to insert a space before comma in the increments of a for statement
1947
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_for_increments"
1948
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1949
//	 *     - default:           DO_NOT_INSERT
1950
//	 * </pre>
1951
//	 * @see CCorePlugin#INSERT
1952
//	 * @see CCorePlugin#DO_NOT_INSERT
1953
//	 */
1954
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_for_increments";	//$NON-NLS-1$
1955
//	/**
1956
//	 * <pre>
1957
//	 * FORMATTER / Option to insert a space before comma in the initializations of a for statement
1958
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_for_inits"
1959
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1960
//	 *     - default:           DO_NOT_INSERT
1961
//	 * </pre>
1962
//	 * @see CCorePlugin#INSERT
1963
//	 * @see CCorePlugin#DO_NOT_INSERT
1964
//	 */
1965
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_for_inits";	//$NON-NLS-1$
1966
//	/**
1967
//	 * <pre>
1968
//	 * FORMATTER / Option to insert a space before comma in the parameters of a method declaration
1969
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters"
1970
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1971
//	 *     - default:           DO_NOT_INSERT
1972
//	 * </pre>
1973
//	 * @see CCorePlugin#INSERT
1974
//	 * @see CCorePlugin#DO_NOT_INSERT
1975
//	 */
1976
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_declaration_parameters";	//$NON-NLS-1$
1977
//	/**
1978
//	 * <pre>
1979
//	 * FORMATTER / Option to insert a space before comma in the exception names of the throws clause of a method declaration
1980
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws"
1981
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1982
//	 *     - default:           DO_NOT_INSERT
1983
//	 * </pre>
1984
//	 * @see CCorePlugin#INSERT
1985
//	 * @see CCorePlugin#DO_NOT_INSERT
1986
//	 */
1987
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_declaration_throws";	//$NON-NLS-1$
1988
//	/**
1989
//	 * <pre>
1990
//	 * FORMATTER / Option to insert a space before comma in the arguments of a method invocation
1991
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments"
1992
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1993
//	 *     - default:           DO_NOT_INSERT
1994
//	 * </pre>
1995
//	 * @see CCorePlugin#INSERT
1996
//	 * @see CCorePlugin#DO_NOT_INSERT
1997
//	 */
1998
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_invocation_arguments";	//$NON-NLS-1$
1999
//	/**
2000
//	 * <pre>
2001
//	 * FORMATTER / Option to insert a space before comma in a multiple field declaration
2002
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations"
2003
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2004
//	 *     - default:           DO_NOT_INSERT
2005
//	 * </pre>
2006
//	 * @see CCorePlugin#INSERT
2007
//	 * @see CCorePlugin#DO_NOT_INSERT
2008
//	 */
2009
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_multiple_field_declarations";	//$NON-NLS-1$
2010
//	/**
2011
//	 * <pre>
2012
//	 * FORMATTER / Option to insert a space before comma in a multiple local declaration
2013
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations"
2014
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2015
//	 *     - default:           DO_NOT_INSERT
2016
//	 * </pre>
2017
//	 * @see CCorePlugin#INSERT
2018
//	 * @see CCorePlugin#DO_NOT_INSERT
2019
//	 */
2020
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_multiple_local_declarations";	//$NON-NLS-1$
2021
//	/**
2022
//	 * <pre>
2023
//	 * FORMATTER / Option to insert a space before comma in parameterized type reference
2024
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference"
2025
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2026
//	 *     - default:           DO_NOT_INSERT
2027
//	 * </pre>
2028
//	 * @see CCorePlugin#INSERT
2029
//	 * @see CCorePlugin#DO_NOT_INSERT
2030
//	 */
2031
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_parameterized_type_reference";	//$NON-NLS-1$
2032
//	/**
2033
//	 * <pre>
2034
//	 * FORMATTER / Option to insert a space before comma in the superinterfaces names in a type header
2035
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_superinterfaces"
2036
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2037
//	 *     - default:           DO_NOT_INSERT
2038
//	 * </pre>
2039
//	 * @see CCorePlugin#INSERT
2040
//	 * @see CCorePlugin#DO_NOT_INSERT
2041
//	 */
2042
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_superinterfaces";	//$NON-NLS-1$
2043
//	/**
2044
//	 * <pre>
2045
//	 * FORMATTER / Option to insert a space before comma in type arguments
2046
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_type_arguments"
2047
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2048
//	 *     - default:           DO_NOT_INSERT
2049
//	 * </pre>
2050
//	 * @see CCorePlugin#INSERT
2051
//	 * @see CCorePlugin#DO_NOT_INSERT
2052
//	 */
2053
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_type_arguments";	//$NON-NLS-1$
2054
//	/**
2055
//	 * <pre>
2056
//	 * FORMATTER / Option to insert a space before comma in type parameters
2057
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_type_parameters"
2058
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2059
//	 *     - default:           DO_NOT_INSERT
2060
//	 * </pre>
2061
//	 * @see CCorePlugin#INSERT
2062
//	 * @see CCorePlugin#DO_NOT_INSERT
2063
//	 */
2064
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_type_parameters";	//$NON-NLS-1$
2065
//	/**
2066
//	 * <pre>
2067
//	 * FORMATTER / Option to insert a space before ellipsis
2068
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_ellipsis"
2069
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2070
//	 *     - default:           DO_NOT_INSERT
2071
//	 * </pre>
2072
//	 * @see CCorePlugin#INSERT
2073
//	 * @see CCorePlugin#DO_NOT_INSERT
2074
//	 */
2075
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS  = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_ellipsis";	//$NON-NLS-1$
2076
//	/**
2077
//	 * <pre>
2078
//	 * FORMATTER / Option to insert a space before the opening angle bracket in parameterized type reference
2079
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference"
2080
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2081
//	 *     - default:           DO_NOT_INSERT
2082
//	 * </pre>
2083
//	 * @see CCorePlugin#INSERT
2084
//	 * @see CCorePlugin#DO_NOT_INSERT
2085
//	 */
2086
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE  = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference";	//$NON-NLS-1$
2087
//	/**
2088
//	 * <pre>
2089
//	 * FORMATTER / Option to insert a space before the opening angle bracket in type arguments
2090
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments"
2091
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2092
//	 *     - default:           DO_NOT_INSERT
2093
//	 * </pre>
2094
//	 * @see CCorePlugin#INSERT
2095
//	 * @see CCorePlugin#DO_NOT_INSERT
2096
//	 */
2097
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_angle_bracket_in_type_arguments";	//$NON-NLS-1$
2098
//	/**
2099
//	 * <pre>
2100
//	 * FORMATTER / Option to insert a space before the opening angle bracket in type parameters
2101
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters"
2102
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2103
//	 *     - default:           DO_NOT_INSERT
2104
//	 * </pre>
2105
//	 * @see CCorePlugin#INSERT
2106
//	 * @see CCorePlugin#DO_NOT_INSERT
2107
//	 */
2108
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_angle_bracket_in_type_parameters";	//$NON-NLS-1$
2109
//	/**
2110
//	 * <pre>
2111
//	 * FORMATTER / Option to insert a space before the opening brace in an annotation type declaration
2112
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration"
2113
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2114
//	 *     - default:           INSERT
2115
//	 * </pre>
2116
//	 * @see CCorePlugin#INSERT
2117
//	 * @see CCorePlugin#DO_NOT_INSERT
2118
//	 */
2119
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANNOTATION_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_annotation_type_declaration"; 	//$NON-NLS-1$
2120
//	/**
2121
//	 * <pre>
2122
//	 * FORMATTER / Option to insert a space before the opening brace in an anonymous type declaration
2123
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration"
2124
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2125
//	 *     - default:           INSERT
2126
//	 * </pre>
2127
//	 * @see CCorePlugin#INSERT
2128
//	 * @see CCorePlugin#DO_NOT_INSERT
2129
//	 */
2130
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_anonymous_type_declaration"; 	//$NON-NLS-1$
2131
//	/**
2132
//	 * <pre>
2133
//	 * FORMATTER / Option to insert a space before the opening brace in an array initializer
2134
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer"
2135
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2136
//	 *     - default:           DO_NOT_INSERT
2137
//	 * </pre>
2138
//	 * @see CCorePlugin#INSERT
2139
//	 * @see CCorePlugin#DO_NOT_INSERT
2140
//	 */
2141
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_array_initializer"; //$NON-NLS-1$
2142
//	/**
2143
//	 * <pre>
2144
//	 * FORMATTER / Option to insert a space before the opening brace in a block
2145
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block"
2146
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2147
//	 *     - default:           INSERT
2148
//	 * </pre>
2149
//	 * @see CCorePlugin#INSERT
2150
//	 * @see CCorePlugin#DO_NOT_INSERT
2151
//	 */
2152
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_block";	//$NON-NLS-1$
2153
//	/**
2154
//	 * <pre>
2155
//	 * FORMATTER / Option to insert a space before the opening brace in a constructor declaration
2156
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration"
2157
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2158
//	 *     - default:           INSERT
2159
//	 * </pre>
2160
//	 * @see CCorePlugin#INSERT
2161
//	 * @see CCorePlugin#DO_NOT_INSERT
2162
//	 */
2163
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_constructor_declaration";	//$NON-NLS-1$
2164
//	/**
2165
//	 * <pre>
2166
//	 * FORMATTER / Option to insert a space before the opening brace in an enum constant
2167
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_enum_constant"
2168
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2169
//	 *     - default:           INSERT
2170
//	 * </pre>
2171
//	 * @see CCorePlugin#INSERT
2172
//	 * @see CCorePlugin#DO_NOT_INSERT
2173
//	 */
2174
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_enum_constant";	//$NON-NLS-1$
2175
//	/**
2176
//	 * <pre>
2177
//	 * FORMATTER / Option to insert a space before the opening brace in an enum declaration
2178
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration"
2179
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2180
//	 *     - default:           INSERT
2181
//	 * </pre>
2182
//	 * @see CCorePlugin#INSERT
2183
//	 * @see CCorePlugin#DO_NOT_INSERT
2184
//	 */
2185
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_enum_declaration";	//$NON-NLS-1$
2186
//	/**
2187
//	 * <pre>
2188
//	 * FORMATTER / Option to insert a space before the opening brace in a method declaration
2189
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration"
2190
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2191
//	 *     - default:           INSERT
2192
//	 * </pre>
2193
//	 * @see CCorePlugin#INSERT
2194
//	 * @see CCorePlugin#DO_NOT_INSERT
2195
//	 */
2196
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_method_declaration";	//$NON-NLS-1$
2197
//	/**
2198
//	 * <pre>
2199
//	 * FORMATTER / Option to insert a space before the opening brace in a switch statement
2200
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch"
2201
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2202
//	 *     - default:           INSERT
2203
//	 * </pre>
2204
//	 * @see CCorePlugin#INSERT
2205
//	 * @see CCorePlugin#DO_NOT_INSERT
2206
//	 */
2207
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_switch";	//$NON-NLS-1$
2208
//	/**
2209
//	 * <pre>
2210
//	 * FORMATTER / Option to insert a space before the opening brace in a type declaration
2211
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration"
2212
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2213
//	 *     - default:           INSERT
2214
//	 * </pre>
2215
//	 * @see CCorePlugin#INSERT
2216
//	 * @see CCorePlugin#DO_NOT_INSERT
2217
//	 */
2218
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_type_declaration";	//$NON-NLS-1$
2219
//	/**
2220
//	 * <pre>
2221
//	 * FORMATTER / Option to insert a space before the opening bracket in an array allocation expression
2222
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression"
2223
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2224
//	 *     - default:           DO_NOT_INSERT
2225
//	 * </pre>
2226
//	 * @see CCorePlugin#INSERT
2227
//	 * @see CCorePlugin#DO_NOT_INSERT
2228
//	 */
2229
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_bracket_in_array_allocation_expression";//$NON-NLS-1$
2230
//	/**
2231
//	 * <pre>
2232
//	 * FORMATTER / Option to insert a space before the opening bracket in an array reference
2233
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket_in_array_reference"
2234
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2235
//	 *     - default:           DO_NOT_INSERT
2236
//	 * </pre>
2237
//	 * @see CCorePlugin#INSERT
2238
//	 * @see CCorePlugin#DO_NOT_INSERT
2239
//	 */
2240
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_bracket_in_array_reference";//$NON-NLS-1$
2241
//	/**
2242
//	 * <pre>
2243
//	 * FORMATTER / Option to insert a space before the opening bracket in an array type reference
2244
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference"
2245
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2246
//	 *     - default:           DO_NOT_INSERT
2247
//	 * </pre>
2248
//	 * @see CCorePlugin#INSERT
2249
//	 * @see CCorePlugin#DO_NOT_INSERT
2250
//	 */
2251
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_bracket_in_array_type_reference";	//$NON-NLS-1$
2252
//	/**
2253
//	 * <pre>
2254
//	 * FORMATTER / Option to insert a space before the opening parenthesis in annotation
2255
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_annotation"
2256
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2257
//	 *     - default:           DO_NOT_INSERT
2258
//	 * </pre>
2259
//	 * @see CCorePlugin#INSERT
2260
//	 * @see CCorePlugin#DO_NOT_INSERT
2261
//	 */
2262
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_annotation";	//$NON-NLS-1$
2263
//	/**
2264
//	 * <pre>
2265
//	 * FORMATTER / Option to insert a space before the opening parenthesis in annotation type member declaration
2266
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration"
2267
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2268
//	 *     - default:           DO_NOT_INSERT
2269
//	 * </pre>
2270
//	 * @see CCorePlugin#INSERT
2271
//	 * @see CCorePlugin#DO_NOT_INSERT
2272
//	 */
2273
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION_TYPE_MEMBER_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration";	//$NON-NLS-1$
2274
//	/**
2275
//	 * <pre>
2276
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a catch
2277
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch"
2278
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2279
//	 *     - default:           INSERT
2280
//	 * </pre>
2281
//	 * @see CCorePlugin#INSERT
2282
//	 * @see CCorePlugin#DO_NOT_INSERT
2283
//	 */
2284
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_catch";	//$NON-NLS-1$
2285
//	/**
2286
//	 * <pre>
2287
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a constructor declaration
2288
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration"
2289
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2290
//	 *     - default:           DO_NOT_INSERT
2291
//	 * </pre>
2292
//	 * @see CCorePlugin#INSERT
2293
//	 * @see CCorePlugin#DO_NOT_INSERT
2294
//	 */
2295
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_constructor_declaration";	//$NON-NLS-1$
2296
//	/**
2297
//	 * <pre>
2298
//	 * FORMATTER / Option to insert a space before the opening parenthesis in enum constant
2299
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_enum_constant"
2300
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2301
//	 *     - default:           DO_NOT_INSERT
2302
//	 * </pre>
2303
//	 * @see CCorePlugin#INSERT
2304
//	 * @see CCorePlugin#DO_NOT_INSERT
2305
//	 */
2306
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_enum_constant";	//$NON-NLS-1$
2307
//	/**
2308
//	 * <pre>
2309
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a for statement
2310
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for"
2311
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2312
//	 *     - default:           INSERT
2313
//	 * </pre>
2314
//	 * @see CCorePlugin#INSERT
2315
//	 * @see CCorePlugin#DO_NOT_INSERT
2316
//	 */
2317
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_for";	//$NON-NLS-1$
2318
//	/**
2319
//	 * <pre>
2320
//	 * FORMATTER / Option to insert a space before the opening parenthesis in an if statement
2321
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if"
2322
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2323
//	 *     - default:           INSERT
2324
//	 * </pre>
2325
//	 * @see CCorePlugin#INSERT
2326
//	 * @see CCorePlugin#DO_NOT_INSERT
2327
//	 */
2328
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_if";	//$NON-NLS-1$
2329
//	/**
2330
//	 * <pre>
2331
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a method declaration
2332
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration"
2333
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2334
//	 *     - default:           DO_NOT_INSERT
2335
//	 * </pre>
2336
//	 * @see CCorePlugin#INSERT
2337
//	 * @see CCorePlugin#DO_NOT_INSERT
2338
//	 */
2339
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_method_declaration";	//$NON-NLS-1$
2340
//	/**
2341
//	 * <pre>
2342
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a method invocation
2343
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation"
2344
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2345
//	 *     - default:           DO_NOT_INSERT
2346
//	 * </pre>
2347
//	 * @see CCorePlugin#INSERT
2348
//	 * @see CCorePlugin#DO_NOT_INSERT
2349
//	 */
2350
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_method_invocation";	//$NON-NLS-1$
2351
//	/**
2352
//	 * <pre>
2353
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a parenthesized expression
2354
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression"
2355
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2356
//	 *     - default:           DO_NOT_INSERT
2357
//	 * </pre>
2358
//	 * @see CCorePlugin#INSERT
2359
//	 * @see CCorePlugin#DO_NOT_INSERT
2360
//	 */
2361
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_parenthesized_expression"; //$NON-NLS-1$
2362
//	/**
2363
//	 * <pre>
2364
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a switch statement
2365
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch"
2366
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2367
//	 *     - default:           INSERT
2368
//	 * </pre>
2369
//	 * @see CCorePlugin#INSERT
2370
//	 * @see CCorePlugin#DO_NOT_INSERT
2371
//	 */
2372
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_switch";	//$NON-NLS-1$
2373
//	/**
2374
//	 * <pre>
2375
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a synchronized statement
2376
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_synchronized"
2377
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2378
//	 *     - default:           INSERT
2379
//	 * </pre>
2380
//	 * @see CCorePlugin#INSERT
2381
//	 * @see CCorePlugin#DO_NOT_INSERT
2382
//	 */
2383
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_synchronized";	//$NON-NLS-1$
2384
//	/**
2385
//	 * <pre>
2386
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a while statement
2387
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while"
2388
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2389
//	 *     - default:           INSERT
2390
//	 * </pre>
2391
//	 * @see CCorePlugin#INSERT
2392
//	 * @see CCorePlugin#DO_NOT_INSERT
2393
//	 */
2394
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_while";	//$NON-NLS-1$
2395
//	/**
2396
//	 * <pre>
2397
//	 * FORMATTER / Option to insert a space before parenthesized expression in return statement
2398
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_parenthesized_expression_in_return"
2399
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2400
//	 *     - default:           INSERT
2401
//	 * </pre>
2402
//	 * 
2403
//	 * @see CCorePlugin#INSERT
2404
//	 * @see CCorePlugin#DO_NOT_INSERT
2405
//	 */
2406
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN  = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_parenthesized_expression_in_return";	//$NON-NLS-1$
2407
//	/**
2408
//	 * <pre>
2409
//	 * FORMATTER / Option to insert a space before a postfix operator
2410
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator"
2411
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2412
//	 *     - default:           DO_NOT_INSERT
2413
//	 * </pre>
2414
//	 * @see CCorePlugin#INSERT
2415
//	 * @see CCorePlugin#DO_NOT_INSERT
2416
//	 */
2417
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_postfix_operator";	//$NON-NLS-1$
2418
//	/**
2419
//	 * <pre>
2420
//	 * FORMATTER / Option to insert a space before a prefix operator
2421
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator"
2422
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2423
//	 *     - default:           DO_NOT_INSERT
2424
//	 * </pre>
2425
//	 * @see CCorePlugin#INSERT
2426
//	 * @see CCorePlugin#DO_NOT_INSERT
2427
//	 */
2428
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_prefix_operator";	//$NON-NLS-1$
2429
//	/**
2430
//	 * <pre>
2431
//	 * FORMATTER / Option to insert a space before question mark in a conditional expression
2432
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional"
2433
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2434
//	 *     - default:           INSERT
2435
//	 * </pre>
2436
//	 * @see CCorePlugin#INSERT
2437
//	 * @see CCorePlugin#DO_NOT_INSERT
2438
//	 */
2439
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_question_in_conditional";	//$NON-NLS-1$
2440
//	/**
2441
//	 * <pre>
2442
//	 * FORMATTER / Option to insert a space before question mark in a wildcard
2443
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_question_in_wildcard"
2444
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2445
//	 *     - default:           DO_NOT_INSERT
2446
//	 * </pre>
2447
//	 * @see CCorePlugin#INSERT
2448
//	 * @see CCorePlugin#DO_NOT_INSERT
2449
//	 */
2450
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_WILDCARD = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_question_in_wildcard"; //$NON-NLS-1$
2451
//	/**
2452
//	 * <pre>
2453
//	 * FORMATTER / Option to insert a space before semicolon
2454
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_semicolon"
2455
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2456
//	 *     - default:           DO_NOT_INSERT
2457
//	 * </pre>
2458
//	 * @see CCorePlugin#INSERT
2459
//	 * @see CCorePlugin#DO_NOT_INSERT
2460
//	 */
2461
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_semicolon";	//$NON-NLS-1$
2462
//	/**
2463
//	 * <pre>
2464
//	 * FORMATTER / Option to insert a space before semicolon in for statement
2465
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for"
2466
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2467
//	 *     - default:           DO_NOT_INSERT
2468
//	 * </pre>
2469
//	 * @see CCorePlugin#INSERT
2470
//	 * @see CCorePlugin#DO_NOT_INSERT
2471
//	 */
2472
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_semicolon_in_for";	//$NON-NLS-1$
2473
//	/**
2474
//	 * <pre>
2475
//	 * FORMATTER / Option to insert a space before unary operator
2476
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_unary_operator"
2477
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2478
//	 *     - default:           DO_NOT_INSERT
2479
//	 * </pre>
2480
//	 * @see CCorePlugin#INSERT
2481
//	 * @see CCorePlugin#DO_NOT_INSERT
2482
//	 */
2483
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_unary_operator";	//$NON-NLS-1$
2484
//
2485
//	/**
2486
//	 * <pre>
2487
//	 * FORMATTER / Option to insert a space between brackets in an array type reference
2488
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_brackets_in_array_type_reference"
2489
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2490
//	 *     - default:           DO_NOT_INSERT
2491
//	 * </pre>
2492
//	 * @see CCorePlugin#INSERT
2493
//	 * @see CCorePlugin#DO_NOT_INSERT
2494
//	 */
2495
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_brackets_in_array_type_reference";	//$NON-NLS-1$
2496
//	/**
2497
//	 * <pre>
2498
//	 * FORMATTER / Option to insert a space between empty braces in an array initializer
2499
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer"
2500
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2501
//	 *     - default:           DO_NOT_INSERT
2502
//	 * </pre>
2503
//	 * @see CCorePlugin#INSERT
2504
//	 * @see CCorePlugin#DO_NOT_INSERT
2505
//	 */
2506
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_braces_in_array_initializer";	//$NON-NLS-1$
2507
//	/**
2508
//	 * <pre>
2509
//	 * FORMATTER / Option to insert a space between empty brackets in an array allocation expression
2510
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression"
2511
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2512
//	 *     - default:           DO_NOT_INSERT
2513
//	 * </pre>
2514
//	 * @see CCorePlugin#INSERT
2515
//	 * @see CCorePlugin#DO_NOT_INSERT
2516
//	 */
2517
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_brackets_in_array_allocation_expression";	//$NON-NLS-1$
2518
//	/**
2519
//	 * <pre>
2520
//	 * FORMATTER / Option to insert a space between empty parenthesis in an annotation type member declaration
2521
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration"
2522
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2523
//	 *     - default:           DO_NOT_INSERT
2524
//	 * </pre>
2525
//	 * @see CCorePlugin#INSERT
2526
//	 * @see CCorePlugin#DO_NOT_INSERT
2527
//	 */
2528
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ANNOTATION_TYPE_MEMBER_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration";	//$NON-NLS-1$
2529
//	/**
2530
//	 * <pre>
2531
//	 * FORMATTER / Option to insert a space between empty parenthesis in a constructor declaration
2532
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration"
2533
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2534
//	 *     - default:           DO_NOT_INSERT
2535
//	 * </pre>
2536
//	 * @see CCorePlugin#INSERT
2537
//	 * @see CCorePlugin#DO_NOT_INSERT
2538
//	 */
2539
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_constructor_declaration";	//$NON-NLS-1$
2540
//	/**
2541
//	 * <pre>
2542
//	 * FORMATTER / Option to insert a space between empty parenthesis in enum constant
2543
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_enum_constant"
2544
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2545
//	 *     - default:           DO_NOT_INSERT
2546
//	 * </pre>
2547
//	 * @see CCorePlugin#INSERT
2548
//	 * @see CCorePlugin#DO_NOT_INSERT
2549
//	 */
2550
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_enum_constant";	//$NON-NLS-1$
2551
//	/**
2552
//	 * <pre>
2553
//	 * FORMATTER / Option to insert a space between empty parenthesis in a method declaration
2554
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration"
2555
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2556
//	 *     - default:           DO_NOT_INSERT
2557
//	 * </pre>
2558
//	 * @see CCorePlugin#INSERT
2559
//	 * @see CCorePlugin#DO_NOT_INSERT
2560
//	 */
2561
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_method_declaration";	//$NON-NLS-1$
2562
//	/**
2563
//	 * <pre>
2564
//	 * FORMATTER / Option to insert a space between empty parenthesis in a method invocation
2565
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation"
2566
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2567
//	 *     - default:           DO_NOT_INSERT
2568
//	 * </pre>
2569
//	 * @see CCorePlugin#INSERT
2570
//	 * @see CCorePlugin#DO_NOT_INSERT
2571
//	 */
2572
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_method_invocation";	//$NON-NLS-1$
2573
//	/**
2574
//	 * <pre>
2575
//	 * FORMATTER / Option to keep else statement on the same line
2576
//	 *     - option id:         "org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line"
2577
//	 *     - possible values:   { TRUE, FALSE }
2578
//	 *     - default:           FALSE
2579
//	 * </pre>
2580
//	 * @see #TRUE
2581
//	 * @see #FALSE
2582
//	 */
2583
//	public static final String FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE = CCorePlugin.PLUGIN_ID + ".formatter.keep_else_statement_on_same_line"; //$NON-NLS-1$
2584
//	/**
2585
//	 * <pre>
2586
//	 * FORMATTER / Option to keep empty array initializer one one line
2587
//	 *     - option id:         "org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line"
2588
//	 *     - possible values:   { TRUE, FALSE }
2589
//	 *     - default:           FALSE
2590
//	 * </pre>
2591
//	 * @see #TRUE
2592
//	 * @see #FALSE
2593
//	 */
2594
//	public static final String FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE = CCorePlugin.PLUGIN_ID + ".formatter.keep_empty_array_initializer_on_one_line"; //$NON-NLS-1$
2595
//	/**
2596
//	 * <pre>
2597
//	 * FORMATTER / Option to keep guardian clause on one line
2598
//	 *     - option id:         "org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line"
2599
//	 *     - possible values:   { TRUE, FALSE }
2600
//	 *     - default:           FALSE
2601
//	 * </pre>
2602
//	 * @see #TRUE
2603
//	 * @see #FALSE
2604
//	 */
2605
//	public static final String FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE = CCorePlugin.PLUGIN_ID + ".formatter.format_guardian_clause_on_one_line";	//$NON-NLS-1$
2606
//	/**
2607
//	 * <pre>
2608
//	 * FORMATTER / Option to keep simple if statement on the one line
2609
//	 *     - option id:         "org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line"
2610
//	 *     - possible values:   { TRUE, FALSE }
2611
//	 *     - default:           FALSE
2612
//	 * </pre>
2613
//	 * @see #TRUE
2614
//	 * @see #FALSE
2615
//	 */
2616
//	public static final String FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE = CCorePlugin.PLUGIN_ID + ".formatter.keep_imple_if_on_one_line"; //$NON-NLS-1$
2617
//	/**
2618
//	 * <pre>
2619
//	 * FORMATTER / Option to keep then statement on the same line
2620
//	 *     - option id:         "org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line"
2621
//	 *     - possible values:   { TRUE, FALSE }
2622
//	 *     - default:           FALSE
2623
//	 * </pre>
2624
//	 * @see #TRUE
2625
//	 * @see #FALSE
2626
//	 */
2627
//	public static final String FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE = CCorePlugin.PLUGIN_ID + ".formatter.keep_then_statement_on_same_line";//$NON-NLS-1$
2628
2629
	/**
2630
	 * <pre>
2631
	 * FORMATTER / Option to specify the length of the page. Beyond this length, the formatter will try to split the code
2632
	 *     - option id:         "org.eclipse.cdt.core.formatter.lineSplit"
2633
	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
2634
	 *     - default:           "80"
2635
	 * </pre>
2636
	 */
2637
	public static final String FORMATTER_LINE_SPLIT = CCorePlugin.PLUGIN_ID + ".formatter.lineSplit"; //$NON-NLS-1$
2638
//
2639
//	/**
2640
//	 * <pre>
2641
//	 * FORMATTER / Option to specify the number of empty lines to preserve
2642
//	 *     - option id:         "org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve"
2643
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
2644
//	 *     - default:           "0"
2645
//	 * </pre>
2646
//	 */
2647
//	public static final String FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE = CCorePlugin.PLUGIN_ID + ".formatter.number_of_empty_lines_to_preserve";	//$NON-NLS-1$
2648
//	/**
2649
//	 * <pre>
2650
//	 * FORMATTER / Option to specify whether or not empty statement should be on a new line
2651
//	 *     - option id:         "org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line"
2652
//	 *     - possible values:   { TRUE, FALSE }
2653
//	 *     - default:           FALSE
2654
//	 * </pre>
2655
//	 * @see #TRUE
2656
//	 * @see #FALSE
2657
//	 */
2658
//	public static final String FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE = CCorePlugin.PLUGIN_ID + ".formatter.put_empty_statement_on_new_line";	//$NON-NLS-1$
2659
	/**
2660
	 * <pre>
2661
	 * FORMATTER / Option to specify the tabulation size
2662
	 *     - option id:         "org.eclipse.cdt.core.formatter.tabulation.char"
2663
	 *     - possible values:   { TAB, SPACE, MIXED }
2664
	 *     - default:           TAB
2665
	 * </pre>
2666
	 * More values may be added in the future.
2667
	 * 
2668
	 * @see CCorePlugin#TAB
2669
	 * @see CCorePlugin#SPACE
2670
	 * @see #MIXED
2671
	 */
2672
	public static final String FORMATTER_TAB_CHAR = CCorePlugin.PLUGIN_ID + ".formatter.tabulation.char"; //$NON-NLS-1$
2673
	/**
2674
	 * <pre>
2675
	 * FORMATTER / Option to specify the equivalent number of spaces that represents one tabulation 
2676
	 *     - option id:         "org.eclipse.cdt.core.formatter.tabulation.size"
2677
	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
2678
	 *     - default:           "4"
2679
	 * </pre>
2680
	 */
2681
	public static final String FORMATTER_TAB_SIZE = CCorePlugin.PLUGIN_ID + ".formatter.tabulation.size"; //$NON-NLS-1$
2682
2683
	/**
2684
	 * <pre>
2685
	 * FORMATTER / Option to use tabulations only for leading indentations 
2686
	 *     - option id:         "org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations"
2687
	 *     - possible values:   { TRUE, FALSE }
2688
	 *     - default:           FALSE
2689
	 * </pre>
2690
	 * @see #TRUE
2691
	 * @see #FALSE
2692
	 */
2693
	public static final String FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS = CCorePlugin.PLUGIN_ID + ".formatter.use_tabs_only_for_leading_indentations"; //$NON-NLS-1$
2694
2695
	/**
2696
	 * <pre>
2697
	 * FORMATTER / The wrapping is done by indenting by one compare to the current indentation.
2698
	 * </pre>
2699
	 */
2700
	public static final int INDENT_BY_ONE= 2;
2701
	
2702
	/**
2703
	 * <pre>
2704
	 * FORMATTER / The wrapping is done by using the current indentation.
2705
	 * </pre>
2706
	 */
2707
	public static final int INDENT_DEFAULT= 0;
2708
	/**
2709
	 * <pre>
2710
	 * FORMATTER / The wrapping is done by indenting on column under the splitting location.
2711
	 * </pre>
2712
	 */
2713
	public static final int INDENT_ON_COLUMN = 1;
2714
	
2715
	/**
2716
	 * <pre>
2717
	 * FORMATTER / Possible value for the option FORMATTER_TAB_CHAR
2718
	 * </pre>
2719
	 * @see CCorePlugin#TAB
2720
	 * @see CCorePlugin#SPACE
2721
	 * @see #FORMATTER_TAB_CHAR
2722
	 */
2723
	public static final String MIXED = "mixed"; //$NON-NLS-1$
2724
//	/**
2725
//	 * <pre>
2726
//	 * FORMATTER / Value to set a brace location at the start of the next line with
2727
//	 *             the right indentation.
2728
//	 * </pre>
2729
//	 * @see #FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION
2730
//	 * @see #FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER
2731
//	 * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
2732
//	 * @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
2733
// 	 * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
2734
// 	 * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
2735
//	 * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
2736
//	 */
2737
//	public static final String NEXT_LINE = "next_line"; //$NON-NLS-1$
2738
//	/**
2739
//	 * <pre>
2740
//	 * FORMATTER / Value to set a brace location at the start of the next line if a wrapping
2741
//	 *             occured.
2742
//	 * </pre>
2743
//	 * @see #FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION
2744
//	 * @see #FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER
2745
//	 * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
2746
//	 * @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
2747
// 	 * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
2748
// 	 * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
2749
//	 * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
2750
//	 */
2751
//    public static final String NEXT_LINE_ON_WRAP = "next_line_on_wrap"; //$NON-NLS-1$
2752
	/**
2753
	 * <pre>
2754
	 * FORMATTER / Value to set a brace location at the start of the next line with
2755
	 *             an extra indentation.
2756
	 * </pre>
2757
	 * @see #FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION
2758
	 * @see #FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER
2759
	 * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
2760
	 * @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
2761
 	 * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
2762
 	 * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
2763
	 * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
2764
	 */
2765
	public static final String NEXT_LINE_SHIFTED = "next_line_shifted";	//$NON-NLS-1$
2766
	/**
2767
	 * <pre>
2768
	 * FORMATTER / Value to set an option to true.
2769
	 * </pre>
2770
	 */
2771
	public static final String TRUE = "true"; //$NON-NLS-1$
2772
	/**
2773
	 * <pre>
2774
	 * FORMATTER / The wrapping is done using as few lines as possible.
2775
	 * </pre>
2776
	 */
2777
	public static final int WRAP_COMPACT= 1;
2778
	/**
2779
	 * <pre>
2780
	 * FORMATTER / The wrapping is done putting the first element on a new
2781
	 *             line and then wrapping next elements using as few lines as possible.
2782
	 * </pre>
2783
	 */
2784
	public static final int WRAP_COMPACT_FIRST_BREAK= 2;
2785
	/**
2786
	 * <pre>
2787
	 * FORMATTER / The wrapping is done by putting each element on its own line
2788
	 *             except the first element.
2789
	 * </pre>
2790
	 */
2791
	public static final int WRAP_NEXT_PER_LINE= 5;
2792
	/**
2793
	 * <pre>
2794
	 * FORMATTER / The wrapping is done by putting each element on its own line.
2795
	 *             All elements are indented by one except the first element.
2796
	 * </pre>
2797
	 */
2798
	public static final int WRAP_NEXT_SHIFTED= 4;
2799
2800
	/**
2801
	 * <pre>
2802
	 * FORMATTER / Value to disable alignment.
2803
	 * </pre>
2804
	 */
2805
	public static final int WRAP_NO_SPLIT= 0;
2806
	/**
2807
	 * <pre>
2808
	 * FORMATTER / The wrapping is done by putting each element on its own line.
2809
	 * </pre>
2810
	 */
2811
	public static final int WRAP_ONE_PER_LINE= 3;
2812
2813
	/*
2814
	 * Private constants.
2815
	 */
2816
	private static final IllegalArgumentException WRONG_ARGUMENT = new IllegalArgumentException();
2817
	
2818
	/**
2819
	 * Create a new alignment value according to the given values. This must be used to set up
2820
	 * the alignment options.
2821
	 * 
2822
	 * @param forceSplit the given force value
2823
	 * @param wrapStyle the given wrapping style
2824
	 * @param indentStyle the given indent style
2825
	 * 
2826
	 * @return the new alignement value
2827
	 */
2828
	public static String createAlignmentValue(boolean forceSplit, int wrapStyle, int indentStyle) {
2829
		int alignmentValue = 0; 
2830
		switch(wrapStyle) {
2831
			case WRAP_COMPACT :
2832
				alignmentValue |= Alignment.M_COMPACT_SPLIT;
2833
				break;
2834
			case WRAP_COMPACT_FIRST_BREAK :
2835
				alignmentValue |= Alignment.M_COMPACT_FIRST_BREAK_SPLIT;
2836
				break;
2837
			case WRAP_NEXT_PER_LINE :
2838
				alignmentValue |= Alignment.M_NEXT_PER_LINE_SPLIT;
2839
				break;
2840
			case WRAP_NEXT_SHIFTED :
2841
				alignmentValue |= Alignment.M_NEXT_SHIFTED_SPLIT;
2842
				break;
2843
			case WRAP_ONE_PER_LINE :
2844
				alignmentValue |= Alignment.M_ONE_PER_LINE_SPLIT;
2845
				break;
2846
		}		
2847
		if (forceSplit) {
2848
			alignmentValue |= Alignment.M_FORCE;
2849
		}
2850
		switch(indentStyle) {
2851
			case INDENT_BY_ONE :
2852
				alignmentValue |= Alignment.M_INDENT_BY_ONE;
2853
				break;
2854
			case INDENT_ON_COLUMN :
2855
				alignmentValue |= Alignment.M_INDENT_ON_COLUMN;
2856
		}
2857
		return String.valueOf(alignmentValue);
2858
	}
2859
2860
	/**
2861
	 * Returns the default Eclipse formatter settings
2862
	 * 
2863
	 * @return the Eclipse default settings
2864
	 */
2865
	public static Map getEclipseDefaultSettings() {
2866
		return DefaultCodeFormatterOptions.getEclipseDefaultSettings().getMap();
2867
	}
2868
2869
	/**
2870
	 * <p>Return the force value of the given alignment value.
2871
	 * The given alignment value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
2872
	 * API.
2873
	 * </p>
2874
	 *
2875
	 * @param value the given alignment value
2876
	 * @return the force value of the given alignment value
2877
	 * @see #createAlignmentValue(boolean, int, int)
2878
	 * @exception IllegalArgumentException if the given alignment value is null, or if it 
2879
	 * doesn't have a valid format.
2880
	 */
2881
	public static boolean getForceWrapping(String value) {
2882
		if (value == null) {
2883
			throw WRONG_ARGUMENT;
2884
		}
2885
		try {
2886
			int existingValue = Integer.parseInt(value);
2887
			return (existingValue & Alignment.M_FORCE) != 0;
2888
		} catch (NumberFormatException e) {
2889
			throw WRONG_ARGUMENT;
2890
		}
2891
	}
2892
	
2893
	/**
2894
	 * <p>Return the indentation style of the given alignment value.
2895
	 * The given alignment value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
2896
	 * API.
2897
	 * </p>
2898
	 *
2899
	 * @param value the given alignment value
2900
	 * @return the indentation style of the given alignment value
2901
	 * @see #createAlignmentValue(boolean, int, int)
2902
	 * @exception IllegalArgumentException if the given alignment value is null, or if it 
2903
	 * doesn't have a valid format.
2904
	 */
2905
	public static int getIndentStyle(String value) {
2906
		if (value == null) {
2907
			throw WRONG_ARGUMENT;
2908
		}
2909
		try {
2910
			int existingValue = Integer.parseInt(value);
2911
			if ((existingValue & Alignment.M_INDENT_BY_ONE) != 0) {
2912
				return INDENT_BY_ONE;
2913
			} else if ((existingValue & Alignment.M_INDENT_ON_COLUMN) != 0) {
2914
				return INDENT_ON_COLUMN;
2915
			} else {
2916
				return INDENT_DEFAULT;
2917
			}
2918
		} catch (NumberFormatException e) {
2919
			throw WRONG_ARGUMENT;
2920
		}
2921
	}
2922
2923
	/**
2924
	 * <p>Return the wrapping style of the given alignment value.
2925
	 * The given alignment value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
2926
	 * API.
2927
	 * </p>
2928
	 *
2929
	 * @param value the given alignment value
2930
	 * @return the wrapping style of the given alignment value
2931
	 * @see #createAlignmentValue(boolean, int, int)
2932
	 * @exception IllegalArgumentException if the given alignment value is null, or if it 
2933
	 * doesn't have a valid format.
2934
	 */
2935
	public static int getWrappingStyle(String value) {
2936
		if (value == null) {
2937
			throw WRONG_ARGUMENT;
2938
		}
2939
		try {
2940
			int existingValue = Integer.parseInt(value) & Alignment.SPLIT_MASK;
2941
			switch(existingValue) {
2942
				case Alignment.M_COMPACT_SPLIT :
2943
					return WRAP_COMPACT;
2944
				case Alignment.M_COMPACT_FIRST_BREAK_SPLIT :
2945
					return WRAP_COMPACT_FIRST_BREAK;
2946
				case Alignment.M_NEXT_PER_LINE_SPLIT :
2947
					return WRAP_NEXT_PER_LINE;
2948
				case Alignment.M_NEXT_SHIFTED_SPLIT :
2949
					return WRAP_NEXT_SHIFTED;
2950
				case Alignment.M_ONE_PER_LINE_SPLIT :
2951
					return WRAP_ONE_PER_LINE;
2952
				default:
2953
					return WRAP_NO_SPLIT;
2954
			}
2955
		} catch (NumberFormatException e) {
2956
			throw WRONG_ARGUMENT;
2957
		}
2958
	}
2959
	/**
2960
	 * <p>Set the force value of the given alignment value and return the new value.
2961
	 * The given alignment value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
2962
	 * API.
2963
	 * </p>
2964
	 *
2965
	 * @param value the given alignment value
2966
	 * @param force the given force value
2967
	 * @return the new alignment value
2968
	 * @see #createAlignmentValue(boolean, int, int)
2969
	 * @exception IllegalArgumentException if the given alignment value is null, or if it 
2970
	 * doesn't have a valid format.
2971
	 */
2972
	public static String setForceWrapping(String value, boolean force) {
2973
		if (value == null) {
2974
			throw WRONG_ARGUMENT;
2975
		}
2976
		try {
2977
			int existingValue = Integer.parseInt(value);
2978
			// clear existing force bit
2979
			existingValue &= ~Alignment.M_FORCE;
2980
			if (force) {
2981
				existingValue |= Alignment.M_FORCE;
2982
			}
2983
			return String.valueOf(existingValue);
2984
		} catch (NumberFormatException e) {
2985
			throw WRONG_ARGUMENT;
2986
		}		
2987
	}
2988
	
2989
	/**
2990
	 * <p>Set the indentation style of the given alignment value and return the new value.
2991
	 * The given value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
2992
	 * API.
2993
	 * </p>
2994
	 *
2995
	 * @param value the given alignment value
2996
	 * @param indentStyle the given indentation style
2997
	 * @return the new alignment value
2998
	 * @see #INDENT_BY_ONE
2999
	 * @see #INDENT_DEFAULT
3000
	 * @see #INDENT_ON_COLUMN
3001
	 * @see #createAlignmentValue(boolean, int, int)
3002
	 * @exception IllegalArgumentException if the given alignment value is null, if the given
3003
	 * indentation style is not one of the possible indentation styles, or if the given
3004
	 * alignment value doesn't have a valid format.
3005
	 */
3006
	public static String setIndentStyle(String value, int indentStyle) {
3007
		if (value == null) {
3008
			throw WRONG_ARGUMENT;
3009
		}
3010
		switch(indentStyle) {
3011
			case INDENT_BY_ONE :
3012
			case INDENT_DEFAULT :
3013
			case INDENT_ON_COLUMN :
3014
				break;
3015
			default :
3016
				throw WRONG_ARGUMENT;
3017
		}
3018
		try {
3019
			int existingValue = Integer.parseInt(value);
3020
			// clear existing indent bits
3021
			existingValue &= ~(Alignment.M_INDENT_BY_ONE | Alignment.M_INDENT_ON_COLUMN);
3022
			switch(indentStyle) {
3023
				case INDENT_BY_ONE :
3024
					existingValue |= Alignment.M_INDENT_BY_ONE;
3025
					break;
3026
				case INDENT_ON_COLUMN :
3027
					existingValue |= Alignment.M_INDENT_ON_COLUMN;
3028
			}
3029
			return String.valueOf(existingValue);
3030
		} catch (NumberFormatException e) {
3031
			throw WRONG_ARGUMENT;
3032
		}
3033
	}
3034
	/**
3035
	 * <p>Set the wrapping style of the given alignment value and return the new value.
3036
	 * The given value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
3037
	 * API.
3038
	 * </p>
3039
	 *
3040
	 * @param value the given alignment value
3041
	 * @param wrappingStyle the given wrapping style
3042
	 * @return the new alignment value
3043
	 * @see #WRAP_COMPACT
3044
	 * @see #WRAP_COMPACT_FIRST_BREAK
3045
	 * @see #WRAP_NEXT_PER_LINE
3046
	 * @see #WRAP_NEXT_SHIFTED
3047
	 * @see #WRAP_NO_SPLIT
3048
	 * @see #WRAP_ONE_PER_LINE
3049
	 * @see #createAlignmentValue(boolean, int, int)
3050
	 * @exception IllegalArgumentException if the given alignment value is null, if the given
3051
	 * wrapping style is not one of the possible wrapping styles, or if the given
3052
	 * alignment value doesn't have a valid format.
3053
	 */
3054
	public static String setWrappingStyle(String value, int wrappingStyle) {
3055
		if (value == null) {
3056
			throw WRONG_ARGUMENT;
3057
		}
3058
		switch(wrappingStyle) {
3059
			case WRAP_COMPACT :
3060
			case WRAP_COMPACT_FIRST_BREAK :
3061
			case WRAP_NEXT_PER_LINE :
3062
			case WRAP_NEXT_SHIFTED :
3063
			case WRAP_NO_SPLIT :
3064
			case WRAP_ONE_PER_LINE :
3065
				break;
3066
			default:
3067
				throw WRONG_ARGUMENT;
3068
		}
3069
		try {
3070
			int existingValue = Integer.parseInt(value);
3071
			// clear existing split bits
3072
			existingValue &= ~(Alignment.SPLIT_MASK);
3073
			switch(wrappingStyle) {
3074
				case WRAP_COMPACT :
3075
					existingValue |= Alignment.M_COMPACT_SPLIT;
3076
					break;
3077
				case WRAP_COMPACT_FIRST_BREAK :
3078
					existingValue |= Alignment.M_COMPACT_FIRST_BREAK_SPLIT;
3079
					break;
3080
				case WRAP_NEXT_PER_LINE :
3081
					existingValue |= Alignment.M_NEXT_PER_LINE_SPLIT;
3082
					break;
3083
				case WRAP_NEXT_SHIFTED :
3084
					existingValue |= Alignment.M_NEXT_SHIFTED_SPLIT;
3085
					break;
3086
				case WRAP_ONE_PER_LINE :
3087
					existingValue |= Alignment.M_ONE_PER_LINE_SPLIT;
3088
					break;
3089
			}
3090
			return String.valueOf(existingValue);
3091
		} catch (NumberFormatException e) {
3092
			throw WRONG_ARGUMENT;
3093
		}
3094
	}
3095
}
(-)src/org/eclipse/cdt/internal/formatter/DefaultCodeFormatterOptions.java (-136 / +143 lines)
Lines 14-20 Link Here
14
import java.util.HashMap;
14
import java.util.HashMap;
15
import java.util.Map;
15
import java.util.Map;
16
16
17
import org.eclipse.cdt.core.formatter.CodeFormatterConstants;
17
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
18
import org.eclipse.cdt.core.CCorePlugin;
18
import org.eclipse.cdt.core.CCorePlugin;
19
import org.eclipse.cdt.internal.formatter.align.Alignment;
19
import org.eclipse.cdt.internal.formatter.align.Alignment;
20
20
Lines 95-101 Link Here
95
	public boolean indent_statements_compare_to_body;
95
	public boolean indent_statements_compare_to_body;
96
	public boolean indent_body_declarations_compare_to_enum_constant_header;
96
	public boolean indent_body_declarations_compare_to_enum_constant_header;
97
	public boolean indent_body_declarations_compare_to_enum_declaration_header;
97
	public boolean indent_body_declarations_compare_to_enum_declaration_header;
98
	public boolean indent_body_declarations_compare_to_type_header;
98
	public boolean indent_body_declarations_compare_to_access_specifier;
99
	public boolean indent_access_specifier_compare_to_type_header;
99
	public boolean indent_breaks_compare_to_cases;
100
	public boolean indent_breaks_compare_to_cases;
100
	public boolean indent_empty_lines;
101
	public boolean indent_empty_lines;
101
	public boolean indent_switchstatements_compare_to_cases;
102
	public boolean indent_switchstatements_compare_to_cases;
Lines 288-331 Link Here
288
289
289
	public Map getMap() {
290
	public Map getMap() {
290
		Map options = new HashMap();
291
		Map options = new HashMap();
291
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION, getAlignment(this.alignment_for_arguments_in_allocation_expression));
292
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION, getAlignment(this.alignment_for_arguments_in_allocation_expression));
292
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT, getAlignment(this.alignment_for_arguments_in_enum_constant));
293
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT, getAlignment(this.alignment_for_arguments_in_enum_constant));
293
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL, getAlignment(this.alignment_for_arguments_in_explicit_constructor_call));
294
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL, getAlignment(this.alignment_for_arguments_in_explicit_constructor_call));
294
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_arguments_in_method_invocation));
295
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_arguments_in_method_invocation));
295
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION, getAlignment(this.alignment_for_arguments_in_qualified_allocation_expression));
296
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION, getAlignment(this.alignment_for_arguments_in_qualified_allocation_expression));
296
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, getAlignment(this.alignment_for_assignment));
297
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, getAlignment(this.alignment_for_assignment));
297
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION, getAlignment(this.alignment_for_binary_expression));
298
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION, getAlignment(this.alignment_for_binary_expression));
298
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF, getAlignment(this.alignment_for_compact_if));
299
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF, getAlignment(this.alignment_for_compact_if));
299
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, getAlignment(this.alignment_for_conditional_expression));
300
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION, getAlignment(this.alignment_for_conditional_expression));
300
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, getAlignment(this.alignment_for_enum_constants));
301
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS, getAlignment(this.alignment_for_enum_constants));
301
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, getAlignment(this.alignment_for_expressions_in_array_initializer));
302
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER, getAlignment(this.alignment_for_expressions_in_array_initializer));
302
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS, getAlignment(this.alignment_for_multiple_fields));
303
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS, getAlignment(this.alignment_for_multiple_fields));
303
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, getAlignment(this.alignment_for_parameters_in_constructor_declaration));
304
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION, getAlignment(this.alignment_for_parameters_in_constructor_declaration));
304
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_parameters_in_method_declaration));
305
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_parameters_in_method_declaration));
305
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_selector_in_method_invocation));
306
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_selector_in_method_invocation));
306
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION, getAlignment(this.alignment_for_superclass_in_type_declaration));
307
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION, getAlignment(this.alignment_for_superclass_in_type_declaration));
307
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION, getAlignment(this.alignment_for_superinterfaces_in_enum_declaration));
308
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION, getAlignment(this.alignment_for_superinterfaces_in_enum_declaration));
308
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION, getAlignment(this.alignment_for_superinterfaces_in_type_declaration));
309
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION, getAlignment(this.alignment_for_superinterfaces_in_type_declaration));
309
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION, getAlignment(this.alignment_for_throws_clause_in_constructor_declaration));
310
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION, getAlignment(this.alignment_for_throws_clause_in_constructor_declaration));
310
		options.put(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_throws_clause_in_method_declaration));
311
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION, getAlignment(this.alignment_for_throws_clause_in_method_declaration));
311
		options.put(CodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS, this.align_type_members_on_columns ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
312
		options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS, this.align_type_members_on_columns ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
312
		options.put(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, this.brace_position_for_array_initializer);
313
		options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER, this.brace_position_for_array_initializer);
313
		options.put(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, this.brace_position_for_block);
314
		options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK, this.brace_position_for_block);
314
		options.put(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE, this.brace_position_for_block_in_case);
315
		options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE, this.brace_position_for_block_in_case);
315
		options.put(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, this.brace_position_for_constructor_declaration);
316
		options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION, this.brace_position_for_constructor_declaration);
316
		options.put(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT, this.brace_position_for_enum_constant);
317
		options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT, this.brace_position_for_enum_constant);
317
		options.put(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION, this.brace_position_for_enum_declaration);
318
		options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION, this.brace_position_for_enum_declaration);
318
		options.put(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, this.brace_position_for_method_declaration);
319
		options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION, this.brace_position_for_method_declaration);
319
		options.put(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, this.brace_position_for_type_declaration);
320
		options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION, this.brace_position_for_type_declaration);
320
		options.put(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, this.brace_position_for_switch);
321
		options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, this.brace_position_for_switch);
321
//		options.put(CodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES, this.comment_clear_blank_lines ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
322
//		options.put(CodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES, this.comment_clear_blank_lines ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
322
//		options.put(CodeFormatterConstants.FORMATTER_COMMENT_FORMAT, this.comment_format ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
323
//		options.put(CodeFormatterConstants.FORMATTER_COMMENT_FORMAT, this.comment_format ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
323
//		options.put(CodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, this.comment_format_header ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
324
//		options.put(CodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, this.comment_format_header ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
324
//		options.put(CodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HTML, this.comment_format_html ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
325
//		options.put(CodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HTML, this.comment_format_html ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
325
//		options.put(CodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE, this.comment_format_source ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
326
//		options.put(CodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE, this.comment_format_source ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
326
//		options.put(CodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, Integer.toString(this.comment_line_length));
327
//		options.put(CodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, Integer.toString(this.comment_line_length));
327
		options.put(CodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, Integer.toString(this.continuation_indentation));
328
		options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION, Integer.toString(this.continuation_indentation));
328
		options.put(CodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, Integer.toString(this.continuation_indentation_for_array_initializer));
329
		options.put(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER, Integer.toString(this.continuation_indentation_for_array_initializer));
329
//		options.put(CodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS, Integer.toString(this.blank_lines_after_imports));
330
//		options.put(CodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_IMPORTS, Integer.toString(this.blank_lines_after_imports));
330
//		options.put(CodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE, Integer.toString(this.blank_lines_after_package));
331
//		options.put(CodeFormatterConstants.FORMATTER_BLANK_LINES_AFTER_PACKAGE, Integer.toString(this.blank_lines_after_package));
331
//		options.put(CodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIELD, Integer.toString(this.blank_lines_before_field));
332
//		options.put(CodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_FIELD, Integer.toString(this.blank_lines_before_field));
Lines 337-352 Link Here
337
//		options.put(CodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE, Integer.toString(this.blank_lines_before_package));
338
//		options.put(CodeFormatterConstants.FORMATTER_BLANK_LINES_BEFORE_PACKAGE, Integer.toString(this.blank_lines_before_package));
338
//		options.put(CodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS, Integer.toString(this.blank_lines_between_type_declarations));
339
//		options.put(CodeFormatterConstants.FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS, Integer.toString(this.blank_lines_between_type_declarations));
339
//		options.put(CodeFormatterConstants.FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY, Integer.toString(this.blank_lines_at_beginning_of_method_body));
340
//		options.put(CodeFormatterConstants.FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY, Integer.toString(this.blank_lines_at_beginning_of_method_body));
340
		options.put(CodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, this.indent_statements_compare_to_block ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
341
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, this.indent_statements_compare_to_block ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
341
		options.put(CodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, this.indent_statements_compare_to_body ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
342
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, this.indent_statements_compare_to_body ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
342
		options.put(CodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER, this.indent_body_declarations_compare_to_enum_constant_header ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
343
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER, this.indent_body_declarations_compare_to_enum_constant_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
343
		options.put(CodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER, this.indent_body_declarations_compare_to_enum_declaration_header ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
344
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER, this.indent_body_declarations_compare_to_enum_declaration_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
344
		options.put(CodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER, this.indent_body_declarations_compare_to_type_header ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
345
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER, this.indent_body_declarations_compare_to_access_specifier ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
345
		options.put(CodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES, this.indent_breaks_compare_to_cases ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
346
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER, this.indent_body_declarations_compare_to_access_specifier ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
346
		options.put(CodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, this.indent_empty_lines ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
347
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER, this.indent_access_specifier_compare_to_type_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
347
		options.put(CodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, this.indent_switchstatements_compare_to_cases ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
348
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES, this.indent_breaks_compare_to_cases ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
348
		options.put(CodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, this.indent_switchstatements_compare_to_switch ? CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
349
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, this.indent_empty_lines ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
349
		options.put(CodeFormatterConstants.FORMATTER_INDENTATION_SIZE, Integer.toString(this.indentation_size));
350
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, this.indent_switchstatements_compare_to_cases ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
351
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, this.indent_switchstatements_compare_to_switch ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
352
		options.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, Integer.toString(this.indentation_size));
350
//		options.put(CodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, this.insert_new_line_after_opening_brace_in_array_initializer? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
353
//		options.put(CodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, this.insert_new_line_after_opening_brace_in_array_initializer? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
351
//		options.put(CodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, this.insert_new_line_at_end_of_file_if_missing ? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
354
//		options.put(CodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING, this.insert_new_line_at_end_of_file_if_missing ? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
352
//		options.put(CodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, this.insert_new_line_before_catch_in_try_statement? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
355
//		options.put(CodeFormatterConstants.FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT, this.insert_new_line_before_catch_in_try_statement? CCorePlugin.INSERT : CCorePlugin.DO_NOT_INSERT);
Lines 511-532 Link Here
511
//		options.put(CodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(this.page_width));
514
//		options.put(CodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(this.page_width));
512
		switch(this.tab_char) {
515
		switch(this.tab_char) {
513
			case SPACE :
516
			case SPACE :
514
				options.put(CodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
517
				options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
515
				break;
518
				break;
516
			case TAB :
519
			case TAB :
517
				options.put(CodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.TAB);
520
				options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.TAB);
518
				break;
521
				break;
519
			case MIXED :
522
			case MIXED :
520
				options.put(CodeFormatterConstants.FORMATTER_TAB_CHAR, CodeFormatterConstants.MIXED);
523
				options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, DefaultCodeFormatterConstants.MIXED);
521
				break;
524
				break;
522
		}
525
		}
523
		options.put(CodeFormatterConstants.FORMATTER_TAB_SIZE, Integer.toString(this.tab_size));
526
		options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, Integer.toString(this.tab_size));
524
		options.put(CodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, this.use_tabs_only_for_leading_indentations ?  CodeFormatterConstants.TRUE : CodeFormatterConstants.FALSE);
527
		options.put(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, this.use_tabs_only_for_leading_indentations ?  DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
525
		return options;
528
		return options;
526
	}
529
	}
527
530
528
	public void set(Map settings) {
531
	public void set(Map settings) {
529
		final Object alignmentForArgumentsInAllocationExpressionOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION);
532
		final Object alignmentForArgumentsInAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION);
530
		if (alignmentForArgumentsInAllocationExpressionOption != null) {
533
		if (alignmentForArgumentsInAllocationExpressionOption != null) {
531
			try {
534
			try {
532
				this.alignment_for_arguments_in_allocation_expression = Integer.parseInt((String) alignmentForArgumentsInAllocationExpressionOption);
535
				this.alignment_for_arguments_in_allocation_expression = Integer.parseInt((String) alignmentForArgumentsInAllocationExpressionOption);
Lines 536-542 Link Here
536
				this.alignment_for_arguments_in_allocation_expression = Alignment.M_COMPACT_SPLIT;
539
				this.alignment_for_arguments_in_allocation_expression = Alignment.M_COMPACT_SPLIT;
537
			}
540
			}
538
		}
541
		}
539
		final Object alignmentForArgumentsInEnumConstantOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT);
542
		final Object alignmentForArgumentsInEnumConstantOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT);
540
		if (alignmentForArgumentsInEnumConstantOption != null) {
543
		if (alignmentForArgumentsInEnumConstantOption != null) {
541
			try {
544
			try {
542
				this.alignment_for_arguments_in_enum_constant = Integer.parseInt((String) alignmentForArgumentsInEnumConstantOption);
545
				this.alignment_for_arguments_in_enum_constant = Integer.parseInt((String) alignmentForArgumentsInEnumConstantOption);
Lines 546-552 Link Here
546
				this.alignment_for_arguments_in_enum_constant = Alignment.M_COMPACT_SPLIT;
549
				this.alignment_for_arguments_in_enum_constant = Alignment.M_COMPACT_SPLIT;
547
			}
550
			}
548
		}
551
		}
549
		final Object alignmentForArgumentsInExplicitConstructorCallOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL);
552
		final Object alignmentForArgumentsInExplicitConstructorCallOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL);
550
		if (alignmentForArgumentsInExplicitConstructorCallOption != null) {
553
		if (alignmentForArgumentsInExplicitConstructorCallOption != null) {
551
			try {
554
			try {
552
				this.alignment_for_arguments_in_explicit_constructor_call = Integer.parseInt((String) alignmentForArgumentsInExplicitConstructorCallOption);
555
				this.alignment_for_arguments_in_explicit_constructor_call = Integer.parseInt((String) alignmentForArgumentsInExplicitConstructorCallOption);
Lines 556-562 Link Here
556
				this.alignment_for_arguments_in_explicit_constructor_call = Alignment.M_COMPACT_SPLIT;
559
				this.alignment_for_arguments_in_explicit_constructor_call = Alignment.M_COMPACT_SPLIT;
557
			}
560
			}
558
		}
561
		}
559
		final Object alignmentForArgumentsInMethodInvocationOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
562
		final Object alignmentForArgumentsInMethodInvocationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
560
		if (alignmentForArgumentsInMethodInvocationOption != null) {
563
		if (alignmentForArgumentsInMethodInvocationOption != null) {
561
			try {
564
			try {
562
				this.alignment_for_arguments_in_method_invocation = Integer.parseInt((String) alignmentForArgumentsInMethodInvocationOption);
565
				this.alignment_for_arguments_in_method_invocation = Integer.parseInt((String) alignmentForArgumentsInMethodInvocationOption);
Lines 566-572 Link Here
566
				this.alignment_for_arguments_in_method_invocation = Alignment.M_COMPACT_SPLIT;
569
				this.alignment_for_arguments_in_method_invocation = Alignment.M_COMPACT_SPLIT;
567
			}
570
			}
568
		}
571
		}
569
		final Object alignmentForArgumentsInQualifiedAllocationExpressionOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION);
572
		final Object alignmentForArgumentsInQualifiedAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION);
570
		if (alignmentForArgumentsInQualifiedAllocationExpressionOption != null) {
573
		if (alignmentForArgumentsInQualifiedAllocationExpressionOption != null) {
571
			try {
574
			try {
572
				this.alignment_for_arguments_in_qualified_allocation_expression = Integer.parseInt((String) alignmentForArgumentsInQualifiedAllocationExpressionOption);
575
				this.alignment_for_arguments_in_qualified_allocation_expression = Integer.parseInt((String) alignmentForArgumentsInQualifiedAllocationExpressionOption);
Lines 576-582 Link Here
576
				this.alignment_for_arguments_in_qualified_allocation_expression = Alignment.M_COMPACT_SPLIT;
579
				this.alignment_for_arguments_in_qualified_allocation_expression = Alignment.M_COMPACT_SPLIT;
577
			}
580
			}
578
		}
581
		}
579
		final Object alignmentForAssignmentOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT);
582
		final Object alignmentForAssignmentOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT);
580
		if (alignmentForAssignmentOption != null) {
583
		if (alignmentForAssignmentOption != null) {
581
			try {
584
			try {
582
				this.alignment_for_assignment = Integer.parseInt((String) alignmentForAssignmentOption);
585
				this.alignment_for_assignment = Integer.parseInt((String) alignmentForAssignmentOption);
Lines 586-592 Link Here
586
				this.alignment_for_assignment =  Alignment.M_ONE_PER_LINE_SPLIT;
589
				this.alignment_for_assignment =  Alignment.M_ONE_PER_LINE_SPLIT;
587
			}
590
			}
588
		}
591
		}
589
		final Object alignmentForBinaryExpressionOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION);
592
		final Object alignmentForBinaryExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION);
590
		if (alignmentForBinaryExpressionOption != null) {
593
		if (alignmentForBinaryExpressionOption != null) {
591
			try {
594
			try {
592
				this.alignment_for_binary_expression = Integer.parseInt((String) alignmentForBinaryExpressionOption);
595
				this.alignment_for_binary_expression = Integer.parseInt((String) alignmentForBinaryExpressionOption);
Lines 596-602 Link Here
596
				this.alignment_for_binary_expression =  Alignment.M_COMPACT_SPLIT;
599
				this.alignment_for_binary_expression =  Alignment.M_COMPACT_SPLIT;
597
			}
600
			}
598
		}
601
		}
599
		final Object alignmentForCompactIfOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF);
602
		final Object alignmentForCompactIfOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_COMPACT_IF);
600
		if (alignmentForCompactIfOption != null) {
603
		if (alignmentForCompactIfOption != null) {
601
			try {
604
			try {
602
				this.alignment_for_compact_if = Integer.parseInt((String) alignmentForCompactIfOption);
605
				this.alignment_for_compact_if = Integer.parseInt((String) alignmentForCompactIfOption);
Lines 606-612 Link Here
606
				this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE;
609
				this.alignment_for_compact_if = Alignment.M_ONE_PER_LINE_SPLIT | Alignment.M_INDENT_BY_ONE;
607
			}
610
			}
608
		}
611
		}
609
		final Object alignmentForConditionalExpressionOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
612
		final Object alignmentForConditionalExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
610
		if (alignmentForConditionalExpressionOption != null) {
613
		if (alignmentForConditionalExpressionOption != null) {
611
			try {
614
			try {
612
				this.alignment_for_conditional_expression = Integer.parseInt((String) alignmentForConditionalExpressionOption);
615
				this.alignment_for_conditional_expression = Integer.parseInt((String) alignmentForConditionalExpressionOption);
Lines 616-622 Link Here
616
				this.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT;
619
				this.alignment_for_conditional_expression = Alignment.M_ONE_PER_LINE_SPLIT;
617
			}
620
			}
618
		}
621
		}
619
		final Object alignmentForEnumConstantsOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS);
622
		final Object alignmentForEnumConstantsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS);
620
		if (alignmentForEnumConstantsOption != null) {
623
		if (alignmentForEnumConstantsOption != null) {
621
			try {
624
			try {
622
				this.alignment_for_enum_constants = Integer.parseInt((String) alignmentForEnumConstantsOption);
625
				this.alignment_for_enum_constants = Integer.parseInt((String) alignmentForEnumConstantsOption);
Lines 626-632 Link Here
626
				this.alignment_for_enum_constants = Alignment.NONE;
629
				this.alignment_for_enum_constants = Alignment.NONE;
627
			}
630
			}
628
		}
631
		}
629
		final Object alignmentForExpressionsInArrayInitializerOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
632
		final Object alignmentForExpressionsInArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
630
		if (alignmentForExpressionsInArrayInitializerOption != null) {
633
		if (alignmentForExpressionsInArrayInitializerOption != null) {
631
			try {
634
			try {
632
				this.alignment_for_expressions_in_array_initializer = Integer.parseInt((String) alignmentForExpressionsInArrayInitializerOption);
635
				this.alignment_for_expressions_in_array_initializer = Integer.parseInt((String) alignmentForExpressionsInArrayInitializerOption);
Lines 636-642 Link Here
636
				this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT;
639
				this.alignment_for_expressions_in_array_initializer = Alignment.M_COMPACT_SPLIT;
637
			}
640
			}
638
		}
641
		}
639
		final Object alignmentForMultipleFieldsOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS);
642
		final Object alignmentForMultipleFieldsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS);
640
		if (alignmentForMultipleFieldsOption != null) {
643
		if (alignmentForMultipleFieldsOption != null) {
641
			try {
644
			try {
642
				this.alignment_for_multiple_fields = Integer.parseInt((String) alignmentForMultipleFieldsOption);
645
				this.alignment_for_multiple_fields = Integer.parseInt((String) alignmentForMultipleFieldsOption);
Lines 646-652 Link Here
646
				this.alignment_for_multiple_fields = Alignment.M_COMPACT_SPLIT;
649
				this.alignment_for_multiple_fields = Alignment.M_COMPACT_SPLIT;
647
			}
650
			}
648
		}
651
		}
649
		final Object alignmentForParametersInConstructorDeclarationOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION);
652
		final Object alignmentForParametersInConstructorDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION);
650
		if (alignmentForParametersInConstructorDeclarationOption != null) {
653
		if (alignmentForParametersInConstructorDeclarationOption != null) {
651
			try {
654
			try {
652
				this.alignment_for_parameters_in_constructor_declaration = Integer.parseInt((String) alignmentForParametersInConstructorDeclarationOption);
655
				this.alignment_for_parameters_in_constructor_declaration = Integer.parseInt((String) alignmentForParametersInConstructorDeclarationOption);
Lines 656-662 Link Here
656
				this.alignment_for_parameters_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
659
				this.alignment_for_parameters_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
657
			}
660
			}
658
		}
661
		}
659
		final Object alignmentForParametersInMethodDeclarationOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
662
		final Object alignmentForParametersInMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
660
		if (alignmentForParametersInMethodDeclarationOption != null) {
663
		if (alignmentForParametersInMethodDeclarationOption != null) {
661
			try {
664
			try {
662
				this.alignment_for_parameters_in_method_declaration = Integer.parseInt((String) alignmentForParametersInMethodDeclarationOption);
665
				this.alignment_for_parameters_in_method_declaration = Integer.parseInt((String) alignmentForParametersInMethodDeclarationOption);
Lines 666-672 Link Here
666
				this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT;
669
				this.alignment_for_parameters_in_method_declaration = Alignment.M_COMPACT_SPLIT;
667
			}
670
			}
668
		}
671
		}
669
		final Object alignmentForSelectorInMethodInvocationOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION);
672
		final Object alignmentForSelectorInMethodInvocationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION);
670
		if (alignmentForSelectorInMethodInvocationOption != null) {
673
		if (alignmentForSelectorInMethodInvocationOption != null) {
671
			try {
674
			try {
672
				this.alignment_for_selector_in_method_invocation = Integer.parseInt((String) alignmentForSelectorInMethodInvocationOption);
675
				this.alignment_for_selector_in_method_invocation = Integer.parseInt((String) alignmentForSelectorInMethodInvocationOption);
Lines 676-682 Link Here
676
				this.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_SPLIT;
679
				this.alignment_for_selector_in_method_invocation = Alignment.M_COMPACT_SPLIT;
677
			}
680
			}
678
		}
681
		}
679
		final Object alignmentForSuperclassInTypeDeclarationOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION);
682
		final Object alignmentForSuperclassInTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION);
680
		if (alignmentForSuperclassInTypeDeclarationOption != null) {
683
		if (alignmentForSuperclassInTypeDeclarationOption != null) {
681
			try {
684
			try {
682
				this.alignment_for_superclass_in_type_declaration = Integer.parseInt((String) alignmentForSuperclassInTypeDeclarationOption);
685
				this.alignment_for_superclass_in_type_declaration = Integer.parseInt((String) alignmentForSuperclassInTypeDeclarationOption);
Lines 686-692 Link Here
686
				this.alignment_for_superclass_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
689
				this.alignment_for_superclass_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
687
			}
690
			}
688
		}
691
		}
689
		final Object alignmentForSuperinterfacesInEnumDeclarationOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION);
692
		final Object alignmentForSuperinterfacesInEnumDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION);
690
		if (alignmentForSuperinterfacesInEnumDeclarationOption != null) {
693
		if (alignmentForSuperinterfacesInEnumDeclarationOption != null) {
691
			try {
694
			try {
692
				this.alignment_for_superinterfaces_in_enum_declaration = Integer.parseInt((String) alignmentForSuperinterfacesInEnumDeclarationOption);
695
				this.alignment_for_superinterfaces_in_enum_declaration = Integer.parseInt((String) alignmentForSuperinterfacesInEnumDeclarationOption);
Lines 696-702 Link Here
696
				this.alignment_for_superinterfaces_in_enum_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
699
				this.alignment_for_superinterfaces_in_enum_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
697
			}
700
			}
698
		}
701
		}
699
		final Object alignmentForSuperinterfacesInTypeDeclarationOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION);
702
		final Object alignmentForSuperinterfacesInTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION);
700
		if (alignmentForSuperinterfacesInTypeDeclarationOption != null) {
703
		if (alignmentForSuperinterfacesInTypeDeclarationOption != null) {
701
			try {
704
			try {
702
				this.alignment_for_superinterfaces_in_type_declaration = Integer.parseInt((String) alignmentForSuperinterfacesInTypeDeclarationOption);
705
				this.alignment_for_superinterfaces_in_type_declaration = Integer.parseInt((String) alignmentForSuperinterfacesInTypeDeclarationOption);
Lines 706-712 Link Here
706
				this.alignment_for_superinterfaces_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
709
				this.alignment_for_superinterfaces_in_type_declaration = Alignment.M_NEXT_SHIFTED_SPLIT;
707
			}
710
			}
708
		}
711
		}
709
		final Object alignmentForThrowsClauseInConstructorDeclarationOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION);
712
		final Object alignmentForThrowsClauseInConstructorDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION);
710
		if (alignmentForThrowsClauseInConstructorDeclarationOption != null) {
713
		if (alignmentForThrowsClauseInConstructorDeclarationOption != null) {
711
			try {
714
			try {
712
				this.alignment_for_throws_clause_in_constructor_declaration = Integer.parseInt((String) alignmentForThrowsClauseInConstructorDeclarationOption);
715
				this.alignment_for_throws_clause_in_constructor_declaration = Integer.parseInt((String) alignmentForThrowsClauseInConstructorDeclarationOption);
Lines 716-722 Link Here
716
				this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
719
				this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
717
			}
720
			}
718
		}
721
		}
719
		final Object alignmentForThrowsClauseInMethodDeclarationOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION);
722
		final Object alignmentForThrowsClauseInMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION);
720
		if (alignmentForThrowsClauseInMethodDeclarationOption != null) {
723
		if (alignmentForThrowsClauseInMethodDeclarationOption != null) {
721
			try {
724
			try {
722
				this.alignment_for_throws_clause_in_method_declaration = Integer.parseInt((String) alignmentForThrowsClauseInMethodDeclarationOption);
725
				this.alignment_for_throws_clause_in_method_declaration = Integer.parseInt((String) alignmentForThrowsClauseInMethodDeclarationOption);
Lines 726-808 Link Here
726
				this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
729
				this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
727
			}
730
			}
728
		}
731
		}
729
		final Object alignTypeMembersOnColumnsOption = settings.get(CodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS);
732
		final Object alignTypeMembersOnColumnsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS);
730
		if (alignTypeMembersOnColumnsOption != null) {
733
		if (alignTypeMembersOnColumnsOption != null) {
731
			this.align_type_members_on_columns = CodeFormatterConstants.TRUE.equals(alignTypeMembersOnColumnsOption);
734
			this.align_type_members_on_columns = DefaultCodeFormatterConstants.TRUE.equals(alignTypeMembersOnColumnsOption);
732
		}
735
		}
733
		final Object bracePositionForArrayInitializerOption = settings.get(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER);
736
		final Object bracePositionForArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER);
734
		if (bracePositionForArrayInitializerOption != null) {
737
		if (bracePositionForArrayInitializerOption != null) {
735
			try {
738
			try {
736
				this.brace_position_for_array_initializer = (String) bracePositionForArrayInitializerOption;
739
				this.brace_position_for_array_initializer = (String) bracePositionForArrayInitializerOption;
737
			} catch(ClassCastException e) {
740
			} catch(ClassCastException e) {
738
				this.brace_position_for_array_initializer = CodeFormatterConstants.END_OF_LINE;
741
				this.brace_position_for_array_initializer = DefaultCodeFormatterConstants.END_OF_LINE;
739
			}
742
			}
740
		}
743
		}
741
		final Object bracePositionForBlockOption = settings.get(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK);
744
		final Object bracePositionForBlockOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK);
742
		if (bracePositionForBlockOption != null) {
745
		if (bracePositionForBlockOption != null) {
743
			try {
746
			try {
744
				this.brace_position_for_block = (String) bracePositionForBlockOption;
747
				this.brace_position_for_block = (String) bracePositionForBlockOption;
745
			} catch(ClassCastException e) {
748
			} catch(ClassCastException e) {
746
				this.brace_position_for_block = CodeFormatterConstants.END_OF_LINE;
749
				this.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE;
747
			}
750
			}
748
		}
751
		}
749
		final Object bracePositionForBlockInCaseOption = settings.get(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE);
752
		final Object bracePositionForBlockInCaseOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE);
750
		if (bracePositionForBlockInCaseOption != null) {
753
		if (bracePositionForBlockInCaseOption != null) {
751
			try {
754
			try {
752
				this.brace_position_for_block_in_case = (String) bracePositionForBlockInCaseOption;
755
				this.brace_position_for_block_in_case = (String) bracePositionForBlockInCaseOption;
753
			} catch(ClassCastException e) {
756
			} catch(ClassCastException e) {
754
				this.brace_position_for_block_in_case = CodeFormatterConstants.END_OF_LINE;
757
				this.brace_position_for_block_in_case = DefaultCodeFormatterConstants.END_OF_LINE;
755
			}
758
			}
756
		}
759
		}
757
		final Object bracePositionForConstructorDeclarationOption = settings.get(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION);
760
		final Object bracePositionForConstructorDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION);
758
		if (bracePositionForConstructorDeclarationOption != null) {
761
		if (bracePositionForConstructorDeclarationOption != null) {
759
			try {
762
			try {
760
				this.brace_position_for_constructor_declaration = (String) bracePositionForConstructorDeclarationOption;
763
				this.brace_position_for_constructor_declaration = (String) bracePositionForConstructorDeclarationOption;
761
			} catch(ClassCastException e) {
764
			} catch(ClassCastException e) {
762
				this.brace_position_for_constructor_declaration = CodeFormatterConstants.END_OF_LINE;
765
				this.brace_position_for_constructor_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
763
			}
766
			}
764
		}
767
		}
765
		final Object bracePositionForEnumConstantOption = settings.get(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT);
768
		final Object bracePositionForEnumConstantOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT);
766
		if (bracePositionForEnumConstantOption != null) {
769
		if (bracePositionForEnumConstantOption != null) {
767
			try {
770
			try {
768
				this.brace_position_for_enum_constant = (String) bracePositionForEnumConstantOption;
771
				this.brace_position_for_enum_constant = (String) bracePositionForEnumConstantOption;
769
			} catch(ClassCastException e) {
772
			} catch(ClassCastException e) {
770
				this.brace_position_for_enum_constant = CodeFormatterConstants.END_OF_LINE;
773
				this.brace_position_for_enum_constant = DefaultCodeFormatterConstants.END_OF_LINE;
771
			}
774
			}
772
		}
775
		}
773
		final Object bracePositionForEnumDeclarationOption = settings.get(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION);
776
		final Object bracePositionForEnumDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION);
774
		if (bracePositionForEnumDeclarationOption != null) {
777
		if (bracePositionForEnumDeclarationOption != null) {
775
			try {
778
			try {
776
				this.brace_position_for_enum_declaration = (String) bracePositionForEnumDeclarationOption;
779
				this.brace_position_for_enum_declaration = (String) bracePositionForEnumDeclarationOption;
777
			} catch(ClassCastException e) {
780
			} catch(ClassCastException e) {
778
				this.brace_position_for_enum_declaration = CodeFormatterConstants.END_OF_LINE;
781
				this.brace_position_for_enum_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
779
			}
782
			}
780
		}
783
		}
781
		final Object bracePositionForMethodDeclarationOption = settings.get(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION);
784
		final Object bracePositionForMethodDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION);
782
		if (bracePositionForMethodDeclarationOption != null) {
785
		if (bracePositionForMethodDeclarationOption != null) {
783
			try {
786
			try {
784
				this.brace_position_for_method_declaration = (String) bracePositionForMethodDeclarationOption;
787
				this.brace_position_for_method_declaration = (String) bracePositionForMethodDeclarationOption;
785
			} catch(ClassCastException e) {
788
			} catch(ClassCastException e) {
786
				this.brace_position_for_method_declaration = CodeFormatterConstants.END_OF_LINE;
789
				this.brace_position_for_method_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
787
			}
790
			}
788
		}
791
		}
789
		final Object bracePositionForSwitchOption = settings.get(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH);
792
		final Object bracePositionForSwitchOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH);
790
		if (bracePositionForSwitchOption != null) {
793
		if (bracePositionForSwitchOption != null) {
791
			try {
794
			try {
792
				this.brace_position_for_switch = (String) bracePositionForSwitchOption;
795
				this.brace_position_for_switch = (String) bracePositionForSwitchOption;
793
			} catch(ClassCastException e) {
796
			} catch(ClassCastException e) {
794
				this.brace_position_for_switch = CodeFormatterConstants.END_OF_LINE;
797
				this.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE;
795
			}
798
			}
796
		}
799
		}
797
		final Object bracePositionForTypeDeclarationOption = settings.get(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION);
800
		final Object bracePositionForTypeDeclarationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION);
798
		if (bracePositionForTypeDeclarationOption != null) {
801
		if (bracePositionForTypeDeclarationOption != null) {
799
			try {
802
			try {
800
				this.brace_position_for_type_declaration = (String) bracePositionForTypeDeclarationOption;
803
				this.brace_position_for_type_declaration = (String) bracePositionForTypeDeclarationOption;
801
			} catch(ClassCastException e) {
804
			} catch(ClassCastException e) {
802
				this.brace_position_for_type_declaration = CodeFormatterConstants.END_OF_LINE;
805
				this.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
803
			}
806
			}
804
		}
807
		}
805
		final Object continuationIndentationOption = settings.get(CodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
808
		final Object continuationIndentationOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
806
		if (continuationIndentationOption != null) {
809
		if (continuationIndentationOption != null) {
807
			try {
810
			try {
808
				this.continuation_indentation = Integer.parseInt((String) continuationIndentationOption);
811
				this.continuation_indentation = Integer.parseInt((String) continuationIndentationOption);
Lines 812-818 Link Here
812
				this.continuation_indentation = 2;
815
				this.continuation_indentation = 2;
813
			}
816
			}
814
		}
817
		}
815
		final Object continuationIndentationForArrayInitializerOption = settings.get(CodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER);
818
		final Object continuationIndentationForArrayInitializerOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER);
816
		if (continuationIndentationForArrayInitializerOption != null) {
819
		if (continuationIndentationForArrayInitializerOption != null) {
817
			try {
820
			try {
818
				this.continuation_indentation_for_array_initializer = Integer.parseInt((String) continuationIndentationForArrayInitializerOption);
821
				this.continuation_indentation_for_array_initializer = Integer.parseInt((String) continuationIndentationForArrayInitializerOption);
Lines 962-1004 Link Here
962
//				this.comment_line_length = 80;
965
//				this.comment_line_length = 80;
963
//			}
966
//			}
964
//		}
967
//		}
965
		final Object indentStatementsCompareToBlockOption = settings.get(CodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK);
968
		final Object indentStatementsCompareToBlockOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK);
966
		if (indentStatementsCompareToBlockOption != null) {
969
		if (indentStatementsCompareToBlockOption != null) {
967
			this.indent_statements_compare_to_block = CodeFormatterConstants.TRUE.equals(indentStatementsCompareToBlockOption);
970
			this.indent_statements_compare_to_block = DefaultCodeFormatterConstants.TRUE.equals(indentStatementsCompareToBlockOption);
968
		}
971
		}
969
		final Object indentStatementsCompareToBodyOption = settings.get(CodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY);
972
		final Object indentStatementsCompareToBodyOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY);
970
		if (indentStatementsCompareToBodyOption != null) {
973
		if (indentStatementsCompareToBodyOption != null) {
971
			this.indent_statements_compare_to_body = CodeFormatterConstants.TRUE.equals(indentStatementsCompareToBodyOption);
974
			this.indent_statements_compare_to_body = DefaultCodeFormatterConstants.TRUE.equals(indentStatementsCompareToBodyOption);
972
		}
975
		}
973
		final Object indentBodyDeclarationsCompareToEnumConstantHeaderOption = settings.get(CodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER);
976
		final Object indentBodyDeclarationsCompareToEnumConstantHeaderOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER);
974
		if (indentBodyDeclarationsCompareToEnumConstantHeaderOption != null) {
977
		if (indentBodyDeclarationsCompareToEnumConstantHeaderOption != null) {
975
			this.indent_body_declarations_compare_to_enum_constant_header = CodeFormatterConstants.TRUE.equals(indentBodyDeclarationsCompareToEnumConstantHeaderOption);
978
			this.indent_body_declarations_compare_to_enum_constant_header = DefaultCodeFormatterConstants.TRUE.equals(indentBodyDeclarationsCompareToEnumConstantHeaderOption);
976
		}
979
		}
977
		final Object indentBodyDeclarationsCompareToEnumDeclarationHeaderOption = settings.get(CodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER);
980
		final Object indentBodyDeclarationsCompareToEnumDeclarationHeaderOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER);
978
		if (indentBodyDeclarationsCompareToEnumDeclarationHeaderOption != null) {
981
		if (indentBodyDeclarationsCompareToEnumDeclarationHeaderOption != null) {
979
			this.indent_body_declarations_compare_to_enum_declaration_header = CodeFormatterConstants.TRUE.equals(indentBodyDeclarationsCompareToEnumDeclarationHeaderOption);
982
			this.indent_body_declarations_compare_to_enum_declaration_header = DefaultCodeFormatterConstants.TRUE.equals(indentBodyDeclarationsCompareToEnumDeclarationHeaderOption);
980
		}
983
		}
981
		final Object indentBodyDeclarationsCompareToTypeHeaderOption = settings.get(CodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER);
984
		final Object indentAccessSpecifierCompareToTypeHeaderOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER);
982
		if (indentBodyDeclarationsCompareToTypeHeaderOption != null) {
985
		if (indentAccessSpecifierCompareToTypeHeaderOption != null) {
983
			this.indent_body_declarations_compare_to_type_header = CodeFormatterConstants.TRUE.equals(indentBodyDeclarationsCompareToTypeHeaderOption);
986
			this.indent_access_specifier_compare_to_type_header = DefaultCodeFormatterConstants.TRUE.equals(indentAccessSpecifierCompareToTypeHeaderOption);
984
		}
987
		}
985
		final Object indentBreaksCompareToCasesOption = settings.get(CodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES);
988
		final Object indentBodyDeclarationsCompareToAccessSpecifierOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER);
989
		if (indentBodyDeclarationsCompareToAccessSpecifierOption != null) {
990
			this.indent_body_declarations_compare_to_access_specifier = DefaultCodeFormatterConstants.TRUE.equals(indentBodyDeclarationsCompareToAccessSpecifierOption);
991
		}
992
		final Object indentBreaksCompareToCasesOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES);
986
		if (indentBreaksCompareToCasesOption != null) {
993
		if (indentBreaksCompareToCasesOption != null) {
987
			this.indent_breaks_compare_to_cases = CodeFormatterConstants.TRUE.equals(indentBreaksCompareToCasesOption);
994
			this.indent_breaks_compare_to_cases = DefaultCodeFormatterConstants.TRUE.equals(indentBreaksCompareToCasesOption);
988
		}
995
		}
989
		final Object indentEmptyLinesOption = settings.get(CodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES);
996
		final Object indentEmptyLinesOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES);
990
		if (indentEmptyLinesOption != null) {
997
		if (indentEmptyLinesOption != null) {
991
			this.indent_empty_lines = CodeFormatterConstants.TRUE.equals(indentEmptyLinesOption);
998
			this.indent_empty_lines = DefaultCodeFormatterConstants.TRUE.equals(indentEmptyLinesOption);
992
		}
999
		}
993
		final Object indentSwitchstatementsCompareToCasesOption = settings.get(CodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES);
1000
		final Object indentSwitchstatementsCompareToCasesOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES);
994
		if (indentSwitchstatementsCompareToCasesOption != null) {
1001
		if (indentSwitchstatementsCompareToCasesOption != null) {
995
			this.indent_switchstatements_compare_to_cases = CodeFormatterConstants.TRUE.equals(indentSwitchstatementsCompareToCasesOption);
1002
			this.indent_switchstatements_compare_to_cases = DefaultCodeFormatterConstants.TRUE.equals(indentSwitchstatementsCompareToCasesOption);
996
		}
1003
		}
997
		final Object indentSwitchstatementsCompareToSwitchOption = settings.get(CodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH);
1004
		final Object indentSwitchstatementsCompareToSwitchOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH);
998
		if (indentSwitchstatementsCompareToSwitchOption != null) {
1005
		if (indentSwitchstatementsCompareToSwitchOption != null) {
999
			this.indent_switchstatements_compare_to_switch = CodeFormatterConstants.TRUE.equals(indentSwitchstatementsCompareToSwitchOption);
1006
			this.indent_switchstatements_compare_to_switch = DefaultCodeFormatterConstants.TRUE.equals(indentSwitchstatementsCompareToSwitchOption);
1000
		}
1007
		}
1001
		final Object indentationSizeOption = settings.get(CodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
1008
		final Object indentationSizeOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
1002
		if (indentationSizeOption != null) {
1009
		if (indentationSizeOption != null) {
1003
			try {
1010
			try {
1004
				this.indentation_size = Integer.parseInt((String) indentationSizeOption);
1011
				this.indentation_size = Integer.parseInt((String) indentationSizeOption);
Lines 1658-1664 Link Here
1658
//		if (putEmptyStatementOnNewLineOption != null) {
1665
//		if (putEmptyStatementOnNewLineOption != null) {
1659
//			this.put_empty_statement_on_new_line = CodeFormatterConstants.TRUE.equals(putEmptyStatementOnNewLineOption);
1666
//			this.put_empty_statement_on_new_line = CodeFormatterConstants.TRUE.equals(putEmptyStatementOnNewLineOption);
1660
//		}
1667
//		}
1661
		final Object tabSizeOption = settings.get(CodeFormatterConstants.FORMATTER_TAB_SIZE);
1668
		final Object tabSizeOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
1662
		if (tabSizeOption != null) {
1669
		if (tabSizeOption != null) {
1663
			try {
1670
			try {
1664
				this.tab_size = Integer.parseInt((String) tabSizeOption);
1671
				this.tab_size = Integer.parseInt((String) tabSizeOption);
Lines 1668-1678 Link Here
1668
				this.tab_size = 4;
1675
				this.tab_size = 4;
1669
			}
1676
			}
1670
		}
1677
		}
1671
		final Object useTabsOnlyForLeadingIndentationsOption = settings.get(CodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS);
1678
		final Object useTabsOnlyForLeadingIndentationsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS);
1672
		if (useTabsOnlyForLeadingIndentationsOption != null) {
1679
		if (useTabsOnlyForLeadingIndentationsOption != null) {
1673
			this.use_tabs_only_for_leading_indentations = CodeFormatterConstants.TRUE.equals(useTabsOnlyForLeadingIndentationsOption);
1680
			this.use_tabs_only_for_leading_indentations = DefaultCodeFormatterConstants.TRUE.equals(useTabsOnlyForLeadingIndentationsOption);
1674
		}
1681
		}
1675
		final Object pageWidthOption = settings.get(CodeFormatterConstants.FORMATTER_LINE_SPLIT);
1682
		final Object pageWidthOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT);
1676
		if (pageWidthOption != null) {
1683
		if (pageWidthOption != null) {
1677
			try {
1684
			try {
1678
				this.page_width = Integer.parseInt((String) pageWidthOption);
1685
				this.page_width = Integer.parseInt((String) pageWidthOption);
Lines 1682-1688 Link Here
1682
				this.page_width = 80;
1689
				this.page_width = 80;
1683
			}
1690
			}
1684
		}
1691
		}
1685
		final Object useTabOption = settings.get(CodeFormatterConstants.FORMATTER_TAB_CHAR);
1692
		final Object useTabOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
1686
		if (useTabOption != null) {
1693
		if (useTabOption != null) {
1687
			if (CCorePlugin.TAB.equals(useTabOption)) {
1694
			if (CCorePlugin.TAB.equals(useTabOption)) {
1688
				this.tab_char = TAB;
1695
				this.tab_char = TAB;
Lines 1716-1730 Link Here
1716
		this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
1723
		this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
1717
		this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
1724
		this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
1718
		this.align_type_members_on_columns = false;
1725
		this.align_type_members_on_columns = false;
1719
		this.brace_position_for_array_initializer = CodeFormatterConstants.END_OF_LINE;
1726
		this.brace_position_for_array_initializer = DefaultCodeFormatterConstants.END_OF_LINE;
1720
		this.brace_position_for_block = CodeFormatterConstants.END_OF_LINE;
1727
		this.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE;
1721
		this.brace_position_for_block_in_case = CodeFormatterConstants.END_OF_LINE;
1728
		this.brace_position_for_block_in_case = DefaultCodeFormatterConstants.END_OF_LINE;
1722
		this.brace_position_for_constructor_declaration = CodeFormatterConstants.END_OF_LINE;
1729
		this.brace_position_for_constructor_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
1723
		this.brace_position_for_enum_constant = CodeFormatterConstants.END_OF_LINE;
1730
		this.brace_position_for_enum_constant = DefaultCodeFormatterConstants.END_OF_LINE;
1724
		this.brace_position_for_enum_declaration = CodeFormatterConstants.END_OF_LINE;
1731
		this.brace_position_for_enum_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
1725
		this.brace_position_for_method_declaration = CodeFormatterConstants.END_OF_LINE;
1732
		this.brace_position_for_method_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
1726
		this.brace_position_for_type_declaration = CodeFormatterConstants.END_OF_LINE;
1733
		this.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
1727
		this.brace_position_for_switch = CodeFormatterConstants.END_OF_LINE;
1734
		this.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE;
1728
//		this.comment_clear_blank_lines = false;
1735
//		this.comment_clear_blank_lines = false;
1729
//		this.comment_format = true;
1736
//		this.comment_format = true;
1730
//		this.comment_format_header = false;
1737
//		this.comment_format_header = false;
Lines 1752-1758 Link Here
1752
		this.indent_statements_compare_to_body = true;
1759
		this.indent_statements_compare_to_body = true;
1753
		this.indent_body_declarations_compare_to_enum_constant_header = true;
1760
		this.indent_body_declarations_compare_to_enum_constant_header = true;
1754
		this.indent_body_declarations_compare_to_enum_declaration_header = true;
1761
		this.indent_body_declarations_compare_to_enum_declaration_header = true;
1755
		this.indent_body_declarations_compare_to_type_header = true;
1762
		this.indent_body_declarations_compare_to_access_specifier = true;
1756
		this.indent_breaks_compare_to_cases = true;
1763
		this.indent_breaks_compare_to_cases = true;
1757
		this.indent_empty_lines = false;
1764
		this.indent_empty_lines = false;
1758
		this.indent_switchstatements_compare_to_cases = true;
1765
		this.indent_switchstatements_compare_to_cases = true;
Lines 1947-1961 Link Here
1947
		this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
1954
		this.alignment_for_throws_clause_in_constructor_declaration = Alignment.M_COMPACT_SPLIT;
1948
		this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
1955
		this.alignment_for_throws_clause_in_method_declaration = Alignment.M_COMPACT_SPLIT;
1949
		this.align_type_members_on_columns = false;
1956
		this.align_type_members_on_columns = false;
1950
		this.brace_position_for_array_initializer = CodeFormatterConstants.END_OF_LINE;
1957
		this.brace_position_for_array_initializer = DefaultCodeFormatterConstants.END_OF_LINE;
1951
		this.brace_position_for_block = CodeFormatterConstants.END_OF_LINE;
1958
		this.brace_position_for_block = DefaultCodeFormatterConstants.END_OF_LINE;
1952
		this.brace_position_for_block_in_case = CodeFormatterConstants.END_OF_LINE;
1959
		this.brace_position_for_block_in_case = DefaultCodeFormatterConstants.END_OF_LINE;
1953
		this.brace_position_for_constructor_declaration = CodeFormatterConstants.END_OF_LINE;
1960
		this.brace_position_for_constructor_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
1954
		this.brace_position_for_enum_constant = CodeFormatterConstants.END_OF_LINE;
1961
		this.brace_position_for_enum_constant = DefaultCodeFormatterConstants.END_OF_LINE;
1955
		this.brace_position_for_enum_declaration = CodeFormatterConstants.END_OF_LINE;
1962
		this.brace_position_for_enum_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
1956
		this.brace_position_for_method_declaration = CodeFormatterConstants.END_OF_LINE;
1963
		this.brace_position_for_method_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
1957
		this.brace_position_for_type_declaration = CodeFormatterConstants.END_OF_LINE;
1964
		this.brace_position_for_type_declaration = DefaultCodeFormatterConstants.END_OF_LINE;
1958
		this.brace_position_for_switch = CodeFormatterConstants.END_OF_LINE;
1965
		this.brace_position_for_switch = DefaultCodeFormatterConstants.END_OF_LINE;
1959
//		this.comment_clear_blank_lines = false;
1966
//		this.comment_clear_blank_lines = false;
1960
//		this.comment_format = true;
1967
//		this.comment_format = true;
1961
//		this.comment_format_header = false;
1968
//		this.comment_format_header = false;
Lines 1983-1989 Link Here
1983
		this.indent_statements_compare_to_body = true;
1990
		this.indent_statements_compare_to_body = true;
1984
		this.indent_body_declarations_compare_to_enum_constant_header = true;
1991
		this.indent_body_declarations_compare_to_enum_constant_header = true;
1985
		this.indent_body_declarations_compare_to_enum_declaration_header = true;
1992
		this.indent_body_declarations_compare_to_enum_declaration_header = true;
1986
		this.indent_body_declarations_compare_to_type_header = true;
1993
		this.indent_body_declarations_compare_to_access_specifier = true;
1987
		this.indent_breaks_compare_to_cases = true;
1994
		this.indent_breaks_compare_to_cases = true;
1988
		this.indent_empty_lines = false;
1995
		this.indent_empty_lines = false;
1989
		this.indent_switchstatements_compare_to_cases = true;
1996
		this.indent_switchstatements_compare_to_cases = true;
(-)src/org/eclipse/cdt/internal/formatter/CCodeFormatter.java (-16 / +82 lines)
Lines 7-30 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     QNX Software Systems - Initial API and implementation
9
 *     QNX Software Systems - Initial API and implementation
10
 *     Sergey Prigogin, Google
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.formatter;
12
package org.eclipse.cdt.internal.formatter;
12
13
14
import java.util.Map;
13
15
14
public class CCodeFormatter {
16
import org.eclipse.cdt.core.formatter.CodeFormatter;
15
	//public FormatterOptions options;
17
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
16
	
18
import org.eclipse.text.edits.TextEdit;
17
	public CCodeFormatter() {
19
18
	}
20
19
	
21
public class CCodeFormatter extends CodeFormatter {
20
//	CCodeFormatter(FormatterOptions options) {
22
  
21
//	}
23
  private DefaultCodeFormatterOptions preferences;
22
	
24
  
23
	public String formatSourceString(String content) {
25
  public CCodeFormatter() {
24
		return content;
26
    this(new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipseDefaultSettings()), null);
25
	}
27
  }
26
28
  
27
29
  public CCodeFormatter(DefaultCodeFormatterOptions preferences) {
30
    this(preferences, null);
31
  }
32
33
  public CCodeFormatter(DefaultCodeFormatterOptions defaultCodeFormatterOptions, Map options) {
34
    setOptions(options);
35
    if (defaultCodeFormatterOptions != null) {
36
      preferences.set(defaultCodeFormatterOptions.getMap());
37
    }
38
  }
39
40
  public CCodeFormatter(Map options) {
41
    this(null, options);
42
  }
43
  
44
  public String createIndentationString(final int indentationLevel) {
45
    if (indentationLevel < 0) {
46
      throw new IllegalArgumentException();
47
    }
48
    
49
    int tabs = 0;
50
    int spaces = 0;
51
    switch (preferences.tab_char) {
52
      case DefaultCodeFormatterOptions.SPACE :
53
        spaces = indentationLevel * preferences.tab_size;
54
        break;
55
        
56
      case DefaultCodeFormatterOptions.TAB :
57
        tabs = indentationLevel;
58
        break;
59
        
60
      case DefaultCodeFormatterOptions.MIXED :
61
        int tabSize = preferences.tab_size;
62
        int spaceEquivalents = indentationLevel * preferences.indentation_size;
63
        tabs = spaceEquivalents / tabSize;
64
        spaces = spaceEquivalents % tabSize;
65
        break;
66
        
67
      default:
68
        return EMPTY_STRING;
69
    }
70
    
71
    if (tabs == 0 && spaces == 0) {
72
      return EMPTY_STRING;
73
    }
74
    StringBuffer buffer = new StringBuffer(tabs + spaces);
75
    for (int i = 0; i < tabs; i++) {
76
      buffer.append('\t');
77
    }
78
    for(int i = 0; i < spaces; i++) {
79
      buffer.append(' ');
80
    }
81
    return buffer.toString();
82
  }
83
84
  public void setOptions(Map options) {
85
    if (options != null) {
86
      preferences = new DefaultCodeFormatterOptions(options);
87
    } else {
88
      preferences = new DefaultCodeFormatterOptions(DefaultCodeFormatterConstants.getEclipseDefaultSettings());
89
    }
90
  }
91
92
  public TextEdit format(int kind, String source, int offset, int length, int indentationLevel, String lineSeparator) {
93
    // TODO Not implemented yet
94
    return null;
95
  }
28
}
96
}
29
30
(-)src/org/eclipse/cdt/internal/core/CCorePreferenceInitializer.java (-2 / +2 lines)
Lines 17-23 Link Here
17
17
18
import org.eclipse.cdt.core.CCorePlugin;
18
import org.eclipse.cdt.core.CCorePlugin;
19
import org.eclipse.cdt.core.CCorePreferenceConstants;
19
import org.eclipse.cdt.core.CCorePreferenceConstants;
20
import org.eclipse.cdt.core.formatter.CodeFormatterConstants;
20
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
21
import org.eclipse.cdt.internal.core.model.CModelManager;
21
import org.eclipse.cdt.internal.core.model.CModelManager;
22
//import org.eclipse.core.runtime.Preferences;
22
//import org.eclipse.core.runtime.Preferences;
23
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
23
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
Lines 35-41 Link Here
35
        HashSet optionNames = CModelManager.OptionNames;
35
        HashSet optionNames = CModelManager.OptionNames;
36
    
36
    
37
		// Formatter settings
37
		// Formatter settings
38
		Map defaultOptionsMap = CodeFormatterConstants.getEclipseDefaultSettings(); // code formatter defaults
38
		Map defaultOptionsMap = DefaultCodeFormatterConstants.getEclipseDefaultSettings(); // code formatter defaults
39
39
40
		// Compiler settings
40
		// Compiler settings
41
		defaultOptionsMap.put(CCorePreferenceConstants.TRANSLATION_TASK_TAGS, CCorePreferenceConstants.DEFAULT_TASK_TAG); 
41
		defaultOptionsMap.put(CCorePreferenceConstants.TRANSLATION_TASK_TAGS, CCorePreferenceConstants.DEFAULT_TASK_TAG); 
(-)src/org/eclipse/cdt/core/ToolFactory.java (-1 / +5 lines)
Lines 14-19 Link Here
14
import java.util.Map;
14
import java.util.Map;
15
15
16
import org.eclipse.cdt.core.formatter.CodeFormatter;
16
import org.eclipse.cdt.core.formatter.CodeFormatter;
17
import org.eclipse.cdt.internal.formatter.CCodeFormatter;
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IExtension;
20
import org.eclipse.core.runtime.IExtension;
Lines 67-71 Link Here
67
		return null;
68
		return null;
68
	}
69
	}
69
70
70
	
71
  public static CodeFormatter createDefaultCodeFormatter(Map options){
72
    if (options == null) options = CCorePlugin.getOptions();
73
    return new CCodeFormatter(options);
74
  }
71
}
75
}
(-)src/org/eclipse/cdt/core/formatter/DefaultCodeFormatterConstants.java (+3094 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 QNX Software Systems and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     QNX Software Systems - Initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.core.formatter;
13
14
import java.util.Map;
15
16
import org.eclipse.cdt.core.CCorePlugin;
17
import org.eclipse.cdt.internal.formatter.DefaultCodeFormatterOptions;
18
import org.eclipse.cdt.internal.formatter.align.Alignment;
19
20
/**
21
 */
22
public class DefaultCodeFormatterConstants {
23
24
	/**
25
	 * <pre>
26
	 * FORMATTER / Option for alignment of arguments in allocation expression
27
	 *     - option id:         "org.eclipse.cdt.core.formatter.language"
28
	 *     - possible values:   values proposed in class <code>ParserLanguage</code> 
29
	 *     - default:           ParserLanguage.CPP
30
	 * </pre>
31
	 */
32
	public static final String FORMATTER_LANGUAGE = CCorePlugin.PLUGIN_ID + ".formatter.language";	 //$NON-NLS-1$
33
	
34
	/**
35
	 * <pre>
36
	 * FORMATTER / Option for alignment of arguments in allocation expression
37
	 *     - option id:         "org.eclipse.cdt.core.formatter.current_file"
38
	 *     - possible values:   object of class <code>IFile</code> or <code>null</code> 
39
	 *     - default:           null
40
	 * </pre>
41
	 */
42
	public static final String FORMATTER_CURRENT_FILE = CCorePlugin.PLUGIN_ID + ".formatter.current_file";	 //$NON-NLS-1$
43
	
44
	/**
45
	 * <pre>
46
	 * FORMATTER / Value to set a brace location at the end of a line.
47
	 * </pre>
48
	 * @see #FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION
49
	 * @see #FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER
50
	 * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
51
	 * @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
52
 	 * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
53
 	 * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
54
	 * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
55
	 */
56
	public static final String END_OF_LINE = "end_of_line";	//$NON-NLS-1$
57
58
	/**
59
	 * <pre>
60
	 * FORMATTER / Value to set an option to false.
61
	 * </pre>
62
	 */
63
	public static final String FALSE = "false"; //$NON-NLS-1$
64
	
65
	/**
66
	 * <pre>
67
	 * FORMATTER / Option to align type members of a type declaration on column
68
	 *     - option id:         "org.eclipse.cdt.core.formatter.formatter.align_type_members_on_columns"
69
	 *     - possible values:   { TRUE, FALSE }
70
	 *     - default:           FALSE
71
	 * </pre>
72
	 * @see #TRUE
73
	 * @see #FALSE
74
	 */
75
	public static final String FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS = CCorePlugin.PLUGIN_ID + ".formatter.align_type_members_on_columns";	 //$NON-NLS-1$
76
77
	/**
78
	 * <pre>
79
	 * FORMATTER / Option for alignment of arguments in allocation expression
80
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_arguments_in_allocation_expression"
81
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
82
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
83
	 * </pre>
84
	 * @see #createAlignmentValue(boolean, int, int)
85
	 */
86
	public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_arguments_in_allocation_expression";	 //$NON-NLS-1$
87
	/**
88
	 * <pre>
89
	 * FORMATTER / Option for alignment of arguments in enum constant
90
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_arguments_in_enum_constant"
91
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
92
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
93
	 * </pre>
94
	 * @see #createAlignmentValue(boolean, int, int)
95
	 */
96
	public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_arguments_in_enum_constant";	 //$NON-NLS-1$
97
	/**
98
	 * <pre>
99
	 * FORMATTER / Option for alignment of arguments in explicit constructor call
100
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call"
101
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
102
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
103
	 * </pre>
104
	 * @see #createAlignmentValue(boolean, int, int)
105
	 */
106
	public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_EXPLICIT_CONSTRUCTOR_CALL = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_arguments_in_explicit_constructor_call";	 //$NON-NLS-1$
107
	/**
108
	 * <pre>
109
	 * FORMATTER / Option for alignment of arguments in method invocation
110
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation"
111
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
112
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
113
	 * </pre>
114
	 * @see #createAlignmentValue(boolean, int, int)
115
	 */
116
	public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_arguments_in_method_invocation";	 //$NON-NLS-1$
117
	/**
118
	 * <pre>
119
	 * FORMATTER / Option for alignment of arguments in qualified allocation expression
120
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression"
121
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
122
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
123
	 * </pre>
124
	 * @see #createAlignmentValue(boolean, int, int)
125
	 */
126
	public static final String FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_QUALIFIED_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_arguments_in_qualified_allocation_expression";	 //$NON-NLS-1$
127
	/**
128
	 * <pre>
129
	 * FORMATTER / Option for alignment of assignment
130
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_assignment"
131
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
132
	 *     - default:           createAlignmentValue(false, M_NO_ALIGNMENT, INDENT_DEFAULT)
133
	 * </pre>
134
	 * @see #createAlignmentValue(boolean, int, int)
135
	 */
136
	public static final String FORMATTER_ALIGNMENT_FOR_ASSIGNMENT  = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_assignment";	 //$NON-NLS-1$
137
	/**
138
	 * <pre>
139
	 * FORMATTER / Option for alignment of binary expression
140
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_binary_expression"
141
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
142
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
143
	 * </pre>
144
	 * @see #createAlignmentValue(boolean, int, int)
145
	 */
146
	public static final String FORMATTER_ALIGNMENT_FOR_BINARY_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_binary_expression";	 //$NON-NLS-1$
147
	/**
148
	 * <pre>
149
	 * FORMATTER / Option for alignment of compact if
150
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_compact_if"
151
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
152
	 *     - default:           createAlignmentValue(false, WRAP_ONE_PER_LINE, INDENT_BY_ONE)
153
	 * </pre>
154
	 * @see #createAlignmentValue(boolean, int, int)
155
	 */
156
	public static final String FORMATTER_ALIGNMENT_FOR_COMPACT_IF = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_compact_if";	 //$NON-NLS-1$
157
	/**
158
	 * <pre>
159
	 * FORMATTER / Option for alignment of conditional expression
160
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_conditional_expression"
161
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
162
	 *     - default:           createAlignmentValue(false, WRAP_ONE_PER_LINE, INDENT_DEFAULT)
163
	 * </pre>
164
	 * @see #createAlignmentValue(boolean, int, int)
165
	 */
166
	public static final String FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_conditional_expression";	 //$NON-NLS-1$
167
	/**
168
	 * <pre>
169
	 * FORMATTER / Option for alignment of enum constants
170
	 *     - option id:        "org.eclipse.cdt.core.formatter.alignment_for_enum_constants"
171
	 *     - possible values:  values returned by <code>createAlignmentValue(boolean, int, int)</code> call
172
	 *     - default:          createAlignmentValue(false, WRAP_NO_SPLIT, INDENT_DEFAULT)
173
	 * </pre>
174
	 * @see #createAlignmentValue(boolean, int, int)
175
	 */
176
	public static final String FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_enum_constants";	 //$NON-NLS-1$
177
	/**
178
	 * <pre>
179
	 * FORMATTER / Option for alignment of expressions in array initializer
180
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer"
181
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
182
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
183
	 * </pre>
184
	 * @see #createAlignmentValue(boolean, int, int)
185
	 */
186
	public static final String FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_expressions_in_array_initializer";	 //$NON-NLS-1$
187
	/**
188
	 * <pre>
189
	 * FORMATTER / Option for alignment of multiple fields
190
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_multiple_fields"
191
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
192
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
193
	 * </pre>
194
	 * @see #createAlignmentValue(boolean, int, int)
195
	 */
196
	public static final String FORMATTER_ALIGNMENT_FOR_MULTIPLE_FIELDS = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_multiple_fields";//$NON-NLS-1$	
197
	/**
198
	 * <pre>
199
	 * FORMATTER / Option for alignment of parameters in constructor declaration
200
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_parameters_in_constructor_declaration"
201
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
202
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
203
	 * </pre>
204
	 * @see #createAlignmentValue(boolean, int, int)
205
	 */
206
	public static final String FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_parameters_in_constructor_declaration";	 //$NON-NLS-1$
207
	/**
208
	 * <pre>
209
	 * FORMATTER / Option for alignment of parameters in method declaration
210
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration"
211
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
212
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
213
	 * </pre>
214
	 * @see #createAlignmentValue(boolean, int, int)
215
	 */
216
	public static final String FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_parameters_in_method_declaration";	 //$NON-NLS-1$
217
	/**
218
	 * <pre>
219
	 * FORMATTER / Option for alignment of selector in method invocation
220
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_selector_in_method_invocation"
221
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
222
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
223
	 * </pre>
224
	 * @see #createAlignmentValue(boolean, int, int)
225
	 */
226
	public static final String FORMATTER_ALIGNMENT_FOR_SELECTOR_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_selector_in_method_invocation";	 //$NON-NLS-1$
227
	/**
228
	 * <pre>
229
	 * FORMATTER / Option for alignment of superclass in type declaration
230
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_superclass_in_type_declaration"
231
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
232
	 *     - default:           createAlignmentValue(false, WRAP_NEXT_SHIFTED, INDENT_DEFAULT)
233
	 * </pre>
234
	 * @see #createAlignmentValue(boolean, int, int)
235
	 */
236
	public static final String FORMATTER_ALIGNMENT_FOR_SUPERCLASS_IN_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_superclass_in_type_declaration";	 //$NON-NLS-1$
237
	/**
238
	 * <pre>
239
	 * FORMATTER / Option for alignment of superinterfaces in enum declaration
240
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration"
241
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
242
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
243
	 * </pre>
244
	 * @see #createAlignmentValue(boolean, int, int)
245
	 */
246
	public static final String FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_ENUM_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_superinterfaces_in_enum_declaration";	 //$NON-NLS-1$
247
	/**
248
	 * <pre>
249
	 * FORMATTER / Option for alignment of superinterfaces in type declaration
250
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_superinterfaces_in_type_declaration"
251
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
252
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
253
	 * </pre>
254
	 * @see #createAlignmentValue(boolean, int, int)
255
	 */
256
	public static final String FORMATTER_ALIGNMENT_FOR_SUPERINTERFACES_IN_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_superinterfaces_in_type_declaration";	 //$NON-NLS-1$
257
	/**
258
	 * <pre>
259
	 * FORMATTER / Option for alignment of throws clause in constructor declaration
260
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration"
261
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
262
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
263
	 * </pre>
264
	 * @see #createAlignmentValue(boolean, int, int)
265
	 */
266
	public static final String FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_throws_clause_in_constructor_declaration";	 //$NON-NLS-1$
267
	/**
268
	 * <pre>
269
	 * FORMATTER / Option for alignment of throws clause in method declaration
270
	 *     - option id:         "org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration"
271
	 *     - possible values:   values returned by <code>createAlignmentValue(boolean, int, int)</code> call
272
	 *     - default:           createAlignmentValue(false, WRAP_COMPACT, INDENT_DEFAULT)
273
	 * </pre>
274
	 * @see #createAlignmentValue(boolean, int, int)
275
	 */
276
	public static final String FORMATTER_ALIGNMENT_FOR_THROWS_CLAUSE_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.alignment_for_throws_clause_in_method_declaration";	 //$NON-NLS-1$
277
278
//	/**
279
//	 * <pre>
280
//	 * FORMATTER / Option to add blank lines after the imports declaration
281
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_after_imports"
282
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
283
//	 *     - default:           "0"
284
//	 * </pre>
285
//	 */
286
//	public static final String FORMATTER_BLANK_LINES_AFTER_IMPORTS = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_after_imports";	//$NON-NLS-1$
287
//	/**
288
//	 * <pre>
289
//	 * FORMATTER / Option to add blank lines after the package declaration
290
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_after_package"
291
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
292
//	 *     - default:           "0"
293
//	 * </pre>
294
//	 */
295
//	public static final String FORMATTER_BLANK_LINES_AFTER_PACKAGE = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_after_package";	//$NON-NLS-1$
296
//	/**
297
//	 * <pre>
298
//	 * FORMATTER / Option to add blank lines at the beginning of the method body
299
//	 *     - option id:         "org.eclipse.cdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body"
300
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
301
//	 *     - default:           "0"
302
//	 * </pre>
303
//	 */
304
//	public static final String FORMATTER_BLANK_LINES_AT_BEGINNING_OF_METHOD_BODY = CCorePlugin.PLUGIN_ID + ".formatter.number_of_blank_lines_at_beginning_of_method_body"; //$NON-NLS-1$
305
//	/**
306
//	 * <pre>
307
//	 * FORMATTER / Option to add blank lines before a field declaration
308
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_field"
309
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
310
//	 *     - default:           "0"
311
//	 * </pre>
312
//	 */
313
//	public static final String FORMATTER_BLANK_LINES_BEFORE_FIELD = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_field";	//$NON-NLS-1$
314
//	/**
315
//	 * <pre>
316
//	 * FORMATTER / Option to add blank lines before the first class body declaration
317
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_first_class_body_declaration"
318
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
319
//	 *     - default:           "0"
320
//	 * </pre>
321
//	 */
322
//	public static final String FORMATTER_BLANK_LINES_BEFORE_FIRST_CLASS_BODY_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_first_class_body_declaration";	//$NON-NLS-1$
323
//	/**
324
//	 * <pre>
325
//	 * FORMATTER / Option to add blank lines before the imports declaration
326
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_imports"
327
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
328
//	 *     - default:           "0"
329
//	 * </pre>
330
//	 */
331
//	public static final String FORMATTER_BLANK_LINES_BEFORE_IMPORTS = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_imports";	//$NON-NLS-1$
332
//	/**
333
//	 * <pre>
334
//	 * FORMATTER / Option to add blank lines before a member type declaration
335
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_member_type"
336
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
337
//	 *     - default:           "0"
338
//	 * </pre>
339
//	 */
340
//	public static final String FORMATTER_BLANK_LINES_BEFORE_MEMBER_TYPE = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_member_type";	//$NON-NLS-1$
341
//	/**
342
//	 * <pre>
343
//	 * FORMATTER / Option to add blank lines before a method declaration
344
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_method"
345
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
346
//	 *     - default:           "0"
347
//	 * </pre>
348
//	 */
349
//	public static final String FORMATTER_BLANK_LINES_BEFORE_METHOD = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_method";	//$NON-NLS-1$
350
//	/**
351
//	 * <pre>
352
//	 * FORMATTER / Option to add blank lines before a new chunk
353
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_new_chunk"
354
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
355
//	 *     - default:           "0"
356
//	 * </pre>
357
//	 */
358
//	public static final String FORMATTER_BLANK_LINES_BEFORE_NEW_CHUNK = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_new_chunk";	//$NON-NLS-1$
359
//	/**
360
//	 * <pre>
361
//	 * FORMATTER / Option to add blank lines before the package declaration
362
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_before_package"
363
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
364
//	 *     - default:           "0"
365
//	 * </pre>
366
//	 */
367
//	public static final String FORMATTER_BLANK_LINES_BEFORE_PACKAGE = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_before_package";	//$NON-NLS-1$
368
//	/**
369
//	 * <pre>
370
//	 * FORMATTER / Option to add blank lines between type declarations
371
//	 *     - option id:         "org.eclipse.cdt.core.formatter.blank_lines_between_type_declarations"
372
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
373
//	 *     - default:           "0"
374
//	 * </pre>
375
//	 */
376
//	public static final String FORMATTER_BLANK_LINES_BETWEEN_TYPE_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.blank_lines_between_type_declarations";	//$NON-NLS-1$
377
378
	/**
379
	 * <pre>
380
	 * FORMATTER / Option to position the braces of an annotation type declaration
381
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_annotation_type_declaration"
382
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
383
	 *     - default:           END_OF_LINE
384
	 * </pre>
385
	 * @see #END_OF_LINE
386
	 * @see #NEXT_LINE
387
	 * @see #NEXT_LINE_SHIFTED
388
	 * @see #NEXT_LINE_ON_WRAP
389
	 */
390
	public static final String FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_array_initializer";	//$NON-NLS-1$
391
	/**
392
	 * <pre>
393
	 * FORMATTER / Option to position the braces of a block
394
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_block"
395
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
396
	 *     - default:           END_OF_LINE
397
	 * </pre>
398
	 * @see #END_OF_LINE
399
	 * @see #NEXT_LINE
400
	 * @see #NEXT_LINE_SHIFTED
401
	 * @see #NEXT_LINE_ON_WRAP
402
	 */
403
	public static final String FORMATTER_BRACE_POSITION_FOR_BLOCK = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_block";	//$NON-NLS-1$
404
	/**
405
	 * <pre>
406
	 * FORMATTER / Option to position the braces of a block in a case statement when the block is the first statement following
407
	 *             the case
408
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_block_in_case"
409
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
410
	 *     - default:           END_OF_LINE
411
	 * </pre>
412
	 * @see #END_OF_LINE
413
	 * @see #NEXT_LINE
414
	 * @see #NEXT_LINE_SHIFTED
415
	 * @see #NEXT_LINE_ON_WRAP
416
	 */
417
	public static final String FORMATTER_BRACE_POSITION_FOR_BLOCK_IN_CASE = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_block_in_case";	//$NON-NLS-1$
418
	/**
419
	 * <pre>
420
	 * FORMATTER / Option to position the braces of a constructor declaration
421
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_constructor_declaration"
422
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
423
	 *     - default:           END_OF_LINE
424
	 * </pre>
425
	 * @see #END_OF_LINE
426
	 * @see #NEXT_LINE
427
	 * @see #NEXT_LINE_SHIFTED
428
	 * @see #NEXT_LINE_ON_WRAP
429
	 */
430
	public static final String FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_constructor_declaration";	//$NON-NLS-1$
431
	/**
432
	 * <pre>
433
	 * FORMATTER / Option to position the braces of an enum constant
434
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_enum_constant"
435
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
436
	 *     - default:           END_OF_LINE
437
	 * </pre>
438
	 * @see #END_OF_LINE
439
	 * @see #NEXT_LINE
440
	 * @see #NEXT_LINE_SHIFTED
441
	 * @see #NEXT_LINE_ON_WRAP
442
	 */
443
	public static final String FORMATTER_BRACE_POSITION_FOR_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_enum_constant";	//$NON-NLS-1$
444
	/**
445
	 * <pre>
446
	 * FORMATTER / Option to position the braces of an enum declaration
447
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_enum_declaration"
448
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
449
	 *     - default:           END_OF_LINE
450
	 * </pre>
451
	 * @see #END_OF_LINE
452
	 * @see #NEXT_LINE
453
	 * @see #NEXT_LINE_SHIFTED
454
	 * @see #NEXT_LINE_ON_WRAP
455
	 */
456
	public static final String FORMATTER_BRACE_POSITION_FOR_ENUM_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_enum_declaration";	//$NON-NLS-1$
457
	/**
458
	 * <pre>
459
	 * FORMATTER / Option to position the braces of a method declaration
460
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_method_declaration"
461
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
462
	 *     - default:           END_OF_LINE
463
	 * </pre>
464
	 * @see #END_OF_LINE
465
	 * @see #NEXT_LINE
466
	 * @see #NEXT_LINE_SHIFTED
467
	 * @see #NEXT_LINE_ON_WRAP
468
	 */
469
	public static final String FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_method_declaration";	//$NON-NLS-1$
470
	/**
471
	 * <pre>
472
	 * FORMATTER / Option to position the braces of a switch statement
473
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_switch"
474
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
475
	 *     - default:           END_OF_LINE
476
	 * </pre>
477
	 * @see #END_OF_LINE
478
	 * @see #NEXT_LINE
479
	 * @see #NEXT_LINE_SHIFTED
480
	 * @see #NEXT_LINE_ON_WRAP
481
	 */
482
	public static final String FORMATTER_BRACE_POSITION_FOR_SWITCH = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_switch";	//$NON-NLS-1$
483
	/**
484
	 * <pre>
485
	 * FORMATTER / Option to position the braces of a type declaration
486
	 *     - option id:         "org.eclipse.cdt.core.formatter.brace_position_for_type_declaration"
487
	 *     - possible values:   { END_OF_LINE, NEXT_LINE, NEXT_LINE_SHIFTED, NEXT_LINE_ON_WRAP }
488
	 *     - default:           END_OF_LINE
489
	 * </pre>
490
	 * @see #END_OF_LINE
491
	 * @see #NEXT_LINE
492
	 * @see #NEXT_LINE_SHIFTED
493
	 * @see #NEXT_LINE_ON_WRAP
494
	 */
495
	public static final String FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.brace_position_for_type_declaration";	//$NON-NLS-1$
496
497
	/**
498
	 * <pre>
499
	 * FORMATTER / Option to control whether blank lines are cleared inside comments
500
	 *     - option id:         "org.eclipse.cdt.core.formatter.comment.clear_blank_lines"
501
	 *     - possible values:   { TRUE, FALSE }
502
	 *     - default:           FALSE
503
	 * </pre>
504
	 * @see #TRUE
505
	 * @see #FALSE
506
	 */	
507
	public final static String FORMATTER_COMMENT_CLEAR_BLANK_LINES = CCorePlugin.PLUGIN_ID + ".formatter.comment.clear_blank_lines"; //$NON-NLS-1$
508
	
509
	/**
510
	 * <pre>
511
	 * FORMATTER / Option to control whether comments are formatted
512
	 *     - option id:         "org.eclipse.cdt.core.formatter.comment.format_comments"
513
	 *     - possible values:   { TRUE, FALSE }
514
	 *     - default:           TRUE
515
	 * </pre>
516
	 * @see #TRUE
517
	 * @see #FALSE
518
	 */	
519
	public final static String FORMATTER_COMMENT_FORMAT = CCorePlugin.PLUGIN_ID + ".formatter.comment.format_comments"; //$NON-NLS-1$
520
521
	/**
522
	 * <pre>
523
	 * FORMATTER / Option to control whether the header comment of a C/C++ source file is formatted
524
	 *     - option id:         "org.eclipse.cdt.core.formatter.comment.format_header"
525
	 *     - possible values:   { TRUE, FALSE }
526
	 *     - default:           FALSE
527
	 * </pre>
528
	 * @see #TRUE
529
	 * @see #FALSE
530
	 */	
531
	public final static String FORMATTER_COMMENT_FORMAT_HEADER = CCorePlugin.PLUGIN_ID + ".formatter.comment.format_header"; //$NON-NLS-1$
532
533
	/**
534
	 * <pre>
535
	 * FORMATTER / Option to control whether code snippets are formatted in comments
536
	 *     - option id:         "org.eclipse.cdt.core.formatter.comment.format_source_code"
537
	 *     - possible values:   { TRUE, FALSE }
538
	 *     - default:           TRUE
539
	 * </pre>
540
	 * @see #TRUE
541
	 * @see #FALSE
542
	 */	
543
	public final static String FORMATTER_COMMENT_FORMAT_SOURCE = CCorePlugin.PLUGIN_ID + ".formatter.comment.format_source_code"; //$NON-NLS-1$
544
	
545
	/**
546
	 * <pre>
547
	 * FORMATTER / Option to specify the line length for comments.
548
	 *     - option id:         "org.eclipse.cdt.core.formatter.comment.line_length"
549
	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
550
	 *     - default:           "80"
551
	 * </pre>
552
	 */	
553
	public final static String FORMATTER_COMMENT_LINE_LENGTH = CCorePlugin.PLUGIN_ID + ".formatter.comment.line_length"; //$NON-NLS-1$
554
555
//	/**
556
//	 * <pre>
557
//	 * FORMATTER / Option to compact else/if
558
//	 *     - option id:         "org.eclipse.cdt.core.formatter.compact_else_if"
559
//	 *     - possible values:   { TRUE, FALSE }
560
//	 *     - default:           TRUE
561
//	 * </pre>
562
//	 * @see #TRUE
563
//	 * @see #FALSE
564
//	 */
565
//	public static final String FORMATTER_COMPACT_ELSE_IF = CCorePlugin.PLUGIN_ID + ".formatter.compact_else_if";	//$NON-NLS-1$
566
567
	/**
568
	 * <pre>
569
	 * FORMATTER / Option to set the continuation indentation
570
	 *     - option id:         "org.eclipse.cdt.core.formatter.continuation_indentation"
571
	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
572
	 *     - default:           "2"
573
	 * </pre>
574
	 */
575
	public static final String FORMATTER_CONTINUATION_INDENTATION = CCorePlugin.PLUGIN_ID + ".formatter.continuation_indentation";	//$NON-NLS-1$
576
	/**
577
	 * <pre>
578
	 * FORMATTER / Option to set the continuation indentation inside array initializer
579
	 *     - option id:         "org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer"
580
	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
581
	 *     - default:           "2"
582
	 * </pre>
583
	 */
584
	public static final String FORMATTER_CONTINUATION_INDENTATION_FOR_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.continuation_indentation_for_array_initializer";	//$NON-NLS-1$
585
	/**
586
	 * <pre>
587
	 * FORMATTER / Option to indent body declarations compare to its enclosing annotation declaration header
588
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header"
589
	 *     - possible values:   { TRUE, FALSE }
590
	 *     - default:           TRUE
591
	 * </pre>
592
	 * @see #TRUE
593
	 * @see #FALSE
594
	 */
595
	public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ANNOTATION_DECLARATION_HEADER = CCorePlugin.PLUGIN_ID + ".formatter.indent_body_declarations_compare_to_annotation_declaration_header";	//$NON-NLS-1$
596
	/**
597
	 * <pre>
598
	 * FORMATTER / Option to indent body declarations compare to its enclosing enum constant header
599
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header"
600
	 *     - possible values:   { TRUE, FALSE }
601
	 *     - default:           TRUE
602
	 * </pre>
603
	 * @see #TRUE
604
	 * @see #FALSE
605
	 */
606
	public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER = CCorePlugin.PLUGIN_ID + ".formatter.indent_body_declarations_compare_to_enum_constant_header";	//$NON-NLS-1$
607
	/**
608
	 * <pre>
609
	 * FORMATTER / Option to indent body declarations compare to its enclosing enum declaration header
610
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header"
611
	 *     - possible values:   { TRUE, FALSE }
612
	 *     - default:           TRUE
613
	 * </pre>
614
	 * @see #TRUE
615
	 * @see #FALSE
616
	 */
617
	public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER = CCorePlugin.PLUGIN_ID + ".formatter.indent_body_declarations_compare_to_enum_declaration_header";	//$NON-NLS-1$
618
  /**
619
   * <pre>
620
   * FORMATTER / Option to indent body declarations compare to its enclosing type header
621
   *     - option id:         "org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header"
622
   *     - possible values:   { TRUE, FALSE }
623
   *     - default:           FALSE
624
   * </pre>
625
   * @see #TRUE
626
   * @see #FALSE
627
   */
628
  public static final String FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER = CCorePlugin.PLUGIN_ID + ".formatter.indent_access_specifier_compare_to_type_header";  //$NON-NLS-1$
629
	/**
630
	 * <pre>
631
	 * FORMATTER / Option to indent body declarations compare to its enclosing type header
632
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier"
633
	 *     - possible values:   { TRUE, FALSE }
634
	 *     - default:           TRUE
635
	 * </pre>
636
	 * @see #TRUE
637
	 * @see #FALSE
638
	 */
639
	public static final String FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER = CCorePlugin.PLUGIN_ID + ".formatter.indent_body_declarations_compare_to_access_specifier";	//$NON-NLS-1$
640
	/**
641
	 * <pre>
642
	 * FORMATTER / Option to indent breaks compare to cases
643
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases"
644
	 *     - possible values:   { TRUE, FALSE }
645
	 *     - default:           TRUE
646
	 * </pre>
647
	 * @see #TRUE
648
	 * @see #FALSE
649
	 */
650
	public static final String FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES = CCorePlugin.PLUGIN_ID + ".formatter.indent_breaks_compare_to_cases";	//$NON-NLS-1$
651
	/**
652
	 * <pre>
653
	 * FORMATTER / Option to indent empty lines
654
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_empty_lines"
655
	 *     - possible values:   { TRUE, FALSE }
656
	 *     - default:           FALSE
657
	 * </pre>
658
	 * @see #TRUE
659
	 * @see #FALSE
660
	 */
661
	public static final String FORMATTER_INDENT_EMPTY_LINES = CCorePlugin.PLUGIN_ID + ".formatter.indent_empty_lines"; //$NON-NLS-1$	
662
	/**
663
	 * <pre>
664
	 * FORMATTER / Option to indent statements inside a block
665
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_statements_compare_to_block"
666
	 *     - possible values:   { TRUE, FALSE }
667
	 *     - default:           TRUE
668
	 * </pre>
669
	 * @see #TRUE
670
	 * @see #FALSE
671
	 */
672
	public static final String FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK = CCorePlugin.PLUGIN_ID + ".formatter.indent_statements_compare_to_block"; //$NON-NLS-1$
673
	/**
674
	 * <pre>
675
	 * FORMATTER / Option to indent statements inside the body of a method or a constructor
676
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_statements_compare_to_body"
677
	 *     - possible values:   { TRUE, FALSE }
678
	 *     - default:           TRUE
679
	 * </pre>
680
	 * @see #TRUE
681
	 * @see #FALSE
682
	 */
683
	public static final String FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY = CCorePlugin.PLUGIN_ID + ".formatter.indent_statements_compare_to_body"; //$NON-NLS-1$
684
	/**
685
	 * <pre>
686
	 * FORMATTER / Option to indent switch statements compare to cases
687
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases"
688
	 *     - possible values:   { TRUE, FALSE }
689
	 *     - default:           TRUE
690
	 * </pre>
691
	 * @see #TRUE
692
	 * @see #FALSE
693
	 */
694
	public static final String FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES = CCorePlugin.PLUGIN_ID + ".formatter.indent_switchstatements_compare_to_cases";	//$NON-NLS-1$
695
	/**
696
	 * <pre>
697
	 * FORMATTER / Option to indent switch statements compare to switch
698
	 *     - option id:         "org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch"
699
	 *     - possible values:   { TRUE, FALSE }
700
	 *     - default:           TRUE
701
	 * </pre>
702
	 * @see #TRUE
703
	 * @see #FALSE
704
	 */
705
	public static final String FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH = CCorePlugin.PLUGIN_ID + ".formatter.indent_switchstatements_compare_to_switch";	//$NON-NLS-1$
706
707
	/**
708
	 * <pre>
709
	 * FORMATTER / Option to specify the equivalent number of spaces that represents one indentation 
710
	 *     - option id:         "org.eclipse.cdt.core.formatter.indentation.size"
711
	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
712
	 *     - default:           "4"
713
	 * </pre>
714
	 * <p>This option is used only if the tab char is set to MIXED.
715
	 * </p>
716
	 * @see #FORMATTER_TAB_CHAR
717
	 */
718
	public static final String FORMATTER_INDENTATION_SIZE = CCorePlugin.PLUGIN_ID + ".formatter.indentation.size"; //$NON-NLS-1$
719
720
//	/**
721
//	 * <pre>
722
//	 * FORMATTER / Option to insert a new line after an annotation
723
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_after_annotation"
724
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
725
//	 *     - default:           INSERT
726
//	 * </pre>
727
//	 * @see CCorePlugin#INSERT
728
//	 * @see CCorePlugin#DO_NOT_INSERT
729
//	 */
730
//	public static final String FORMATTER_INSERT_NEW_LINE_AFTER_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_after_annotation";//$NON-NLS-1$
731
//
732
//	/**
733
//	 * <pre>
734
//	 * FORMATTER / Option to insert a new line after the opening brace in an array initializer
735
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer"
736
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
737
//	 *     - default:           DO_NOT_INSERT
738
//	 * </pre>
739
//	 * @see CCorePlugin#INSERT
740
//	 * @see CCorePlugin#DO_NOT_INSERT
741
//	 */
742
//	public static final String FORMATTER_INSERT_NEW_LINE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_after_opening_brace_in_array_initializer";//$NON-NLS-1$
743
//
744
//	/**
745
//	 * <pre>
746
//	 * FORMATTER / Option to insert a new line at the end of the current file if missing
747
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing"
748
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
749
//	 *     - default:           DO_NOT_INSERT
750
//	 * </pre>
751
//	 * @see CCorePlugin#INSERT
752
//	 * @see CCorePlugin#DO_NOT_INSERT
753
//	 */
754
//	public static final String FORMATTER_INSERT_NEW_LINE_AT_END_OF_FILE_IF_MISSING = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_at_end_of_file_if_missing";//$NON-NLS-1$
755
//	/**
756
//	 * <pre>
757
//	 * FORMATTER / Option to insert a new line before the catch keyword in try statement
758
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement"
759
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
760
//	 *     - default:           DO_NOT_INSERT
761
//	 * </pre>
762
//	 * @see CCorePlugin#INSERT
763
//	 * @see CCorePlugin#DO_NOT_INSERT
764
//	 */
765
//	public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_CATCH_IN_TRY_STATEMENT = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_before_catch_in_try_statement";	//$NON-NLS-1$
766
//	/**
767
//	 * <pre>
768
//	 * FORMATTER / Option to insert a new line before the closing brace in an array initializer
769
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer"
770
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
771
//	 *     - default:           DO_NOT_INSERT
772
//	 * </pre>
773
//	 * @see CCorePlugin#INSERT
774
//	 * @see CCorePlugin#DO_NOT_INSERT
775
//	 */
776
//	public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_before_closing_brace_in_array_initializer";//$NON-NLS-1$
777
//	/**
778
//	 * <pre>
779
//	 * FORMATTER / Option to insert a new line before the else keyword in if statement
780
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement"
781
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
782
//	 *     - default:           DO_NOT_INSERT
783
//	 * </pre>
784
//	 * @see CCorePlugin#INSERT
785
//	 * @see CCorePlugin#DO_NOT_INSERT
786
//	 */
787
//	public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_ELSE_IN_IF_STATEMENT = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_before_else_in_if_statement";	//$NON-NLS-1$
788
//	/**
789
//	 * <pre>
790
//	 * FORMATTER / Option to insert a new line before the finally keyword in try statement
791
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_before_finally_in_try_statement"
792
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
793
//	 *     - default:           DO_NOT_INSERT
794
//	 * </pre>
795
//	 * @see CCorePlugin#INSERT
796
//	 * @see CCorePlugin#DO_NOT_INSERT
797
//	 */
798
//	public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_FINALLY_IN_TRY_STATEMENT = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_before_finally_in_try_statement";	//$NON-NLS-1$
799
//	/**
800
//	 * <pre>
801
//	 * FORMATTER / Option to insert a new line before while in do statement
802
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement"
803
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
804
//	 *     - default:           DO_NOT_INSERT
805
//	 * </pre>
806
//	 * @see CCorePlugin#INSERT
807
//	 * @see CCorePlugin#DO_NOT_INSERT
808
//	 */
809
//	public static final String FORMATTER_INSERT_NEW_LINE_BEFORE_WHILE_IN_DO_STATEMENT = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_before_while_in_do_statement";	//$NON-NLS-1$
810
//	/**
811
//	 * <pre>
812
//	 * FORMATTER / Option to insert a new line in an empty annotation declaration
813
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_annotation_declaration"
814
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
815
//	 *     - default:           INSERT
816
//	 * </pre>
817
//	 * @see CCorePlugin#INSERT
818
//	 * @see CCorePlugin#DO_NOT_INSERT
819
//	 */
820
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANNOTATION_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_annotation_declaration";	//$NON-NLS-1$
821
//	/**
822
//	 * <pre>
823
//	 * FORMATTER / Option to insert a new line in an empty anonymous type declaration
824
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration"
825
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
826
//	 *     - default:           INSERT
827
//	 * </pre>
828
//	 * @see CCorePlugin#INSERT
829
//	 * @see CCorePlugin#DO_NOT_INSERT
830
//	 */
831
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ANONYMOUS_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_anonymous_type_declaration";	//$NON-NLS-1$
832
//	/**
833
//	 * <pre>
834
//	 * FORMATTER / Option to insert a new line in an empty block
835
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block"
836
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
837
//	 *     - default:           INSERT
838
//	 * </pre>
839
//	 * @see CCorePlugin#INSERT
840
//	 * @see CCorePlugin#DO_NOT_INSERT
841
//	 */
842
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_BLOCK = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_block";	//$NON-NLS-1$
843
//	/**
844
//	 * <pre>
845
//	 * FORMATTER / Option to insert a new line in an empty enum constant
846
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_enum_constant"
847
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
848
//	 *     - default:           INSERT
849
//	 * </pre>
850
//	 * @see CCorePlugin#INSERT
851
//	 * @see CCorePlugin#DO_NOT_INSERT
852
//	 */
853
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_enum_constant";	//$NON-NLS-1$
854
//	/**
855
//	 * <pre>
856
//	 * FORMATTER / Option to insert a new line in an empty enum declaration
857
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_enum_declaration"
858
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
859
//	 *     - default:           INSERT
860
//	 * </pre>
861
//	 * @see CCorePlugin#INSERT
862
//	 * @see CCorePlugin#DO_NOT_INSERT
863
//	 */
864
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_ENUM_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_enum_declaration";	//$NON-NLS-1$
865
//	/**
866
//	 * <pre>
867
//	 * FORMATTER / Option to insert a new line in an empty method body
868
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_method_body"
869
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
870
//	 *     - default:           INSERT
871
//	 * </pre>
872
//	 * @see CCorePlugin#INSERT
873
//	 * @see CCorePlugin#DO_NOT_INSERT
874
//	 */
875
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_METHOD_BODY = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_method_body";	//$NON-NLS-1$
876
//	/**
877
//	 * <pre>
878
//	 * FORMATTER / Option to insert a new line in an empty type declaration
879
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_new_line_in_empty_type_declaration"
880
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
881
//	 *     - default:           INSERT
882
//	 * </pre>
883
//	 * @see CCorePlugin#INSERT
884
//	 * @see CCorePlugin#DO_NOT_INSERT
885
//	 */
886
//	public static final String FORMATTER_INSERT_NEW_LINE_IN_EMPTY_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_new_line_in_empty_type_declaration";	//$NON-NLS-1$
887
//	/**
888
//	 * <pre>
889
//	 * FORMATTER / Option to insert a space after and in wilcard
890
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_and_in_type_parameter"
891
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
892
//	 *     - default:           INSERT
893
//	 * </pre>
894
//	 * @see CCorePlugin#INSERT
895
//	 * @see CCorePlugin#DO_NOT_INSERT
896
//	 */
897
//	public static final String FORMATTER_INSERT_SPACE_AFTER_AND_IN_TYPE_PARAMETER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_and_in_type_parameter"; //$NON-NLS-1$
898
//	/**
899
//	 * <pre>
900
//	 * FORMATTER / Option to insert a space after an assignment operator
901
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator"
902
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
903
//	 *     - default:           INSERT
904
//	 * </pre>
905
//	 * @see CCorePlugin#INSERT
906
//	 * @see CCorePlugin#DO_NOT_INSERT
907
//	 */
908
//	public static final String FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_assignment_operator"; //$NON-NLS-1$
909
//	/**
910
//	 * <pre>
911
//	 * FORMATTER / Option to insert a space after at in annotation
912
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_at_in_annotation"
913
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
914
//	 *     - default:           INSERT
915
//	 * </pre>
916
//	 * @see CCorePlugin#INSERT
917
//	 * @see CCorePlugin#DO_NOT_INSERT
918
//	 */
919
//	public static final String FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_at_in_annotation"; //$NON-NLS-1$
920
//	/**
921
//	 * <pre>
922
//	 * FORMATTER / Option to insert a space after at in annotation type declaration
923
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_at_in_annotation_type_declaration"
924
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
925
//	 *     - default:           DO_NOT_INSERT
926
//	 * </pre>
927
//	 * @see CCorePlugin#INSERT
928
//	 * @see CCorePlugin#DO_NOT_INSERT
929
//	 */
930
//	public static final String FORMATTER_INSERT_SPACE_AFTER_AT_IN_ANNOTATION_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_at_in_annotation_type_declaration"; //$NON-NLS-1$
931
//	/**
932
//	 * <pre>
933
//	 * FORMATTER / Option to insert a space after a binary operator
934
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_binary_operator"
935
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
936
//	 *     - default:           INSERT
937
//	 * </pre>
938
//	 * @see CCorePlugin#INSERT
939
//	 * @see CCorePlugin#DO_NOT_INSERT
940
//	 */
941
//	public static final String FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_binary_operator"; //$NON-NLS-1$
942
//	/**
943
//	 * <pre>
944
//	 * FORMATTER / Option to insert a space after the closing angle bracket in type arguments
945
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments"
946
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
947
//	 *     - default:           INSERT
948
//	 * </pre>
949
//	 * @see CCorePlugin#INSERT
950
//	 * @see CCorePlugin#DO_NOT_INSERT
951
//	 */
952
//	public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_closing_angle_bracket_in_type_arguments"; //$NON-NLS-1$
953
//	/**
954
//	 * <pre>
955
//	 * FORMATTER / Option to insert a space after the closing angle bracket in type parameters
956
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters"
957
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
958
//	 *     - default:           INSERT
959
//	 * </pre>
960
//	 * @see CCorePlugin#INSERT
961
//	 * @see CCorePlugin#DO_NOT_INSERT
962
//	 */
963
//	public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_closing_angle_bracket_in_type_parameters"; //$NON-NLS-1$
964
//	/**
965
//	 * <pre>
966
//	 * FORMATTER / Option to insert a space after the closing brace of a block
967
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block"
968
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
969
//	 *     - default:           INSERT
970
//	 * </pre>
971
//	 * @see CCorePlugin#INSERT
972
//	 * @see CCorePlugin#DO_NOT_INSERT
973
//	 */
974
//	public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_closing_brace_in_block"; //$NON-NLS-1$
975
//	/**
976
//	 * <pre>
977
//	 * FORMATTER / Option to insert a space after the closing parenthesis of a cast expression
978
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast"
979
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
980
//	 *     - default:           INSERT
981
//	 * </pre>
982
//	 * @see CCorePlugin#INSERT
983
//	 * @see CCorePlugin#DO_NOT_INSERT
984
//	 */
985
//	public static final String FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_closing_paren_in_cast"; //$NON-NLS-1$
986
//	/**
987
//	 * <pre>
988
//	 * FORMATTER / Option to insert a space after the colon in an assert statement
989
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_colon_in_assert"
990
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
991
//	 *     - default:           INSERT
992
//	 * </pre>
993
//	 * @see CCorePlugin#INSERT
994
//	 * @see CCorePlugin#DO_NOT_INSERT
995
//	 */
996
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_colon_in_assert"; //$NON-NLS-1$
997
//	/**
998
//	 * <pre>
999
//	 * FORMATTER / Option to insert a space after colon in a case statement when a opening brace follows the colon
1000
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case"
1001
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1002
//	 *     - default:           INSERT
1003
//	 * </pre>
1004
//	 * @see CCorePlugin#INSERT
1005
//	 * @see CCorePlugin#DO_NOT_INSERT
1006
//	 */
1007
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CASE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_colon_in_case";	//$NON-NLS-1$
1008
//	/**
1009
//	 * <pre>
1010
//	 * FORMATTER / Option to insert a space after the colon in a conditional expression
1011
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional"
1012
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1013
//	 *     - default:           INSERT
1014
//	 * </pre>
1015
//	 * @see CCorePlugin#INSERT
1016
//	 * @see CCorePlugin#DO_NOT_INSERT
1017
//	 */
1018
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_colon_in_conditional"; //$NON-NLS-1$
1019
//	/**
1020
//	 * <pre>
1021
//	 * FORMATTER / Option to insert a space after colon in a for statement
1022
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_colon_in_for"
1023
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1024
//	 *     - default:           INSERT
1025
//	 * </pre>
1026
//	 * @see CCorePlugin#INSERT
1027
//	 * @see CCorePlugin#DO_NOT_INSERT
1028
//	 */
1029
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_colon_in_for";	//$NON-NLS-1$
1030
//	/**
1031
//	 * <pre>
1032
//	 * FORMATTER / Option to insert a space after the colon in a labeled statement
1033
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement"
1034
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1035
//	 *     - default:           INSERT
1036
//	 * </pre>
1037
//	 * @see CCorePlugin#INSERT
1038
//	 * @see CCorePlugin#DO_NOT_INSERT
1039
//	 */
1040
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_colon_in_labeled_statement"; //$NON-NLS-1$
1041
//	/**
1042
//	 * <pre>
1043
//	 * FORMATTER / Option to insert a space after the comma in an allocation expression
1044
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_allocation_expression"
1045
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1046
//	 *     - default:           INSERT
1047
//	 * </pre>
1048
//	 * @see CCorePlugin#INSERT
1049
//	 * @see CCorePlugin#DO_NOT_INSERT
1050
//	 */
1051
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_allocation_expression"; //$NON-NLS-1$
1052
//	/**
1053
//	 * <pre>
1054
//	 * FORMATTER / Option to insert a space after the comma in annotation
1055
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_annotation"
1056
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1057
//	 *     - default:           INSERT
1058
//	 * </pre>
1059
//	 * @see CCorePlugin#INSERT
1060
//	 * @see CCorePlugin#DO_NOT_INSERT
1061
//	 */
1062
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_annotation"; //$NON-NLS-1$
1063
//	/**
1064
//	 * <pre>
1065
//	 * FORMATTER / Option to insert a space after the comma in an array initializer
1066
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer"
1067
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1068
//	 *     - default:           INSERT
1069
//	 * </pre>
1070
//	 * @see CCorePlugin#INSERT
1071
//	 * @see CCorePlugin#DO_NOT_INSERT
1072
//	 */
1073
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_array_initializer"; //$NON-NLS-1$
1074
//	/**
1075
//	 * <pre>
1076
//	 * FORMATTER / Option to insert a space after the comma in the parameters of a constructor declaration
1077
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters"
1078
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1079
//	 *     - default:           INSERT
1080
//	 * </pre>
1081
//	 * @see CCorePlugin#INSERT
1082
//	 * @see CCorePlugin#DO_NOT_INSERT
1083
//	 */
1084
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_constructor_declaration_parameters"; //$NON-NLS-1$
1085
//	/**
1086
//	 * <pre>
1087
//	 * FORMATTER / Option to insert a space after the comma in the exception names in a throws clause of a constructor declaration
1088
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws"
1089
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1090
//	 *     - default:           INSERT
1091
//	 * </pre>
1092
//	 * @see CCorePlugin#INSERT
1093
//	 * @see CCorePlugin#DO_NOT_INSERT
1094
//	 */
1095
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_constructor_declaration_throws"; //$NON-NLS-1$
1096
//	/**
1097
//	 * <pre>
1098
//	 * FORMATTER / Option to insert a space after the comma in the arguments of an enum constant
1099
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments"
1100
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1101
//	 *     - default:           INSERT
1102
//	 * </pre>
1103
//	 * @see CCorePlugin#INSERT
1104
//	 * @see CCorePlugin#DO_NOT_INSERT
1105
//	 */
1106
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_CONSTANT_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_enum_constant_arguments"; //$NON-NLS-1$
1107
//	/**
1108
//	 * <pre>
1109
//	 * FORMATTER / Option to insert a space after the comma in enum declarations
1110
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations"
1111
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1112
//	 *     - default:           INSERT
1113
//	 * </pre>
1114
//	 * @see CCorePlugin#INSERT
1115
//	 * @see CCorePlugin#DO_NOT_INSERT
1116
//	 */
1117
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ENUM_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_enum_declarations"; //$NON-NLS-1$
1118
//	/**
1119
//	 * <pre>
1120
//	 * FORMATTER / Option to insert a space after the comma in the arguments of an explicit constructor call
1121
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments"
1122
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1123
//	 *     - default:           INSERT
1124
//	 * </pre>
1125
//	 * @see CCorePlugin#INSERT
1126
//	 * @see CCorePlugin#DO_NOT_INSERT
1127
//	 */
1128
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_explicitconstructorcall_arguments"; //$NON-NLS-1$
1129
//	/**
1130
//	 * <pre>
1131
//	 * FORMATTER / Option to insert a space after the comma in the increments of a for statement
1132
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_for_increments"
1133
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1134
//	 *     - default:           INSERT
1135
//	 * </pre>
1136
//	 * @see CCorePlugin#INSERT
1137
//	 * @see CCorePlugin#DO_NOT_INSERT
1138
//	 */
1139
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_for_increments"; //$NON-NLS-1$
1140
//	/**
1141
//	 * <pre>
1142
//	 * FORMATTER / Option to insert a space after the comma in the initializations of a for statement
1143
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_for_inits"
1144
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1145
//	 *     - default:           INSERT
1146
//	 * </pre>
1147
//	 * @see CCorePlugin#INSERT
1148
//	 * @see CCorePlugin#DO_NOT_INSERT
1149
//	 */
1150
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_for_inits"; //$NON-NLS-1$
1151
//	/**
1152
//	 * <pre>
1153
//	 * FORMATTER / Option to insert a space after the comma in the parameters of a method declaration
1154
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters"
1155
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1156
//	 *     - default:           INSERT
1157
//	 * </pre>
1158
//	 * @see CCorePlugin#INSERT
1159
//	 * @see CCorePlugin#DO_NOT_INSERT
1160
//	 */
1161
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_declaration_parameters"; //$NON-NLS-1$
1162
//	/**
1163
//	 * <pre>
1164
//	 * FORMATTER / Option to insert a space after the comma in the exception names in a throws clause of a method declaration
1165
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws"
1166
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1167
//	 *     - default:           INSERT
1168
//	 * </pre>
1169
//	 * @see CCorePlugin#INSERT
1170
//	 * @see CCorePlugin#DO_NOT_INSERT
1171
//	 */
1172
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_declaration_throws"; //$NON-NLS-1$
1173
//	/**
1174
//	 * <pre>
1175
//	 * FORMATTER / Option to insert a space after the comma in the arguments of a method invocation
1176
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments"
1177
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1178
//	 *     - default:           INSERT
1179
//	 * </pre>
1180
//	 * @see CCorePlugin#INSERT
1181
//	 * @see CCorePlugin#DO_NOT_INSERT
1182
//	 */
1183
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_method_invocation_arguments"; //$NON-NLS-1$
1184
//	/**
1185
//	 * <pre>
1186
//	 * FORMATTER / Option to insert a space after the comma in multiple field declaration
1187
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations"
1188
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1189
//	 *     - default:           INSERT
1190
//	 * </pre>
1191
//	 * @see CCorePlugin#INSERT
1192
//	 * @see CCorePlugin#DO_NOT_INSERT
1193
//	 */
1194
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_multiple_field_declarations"; //$NON-NLS-1$
1195
//	/**
1196
//	 * <pre>
1197
//	 * FORMATTER / Option to insert a space after the comma in multiple local declaration
1198
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations"
1199
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1200
//	 *     - default:           INSERT
1201
//	 * </pre>
1202
//	 * @see CCorePlugin#INSERT
1203
//	 * @see CCorePlugin#DO_NOT_INSERT
1204
//	 */
1205
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_multiple_local_declarations"; //$NON-NLS-1$
1206
//	/**
1207
//	 * <pre>
1208
//	 * FORMATTER / Option to insert a space after the comma in parameterized type reference
1209
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference"
1210
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1211
//	 *     - default:           INSERT
1212
//	 * </pre>
1213
//	 * @see CCorePlugin#INSERT
1214
//	 * @see CCorePlugin#DO_NOT_INSERT
1215
//	 */
1216
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_parameterized_type_reference"; //$NON-NLS-1$
1217
//	/**
1218
//	 * <pre>
1219
//	 * FORMATTER / Option to insert a space after the comma in superinterfaces names of a type header
1220
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_superinterfaces"
1221
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1222
//	 *     - default:           INSERT
1223
//	 * </pre>
1224
//	 * @see CCorePlugin#INSERT
1225
//	 * @see CCorePlugin#DO_NOT_INSERT
1226
//	 */
1227
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_superinterfaces"; //$NON-NLS-1$
1228
//	/**
1229
//	 * <pre>
1230
//	 * FORMATTER / Option to insert a space after the comma in type arguments
1231
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_type_arguments"
1232
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1233
//	 *     - default:           INSERT
1234
//	 * </pre>
1235
//	 * @see CCorePlugin#INSERT
1236
//	 * @see CCorePlugin#DO_NOT_INSERT
1237
//	 */
1238
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_type_arguments"; //$NON-NLS-1$
1239
//	/**
1240
//	 * <pre>
1241
//	 * FORMATTER / Option to insert a space after the comma in type parameters
1242
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_comma_in_type_parameters"
1243
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1244
//	 *     - default:           INSERT
1245
//	 * </pre>
1246
//	 * @see CCorePlugin#INSERT
1247
//	 * @see CCorePlugin#DO_NOT_INSERT
1248
//	 */
1249
//	public static final String FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TYPE_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_comma_in_type_parameters"; //$NON-NLS-1$
1250
//	/**
1251
//	 * <pre>
1252
//	 * FORMATTER / Option to insert a space after ellipsis
1253
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_ellipsis"
1254
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1255
//	 *     - default:           INSERT
1256
//	 * </pre>
1257
//	 * @see CCorePlugin#INSERT
1258
//	 * @see CCorePlugin#DO_NOT_INSERT
1259
//	 */
1260
//	public static final String FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS  = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_ellipsis";	//$NON-NLS-1$
1261
//	/**
1262
//	 * <pre>
1263
//	 * FORMATTER / Option to insert a space after the opening angle bracket in parameterized type reference
1264
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference"
1265
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1266
//	 *     - default:           DO_NOT_INSERT
1267
//	 * </pre>
1268
//	 * @see CCorePlugin#INSERT
1269
//	 * @see CCorePlugin#DO_NOT_INSERT
1270
//	 */
1271
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference";//$NON-NLS-1$
1272
//	/**
1273
//	 * <pre>
1274
//	 * FORMATTER / Option to insert a space after the opening angle bracket in type arguments
1275
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments"
1276
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1277
//	 *     - default:           DO_NOT_INSERT
1278
//	 * </pre>
1279
//	 * @see CCorePlugin#INSERT
1280
//	 * @see CCorePlugin#DO_NOT_INSERT
1281
//	 */
1282
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_angle_bracket_in_type_arguments";//$NON-NLS-1$
1283
//	/**
1284
//	 * <pre>
1285
//	 * FORMATTER / Option to insert a space after the opening angle bracket in type parameters
1286
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters"
1287
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1288
//	 *     - default:           DO_NOT_INSERT
1289
//	 * </pre>
1290
//	 * @see CCorePlugin#INSERT
1291
//	 * @see CCorePlugin#DO_NOT_INSERT
1292
//	 */
1293
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_angle_bracket_in_type_parameters";//$NON-NLS-1$
1294
//	/**
1295
//	 * <pre>
1296
//	 * FORMATTER / Option to insert a space after the opening brace in an array initializer
1297
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer"
1298
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1299
//	 *     - default:           DO_NOT_INSERT
1300
//	 * </pre>
1301
//	 * @see CCorePlugin#INSERT
1302
//	 * @see CCorePlugin#DO_NOT_INSERT
1303
//	 */
1304
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_brace_in_array_initializer";	//$NON-NLS-1$
1305
//	/**
1306
//	 * <pre>
1307
//	 * FORMATTER / Option to insert a space after the opening bracket inside an array allocation expression
1308
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression"
1309
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1310
//	 *     - default:           DO_NOT_INSERT
1311
//	 * </pre>
1312
//	 * @see CCorePlugin#INSERT
1313
//	 * @see CCorePlugin#DO_NOT_INSERT
1314
//	 */
1315
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_bracket_in_array_allocation_expression";//$NON-NLS-1$
1316
//	/**
1317
//	 * <pre>
1318
//	 * FORMATTER / Option to insert a space after the opening bracket inside an array reference
1319
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket_in_array_reference"
1320
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1321
//	 *     - default:           DO_NOT_INSERT
1322
//	 * </pre>
1323
//	 * @see CCorePlugin#INSERT
1324
//	 * @see CCorePlugin#DO_NOT_INSERT
1325
//	 */
1326
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_bracket_in_array_reference";//$NON-NLS-1$
1327
//	/**
1328
//	 * <pre>
1329
//	 * FORMATTER / Option to insert a space after the opening parenthesis in annotation
1330
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_annotation"
1331
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1332
//	 *     - default:           DO_NOT_INSERT
1333
//	 * </pre>
1334
//	 * @see CCorePlugin#INSERT
1335
//	 * @see CCorePlugin#DO_NOT_INSERT
1336
//	 */
1337
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_annotation"; //$NON-NLS-1$
1338
//	/**
1339
//	 * <pre>
1340
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a cast expression
1341
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast"
1342
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1343
//	 *     - default:           DO_NOT_INSERT
1344
//	 * </pre>
1345
//	 * @see CCorePlugin#INSERT
1346
//	 * @see CCorePlugin#DO_NOT_INSERT
1347
//	 */
1348
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_cast"; //$NON-NLS-1$
1349
//	/**
1350
//	 * <pre>
1351
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a catch
1352
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch"
1353
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1354
//	 *     - default:           DO_NOT_INSERT
1355
//	 * </pre>
1356
//	 * @see CCorePlugin#INSERT
1357
//	 * @see CCorePlugin#DO_NOT_INSERT
1358
//	 */
1359
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_catch"; //$NON-NLS-1$
1360
//	/**
1361
//	 * <pre>
1362
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a constructor declaration
1363
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration"
1364
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1365
//	 *     - default:           DO_NOT_INSERT
1366
//	 * </pre>
1367
//	 * @see CCorePlugin#INSERT
1368
//	 * @see CCorePlugin#DO_NOT_INSERT
1369
//	 */
1370
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_constructor_declaration";	//$NON-NLS-1$
1371
//	/**
1372
//	 * <pre>
1373
//	 * FORMATTER / Option to insert a space after the opening parenthesis in enum constant
1374
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_enum_constant"
1375
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1376
//	 *     - default:           DO_NOT_INSERT
1377
//	 * </pre>
1378
//	 * @see CCorePlugin#INSERT
1379
//	 * @see CCorePlugin#DO_NOT_INSERT
1380
//	 */
1381
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_enum_constant"; //$NON-NLS-1$
1382
//	/**
1383
//	 * <pre>
1384
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a for statement
1385
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for"
1386
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1387
//	 *     - default:           DO_NOT_INSERT
1388
//	 * </pre>
1389
//	 * @see CCorePlugin#INSERT
1390
//	 * @see CCorePlugin#DO_NOT_INSERT
1391
//	 */
1392
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_for"; //$NON-NLS-1$
1393
//	/**
1394
//	 * <pre>
1395
//	 * FORMATTER / Option to insert a space after the opening parenthesis in an if statement
1396
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if"
1397
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1398
//	 *     - default:           DO_NOT_INSERT
1399
//	 * </pre>
1400
//	 * @see CCorePlugin#INSERT
1401
//	 * @see CCorePlugin#DO_NOT_INSERT
1402
//	 */
1403
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_if"; //$NON-NLS-1$
1404
//	/**
1405
//	 * <pre>
1406
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a method declaration
1407
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration"
1408
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1409
//	 *     - default:           DO_NOT_INSERT
1410
//	 * </pre>
1411
//	 * @see CCorePlugin#INSERT
1412
//	 * @see CCorePlugin#DO_NOT_INSERT
1413
//	 */
1414
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_method_declaration";	//$NON-NLS-1$
1415
//	/**
1416
//	 * <pre>
1417
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a method invocation
1418
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation"
1419
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1420
//	 *     - default:           DO_NOT_INSERT
1421
//	 * </pre>
1422
//	 * @see CCorePlugin#INSERT
1423
//	 * @see CCorePlugin#DO_NOT_INSERT
1424
//	 */
1425
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_method_invocation"; //$NON-NLS-1$
1426
//	/**
1427
//	 * <pre>
1428
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a parenthesized expression
1429
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression"
1430
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1431
//	 *     - default:           DO_NOT_INSERT
1432
//	 * </pre>
1433
//	 * @see CCorePlugin#INSERT
1434
//	 * @see CCorePlugin#DO_NOT_INSERT
1435
//	 */
1436
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_parenthesized_expression"; //$NON-NLS-1$
1437
//	/**
1438
//	 * <pre>
1439
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a switch statement
1440
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch"
1441
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1442
//	 *     - default:           DO_NOT_INSERT
1443
//	 * </pre>
1444
//	 * @see CCorePlugin#INSERT
1445
//	 * @see CCorePlugin#DO_NOT_INSERT
1446
//	 */
1447
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_switch"; //$NON-NLS-1$
1448
//	/**
1449
//	 * <pre>
1450
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a synchronized statement
1451
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_synchronized"
1452
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1453
//	 *     - default:           DO_NOT_INSERT
1454
//	 * </pre>
1455
//	 * @see CCorePlugin#INSERT
1456
//	 * @see CCorePlugin#DO_NOT_INSERT
1457
//	 */
1458
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_synchronized"; //$NON-NLS-1$
1459
//	/**
1460
//	 * <pre>
1461
//	 * FORMATTER / Option to insert a space after the opening parenthesis in a while statement
1462
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while"
1463
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1464
//	 *     - default:           DO_NOT_INSERT
1465
//	 * </pre>
1466
//	 * @see CCorePlugin#INSERT
1467
//	 * @see CCorePlugin#DO_NOT_INSERT
1468
//	 */
1469
//	public static final String FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_opening_paren_in_while"; //$NON-NLS-1$
1470
//	/**
1471
//	 * <pre>
1472
//	 * FORMATTER / Option to insert a space after a postfix operator
1473
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator"
1474
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1475
//	 *     - default:           DO_NOT_INSERT
1476
//	 * </pre>
1477
//	 * @see CCorePlugin#INSERT
1478
//	 * @see CCorePlugin#DO_NOT_INSERT
1479
//	 */
1480
//	public static final String FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_postfix_operator"; //$NON-NLS-1$
1481
//	/**
1482
//	 * <pre>
1483
//	 * FORMATTER / Option to insert a space after a prefix operator
1484
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator"
1485
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1486
//	 *     - default:           DO_NOT_INSERT
1487
//	 * </pre>
1488
//	 * @see CCorePlugin#INSERT
1489
//	 * @see CCorePlugin#DO_NOT_INSERT
1490
//	 */
1491
//	public static final String FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_prefix_operator"; //$NON-NLS-1$
1492
//	/**
1493
//	 * <pre>
1494
//	 * FORMATTER / Option to insert a space after question mark in a conditional expression
1495
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional"
1496
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1497
//	 *     - default:           DO_NOT_INSERT
1498
//	 * </pre>
1499
//	 * @see CCorePlugin#INSERT
1500
//	 * @see CCorePlugin#DO_NOT_INSERT
1501
//	 */
1502
//	public static final String FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_question_in_conditional"; //$NON-NLS-1$
1503
//	/**
1504
//	 * <pre>
1505
//	 * FORMATTER / Option to insert a space after question mark in a wildcard
1506
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_question_in_wildcard"
1507
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1508
//	 *     - default:           DO_NOT_INSERT
1509
//	 * </pre>
1510
//	 * @see CCorePlugin#INSERT
1511
//	 * @see CCorePlugin#DO_NOT_INSERT
1512
//	 */
1513
//	public static final String FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_WILDCARD = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_question_in_wildcard"; //$NON-NLS-1$
1514
//	/**
1515
//	 * <pre>
1516
//	 * FORMATTER / Option to insert a space after semicolon in a for statement
1517
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for"
1518
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1519
//	 *     - default:           INSERT
1520
//	 * </pre>
1521
//	 * @see CCorePlugin#INSERT
1522
//	 * @see CCorePlugin#DO_NOT_INSERT
1523
//	 */
1524
//	public static final String FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_semicolon_in_for"; //$NON-NLS-1$
1525
//	/**
1526
//	 * <pre>
1527
//	 * FORMATTER / Option to insert a space after an unary operator
1528
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_after_unary_operator"
1529
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1530
//	 *     - default:           DO_NOT_INSERT
1531
//	 * </pre>
1532
//	 * @see CCorePlugin#INSERT
1533
//	 * @see CCorePlugin#DO_NOT_INSERT
1534
//	 */
1535
//	public static final String FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_after_unary_operator"; //$NON-NLS-1$
1536
//	/**
1537
//	 * <pre>
1538
//	 * FORMATTER / Option to insert a space before and in wildcard
1539
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_and_in_type_parameter"
1540
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1541
//	 *     - default:           INSERT
1542
//	 * </pre>
1543
//	 * @see CCorePlugin#INSERT
1544
//	 * @see CCorePlugin#DO_NOT_INSERT
1545
//	 */
1546
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_AND_IN_TYPE_PARAMETER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_and_in_type_parameter";	//$NON-NLS-1$
1547
//	/**
1548
//	 * <pre>
1549
//	 * FORMATTER / Option to insert a space before an assignment operator
1550
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator"
1551
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1552
//	 *     - default:           INSERT
1553
//	 * </pre>
1554
//	 * @see CCorePlugin#INSERT
1555
//	 * @see CCorePlugin#DO_NOT_INSERT
1556
//	 */
1557
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_assignment_operator";	//$NON-NLS-1$
1558
//	/**
1559
//	 * <pre>
1560
//	 * FORMATTER / Option to insert a space before at in annotation type declaration
1561
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_at_in_annotation_type_declaration"
1562
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1563
//	 *     - default:           INSERT
1564
//	 * </pre>
1565
//	 * @see CCorePlugin#INSERT
1566
//	 * @see CCorePlugin#DO_NOT_INSERT
1567
//	 */
1568
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_AT_IN_ANNOTATION_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_at_in_annotation_type_declaration";	//$NON-NLS-1$
1569
//	/**
1570
//	 * <pre>
1571
//	 * FORMATTER / Option to insert a space before an binary operator
1572
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_binary_operator"
1573
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1574
//	 *     - default:           DO_NOT_INSERT
1575
//	 * </pre>
1576
//	 * @see CCorePlugin#INSERT
1577
//	 * @see CCorePlugin#DO_NOT_INSERT
1578
//	 */
1579
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_binary_operator";	//$NON-NLS-1$
1580
//	/**
1581
//	 * <pre>
1582
//	 * FORMATTER / Option to insert a space before the closing angle bracket in parameterized type reference
1583
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference"
1584
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1585
//	 *     - default:           DO_NOT_INSERT
1586
//	 * </pre>
1587
//	 * @see CCorePlugin#INSERT
1588
//	 * @see CCorePlugin#DO_NOT_INSERT
1589
//	 */
1590
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference";		//$NON-NLS-1$
1591
//	/**
1592
//	 * <pre>
1593
//	 * FORMATTER / Option to insert a space before the closing angle bracket in type arguments
1594
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments"
1595
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1596
//	 *     - default:           DO_NOT_INSERT
1597
//	 * </pre>
1598
//	 * @see CCorePlugin#INSERT
1599
//	 * @see CCorePlugin#DO_NOT_INSERT
1600
//	 */
1601
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_angle_bracket_in_type_arguments";		//$NON-NLS-1$
1602
//	/**
1603
//	 * <pre>
1604
//	 * FORMATTER / Option to insert a space before the closing angle bracket in type parameters
1605
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters"
1606
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1607
//	 *     - default:           DO_NOT_INSERT
1608
//	 * </pre>
1609
//	 * @see CCorePlugin#INSERT
1610
//	 * @see CCorePlugin#DO_NOT_INSERT
1611
//	 */
1612
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TYPE_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_angle_bracket_in_type_parameters";		//$NON-NLS-1$
1613
//	/**
1614
//	 * <pre>
1615
//	 * FORMATTER / Option to insert a space before the closing brace in an array initializer
1616
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer"
1617
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1618
//	 *     - default:           DO_NOT_INSERT
1619
//	 * </pre>
1620
//	 * @see CCorePlugin#INSERT
1621
//	 * @see CCorePlugin#DO_NOT_INSERT
1622
//	 */
1623
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_brace_in_array_initializer";		//$NON-NLS-1$
1624
//	/**
1625
//	 * <pre>
1626
//	 * FORMATTER / Option to insert a space before the closing bracket in an array allocation expression
1627
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression"
1628
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1629
//	 *     - default:           DO_NOT_INSERT
1630
//	 * </pre>
1631
//	 * @see CCorePlugin#INSERT
1632
//	 * @see CCorePlugin#DO_NOT_INSERT
1633
//	 */
1634
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_bracket_in_array_allocation_expression";//$NON-NLS-1$
1635
//	/**
1636
//	 * <pre>
1637
//	 * FORMATTER / Option to insert a space before the closing bracket in an array reference
1638
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket_in_array_reference"
1639
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1640
//	 *     - default:           DO_NOT_INSERT
1641
//	 * </pre>
1642
//	 * @see CCorePlugin#INSERT
1643
//	 * @see CCorePlugin#DO_NOT_INSERT
1644
//	 */
1645
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_bracket_in_array_reference";//$NON-NLS-1$
1646
//	/**
1647
//	 * <pre>
1648
//	 * FORMATTER / Option to insert a space before the closing parenthesis in annotation
1649
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_annotation"
1650
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1651
//	 *     - default:           DO_NOT_INSERT
1652
//	 * </pre>
1653
//	 * @see CCorePlugin#INSERT
1654
//	 * @see CCorePlugin#DO_NOT_INSERT
1655
//	 */
1656
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_annotation";	//$NON-NLS-1$
1657
//	/**
1658
//	 * <pre>
1659
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a cast expression
1660
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast"
1661
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1662
//	 *     - default:           DO_NOT_INSERT
1663
//	 * </pre>
1664
//	 * @see CCorePlugin#INSERT
1665
//	 * @see CCorePlugin#DO_NOT_INSERT
1666
//	 */
1667
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_cast";	//$NON-NLS-1$
1668
//	/**
1669
//	 * <pre>
1670
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a catch
1671
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch"
1672
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1673
//	 *     - default:           DO_NOT_INSERT
1674
//	 * </pre>
1675
//	 * @see CCorePlugin#INSERT
1676
//	 * @see CCorePlugin#DO_NOT_INSERT
1677
//	 */
1678
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_catch";	//$NON-NLS-1$
1679
//	/**
1680
//	 * <pre>
1681
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a constructor declaration
1682
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration"
1683
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1684
//	 *     - default:           DO_NOT_INSERT
1685
//	 * </pre>
1686
//	 * @see CCorePlugin#INSERT
1687
//	 * @see CCorePlugin#DO_NOT_INSERT
1688
//	 */
1689
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_constructor_declaration";	//$NON-NLS-1$
1690
//	/**
1691
//	 * <pre>
1692
//	 * FORMATTER / Option to insert a space before the closing parenthesis in enum constant
1693
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_enum_constant"
1694
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1695
//	 *     - default:           DO_NOT_INSERT
1696
//	 * </pre>
1697
//	 * @see CCorePlugin#INSERT
1698
//	 * @see CCorePlugin#DO_NOT_INSERT
1699
//	 */
1700
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_enum_constant";	//$NON-NLS-1$
1701
//	/**
1702
//	 * <pre>
1703
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a for statement
1704
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for"
1705
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1706
//	 *     - default:           DO_NOT_INSERT
1707
//	 * </pre>
1708
//	 * @see CCorePlugin#INSERT
1709
//	 * @see CCorePlugin#DO_NOT_INSERT
1710
//	 */
1711
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_for";	//$NON-NLS-1$
1712
//	/**
1713
//	 * <pre>
1714
//	 * FORMATTER / Option to insert a space before the closing parenthesis in an if statement
1715
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if"
1716
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1717
//	 *     - default:           DO_NOT_INSERT
1718
//	 * </pre>
1719
//	 * @see CCorePlugin#INSERT
1720
//	 * @see CCorePlugin#DO_NOT_INSERT
1721
//	 */
1722
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_if";	//$NON-NLS-1$
1723
//	/**
1724
//	 * <pre>
1725
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a method declaration
1726
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration"
1727
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1728
//	 *     - default:           DO_NOT_INSERT
1729
//	 * </pre>
1730
//	 * @see CCorePlugin#INSERT
1731
//	 * @see CCorePlugin#DO_NOT_INSERT
1732
//	 */
1733
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_method_declaration";	//$NON-NLS-1$
1734
//	/**
1735
//	 * <pre>
1736
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a method invocation
1737
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation"
1738
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1739
//	 *     - default:           DO_NOT_INSERT
1740
//	 * </pre>
1741
//	 * @see CCorePlugin#INSERT
1742
//	 * @see CCorePlugin#DO_NOT_INSERT
1743
//	 */
1744
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_method_invocation"; //$NON-NLS-1$
1745
//	/**
1746
//	 * <pre>
1747
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a parenthesized expression
1748
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression"
1749
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1750
//	 *     - default:           DO_NOT_INSERT
1751
//	 * </pre>
1752
//	 * @see CCorePlugin#INSERT
1753
//	 * @see CCorePlugin#DO_NOT_INSERT
1754
//	 */
1755
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_parenthesized_expression"; //$NON-NLS-1$
1756
//	/**
1757
//	 * <pre>
1758
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a switch statement
1759
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch"
1760
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1761
//	 *     - default:           DO_NOT_INSERT
1762
//	 * </pre>
1763
//	 * @see CCorePlugin#INSERT
1764
//	 * @see CCorePlugin#DO_NOT_INSERT
1765
//	 */
1766
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_switch";	//$NON-NLS-1$
1767
//	/**
1768
//	 * <pre>
1769
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a synchronized statement
1770
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_synchronized"
1771
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1772
//	 *     - default:           DO_NOT_INSERT
1773
//	 * </pre>
1774
//	 * @see CCorePlugin#INSERT
1775
//	 * @see CCorePlugin#DO_NOT_INSERT
1776
//	 */
1777
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_synchronized";	//$NON-NLS-1$
1778
//	/**
1779
//	 * <pre>
1780
//	 * FORMATTER / Option to insert a space before the closing parenthesis in a while statement
1781
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while"
1782
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1783
//	 *     - default:           DO_NOT_INSERT
1784
//	 * </pre>
1785
//	 * @see CCorePlugin#INSERT
1786
//	 * @see CCorePlugin#DO_NOT_INSERT
1787
//	 */
1788
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_closing_paren_in_while";	//$NON-NLS-1$
1789
//	/**
1790
//	 * <pre>
1791
//	 * FORMATTER / Option to insert a space before colon in an assert statement
1792
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_colon_in_assert"
1793
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1794
//	 *     - default:           INSERT
1795
//	 * </pre>
1796
//	 * @see CCorePlugin#INSERT
1797
//	 * @see CCorePlugin#DO_NOT_INSERT
1798
//	 */
1799
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_colon_in_assert";	//$NON-NLS-1$
1800
//	/**
1801
//	 * <pre>
1802
//	 * FORMATTER / Option to insert a space before colon in a case statement
1803
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case"
1804
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1805
//	 *     - default:           INSERT
1806
//	 * </pre>
1807
//	 * @see CCorePlugin#INSERT
1808
//	 * @see CCorePlugin#DO_NOT_INSERT
1809
//	 */
1810
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_colon_in_case";	//$NON-NLS-1$
1811
//	/**
1812
//	 * <pre>
1813
//	 * FORMATTER / Option to insert a space before colon in a conditional expression
1814
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional"
1815
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1816
//	 *     - default:           INSERT
1817
//	 * </pre>
1818
//	 * @see CCorePlugin#INSERT
1819
//	 * @see CCorePlugin#DO_NOT_INSERT
1820
//	 */
1821
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_colon_in_conditional";	//$NON-NLS-1$
1822
//	/**
1823
//	 * <pre>
1824
//	 * FORMATTER / Option to insert a space before colon in a default statement
1825
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default"
1826
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1827
//	 *     - default:           INSERT
1828
//	 * </pre>
1829
//	 * @see CCorePlugin#INSERT
1830
//	 * @see CCorePlugin#DO_NOT_INSERT
1831
//	 */
1832
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_colon_in_default";	//$NON-NLS-1$
1833
//	/**
1834
//	 * <pre>
1835
//	 * FORMATTER / Option to insert a space before colon in a for statement
1836
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_colon_in_for"
1837
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1838
//	 *     - default:           INSERT
1839
//	 * </pre>
1840
//	 * @see CCorePlugin#INSERT
1841
//	 * @see CCorePlugin#DO_NOT_INSERT
1842
//	 */
1843
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_colon_in_for";	//$NON-NLS-1$
1844
//	/**
1845
//	 * <pre>
1846
//	 * FORMATTER / Option to insert a space before colon in a labeled statement
1847
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement"
1848
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1849
//	 *     - default:           INSERT
1850
//	 * </pre>
1851
//	 * @see CCorePlugin#INSERT
1852
//	 * @see CCorePlugin#DO_NOT_INSERT
1853
//	 */
1854
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_colon_in_labeled_statement";	//$NON-NLS-1$
1855
//	/**
1856
//	 * <pre>
1857
//	 * FORMATTER / Option to insert a space before comma in an allocation expression
1858
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_allocation_expression"
1859
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1860
//	 *     - default:           DO_NOT_INSERT
1861
//	 * </pre>
1862
//	 * @see CCorePlugin#INSERT
1863
//	 * @see CCorePlugin#DO_NOT_INSERT
1864
//	 */
1865
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_allocation_expression";	//$NON-NLS-1$
1866
//	/**
1867
//	 * <pre>
1868
//	 * FORMATTER / Option to insert a space before comma in annotation
1869
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_annotation"
1870
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1871
//	 *     - default:           DO_NOT_INSERT
1872
//	 * </pre>
1873
//	 * @see CCorePlugin#INSERT
1874
//	 * @see CCorePlugin#DO_NOT_INSERT
1875
//	 */
1876
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_annotation";	//$NON-NLS-1$
1877
//	/**
1878
//	 * <pre>
1879
//	 * FORMATTER / Option to insert a space before comma in an array initializer
1880
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer"
1881
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1882
//	 *     - default:           DO_NOT_INSERT
1883
//	 * </pre>
1884
//	 * @see CCorePlugin#INSERT
1885
//	 * @see CCorePlugin#DO_NOT_INSERT
1886
//	 */
1887
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_array_initializer";	//$NON-NLS-1$
1888
//	/**
1889
//	 * <pre>
1890
//	 * FORMATTER / Option to insert a space before comma in the parameters of a constructor declaration
1891
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters"
1892
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1893
//	 *     - default:           DO_NOT_INSERT
1894
//	 * </pre>
1895
//	 * @see CCorePlugin#INSERT
1896
//	 * @see CCorePlugin#DO_NOT_INSERT
1897
//	 */
1898
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_constructor_declaration_parameters";	//$NON-NLS-1$
1899
//	/**
1900
//	 * <pre>
1901
//	 * FORMATTER / Option to insert a space before comma in the exception names of the throws clause of a constructor declaration
1902
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws"
1903
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1904
//	 *     - default:           DO_NOT_INSERT
1905
//	 * </pre>
1906
//	 * @see CCorePlugin#INSERT
1907
//	 * @see CCorePlugin#DO_NOT_INSERT
1908
//	 */
1909
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_constructor_declaration_throws";	//$NON-NLS-1$
1910
//	/**
1911
//	 * <pre>
1912
//	 * FORMATTER / Option to insert a space before comma in the arguments of enum constant
1913
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments"
1914
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1915
//	 *     - default:           DO_NOT_INSERT
1916
//	 * </pre>
1917
//	 * @see CCorePlugin#INSERT
1918
//	 * @see CCorePlugin#DO_NOT_INSERT
1919
//	 */
1920
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_CONSTANT_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_enum_constant_arguments";	//$NON-NLS-1$
1921
//	/**
1922
//	 * <pre>
1923
//	 * FORMATTER / Option to insert a space before comma in enum declarations
1924
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations"
1925
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1926
//	 *     - default:           DO_NOT_INSERT
1927
//	 * </pre>
1928
//	 * @see CCorePlugin#INSERT
1929
//	 * @see CCorePlugin#DO_NOT_INSERT
1930
//	 */
1931
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ENUM_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_enum_declarations";	//$NON-NLS-1$
1932
//	/**
1933
//	 * <pre>
1934
//	 * FORMATTER / Option to insert a space before comma in the arguments of an explicit constructor call
1935
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments"
1936
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1937
//	 *     - default:           DO_NOT_INSERT
1938
//	 * </pre>
1939
//	 * @see CCorePlugin#INSERT
1940
//	 * @see CCorePlugin#DO_NOT_INSERT
1941
//	 */
1942
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_explicitconstructorcall_arguments";	//$NON-NLS-1$
1943
//	/**
1944
//	 * <pre>
1945
//	 * FORMATTER / Option to insert a space before comma in the increments of a for statement
1946
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_for_increments"
1947
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1948
//	 *     - default:           DO_NOT_INSERT
1949
//	 * </pre>
1950
//	 * @see CCorePlugin#INSERT
1951
//	 * @see CCorePlugin#DO_NOT_INSERT
1952
//	 */
1953
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_for_increments";	//$NON-NLS-1$
1954
//	/**
1955
//	 * <pre>
1956
//	 * FORMATTER / Option to insert a space before comma in the initializations of a for statement
1957
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_for_inits"
1958
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1959
//	 *     - default:           DO_NOT_INSERT
1960
//	 * </pre>
1961
//	 * @see CCorePlugin#INSERT
1962
//	 * @see CCorePlugin#DO_NOT_INSERT
1963
//	 */
1964
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_for_inits";	//$NON-NLS-1$
1965
//	/**
1966
//	 * <pre>
1967
//	 * FORMATTER / Option to insert a space before comma in the parameters of a method declaration
1968
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters"
1969
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1970
//	 *     - default:           DO_NOT_INSERT
1971
//	 * </pre>
1972
//	 * @see CCorePlugin#INSERT
1973
//	 * @see CCorePlugin#DO_NOT_INSERT
1974
//	 */
1975
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_declaration_parameters";	//$NON-NLS-1$
1976
//	/**
1977
//	 * <pre>
1978
//	 * FORMATTER / Option to insert a space before comma in the exception names of the throws clause of a method declaration
1979
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws"
1980
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1981
//	 *     - default:           DO_NOT_INSERT
1982
//	 * </pre>
1983
//	 * @see CCorePlugin#INSERT
1984
//	 * @see CCorePlugin#DO_NOT_INSERT
1985
//	 */
1986
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_declaration_throws";	//$NON-NLS-1$
1987
//	/**
1988
//	 * <pre>
1989
//	 * FORMATTER / Option to insert a space before comma in the arguments of a method invocation
1990
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments"
1991
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
1992
//	 *     - default:           DO_NOT_INSERT
1993
//	 * </pre>
1994
//	 * @see CCorePlugin#INSERT
1995
//	 * @see CCorePlugin#DO_NOT_INSERT
1996
//	 */
1997
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_method_invocation_arguments";	//$NON-NLS-1$
1998
//	/**
1999
//	 * <pre>
2000
//	 * FORMATTER / Option to insert a space before comma in a multiple field declaration
2001
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations"
2002
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2003
//	 *     - default:           DO_NOT_INSERT
2004
//	 * </pre>
2005
//	 * @see CCorePlugin#INSERT
2006
//	 * @see CCorePlugin#DO_NOT_INSERT
2007
//	 */
2008
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_multiple_field_declarations";	//$NON-NLS-1$
2009
//	/**
2010
//	 * <pre>
2011
//	 * FORMATTER / Option to insert a space before comma in a multiple local declaration
2012
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations"
2013
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2014
//	 *     - default:           DO_NOT_INSERT
2015
//	 * </pre>
2016
//	 * @see CCorePlugin#INSERT
2017
//	 * @see CCorePlugin#DO_NOT_INSERT
2018
//	 */
2019
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_multiple_local_declarations";	//$NON-NLS-1$
2020
//	/**
2021
//	 * <pre>
2022
//	 * FORMATTER / Option to insert a space before comma in parameterized type reference
2023
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference"
2024
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2025
//	 *     - default:           DO_NOT_INSERT
2026
//	 * </pre>
2027
//	 * @see CCorePlugin#INSERT
2028
//	 * @see CCorePlugin#DO_NOT_INSERT
2029
//	 */
2030
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_PARAMETERIZED_TYPE_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_parameterized_type_reference";	//$NON-NLS-1$
2031
//	/**
2032
//	 * <pre>
2033
//	 * FORMATTER / Option to insert a space before comma in the superinterfaces names in a type header
2034
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_superinterfaces"
2035
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2036
//	 *     - default:           DO_NOT_INSERT
2037
//	 * </pre>
2038
//	 * @see CCorePlugin#INSERT
2039
//	 * @see CCorePlugin#DO_NOT_INSERT
2040
//	 */
2041
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_superinterfaces";	//$NON-NLS-1$
2042
//	/**
2043
//	 * <pre>
2044
//	 * FORMATTER / Option to insert a space before comma in type arguments
2045
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_type_arguments"
2046
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2047
//	 *     - default:           DO_NOT_INSERT
2048
//	 * </pre>
2049
//	 * @see CCorePlugin#INSERT
2050
//	 * @see CCorePlugin#DO_NOT_INSERT
2051
//	 */
2052
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_type_arguments";	//$NON-NLS-1$
2053
//	/**
2054
//	 * <pre>
2055
//	 * FORMATTER / Option to insert a space before comma in type parameters
2056
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_comma_in_type_parameters"
2057
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2058
//	 *     - default:           DO_NOT_INSERT
2059
//	 * </pre>
2060
//	 * @see CCorePlugin#INSERT
2061
//	 * @see CCorePlugin#DO_NOT_INSERT
2062
//	 */
2063
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TYPE_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_comma_in_type_parameters";	//$NON-NLS-1$
2064
//	/**
2065
//	 * <pre>
2066
//	 * FORMATTER / Option to insert a space before ellipsis
2067
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_ellipsis"
2068
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2069
//	 *     - default:           DO_NOT_INSERT
2070
//	 * </pre>
2071
//	 * @see CCorePlugin#INSERT
2072
//	 * @see CCorePlugin#DO_NOT_INSERT
2073
//	 */
2074
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_ELLIPSIS  = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_ellipsis";	//$NON-NLS-1$
2075
//	/**
2076
//	 * <pre>
2077
//	 * FORMATTER / Option to insert a space before the opening angle bracket in parameterized type reference
2078
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference"
2079
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2080
//	 *     - default:           DO_NOT_INSERT
2081
//	 * </pre>
2082
//	 * @see CCorePlugin#INSERT
2083
//	 * @see CCorePlugin#DO_NOT_INSERT
2084
//	 */
2085
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE  = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference";	//$NON-NLS-1$
2086
//	/**
2087
//	 * <pre>
2088
//	 * FORMATTER / Option to insert a space before the opening angle bracket in type arguments
2089
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments"
2090
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2091
//	 *     - default:           DO_NOT_INSERT
2092
//	 * </pre>
2093
//	 * @see CCorePlugin#INSERT
2094
//	 * @see CCorePlugin#DO_NOT_INSERT
2095
//	 */
2096
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_ARGUMENTS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_angle_bracket_in_type_arguments";	//$NON-NLS-1$
2097
//	/**
2098
//	 * <pre>
2099
//	 * FORMATTER / Option to insert a space before the opening angle bracket in type parameters
2100
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters"
2101
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2102
//	 *     - default:           DO_NOT_INSERT
2103
//	 * </pre>
2104
//	 * @see CCorePlugin#INSERT
2105
//	 * @see CCorePlugin#DO_NOT_INSERT
2106
//	 */
2107
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TYPE_PARAMETERS = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_angle_bracket_in_type_parameters";	//$NON-NLS-1$
2108
//	/**
2109
//	 * <pre>
2110
//	 * FORMATTER / Option to insert a space before the opening brace in an annotation type declaration
2111
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration"
2112
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2113
//	 *     - default:           INSERT
2114
//	 * </pre>
2115
//	 * @see CCorePlugin#INSERT
2116
//	 * @see CCorePlugin#DO_NOT_INSERT
2117
//	 */
2118
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANNOTATION_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_annotation_type_declaration"; 	//$NON-NLS-1$
2119
//	/**
2120
//	 * <pre>
2121
//	 * FORMATTER / Option to insert a space before the opening brace in an anonymous type declaration
2122
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration"
2123
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2124
//	 *     - default:           INSERT
2125
//	 * </pre>
2126
//	 * @see CCorePlugin#INSERT
2127
//	 * @see CCorePlugin#DO_NOT_INSERT
2128
//	 */
2129
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_anonymous_type_declaration"; 	//$NON-NLS-1$
2130
//	/**
2131
//	 * <pre>
2132
//	 * FORMATTER / Option to insert a space before the opening brace in an array initializer
2133
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer"
2134
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2135
//	 *     - default:           DO_NOT_INSERT
2136
//	 * </pre>
2137
//	 * @see CCorePlugin#INSERT
2138
//	 * @see CCorePlugin#DO_NOT_INSERT
2139
//	 */
2140
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_array_initializer"; //$NON-NLS-1$
2141
//	/**
2142
//	 * <pre>
2143
//	 * FORMATTER / Option to insert a space before the opening brace in a block
2144
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block"
2145
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2146
//	 *     - default:           INSERT
2147
//	 * </pre>
2148
//	 * @see CCorePlugin#INSERT
2149
//	 * @see CCorePlugin#DO_NOT_INSERT
2150
//	 */
2151
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_block";	//$NON-NLS-1$
2152
//	/**
2153
//	 * <pre>
2154
//	 * FORMATTER / Option to insert a space before the opening brace in a constructor declaration
2155
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration"
2156
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2157
//	 *     - default:           INSERT
2158
//	 * </pre>
2159
//	 * @see CCorePlugin#INSERT
2160
//	 * @see CCorePlugin#DO_NOT_INSERT
2161
//	 */
2162
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_constructor_declaration";	//$NON-NLS-1$
2163
//	/**
2164
//	 * <pre>
2165
//	 * FORMATTER / Option to insert a space before the opening brace in an enum constant
2166
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_enum_constant"
2167
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2168
//	 *     - default:           INSERT
2169
//	 * </pre>
2170
//	 * @see CCorePlugin#INSERT
2171
//	 * @see CCorePlugin#DO_NOT_INSERT
2172
//	 */
2173
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_enum_constant";	//$NON-NLS-1$
2174
//	/**
2175
//	 * <pre>
2176
//	 * FORMATTER / Option to insert a space before the opening brace in an enum declaration
2177
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration"
2178
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2179
//	 *     - default:           INSERT
2180
//	 * </pre>
2181
//	 * @see CCorePlugin#INSERT
2182
//	 * @see CCorePlugin#DO_NOT_INSERT
2183
//	 */
2184
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ENUM_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_enum_declaration";	//$NON-NLS-1$
2185
//	/**
2186
//	 * <pre>
2187
//	 * FORMATTER / Option to insert a space before the opening brace in a method declaration
2188
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration"
2189
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2190
//	 *     - default:           INSERT
2191
//	 * </pre>
2192
//	 * @see CCorePlugin#INSERT
2193
//	 * @see CCorePlugin#DO_NOT_INSERT
2194
//	 */
2195
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_method_declaration";	//$NON-NLS-1$
2196
//	/**
2197
//	 * <pre>
2198
//	 * FORMATTER / Option to insert a space before the opening brace in a switch statement
2199
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch"
2200
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2201
//	 *     - default:           INSERT
2202
//	 * </pre>
2203
//	 * @see CCorePlugin#INSERT
2204
//	 * @see CCorePlugin#DO_NOT_INSERT
2205
//	 */
2206
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_switch";	//$NON-NLS-1$
2207
//	/**
2208
//	 * <pre>
2209
//	 * FORMATTER / Option to insert a space before the opening brace in a type declaration
2210
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration"
2211
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2212
//	 *     - default:           INSERT
2213
//	 * </pre>
2214
//	 * @see CCorePlugin#INSERT
2215
//	 * @see CCorePlugin#DO_NOT_INSERT
2216
//	 */
2217
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_brace_in_type_declaration";	//$NON-NLS-1$
2218
//	/**
2219
//	 * <pre>
2220
//	 * FORMATTER / Option to insert a space before the opening bracket in an array allocation expression
2221
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression"
2222
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2223
//	 *     - default:           DO_NOT_INSERT
2224
//	 * </pre>
2225
//	 * @see CCorePlugin#INSERT
2226
//	 * @see CCorePlugin#DO_NOT_INSERT
2227
//	 */
2228
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_bracket_in_array_allocation_expression";//$NON-NLS-1$
2229
//	/**
2230
//	 * <pre>
2231
//	 * FORMATTER / Option to insert a space before the opening bracket in an array reference
2232
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket_in_array_reference"
2233
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2234
//	 *     - default:           DO_NOT_INSERT
2235
//	 * </pre>
2236
//	 * @see CCorePlugin#INSERT
2237
//	 * @see CCorePlugin#DO_NOT_INSERT
2238
//	 */
2239
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_bracket_in_array_reference";//$NON-NLS-1$
2240
//	/**
2241
//	 * <pre>
2242
//	 * FORMATTER / Option to insert a space before the opening bracket in an array type reference
2243
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference"
2244
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2245
//	 *     - default:           DO_NOT_INSERT
2246
//	 * </pre>
2247
//	 * @see CCorePlugin#INSERT
2248
//	 * @see CCorePlugin#DO_NOT_INSERT
2249
//	 */
2250
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_bracket_in_array_type_reference";	//$NON-NLS-1$
2251
//	/**
2252
//	 * <pre>
2253
//	 * FORMATTER / Option to insert a space before the opening parenthesis in annotation
2254
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_annotation"
2255
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2256
//	 *     - default:           DO_NOT_INSERT
2257
//	 * </pre>
2258
//	 * @see CCorePlugin#INSERT
2259
//	 * @see CCorePlugin#DO_NOT_INSERT
2260
//	 */
2261
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_annotation";	//$NON-NLS-1$
2262
//	/**
2263
//	 * <pre>
2264
//	 * FORMATTER / Option to insert a space before the opening parenthesis in annotation type member declaration
2265
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration"
2266
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2267
//	 *     - default:           DO_NOT_INSERT
2268
//	 * </pre>
2269
//	 * @see CCorePlugin#INSERT
2270
//	 * @see CCorePlugin#DO_NOT_INSERT
2271
//	 */
2272
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ANNOTATION_TYPE_MEMBER_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration";	//$NON-NLS-1$
2273
//	/**
2274
//	 * <pre>
2275
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a catch
2276
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch"
2277
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2278
//	 *     - default:           INSERT
2279
//	 * </pre>
2280
//	 * @see CCorePlugin#INSERT
2281
//	 * @see CCorePlugin#DO_NOT_INSERT
2282
//	 */
2283
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_catch";	//$NON-NLS-1$
2284
//	/**
2285
//	 * <pre>
2286
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a constructor declaration
2287
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration"
2288
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2289
//	 *     - default:           DO_NOT_INSERT
2290
//	 * </pre>
2291
//	 * @see CCorePlugin#INSERT
2292
//	 * @see CCorePlugin#DO_NOT_INSERT
2293
//	 */
2294
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_constructor_declaration";	//$NON-NLS-1$
2295
//	/**
2296
//	 * <pre>
2297
//	 * FORMATTER / Option to insert a space before the opening parenthesis in enum constant
2298
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_enum_constant"
2299
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2300
//	 *     - default:           DO_NOT_INSERT
2301
//	 * </pre>
2302
//	 * @see CCorePlugin#INSERT
2303
//	 * @see CCorePlugin#DO_NOT_INSERT
2304
//	 */
2305
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_enum_constant";	//$NON-NLS-1$
2306
//	/**
2307
//	 * <pre>
2308
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a for statement
2309
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for"
2310
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2311
//	 *     - default:           INSERT
2312
//	 * </pre>
2313
//	 * @see CCorePlugin#INSERT
2314
//	 * @see CCorePlugin#DO_NOT_INSERT
2315
//	 */
2316
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_for";	//$NON-NLS-1$
2317
//	/**
2318
//	 * <pre>
2319
//	 * FORMATTER / Option to insert a space before the opening parenthesis in an if statement
2320
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if"
2321
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2322
//	 *     - default:           INSERT
2323
//	 * </pre>
2324
//	 * @see CCorePlugin#INSERT
2325
//	 * @see CCorePlugin#DO_NOT_INSERT
2326
//	 */
2327
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_if";	//$NON-NLS-1$
2328
//	/**
2329
//	 * <pre>
2330
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a method declaration
2331
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration"
2332
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2333
//	 *     - default:           DO_NOT_INSERT
2334
//	 * </pre>
2335
//	 * @see CCorePlugin#INSERT
2336
//	 * @see CCorePlugin#DO_NOT_INSERT
2337
//	 */
2338
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_method_declaration";	//$NON-NLS-1$
2339
//	/**
2340
//	 * <pre>
2341
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a method invocation
2342
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation"
2343
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2344
//	 *     - default:           DO_NOT_INSERT
2345
//	 * </pre>
2346
//	 * @see CCorePlugin#INSERT
2347
//	 * @see CCorePlugin#DO_NOT_INSERT
2348
//	 */
2349
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_method_invocation";	//$NON-NLS-1$
2350
//	/**
2351
//	 * <pre>
2352
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a parenthesized expression
2353
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression"
2354
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2355
//	 *     - default:           DO_NOT_INSERT
2356
//	 * </pre>
2357
//	 * @see CCorePlugin#INSERT
2358
//	 * @see CCorePlugin#DO_NOT_INSERT
2359
//	 */
2360
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_parenthesized_expression"; //$NON-NLS-1$
2361
//	/**
2362
//	 * <pre>
2363
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a switch statement
2364
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch"
2365
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2366
//	 *     - default:           INSERT
2367
//	 * </pre>
2368
//	 * @see CCorePlugin#INSERT
2369
//	 * @see CCorePlugin#DO_NOT_INSERT
2370
//	 */
2371
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_switch";	//$NON-NLS-1$
2372
//	/**
2373
//	 * <pre>
2374
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a synchronized statement
2375
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_synchronized"
2376
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2377
//	 *     - default:           INSERT
2378
//	 * </pre>
2379
//	 * @see CCorePlugin#INSERT
2380
//	 * @see CCorePlugin#DO_NOT_INSERT
2381
//	 */
2382
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_synchronized";	//$NON-NLS-1$
2383
//	/**
2384
//	 * <pre>
2385
//	 * FORMATTER / Option to insert a space before the opening parenthesis in a while statement
2386
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while"
2387
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2388
//	 *     - default:           INSERT
2389
//	 * </pre>
2390
//	 * @see CCorePlugin#INSERT
2391
//	 * @see CCorePlugin#DO_NOT_INSERT
2392
//	 */
2393
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_opening_paren_in_while";	//$NON-NLS-1$
2394
//	/**
2395
//	 * <pre>
2396
//	 * FORMATTER / Option to insert a space before parenthesized expression in return statement
2397
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_parenthesized_expression_in_return"
2398
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2399
//	 *     - default:           INSERT
2400
//	 * </pre>
2401
//	 * 
2402
//	 * @see CCorePlugin#INSERT
2403
//	 * @see CCorePlugin#DO_NOT_INSERT
2404
//	 */
2405
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_PARENTHESIZED_EXPRESSION_IN_RETURN  = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_parenthesized_expression_in_return";	//$NON-NLS-1$
2406
//	/**
2407
//	 * <pre>
2408
//	 * FORMATTER / Option to insert a space before a postfix operator
2409
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator"
2410
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2411
//	 *     - default:           DO_NOT_INSERT
2412
//	 * </pre>
2413
//	 * @see CCorePlugin#INSERT
2414
//	 * @see CCorePlugin#DO_NOT_INSERT
2415
//	 */
2416
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_postfix_operator";	//$NON-NLS-1$
2417
//	/**
2418
//	 * <pre>
2419
//	 * FORMATTER / Option to insert a space before a prefix operator
2420
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator"
2421
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2422
//	 *     - default:           DO_NOT_INSERT
2423
//	 * </pre>
2424
//	 * @see CCorePlugin#INSERT
2425
//	 * @see CCorePlugin#DO_NOT_INSERT
2426
//	 */
2427
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_prefix_operator";	//$NON-NLS-1$
2428
//	/**
2429
//	 * <pre>
2430
//	 * FORMATTER / Option to insert a space before question mark in a conditional expression
2431
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional"
2432
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2433
//	 *     - default:           INSERT
2434
//	 * </pre>
2435
//	 * @see CCorePlugin#INSERT
2436
//	 * @see CCorePlugin#DO_NOT_INSERT
2437
//	 */
2438
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_question_in_conditional";	//$NON-NLS-1$
2439
//	/**
2440
//	 * <pre>
2441
//	 * FORMATTER / Option to insert a space before question mark in a wildcard
2442
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_question_in_wildcard"
2443
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2444
//	 *     - default:           DO_NOT_INSERT
2445
//	 * </pre>
2446
//	 * @see CCorePlugin#INSERT
2447
//	 * @see CCorePlugin#DO_NOT_INSERT
2448
//	 */
2449
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_WILDCARD = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_question_in_wildcard"; //$NON-NLS-1$
2450
//	/**
2451
//	 * <pre>
2452
//	 * FORMATTER / Option to insert a space before semicolon
2453
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_semicolon"
2454
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2455
//	 *     - default:           DO_NOT_INSERT
2456
//	 * </pre>
2457
//	 * @see CCorePlugin#INSERT
2458
//	 * @see CCorePlugin#DO_NOT_INSERT
2459
//	 */
2460
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_semicolon";	//$NON-NLS-1$
2461
//	/**
2462
//	 * <pre>
2463
//	 * FORMATTER / Option to insert a space before semicolon in for statement
2464
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for"
2465
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2466
//	 *     - default:           DO_NOT_INSERT
2467
//	 * </pre>
2468
//	 * @see CCorePlugin#INSERT
2469
//	 * @see CCorePlugin#DO_NOT_INSERT
2470
//	 */
2471
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_semicolon_in_for";	//$NON-NLS-1$
2472
//	/**
2473
//	 * <pre>
2474
//	 * FORMATTER / Option to insert a space before unary operator
2475
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_before_unary_operator"
2476
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2477
//	 *     - default:           DO_NOT_INSERT
2478
//	 * </pre>
2479
//	 * @see CCorePlugin#INSERT
2480
//	 * @see CCorePlugin#DO_NOT_INSERT
2481
//	 */
2482
//	public static final String FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_before_unary_operator";	//$NON-NLS-1$
2483
//
2484
//	/**
2485
//	 * <pre>
2486
//	 * FORMATTER / Option to insert a space between brackets in an array type reference
2487
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_brackets_in_array_type_reference"
2488
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2489
//	 *     - default:           DO_NOT_INSERT
2490
//	 * </pre>
2491
//	 * @see CCorePlugin#INSERT
2492
//	 * @see CCorePlugin#DO_NOT_INSERT
2493
//	 */
2494
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_brackets_in_array_type_reference";	//$NON-NLS-1$
2495
//	/**
2496
//	 * <pre>
2497
//	 * FORMATTER / Option to insert a space between empty braces in an array initializer
2498
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer"
2499
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2500
//	 *     - default:           DO_NOT_INSERT
2501
//	 * </pre>
2502
//	 * @see CCorePlugin#INSERT
2503
//	 * @see CCorePlugin#DO_NOT_INSERT
2504
//	 */
2505
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_braces_in_array_initializer";	//$NON-NLS-1$
2506
//	/**
2507
//	 * <pre>
2508
//	 * FORMATTER / Option to insert a space between empty brackets in an array allocation expression
2509
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression"
2510
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2511
//	 *     - default:           DO_NOT_INSERT
2512
//	 * </pre>
2513
//	 * @see CCorePlugin#INSERT
2514
//	 * @see CCorePlugin#DO_NOT_INSERT
2515
//	 */
2516
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_brackets_in_array_allocation_expression";	//$NON-NLS-1$
2517
//	/**
2518
//	 * <pre>
2519
//	 * FORMATTER / Option to insert a space between empty parenthesis in an annotation type member declaration
2520
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration"
2521
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2522
//	 *     - default:           DO_NOT_INSERT
2523
//	 * </pre>
2524
//	 * @see CCorePlugin#INSERT
2525
//	 * @see CCorePlugin#DO_NOT_INSERT
2526
//	 */
2527
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ANNOTATION_TYPE_MEMBER_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration";	//$NON-NLS-1$
2528
//	/**
2529
//	 * <pre>
2530
//	 * FORMATTER / Option to insert a space between empty parenthesis in a constructor declaration
2531
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration"
2532
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2533
//	 *     - default:           DO_NOT_INSERT
2534
//	 * </pre>
2535
//	 * @see CCorePlugin#INSERT
2536
//	 * @see CCorePlugin#DO_NOT_INSERT
2537
//	 */
2538
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_constructor_declaration";	//$NON-NLS-1$
2539
//	/**
2540
//	 * <pre>
2541
//	 * FORMATTER / Option to insert a space between empty parenthesis in enum constant
2542
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_enum_constant"
2543
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2544
//	 *     - default:           DO_NOT_INSERT
2545
//	 * </pre>
2546
//	 * @see CCorePlugin#INSERT
2547
//	 * @see CCorePlugin#DO_NOT_INSERT
2548
//	 */
2549
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_ENUM_CONSTANT = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_enum_constant";	//$NON-NLS-1$
2550
//	/**
2551
//	 * <pre>
2552
//	 * FORMATTER / Option to insert a space between empty parenthesis in a method declaration
2553
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration"
2554
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2555
//	 *     - default:           DO_NOT_INSERT
2556
//	 * </pre>
2557
//	 * @see CCorePlugin#INSERT
2558
//	 * @see CCorePlugin#DO_NOT_INSERT
2559
//	 */
2560
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_method_declaration";	//$NON-NLS-1$
2561
//	/**
2562
//	 * <pre>
2563
//	 * FORMATTER / Option to insert a space between empty parenthesis in a method invocation
2564
//	 *     - option id:         "org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation"
2565
//	 *     - possible values:   { INSERT, DO_NOT_INSERT }
2566
//	 *     - default:           DO_NOT_INSERT
2567
//	 * </pre>
2568
//	 * @see CCorePlugin#INSERT
2569
//	 * @see CCorePlugin#DO_NOT_INSERT
2570
//	 */
2571
//	public static final String FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION = CCorePlugin.PLUGIN_ID + ".formatter.insert_space_between_empty_parens_in_method_invocation";	//$NON-NLS-1$
2572
//	/**
2573
//	 * <pre>
2574
//	 * FORMATTER / Option to keep else statement on the same line
2575
//	 *     - option id:         "org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line"
2576
//	 *     - possible values:   { TRUE, FALSE }
2577
//	 *     - default:           FALSE
2578
//	 * </pre>
2579
//	 * @see #TRUE
2580
//	 * @see #FALSE
2581
//	 */
2582
//	public static final String FORMATTER_KEEP_ELSE_STATEMENT_ON_SAME_LINE = CCorePlugin.PLUGIN_ID + ".formatter.keep_else_statement_on_same_line"; //$NON-NLS-1$
2583
//	/**
2584
//	 * <pre>
2585
//	 * FORMATTER / Option to keep empty array initializer one one line
2586
//	 *     - option id:         "org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line"
2587
//	 *     - possible values:   { TRUE, FALSE }
2588
//	 *     - default:           FALSE
2589
//	 * </pre>
2590
//	 * @see #TRUE
2591
//	 * @see #FALSE
2592
//	 */
2593
//	public static final String FORMATTER_KEEP_EMPTY_ARRAY_INITIALIZER_ON_ONE_LINE = CCorePlugin.PLUGIN_ID + ".formatter.keep_empty_array_initializer_on_one_line"; //$NON-NLS-1$
2594
//	/**
2595
//	 * <pre>
2596
//	 * FORMATTER / Option to keep guardian clause on one line
2597
//	 *     - option id:         "org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line"
2598
//	 *     - possible values:   { TRUE, FALSE }
2599
//	 *     - default:           FALSE
2600
//	 * </pre>
2601
//	 * @see #TRUE
2602
//	 * @see #FALSE
2603
//	 */
2604
//	public static final String FORMATTER_KEEP_GUARDIAN_CLAUSE_ON_ONE_LINE = CCorePlugin.PLUGIN_ID + ".formatter.format_guardian_clause_on_one_line";	//$NON-NLS-1$
2605
//	/**
2606
//	 * <pre>
2607
//	 * FORMATTER / Option to keep simple if statement on the one line
2608
//	 *     - option id:         "org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line"
2609
//	 *     - possible values:   { TRUE, FALSE }
2610
//	 *     - default:           FALSE
2611
//	 * </pre>
2612
//	 * @see #TRUE
2613
//	 * @see #FALSE
2614
//	 */
2615
//	public static final String FORMATTER_KEEP_SIMPLE_IF_ON_ONE_LINE = CCorePlugin.PLUGIN_ID + ".formatter.keep_imple_if_on_one_line"; //$NON-NLS-1$
2616
//	/**
2617
//	 * <pre>
2618
//	 * FORMATTER / Option to keep then statement on the same line
2619
//	 *     - option id:         "org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line"
2620
//	 *     - possible values:   { TRUE, FALSE }
2621
//	 *     - default:           FALSE
2622
//	 * </pre>
2623
//	 * @see #TRUE
2624
//	 * @see #FALSE
2625
//	 */
2626
//	public static final String FORMATTER_KEEP_THEN_STATEMENT_ON_SAME_LINE = CCorePlugin.PLUGIN_ID + ".formatter.keep_then_statement_on_same_line";//$NON-NLS-1$
2627
2628
	/**
2629
	 * <pre>
2630
	 * FORMATTER / Option to specify the length of the page. Beyond this length, the formatter will try to split the code
2631
	 *     - option id:         "org.eclipse.cdt.core.formatter.lineSplit"
2632
	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
2633
	 *     - default:           "80"
2634
	 * </pre>
2635
	 */
2636
	public static final String FORMATTER_LINE_SPLIT = CCorePlugin.PLUGIN_ID + ".formatter.lineSplit"; //$NON-NLS-1$
2637
//
2638
//	/**
2639
//	 * <pre>
2640
//	 * FORMATTER / Option to specify the number of empty lines to preserve
2641
//	 *     - option id:         "org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve"
2642
//	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
2643
//	 *     - default:           "0"
2644
//	 * </pre>
2645
//	 */
2646
//	public static final String FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE = CCorePlugin.PLUGIN_ID + ".formatter.number_of_empty_lines_to_preserve";	//$NON-NLS-1$
2647
//	/**
2648
//	 * <pre>
2649
//	 * FORMATTER / Option to specify whether or not empty statement should be on a new line
2650
//	 *     - option id:         "org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line"
2651
//	 *     - possible values:   { TRUE, FALSE }
2652
//	 *     - default:           FALSE
2653
//	 * </pre>
2654
//	 * @see #TRUE
2655
//	 * @see #FALSE
2656
//	 */
2657
//	public static final String FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE = CCorePlugin.PLUGIN_ID + ".formatter.put_empty_statement_on_new_line";	//$NON-NLS-1$
2658
	/**
2659
	 * <pre>
2660
	 * FORMATTER / Option to specify the tabulation size
2661
	 *     - option id:         "org.eclipse.cdt.core.formatter.tabulation.char"
2662
	 *     - possible values:   { TAB, SPACE, MIXED }
2663
	 *     - default:           TAB
2664
	 * </pre>
2665
	 * More values may be added in the future.
2666
	 * 
2667
	 * @see CCorePlugin#TAB
2668
	 * @see CCorePlugin#SPACE
2669
	 * @see #MIXED
2670
	 */
2671
	public static final String FORMATTER_TAB_CHAR = CCorePlugin.PLUGIN_ID + ".formatter.tabulation.char"; //$NON-NLS-1$
2672
	/**
2673
	 * <pre>
2674
	 * FORMATTER / Option to specify the equivalent number of spaces that represents one tabulation 
2675
	 *     - option id:         "org.eclipse.cdt.core.formatter.tabulation.size"
2676
	 *     - possible values:   "&lt;n&gt;", where n is zero or a positive integer
2677
	 *     - default:           "4"
2678
	 * </pre>
2679
	 */
2680
	public static final String FORMATTER_TAB_SIZE = CCorePlugin.PLUGIN_ID + ".formatter.tabulation.size"; //$NON-NLS-1$
2681
2682
	/**
2683
	 * <pre>
2684
	 * FORMATTER / Option to use tabulations only for leading indentations 
2685
	 *     - option id:         "org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations"
2686
	 *     - possible values:   { TRUE, FALSE }
2687
	 *     - default:           FALSE
2688
	 * </pre>
2689
	 * @see #TRUE
2690
	 * @see #FALSE
2691
	 */
2692
	public static final String FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS = CCorePlugin.PLUGIN_ID + ".formatter.use_tabs_only_for_leading_indentations"; //$NON-NLS-1$
2693
2694
	/**
2695
	 * <pre>
2696
	 * FORMATTER / The wrapping is done by indenting by one compare to the current indentation.
2697
	 * </pre>
2698
	 */
2699
	public static final int INDENT_BY_ONE= 2;
2700
	
2701
	/**
2702
	 * <pre>
2703
	 * FORMATTER / The wrapping is done by using the current indentation.
2704
	 * </pre>
2705
	 */
2706
	public static final int INDENT_DEFAULT= 0;
2707
	/**
2708
	 * <pre>
2709
	 * FORMATTER / The wrapping is done by indenting on column under the splitting location.
2710
	 * </pre>
2711
	 */
2712
	public static final int INDENT_ON_COLUMN = 1;
2713
	
2714
	/**
2715
	 * <pre>
2716
	 * FORMATTER / Possible value for the option FORMATTER_TAB_CHAR
2717
	 * </pre>
2718
	 * @see CCorePlugin#TAB
2719
	 * @see CCorePlugin#SPACE
2720
	 * @see #FORMATTER_TAB_CHAR
2721
	 */
2722
	public static final String MIXED = "mixed"; //$NON-NLS-1$
2723
//	/**
2724
//	 * <pre>
2725
//	 * FORMATTER / Value to set a brace location at the start of the next line with
2726
//	 *             the right indentation.
2727
//	 * </pre>
2728
//	 * @see #FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION
2729
//	 * @see #FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER
2730
//	 * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
2731
//	 * @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
2732
// 	 * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
2733
// 	 * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
2734
//	 * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
2735
//	 */
2736
//	public static final String NEXT_LINE = "next_line"; //$NON-NLS-1$
2737
//	/**
2738
//	 * <pre>
2739
//	 * FORMATTER / Value to set a brace location at the start of the next line if a wrapping
2740
//	 *             occured.
2741
//	 * </pre>
2742
//	 * @see #FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION
2743
//	 * @see #FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER
2744
//	 * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
2745
//	 * @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
2746
// 	 * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
2747
// 	 * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
2748
//	 * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
2749
//	 */
2750
//    public static final String NEXT_LINE_ON_WRAP = "next_line_on_wrap"; //$NON-NLS-1$
2751
	/**
2752
	 * <pre>
2753
	 * FORMATTER / Value to set a brace location at the start of the next line with
2754
	 *             an extra indentation.
2755
	 * </pre>
2756
	 * @see #FORMATTER_BRACE_POSITION_FOR_ANONYMOUS_TYPE_DECLARATION
2757
	 * @see #FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER
2758
	 * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
2759
	 * @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
2760
 	 * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
2761
 	 * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
2762
	 * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
2763
	 */
2764
	public static final String NEXT_LINE_SHIFTED = "next_line_shifted";	//$NON-NLS-1$
2765
	/**
2766
	 * <pre>
2767
	 * FORMATTER / Value to set an option to true.
2768
	 * </pre>
2769
	 */
2770
	public static final String TRUE = "true"; //$NON-NLS-1$
2771
	/**
2772
	 * <pre>
2773
	 * FORMATTER / The wrapping is done using as few lines as possible.
2774
	 * </pre>
2775
	 */
2776
	public static final int WRAP_COMPACT= 1;
2777
	/**
2778
	 * <pre>
2779
	 * FORMATTER / The wrapping is done putting the first element on a new
2780
	 *             line and then wrapping next elements using as few lines as possible.
2781
	 * </pre>
2782
	 */
2783
	public static final int WRAP_COMPACT_FIRST_BREAK= 2;
2784
	/**
2785
	 * <pre>
2786
	 * FORMATTER / The wrapping is done by putting each element on its own line
2787
	 *             except the first element.
2788
	 * </pre>
2789
	 */
2790
	public static final int WRAP_NEXT_PER_LINE= 5;
2791
	/**
2792
	 * <pre>
2793
	 * FORMATTER / The wrapping is done by putting each element on its own line.
2794
	 *             All elements are indented by one except the first element.
2795
	 * </pre>
2796
	 */
2797
	public static final int WRAP_NEXT_SHIFTED= 4;
2798
2799
	/**
2800
	 * <pre>
2801
	 * FORMATTER / Value to disable alignment.
2802
	 * </pre>
2803
	 */
2804
	public static final int WRAP_NO_SPLIT= 0;
2805
	/**
2806
	 * <pre>
2807
	 * FORMATTER / The wrapping is done by putting each element on its own line.
2808
	 * </pre>
2809
	 */
2810
	public static final int WRAP_ONE_PER_LINE= 3;
2811
2812
	/*
2813
	 * Private constants.
2814
	 */
2815
	private static final IllegalArgumentException WRONG_ARGUMENT = new IllegalArgumentException();
2816
	
2817
	/**
2818
	 * Create a new alignment value according to the given values. This must be used to set up
2819
	 * the alignment options.
2820
	 * 
2821
	 * @param forceSplit the given force value
2822
	 * @param wrapStyle the given wrapping style
2823
	 * @param indentStyle the given indent style
2824
	 * 
2825
	 * @return the new alignement value
2826
	 */
2827
	public static String createAlignmentValue(boolean forceSplit, int wrapStyle, int indentStyle) {
2828
		int alignmentValue = 0; 
2829
		switch(wrapStyle) {
2830
			case WRAP_COMPACT :
2831
				alignmentValue |= Alignment.M_COMPACT_SPLIT;
2832
				break;
2833
			case WRAP_COMPACT_FIRST_BREAK :
2834
				alignmentValue |= Alignment.M_COMPACT_FIRST_BREAK_SPLIT;
2835
				break;
2836
			case WRAP_NEXT_PER_LINE :
2837
				alignmentValue |= Alignment.M_NEXT_PER_LINE_SPLIT;
2838
				break;
2839
			case WRAP_NEXT_SHIFTED :
2840
				alignmentValue |= Alignment.M_NEXT_SHIFTED_SPLIT;
2841
				break;
2842
			case WRAP_ONE_PER_LINE :
2843
				alignmentValue |= Alignment.M_ONE_PER_LINE_SPLIT;
2844
				break;
2845
		}		
2846
		if (forceSplit) {
2847
			alignmentValue |= Alignment.M_FORCE;
2848
		}
2849
		switch(indentStyle) {
2850
			case INDENT_BY_ONE :
2851
				alignmentValue |= Alignment.M_INDENT_BY_ONE;
2852
				break;
2853
			case INDENT_ON_COLUMN :
2854
				alignmentValue |= Alignment.M_INDENT_ON_COLUMN;
2855
		}
2856
		return String.valueOf(alignmentValue);
2857
	}
2858
2859
	/**
2860
	 * Returns the default Eclipse formatter settings
2861
	 * 
2862
	 * @return the Eclipse default settings
2863
	 */
2864
	public static Map getEclipseDefaultSettings() {
2865
		return DefaultCodeFormatterOptions.getEclipseDefaultSettings().getMap();
2866
	}
2867
2868
	/**
2869
	 * <p>Return the force value of the given alignment value.
2870
	 * The given alignment value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
2871
	 * API.
2872
	 * </p>
2873
	 *
2874
	 * @param value the given alignment value
2875
	 * @return the force value of the given alignment value
2876
	 * @see #createAlignmentValue(boolean, int, int)
2877
	 * @exception IllegalArgumentException if the given alignment value is null, or if it 
2878
	 * doesn't have a valid format.
2879
	 */
2880
	public static boolean getForceWrapping(String value) {
2881
		if (value == null) {
2882
			throw WRONG_ARGUMENT;
2883
		}
2884
		try {
2885
			int existingValue = Integer.parseInt(value);
2886
			return (existingValue & Alignment.M_FORCE) != 0;
2887
		} catch (NumberFormatException e) {
2888
			throw WRONG_ARGUMENT;
2889
		}
2890
	}
2891
	
2892
	/**
2893
	 * <p>Return the indentation style of the given alignment value.
2894
	 * The given alignment value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
2895
	 * API.
2896
	 * </p>
2897
	 *
2898
	 * @param value the given alignment value
2899
	 * @return the indentation style of the given alignment value
2900
	 * @see #createAlignmentValue(boolean, int, int)
2901
	 * @exception IllegalArgumentException if the given alignment value is null, or if it 
2902
	 * doesn't have a valid format.
2903
	 */
2904
	public static int getIndentStyle(String value) {
2905
		if (value == null) {
2906
			throw WRONG_ARGUMENT;
2907
		}
2908
		try {
2909
			int existingValue = Integer.parseInt(value);
2910
			if ((existingValue & Alignment.M_INDENT_BY_ONE) != 0) {
2911
				return INDENT_BY_ONE;
2912
			} else if ((existingValue & Alignment.M_INDENT_ON_COLUMN) != 0) {
2913
				return INDENT_ON_COLUMN;
2914
			} else {
2915
				return INDENT_DEFAULT;
2916
			}
2917
		} catch (NumberFormatException e) {
2918
			throw WRONG_ARGUMENT;
2919
		}
2920
	}
2921
2922
	/**
2923
	 * <p>Return the wrapping style of the given alignment value.
2924
	 * The given alignment value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
2925
	 * API.
2926
	 * </p>
2927
	 *
2928
	 * @param value the given alignment value
2929
	 * @return the wrapping style of the given alignment value
2930
	 * @see #createAlignmentValue(boolean, int, int)
2931
	 * @exception IllegalArgumentException if the given alignment value is null, or if it 
2932
	 * doesn't have a valid format.
2933
	 */
2934
	public static int getWrappingStyle(String value) {
2935
		if (value == null) {
2936
			throw WRONG_ARGUMENT;
2937
		}
2938
		try {
2939
			int existingValue = Integer.parseInt(value) & Alignment.SPLIT_MASK;
2940
			switch(existingValue) {
2941
				case Alignment.M_COMPACT_SPLIT :
2942
					return WRAP_COMPACT;
2943
				case Alignment.M_COMPACT_FIRST_BREAK_SPLIT :
2944
					return WRAP_COMPACT_FIRST_BREAK;
2945
				case Alignment.M_NEXT_PER_LINE_SPLIT :
2946
					return WRAP_NEXT_PER_LINE;
2947
				case Alignment.M_NEXT_SHIFTED_SPLIT :
2948
					return WRAP_NEXT_SHIFTED;
2949
				case Alignment.M_ONE_PER_LINE_SPLIT :
2950
					return WRAP_ONE_PER_LINE;
2951
				default:
2952
					return WRAP_NO_SPLIT;
2953
			}
2954
		} catch (NumberFormatException e) {
2955
			throw WRONG_ARGUMENT;
2956
		}
2957
	}
2958
	/**
2959
	 * <p>Set the force value of the given alignment value and return the new value.
2960
	 * The given alignment value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
2961
	 * API.
2962
	 * </p>
2963
	 *
2964
	 * @param value the given alignment value
2965
	 * @param force the given force value
2966
	 * @return the new alignment value
2967
	 * @see #createAlignmentValue(boolean, int, int)
2968
	 * @exception IllegalArgumentException if the given alignment value is null, or if it 
2969
	 * doesn't have a valid format.
2970
	 */
2971
	public static String setForceWrapping(String value, boolean force) {
2972
		if (value == null) {
2973
			throw WRONG_ARGUMENT;
2974
		}
2975
		try {
2976
			int existingValue = Integer.parseInt(value);
2977
			// clear existing force bit
2978
			existingValue &= ~Alignment.M_FORCE;
2979
			if (force) {
2980
				existingValue |= Alignment.M_FORCE;
2981
			}
2982
			return String.valueOf(existingValue);
2983
		} catch (NumberFormatException e) {
2984
			throw WRONG_ARGUMENT;
2985
		}		
2986
	}
2987
	
2988
	/**
2989
	 * <p>Set the indentation style of the given alignment value and return the new value.
2990
	 * The given value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
2991
	 * API.
2992
	 * </p>
2993
	 *
2994
	 * @param value the given alignment value
2995
	 * @param indentStyle the given indentation style
2996
	 * @return the new alignment value
2997
	 * @see #INDENT_BY_ONE
2998
	 * @see #INDENT_DEFAULT
2999
	 * @see #INDENT_ON_COLUMN
3000
	 * @see #createAlignmentValue(boolean, int, int)
3001
	 * @exception IllegalArgumentException if the given alignment value is null, if the given
3002
	 * indentation style is not one of the possible indentation styles, or if the given
3003
	 * alignment value doesn't have a valid format.
3004
	 */
3005
	public static String setIndentStyle(String value, int indentStyle) {
3006
		if (value == null) {
3007
			throw WRONG_ARGUMENT;
3008
		}
3009
		switch(indentStyle) {
3010
			case INDENT_BY_ONE :
3011
			case INDENT_DEFAULT :
3012
			case INDENT_ON_COLUMN :
3013
				break;
3014
			default :
3015
				throw WRONG_ARGUMENT;
3016
		}
3017
		try {
3018
			int existingValue = Integer.parseInt(value);
3019
			// clear existing indent bits
3020
			existingValue &= ~(Alignment.M_INDENT_BY_ONE | Alignment.M_INDENT_ON_COLUMN);
3021
			switch(indentStyle) {
3022
				case INDENT_BY_ONE :
3023
					existingValue |= Alignment.M_INDENT_BY_ONE;
3024
					break;
3025
				case INDENT_ON_COLUMN :
3026
					existingValue |= Alignment.M_INDENT_ON_COLUMN;
3027
			}
3028
			return String.valueOf(existingValue);
3029
		} catch (NumberFormatException e) {
3030
			throw WRONG_ARGUMENT;
3031
		}
3032
	}
3033
	/**
3034
	 * <p>Set the wrapping style of the given alignment value and return the new value.
3035
	 * The given value should be created using the <code>createAlignmentValue(boolean, int, int)</code>
3036
	 * API.
3037
	 * </p>
3038
	 *
3039
	 * @param value the given alignment value
3040
	 * @param wrappingStyle the given wrapping style
3041
	 * @return the new alignment value
3042
	 * @see #WRAP_COMPACT
3043
	 * @see #WRAP_COMPACT_FIRST_BREAK
3044
	 * @see #WRAP_NEXT_PER_LINE
3045
	 * @see #WRAP_NEXT_SHIFTED
3046
	 * @see #WRAP_NO_SPLIT
3047
	 * @see #WRAP_ONE_PER_LINE
3048
	 * @see #createAlignmentValue(boolean, int, int)
3049
	 * @exception IllegalArgumentException if the given alignment value is null, if the given
3050
	 * wrapping style is not one of the possible wrapping styles, or if the given
3051
	 * alignment value doesn't have a valid format.
3052
	 */
3053
	public static String setWrappingStyle(String value, int wrappingStyle) {
3054
		if (value == null) {
3055
			throw WRONG_ARGUMENT;
3056
		}
3057
		switch(wrappingStyle) {
3058
			case WRAP_COMPACT :
3059
			case WRAP_COMPACT_FIRST_BREAK :
3060
			case WRAP_NEXT_PER_LINE :
3061
			case WRAP_NEXT_SHIFTED :
3062
			case WRAP_NO_SPLIT :
3063
			case WRAP_ONE_PER_LINE :
3064
				break;
3065
			default:
3066
				throw WRONG_ARGUMENT;
3067
		}
3068
		try {
3069
			int existingValue = Integer.parseInt(value);
3070
			// clear existing split bits
3071
			existingValue &= ~(Alignment.SPLIT_MASK);
3072
			switch(wrappingStyle) {
3073
				case WRAP_COMPACT :
3074
					existingValue |= Alignment.M_COMPACT_SPLIT;
3075
					break;
3076
				case WRAP_COMPACT_FIRST_BREAK :
3077
					existingValue |= Alignment.M_COMPACT_FIRST_BREAK_SPLIT;
3078
					break;
3079
				case WRAP_NEXT_PER_LINE :
3080
					existingValue |= Alignment.M_NEXT_PER_LINE_SPLIT;
3081
					break;
3082
				case WRAP_NEXT_SHIFTED :
3083
					existingValue |= Alignment.M_NEXT_SHIFTED_SPLIT;
3084
					break;
3085
				case WRAP_ONE_PER_LINE :
3086
					existingValue |= Alignment.M_ONE_PER_LINE_SPLIT;
3087
					break;
3088
			}
3089
			return String.valueOf(existingValue);
3090
		} catch (NumberFormatException e) {
3091
			throw WRONG_ARGUMENT;
3092
		}
3093
	}
3094
}
(-)src/org/eclipse/cdt/internal/corext/template/c/CFormatter.java (-259 / +261 lines)
Lines 9-43 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Qnx Software System
10
 *     Qnx Software System
11
 *     Anton Leherbauer (Wind River Systems) - Fixed bug 126617
11
 *     Anton Leherbauer (Wind River Systems) - Fixed bug 126617
12
 *     Sergey Prigogin, Google
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.cdt.internal.corext.template.c;
14
package org.eclipse.cdt.internal.corext.template.c;
14
15
15
import java.util.ArrayList;
16
import java.util.ArrayList;
17
import java.util.HashMap;
16
import java.util.Iterator;
18
import java.util.Iterator;
17
import java.util.List;
19
import java.util.List;
18
import java.util.Map;
20
import java.util.Map;
19
21
20
import org.eclipse.cdt.core.CCorePlugin;
22
import org.eclipse.cdt.core.CCorePlugin;
21
import org.eclipse.cdt.core.formatter.CodeFormatter;
23
import org.eclipse.cdt.core.formatter.CodeFormatter;
24
import org.eclipse.cdt.core.model.ICProject;
25
22
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
26
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
23
import org.eclipse.cdt.internal.ui.editor.CEditor;
27
import org.eclipse.cdt.internal.ui.editor.IndentUtil;
24
import org.eclipse.cdt.internal.ui.util.Strings;
28
import org.eclipse.cdt.internal.ui.text.FastCPartitionScanner;
25
import org.eclipse.cdt.ui.CUIPlugin;
29
import org.eclipse.cdt.ui.text.ICPartitions;
26
import org.eclipse.jface.preference.IPreferenceStore;
30
31
import org.eclipse.jface.text.Assert;
27
import org.eclipse.jface.text.BadLocationException;
32
import org.eclipse.jface.text.BadLocationException;
33
import org.eclipse.jface.text.BadPositionCategoryException;
28
import org.eclipse.jface.text.Document;
34
import org.eclipse.jface.text.Document;
29
import org.eclipse.jface.text.IDocument;
35
import org.eclipse.jface.text.IDocument;
30
import org.eclipse.jface.text.IRegion;
36
import org.eclipse.jface.text.IRegion;
37
import org.eclipse.jface.text.Position;
38
import org.eclipse.jface.text.TypedPosition;
39
import org.eclipse.jface.text.rules.FastPartitioner;
40
import org.eclipse.jface.text.source.LineRange;
41
import org.eclipse.jface.text.templates.DocumentTemplateContext;
31
import org.eclipse.jface.text.templates.TemplateBuffer;
42
import org.eclipse.jface.text.templates.TemplateBuffer;
43
import org.eclipse.jface.text.templates.TemplateContext;
32
import org.eclipse.jface.text.templates.TemplateVariable;
44
import org.eclipse.jface.text.templates.TemplateVariable;
33
import org.eclipse.text.edits.DeleteEdit;
34
import org.eclipse.text.edits.InsertEdit;
35
import org.eclipse.text.edits.MalformedTreeException;
45
import org.eclipse.text.edits.MalformedTreeException;
36
import org.eclipse.text.edits.MultiTextEdit;
46
import org.eclipse.text.edits.MultiTextEdit;
37
import org.eclipse.text.edits.RangeMarker;
47
import org.eclipse.text.edits.RangeMarker;
38
import org.eclipse.text.edits.ReplaceEdit;
48
import org.eclipse.text.edits.ReplaceEdit;
39
import org.eclipse.text.edits.TextEdit;
49
import org.eclipse.text.edits.TextEdit;
40
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
41
50
42
51
43
/**
52
/**
Lines 45-50 Link Here
45
 */
54
 */
46
public class CFormatter {
55
public class CFormatter {
47
56
57
	private static final String COMMENT_START= "/*-"; //$NON-NLS-1$
58
	private static final String COMMENT_END= "*/"; //$NON-NLS-1$
48
//	private static final String CURSOR= "cursor"; //$NON-NLS-1$
59
//	private static final String CURSOR= "cursor"; //$NON-NLS-1$
49
//	private static final String MARKER= "/*${cursor}*/"; //$NON-NLS-1$
60
//	private static final String MARKER= "/*${cursor}*/"; //$NON-NLS-1$
50
61
Lines 55-94 Link Here
55
	
66
	
56
	/** Flag indicating whether to use the code formatter or not. */
67
	/** Flag indicating whether to use the code formatter or not. */
57
	private boolean fUseCodeFormatter;
68
	private boolean fUseCodeFormatter;
69
	private final ICProject fProject;
58
70
59
	public CFormatter(String lineDelimiter, int initialIndentLevel, boolean useCodeFormatter) {
71
	/**
72
	 * Creates a CFormatter with the target line delimiter.
73
	 * 
74
	 * @param lineDelimiter the line delimiter to use
75
	 * @param initialIndentLevel the initial indentation level
76
	 * @param useCodeFormatter <code>true</code> if the core code formatter should be used
77
	 * @param project the C/C++ project from which to get the preferences, or <code>null</code> for workbench settings
78
	 */
79
	public CFormatter(String lineDelimiter, int initialIndentLevel, boolean useCodeFormatter, ICProject project) {
60
		fLineDelimiter= lineDelimiter;
80
		fLineDelimiter= lineDelimiter;
61
		fUseCodeFormatter= useCodeFormatter;
81
		fUseCodeFormatter= useCodeFormatter;
62
		fInitialIndentLevel= initialIndentLevel;
82
		fInitialIndentLevel= initialIndentLevel;
83
		fProject= project;
63
	}
84
	}
64
85
65
	public void edit(TemplateBuffer buffer, CContext context, int indentationLevel) throws BadLocationException {		
86
	/**
87
	 * Formats the template buffer.
88
	 * @param buffer
89
	 * @param context
90
	 * @throws BadLocationException
91
	 */
92
	public void format(TemplateBuffer buffer, TemplateContext context) throws BadLocationException {
66
		try {
93
		try {
67
			if (fUseCodeFormatter)
94
			VariableTracker tracker= new VariableTracker(buffer);
68
				// try to format and fall back to indenting
95
			IDocument document= tracker.getDocument();
69
				try {
96
			
70
					format(buffer, context);
97
			internalFormat(document, context);
71
				} catch (BadLocationException e) {
98
			convertLineDelimiters(document);
72
					indent(buffer);
99
			if (!isReplacedAreaEmpty(context))
73
				} catch (MalformedTreeException e) {
100
				trimStart(document);
74
					indent(buffer);
75
				}
76
			else {
77
				indent(buffer);
78
			}
79
80
			// don't trim the buffer if the replacement area is empty
81
			// case: surrounding empty lines with block
82
			if (context.getStart() == context.getCompletionOffset())
83
				if (context.getDocument().get(context.getStart(), context.getEnd() - context.getEnd()).trim().length() == 0)
84
					return;
85
			
101
			
86
			trimBegin(buffer);
102
			tracker.updateBuffer();
87
		} catch (MalformedTreeException e) {
103
		} catch (MalformedTreeException e) {
88
			throw new BadLocationException();
104
			throw new BadLocationException();
89
		}
105
		}
90
	}
106
	}
91
107
108
	/**
109
	 * @param document
110
	 * @param context
111
	 * @throws BadLocationException
112
	 */
113
	private void internalFormat(IDocument document, TemplateContext context) throws BadLocationException {
114
		if (fUseCodeFormatter) {
115
			// try to format and fall back to indenting
116
			try {
117
				format(document, (TranslationUnitContext) context);
118
			} catch (BadLocationException e) {
119
				indent(document);
120
			} catch (MalformedTreeException e) {
121
				indent(document);
122
			}
123
		} else { 
124
			indent(document);
125
		}
126
	}
127
128
	private void convertLineDelimiters(IDocument document) throws BadLocationException {
129
		int lines= document.getNumberOfLines();
130
		for (int line= 0; line < lines; line++) {
131
			IRegion region= document.getLineInformation(line);
132
			String lineDelimiter= document.getLineDelimiter(line);
133
			if (lineDelimiter != null)
134
				document.replace(region.getOffset() + region.getLength(), lineDelimiter.length(), fLineDelimiter);
135
		}
136
	}
137
138
	private void trimStart(IDocument document) throws BadLocationException {
139
		int i= 0;
140
		while ((i != document.getLength()) && Character.isWhitespace(document.getChar(i)))
141
			i++;
142
		
143
		document.replace(0, i, ""); //$NON-NLS-1$
144
	}
145
146
	private boolean isReplacedAreaEmpty(TemplateContext context) {
147
		// don't trim the buffer if the replacement area is empty
148
		// case: surrounding empty lines with block
149
		if (context instanceof DocumentTemplateContext) {
150
			DocumentTemplateContext dtc= (DocumentTemplateContext) context;
151
			if (dtc.getStart() == dtc.getCompletionOffset())
152
				try {
153
					if (dtc.getDocument().get(dtc.getStart(), dtc.getEnd() - dtc.getStart()).trim().length() == 0)
154
						return true;
155
				} catch (BadLocationException x) {
156
					// ignore - this may happen when the document was modified after the initial invocation, and the
157
					// context does not track the changes properly - don't trim in that case
158
					return true;
159
				}
160
		}
161
		return false;
162
	}
163
92
//	private static int getCaretOffset(TemplateVariable[] variables) {
164
//	private static int getCaretOffset(TemplateVariable[] variables) {
93
//	    for (int i= 0; i != variables.length; i++) {
165
//	    for (int i= 0; i != variables.length; i++) {
94
//	        TemplateVariable variable= variables[i];
166
//	        TemplateVariable variable= variables[i];
Lines 119-170 Link Here
119
//		}
191
//		}
120
//	}
192
//	}
121
193
122
	private void format(TemplateBuffer templateBuffer, CContext context) throws BadLocationException {
194
	private void format(IDocument doc, TranslationUnitContext context) throws BadLocationException {
123
		// XXX 4360, 15247
124
		// workaround for code formatter limitations
125
		// handle a special case where cursor position is surrounded by whitespaces		
126
127
//		String string= templateBuffer.getString();
128
//		TemplateVariable[] variables= templateBuffer.getVariables();
129
//
130
//		int caretOffset= getCaretOffset(variables);
131
//		if ((caretOffset > 0) && Character.isWhitespace(string.charAt(caretOffset - 1)) &&
132
//			(caretOffset < string.length()) && Character.isWhitespace(string.charAt(caretOffset)) &&
133
//			! isInsideCommentOrString(string, caretOffset))
134
//		{
135
//			List positions= variablesToPositions(variables);
136
//
137
//		    TextEdit insert= new InsertEdit(caretOffset, MARKER);
138
//		    string= edit(string, positions, insert);
139
//			positionsToVariables(positions, variables);
140
//		    templateBuffer.setContent(string, variables);
141
//
142
//			plainFormat(templateBuffer, context);			
143
//
144
//			string= templateBuffer.getString();
145
//			variables= templateBuffer.getVariables();
146
//			caretOffset= getCaretOffset(variables);
147
//
148
//			positions= variablesToPositions(variables);
149
//			TextEdit delete= new DeleteEdit(caretOffset, MARKER.length());
150
//		    string= edit(string, positions, delete);
151
//			positionsToVariables(positions, variables);		    
152
//		    templateBuffer.setContent(string, variables);
153
//	
154
//		} else {
155
//			plainFormat(templateBuffer, context);			
156
//		}	    
157
		plainFormat(templateBuffer, context);			
158
	}
159
	
160
	private void plainFormat(TemplateBuffer templateBuffer, CContext context) throws BadLocationException {
161
		
162
		IDocument doc= new Document(templateBuffer.getString());
163
		
164
		TemplateVariable[] variables= templateBuffer.getVariables();
165
		
166
		List offsets= variablesToPositions(variables);
167
		
168
		Map options;
195
		Map options;
169
		if (context.getTranslationUnit() != null)
196
		if (context.getTranslationUnit() != null)
170
			options= context.getTranslationUnit().getCProject().getOptions(true); 
197
			options= context.getTranslationUnit().getCProject().getOptions(true); 
Lines 175-383 Link Here
175
		if (edit == null)
202
		if (edit == null)
176
			throw new BadLocationException(); // fall back to indenting
203
			throw new BadLocationException(); // fall back to indenting
177
		
204
		
178
		MultiTextEdit root;
205
		edit.apply(doc, TextEdit.UPDATE_REGIONS);
179
		if (edit instanceof MultiTextEdit)
180
			root= (MultiTextEdit) edit;
181
		else {
182
			root= new MultiTextEdit(0, doc.getLength());
183
			root.addChild(edit);
184
		}
185
		for (Iterator it= offsets.iterator(); it.hasNext();) {
186
			TextEdit position= (TextEdit) it.next();
187
			try {
188
				root.addChild(position);
189
			} catch (MalformedTreeException e) {
190
				// position conflicts with formatter edit
191
				// ignore this position
192
			}
193
		}
194
		
195
		root.apply(doc, TextEdit.UPDATE_REGIONS);
196
		
197
		positionsToVariables(offsets, variables);
198
		
199
		templateBuffer.setContent(doc.get(), variables);	    
200
	}	
206
	}	
201
207
202
	private void indent(TemplateBuffer templateBuffer) throws BadLocationException, MalformedTreeException {
208
	private void indent(IDocument document) throws BadLocationException, MalformedTreeException {
203
204
		TemplateVariable[] variables= templateBuffer.getVariables();
205
		List positions= variablesToPositions(variables);
206
		
207
		IDocument document= new Document(templateBuffer.getString());
208
		MultiTextEdit root= new MultiTextEdit(0, document.getLength());
209
		root.addChildren((TextEdit[]) positions.toArray(new TextEdit[positions.size()]));
210
		
211
		IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
212
		boolean useSpaces = store.getBoolean(CEditor.SPACES_FOR_TABS);
213
		int tabWidth = store
214
				.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
215
		int indentWidth = tabWidth;
216
		String indent = createIndentString(fInitialIndentLevel * indentWidth, tabWidth, useSpaces);
217
218
		// first line
209
		// first line
219
		int offset= document.getLineOffset(0);
210
		int offset= document.getLineOffset(0);
220
		TextEdit edit= new InsertEdit(offset, indent);
211
		document.replace(offset, 0, CodeFormatterUtil.createIndentString(fInitialIndentLevel, fProject));
221
		root.addChild(edit);
222
		root.apply(document, TextEdit.UPDATE_REGIONS);
223
		root.removeChild(edit);
224
		formatDelimiter(document, root, 0);
225
		
212
		
226
		// following lines
213
		// following lines
227
	    int lineCount= document.getNumberOfLines();
214
		int lineCount= document.getNumberOfLines();
228
	    
215
		IndentUtil.indentLines(document, new LineRange(1, lineCount - 1), fProject, null);
229
	    for (int line= 1; line < lineCount; line++) {
230
			IRegion region= document.getLineInformation(line);
231
			String lineContent= document.get(region.getOffset(), region.getLength());
232
			String lineIndent= Strings.getIndentString(lineContent, tabWidth);
233
			int lineIndentLevel= Strings.computeIndent(lineIndent, tabWidth);
234
			indent= createIndentString((fInitialIndentLevel + lineIndentLevel) * indentWidth, tabWidth, useSpaces);
235
	    	edit= new ReplaceEdit(region.getOffset(), lineIndent.length(), indent);
236
			root.addChild(edit);
237
			root.apply(document, TextEdit.UPDATE_REGIONS);
238
			root.removeChild(edit);
239
240
			formatDelimiter(document, root, line);
241
	    }
242
	    
243
		positionsToVariables(positions, variables);
244
		templateBuffer.setContent(document.get(), variables);
245
	}
216
	}
246
217
247
	/**
218
	/**
248
	 * Changes the delimiter to the configured line delimiter.
219
	 * Wraps a {@link TemplateBuffer} and tracks the variable offsets while changes to the buffer
249
	 * 
220
	 * occur. Whitespace variables are also tracked.
250
	 * @param document the temporary document being edited
251
	 * @param root the root edit containing all positions that will be updated along the way
252
	 * @param line the line to format
253
	 * @throws BadLocationException if applying the changes fails
254
	 */
221
	 */
255
	private void formatDelimiter(IDocument document, MultiTextEdit root, int line) throws BadLocationException {
222
	private static final class VariableTracker {
256
		IRegion region= document.getLineInformation(line);
223
		private static final String CATEGORY= "__template_variables"; //$NON-NLS-1$
257
		String lineDelimiter= document.getLineDelimiter(line);
224
		private Document fDocument;
258
		if (lineDelimiter != null) {
225
		private final TemplateBuffer fBuffer;
259
			TextEdit edit= new ReplaceEdit(region.getOffset() + region.getLength(), lineDelimiter.length(), fLineDelimiter);
226
		private List fPositions;
260
			root.addChild(edit);
227
		
261
			root.apply(document, TextEdit.UPDATE_REGIONS);
228
		/**
262
			root.removeChild(edit);
229
		 * Creates a new tracker.
230
		 * 
231
		 * @param buffer the buffer to track
232
		 * @throws MalformedTreeException
233
		 * @throws BadLocationException
234
		 */
235
		public VariableTracker(TemplateBuffer buffer) throws MalformedTreeException, BadLocationException {
236
			Assert.isLegal(buffer != null);
237
			fBuffer= buffer;
238
			fDocument= new Document(fBuffer.getString());
239
			installCStuff(fDocument);
240
			fDocument.addPositionCategory(CATEGORY);
241
			fDocument.addPositionUpdater(new ExclusivePositionUpdater(CATEGORY));
242
			fPositions= createRangeMarkers(fBuffer.getVariables(), fDocument);
263
		}
243
		}
264
	}
265
266
	private static void trimBegin(TemplateBuffer templateBuffer) throws BadLocationException {
267
		String string= templateBuffer.getString();
268
		TemplateVariable[] variables= templateBuffer.getVariables();
269
270
		List positions= variablesToPositions(variables);
271
272
		int i= 0;
273
		while ((i != string.length()) && Character.isWhitespace(string.charAt(i)))
274
			i++;
275
276
		string= edit(string, positions, new DeleteEdit(0, i));
277
		positionsToVariables(positions, variables);
278
279
		templateBuffer.setContent(string, variables);
280
	}
281
	
282
	private static String edit(String string, List positions, TextEdit edit) throws BadLocationException {
283
		MultiTextEdit root= new MultiTextEdit(0, string.length());
284
		root.addChildren((TextEdit[]) positions.toArray(new TextEdit[positions.size()]));
285
		root.addChild(edit);
286
		IDocument document= new Document(string);
287
		root.apply(document);
288
		
244
		
289
		return document.get();		
245
		/**
290
	}
246
		 * Installs a C partitioner with <code>document</code>.
291
247
		 *
292
	/**
248
		 * @param document the document
293
	 * Create an indent string suitable as line prefix using the given
249
		 */
294
	 * formatting options.
250
		private static void installCStuff(Document document) {
295
	 * 
251
			String[] types= new String[] {
296
	 * @param displayedWidth
252
					ICPartitions.C_MULTI_LINE_COMMENT,
297
	 *            the desired displayed width (in char units)
253
					ICPartitions.C_SINGLE_LINE_COMMENT,
298
	 * @param tabWidth
254
					ICPartitions.C_STRING,
299
	 *            the displayed tab width
255
					ICPartitions.C_CHARACTER,
300
	 * @param useSpaces
256
					IDocument.DEFAULT_CONTENT_TYPE
301
	 *            if <code>true</code>, only spaces are used for the indent
257
			};
302
	 *            string, otherwise, the indent string will contain mixed tabs
258
			FastPartitioner partitioner= new FastPartitioner(new FastCPartitionScanner(), types);
303
	 *            and spaces.
259
			partitioner.connect(document);
304
	 * @return the new indent string
260
			document.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner);
305
	 */
261
		}
306
	private static String createIndentString(int displayedWidth,
262
		
307
			int tabWidth, boolean useSpaces) {
263
		/**
308
		return appendIndentString(new StringBuffer(displayedWidth),
264
		 * Returns the document with the buffer contents. Whitespace variables are decorated with
309
				displayedWidth, tabWidth, useSpaces, 0).toString();
265
		 * comments.
310
	}
266
		 * 
311
267
		 * @return the buffer document
312
	/**
268
		 */
313
	 * Append an indent string to the given buffer so that the resulting string
269
		public IDocument getDocument() {
314
	 * ends at the desired column.
270
			checkState();
315
	 * 
271
			return fDocument;
316
	 * @param buffer
272
		}
317
	 *            the StringBuffer to append to
273
		
318
	 * @param displayedWidth
274
		private void checkState() {
319
	 *            the desired displayed width (in char units)
275
			if (fDocument == null)
320
	 * @param tabWidth
276
				throw new IllegalStateException();
321
	 *            the displayed tab width
322
	 * @param useSpaces
323
	 *            if <code>true</code>, only spaces are used for the indent
324
	 *            string, otherwise, the indent string will contain mixed tabs
325
	 *            and spaces.
326
	 * @param startColumn
327
	 *            the displayed starting column to correctly identify the tab
328
	 *            stops
329
	 * @return the same StringBuffer as provided
330
	 */
331
	private static StringBuffer appendIndentString(StringBuffer buffer,
332
			int displayedWidth, int tabWidth, boolean useSpaces, int startColumn) {
333
		int tabStop= startColumn - startColumn % tabWidth;
334
		int tabs= useSpaces ? 0 : (displayedWidth - tabStop) / tabWidth;
335
		for (int i= 0; i < tabs; ++i) {
336
			buffer.append('\t');
337
			tabStop += tabWidth;
338
			startColumn= tabStop;
339
		}
340
		int spaces= displayedWidth - startColumn;
341
		for (int i= 0; i < spaces; ++i) {
342
			buffer.append(' ');
343
		}
277
		}
344
		return buffer;
345
	}
346
278
347
	private static List variablesToPositions(TemplateVariable[] variables) {
279
		/**
348
   		List positions= new ArrayList(5);
280
		 * Restores any decorated regions and updates the buffer's variable offsets.
349
		for (int i= 0; i != variables.length; i++) {
281
		 * 
350
		    int[] offsets= variables[i].getOffsets();
282
		 * @return the buffer.
351
		    
283
		 * @throws MalformedTreeException
352
		    // trim positions off whitespace
284
		 * @throws BadLocationException
353
		    String value= variables[i].getDefaultValue();
285
		 */
354
		    int wsStart= 0;
286
		public TemplateBuffer updateBuffer() throws MalformedTreeException, BadLocationException {
355
		    while (wsStart < value.length() && Character.isWhitespace(value.charAt(wsStart)) && !Strings.isLineDelimiterChar(value.charAt(wsStart)))
287
			checkState();
356
		    	wsStart++;
288
			TemplateVariable[] variables= fBuffer.getVariables();
357
		    
289
			try {
358
		    variables[i].getValues()[0]= value.substring(wsStart);
290
				removeRangeMarkers(fPositions, fDocument, variables);
359
		    
291
			} catch (BadPositionCategoryException x) {
360
		    for (int j= 0; j != offsets.length; j++) {
292
				Assert.isTrue(false);
361
		    	offsets[j] += wsStart;
293
			}
362
				positions.add(new RangeMarker(offsets[j], 0));
294
			fBuffer.setContent(fDocument.get(), variables);
363
		    }
295
			fDocument= null;
296
			
297
			return fBuffer;
364
		}
298
		}
365
		return positions;	    
366
	}
367
	
368
	private static void positionsToVariables(List positions, TemplateVariable[] variables) {
369
		Iterator iterator= positions.iterator();
370
		
299
		
371
		for (int i= 0; i != variables.length; i++) {
300
		private List createRangeMarkers(TemplateVariable[] variables, IDocument document) throws MalformedTreeException, BadLocationException {
372
		    TemplateVariable variable= variables[i];
301
			Map markerToOriginal= new HashMap();
373
		    
302
			
374
			int[] offsets= new int[variable.getOffsets().length];
303
			MultiTextEdit root= new MultiTextEdit(0, document.getLength());
375
			for (int j= 0; j != offsets.length; j++)
304
			List edits= new ArrayList();
376
				offsets[j]= ((TextEdit) iterator.next()).getOffset();
305
			boolean hasModifications= false;
306
			for (int i= 0; i != variables.length; i++) {
307
				final TemplateVariable variable= variables[i];
308
				int[] offsets= variable.getOffsets();
309
				
310
				String value= variable.getDefaultValue();
311
				if (isWhitespaceVariable(value)) {
312
					// replace whitespace positions with unformattable comments
313
					String placeholder= COMMENT_START + value + COMMENT_END;
314
					for (int j= 0; j != offsets.length; j++) {
315
						ReplaceEdit replace= new ReplaceEdit(offsets[j], value.length(), placeholder);
316
						root.addChild(replace);
317
						hasModifications= true;
318
						markerToOriginal.put(replace, value);
319
						edits.add(replace);
320
					}
321
				} else {
322
					for (int j= 0; j != offsets.length; j++) {
323
						RangeMarker marker= new RangeMarker(offsets[j], value.length());
324
						root.addChild(marker);
325
						edits.add(marker);
326
					}
327
				}
328
			}
329
			
330
			if (hasModifications) {
331
				// update the document and convert the replaces to markers
332
				root.apply(document, TextEdit.UPDATE_REGIONS);
333
			}
334
			
335
			List positions= new ArrayList();
336
			for (Iterator it= edits.iterator(); it.hasNext();) {
337
				TextEdit edit= (TextEdit) it.next();
338
				try {
339
					// abuse TypedPosition to piggy back the original contents of the position
340
					final TypedPosition pos= new TypedPosition(edit.getOffset(), edit.getLength(), (String) markerToOriginal.get(edit));
341
					document.addPosition(CATEGORY, pos);
342
					positions.add(pos);
343
				} catch (BadPositionCategoryException x) {
344
					Assert.isTrue(false);
345
				}
346
			}
377
			
347
			
378
		 	variable.setOffsets(offsets);   
348
			return positions;
379
		}
349
		}
380
	}	
350
		
351
		private boolean isWhitespaceVariable(String value) {
352
			int length= value.length();
353
			return length == 0 || Character.isWhitespace(value.charAt(0)) || Character.isWhitespace(value.charAt(length - 1));
354
		}
355
		
356
		private void removeRangeMarkers(List positions, IDocument document, TemplateVariable[] variables) throws MalformedTreeException, BadLocationException, BadPositionCategoryException {
357
			
358
			// revert previous changes
359
			for (Iterator it= positions.iterator(); it.hasNext();) {
360
				TypedPosition position= (TypedPosition) it.next();
361
				// remove and re-add in order to not confuse ExclusivePositionUpdater
362
				document.removePosition(CATEGORY, position);
363
				final String original= position.getType();
364
				if (original != null) {
365
					document.replace(position.getOffset(), position.getLength(), original);
366
					position.setLength(original.length());
367
				}
368
				document.addPosition(position);
369
			}
370
			
371
			Iterator it= positions.iterator();
372
			for (int i= 0; i != variables.length; i++) {
373
				TemplateVariable variable= variables[i];
374
375
				int[] offsets= new int[variable.getOffsets().length];
376
				for (int j= 0; j != offsets.length; j++)
377
					offsets[j]= ((Position) it.next()).getOffset();
381
378
379
				variable.setOffsets(offsets);   
380
			}
381
382
		}
383
	}
382
}
384
}
383
385
(-)src/org/eclipse/cdt/internal/corext/template/c/CContext.java (-9 / +9 lines)
Lines 11-25 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.corext.template.c;
12
package org.eclipse.cdt.internal.corext.template.c;
13
13
14
import org.eclipse.cdt.core.model.ICProject;
14
import org.eclipse.cdt.core.model.ITranslationUnit;
15
import org.eclipse.cdt.core.model.ITranslationUnit;
15
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
16
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
16
import org.eclipse.cdt.internal.ui.util.Strings;
17
import org.eclipse.cdt.internal.ui.util.Strings;
17
import org.eclipse.cdt.ui.CUIPlugin;
18
import org.eclipse.cdt.ui.CUIPlugin;
18
import org.eclipse.cdt.ui.PreferenceConstants;
19
import org.eclipse.cdt.ui.PreferenceConstants;
20
19
import org.eclipse.jface.preference.IPreferenceStore;
21
import org.eclipse.jface.preference.IPreferenceStore;
20
import org.eclipse.jface.text.BadLocationException;
22
import org.eclipse.jface.text.BadLocationException;
21
import org.eclipse.jface.text.IDocument;
23
import org.eclipse.jface.text.IDocument;
22
import org.eclipse.jface.text.IRegion;
24
import org.eclipse.jface.text.IRegion;
25
import org.eclipse.jface.text.TextUtilities;
23
import org.eclipse.jface.text.templates.Template;
26
import org.eclipse.jface.text.templates.Template;
24
import org.eclipse.jface.text.templates.TemplateBuffer;
27
import org.eclipse.jface.text.templates.TemplateBuffer;
25
import org.eclipse.jface.text.templates.TemplateContextType;
28
import org.eclipse.jface.text.templates.TemplateContextType;
Lines 27-33 Link Here
27
import org.eclipse.jface.text.templates.TemplateTranslator;
30
import org.eclipse.jface.text.templates.TemplateTranslator;
28
31
29
32
30
31
/**
33
/**
32
 * A context for c/c++
34
 * A context for c/c++
33
 */
35
 */
Lines 148-174 Link Here
148
		IPreferenceStore prefs= CUIPlugin.getDefault().getPreferenceStore();
150
		IPreferenceStore prefs= CUIPlugin.getDefault().getPreferenceStore();
149
		boolean useCodeFormatter= prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);			
151
		boolean useCodeFormatter= prefs.getBoolean(PreferenceConstants.TEMPLATES_USE_CODEFORMATTER);			
150
152
151
		CFormatter formatter= new CFormatter(lineDelimiter, getIndentation(), useCodeFormatter);
153
		ICProject project= getTranslationUnit() != null ? getTranslationUnit().getCProject() : null;
152
		formatter.edit(buffer, this, getIndentation());					
154
		CFormatter formatter= new CFormatter(TextUtilities.getDefaultLineDelimiter(getDocument()), getIndentationLevel(project), useCodeFormatter, project);
155
		formatter.format(buffer, this);
156
		
153
		return buffer;
157
		return buffer;
154
	}
158
	}
155
159
156
	/**
160
	/**
157
	 * Returns the indentation level at the position of code completion.
161
	 * Returns the indentation level at the position of code completion.
158
	 */
162
	 */
159
	private int getIndentation() {
163
	private int getIndentationLevel(ICProject project) {
160
		int start= getStart();
164
		int start= getStart();
161
		IDocument document= getDocument();
165
		IDocument document= getDocument();
162
		try {
166
		try {
163
			IRegion region= document.getLineInformationOfOffset(start);
167
			IRegion region= document.getLineInformationOfOffset(start);
164
			String lineContent= document.get(region.getOffset(), region.getLength());
168
			String lineContent= document.get(region.getOffset(), region.getLength());
165
			return Strings.computeIndent(lineContent, CodeFormatterUtil.getTabWidth());
169
			return Strings.computeIndent(lineContent, CodeFormatterUtil.getTabWidth(project), CodeFormatterUtil.getIndentWidth(project));
166
		} catch (BadLocationException e) {
170
		} catch (BadLocationException e) {
167
			return 0;
171
			return 0;
168
		}
172
		}
169
	}	
173
	}	
170
171
}
174
}
172
173
174
(-)src/org/eclipse/cdt/ui/dialogs/CodeFormatterBlock.java (-168 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 QNX Software Systems and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     QNX Software Systems - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.ui.dialogs;
13
14
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.Map;
17
18
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IExtension;
20
import org.eclipse.core.runtime.IExtensionPoint;
21
import org.eclipse.core.runtime.Platform;
22
import org.eclipse.core.runtime.Preferences;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.events.SelectionAdapter;
25
import org.eclipse.swt.events.SelectionEvent;
26
import org.eclipse.swt.layout.GridData;
27
import org.eclipse.swt.layout.GridLayout;
28
import org.eclipse.swt.widgets.Combo;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Control;
31
import org.eclipse.swt.widgets.Label;
32
import org.eclipse.ui.PlatformUI;
33
34
import org.eclipse.cdt.core.CCorePlugin;
35
import org.eclipse.cdt.core.CCorePreferenceConstants;
36
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
37
38
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
39
import org.eclipse.cdt.internal.ui.preferences.PreferencesMessages;
40
41
/**
42
 * 
43
 */
44
public class CodeFormatterBlock {
45
46
	private HashMap idMap = new HashMap();
47
	Preferences fPrefs;
48
	protected Combo fFormatterCombo;
49
	private static final String ATTR_NAME = "name"; //$NON-NLS-1$
50
	private static final String ATTR_ID="id"; //$NON-NLS-1$
51
	// This is a hack until we have a default Formatter.
52
	// For now it is comment out in the plugin.xml
53
	private static final String NONE=PreferencesMessages.getString("CodeFormatterPreferencePage.emptyName"); //$NON-NLS-1$
54
55
56
	public CodeFormatterBlock(Preferences prefs) {
57
		fPrefs = prefs;
58
		initializeFormatters();
59
	}
60
61
	public void performOk() {
62
		String text = fFormatterCombo.getText();
63
		String selection = (String)idMap.get(text);
64
		if (selection != null && selection.length() > 0) {
65
			HashMap options = CCorePlugin.getOptions();
66
			String formatterID = (String)options.get(CCorePreferenceConstants.CODE_FORMATTER);
67
			if (formatterID == null || !formatterID.equals(selection)) {
68
				options.put(CCorePreferenceConstants.CODE_FORMATTER, selection);
69
				CCorePlugin.setOptions(options);
70
			}
71
		} else {
72
			// simply reset to the default one.
73
			performDefaults();
74
		}
75
	}
76
77
	public void performDefaults() {
78
		HashMap optionsDefault = CCorePlugin.getDefaultOptions();
79
		HashMap options = CCorePlugin.getOptions();
80
		String formatterID = (String)optionsDefault.get(CCorePreferenceConstants.CODE_FORMATTER);
81
		options.put(CCorePreferenceConstants.CODE_FORMATTER, formatterID);
82
		CCorePlugin.setOptions(options);
83
84
		fFormatterCombo.clearSelection();
85
		fFormatterCombo.setText(NONE);
86
		Iterator iterator = idMap.entrySet().iterator();
87
		while (iterator.hasNext()) {
88
			Map.Entry entry = (Map.Entry)iterator.next();
89
			String val = (String)entry.getValue();
90
			if (val != null && val.equals(formatterID)) {
91
				fFormatterCombo.setText((String)entry.getKey());
92
			}
93
		}
94
	}
95
96
	/* (non-Javadoc)
97
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
98
	 */
99
	public Control createControl(Composite parent) {
100
		Composite control = ControlFactory.createComposite(parent, 2);
101
		((GridLayout) control.getLayout()).makeColumnsEqualWidth = false;
102
		((GridLayout) control.getLayout()).marginWidth = 5;
103
104
		PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE);
105
106
		ControlFactory.createEmptySpace(control, 2);
107
108
		Label label = ControlFactory.createLabel(control, PreferencesMessages.getString("CodeFormatterPreferencePage.selectionName")); //$NON-NLS-1$
109
		label.setLayoutData(new GridData());
110
		fFormatterCombo = new Combo(control, SWT.DROP_DOWN | SWT.READ_ONLY);
111
		GridData gd = new GridData(GridData.GRAB_HORIZONTAL);
112
		gd.grabExcessHorizontalSpace = true;
113
		fFormatterCombo.setLayoutData(gd);
114
		fFormatterCombo.addSelectionListener(new SelectionAdapter() {
115
			public void widgetSelected(SelectionEvent e) {
116
				handleFormatterChanged();
117
			}
118
		});
119
		Iterator items = idMap.keySet().iterator();
120
		while (items.hasNext()) {
121
			fFormatterCombo.add((String) items.next());
122
		}
123
124
		initDefault();
125
		handleFormatterChanged();
126
		return control;
127
	}
128
129
	public void handleFormatterChanged() {	
130
		// TODO: UI part.
131
	}
132
133
	public void initDefault() {
134
		boolean init = false;
135
		String selection = CCorePlugin.getOption(CCorePreferenceConstants.CODE_FORMATTER);
136
		if (selection != null) {
137
			Iterator iterator = idMap.entrySet().iterator();
138
			while (iterator.hasNext()) {
139
				Map.Entry entry = (Map.Entry)iterator.next();
140
				String val = (String)entry.getValue();
141
				if (val != null && val.equals(selection)) {
142
					fFormatterCombo.setText((String)entry.getKey());
143
					init = true;
144
				}
145
			}
146
		}
147
		if (!init) {
148
			fFormatterCombo.setText(NONE);
149
		}
150
	}
151
152
	private void initializeFormatters() {
153
		idMap = new HashMap();
154
		idMap.put(NONE, null);
155
		IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.FORMATTER_EXTPOINT_ID);
156
		if (point != null) {
157
			IExtension[] exts = point.getExtensions();
158
			for (int i = 0; i < exts.length; i++) {
159
		 		IConfigurationElement[] elements = exts[i].getConfigurationElements();
160
		 		for (int j = 0; j < elements.length; ++j) {
161
		 			String name = elements[j].getAttribute(ATTR_NAME);
162
		 			idMap.put(name, elements[j].getAttribute(ATTR_ID));
163
		 		}
164
			}
165
		}
166
	}
167
168
}
(-)src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties (-7 / +32 lines)
Lines 106-112 Link Here
106
CEditorPreferencePage.colorPage.color=C&olor:
106
CEditorPreferencePage.colorPage.color=C&olor:
107
CEditorPreferencePage.colorPage.bold=&Bold
107
CEditorPreferencePage.colorPage.bold=&Bold
108
CEditorPreferencePage.colorPage.preview=Preview:
108
CEditorPreferencePage.colorPage.preview=Preview:
109
CEditorPreferencePage.behaviorPage.tabSpace=&Insert space for tabs
110
CEditorPreferencePage.behaviorPage.ensureNewline=Ensure &newline at end of file when saving
109
CEditorPreferencePage.behaviorPage.ensureNewline=Ensure &newline at end of file when saving
111
CEditorPreferencePage.behaviorPage.matchingBrackets=Highlight &matching brackets
110
CEditorPreferencePage.behaviorPage.matchingBrackets=Highlight &matching brackets
112
CEditorPreferencePage.behaviorPage.subWordNavigation=Smart &caret positioning in identifiers
111
CEditorPreferencePage.behaviorPage.subWordNavigation=Smart &caret positioning in identifiers
Lines 117-122 Link Here
117
CEditorPreferencePage.behaviorPage.Color=Color:
116
CEditorPreferencePage.behaviorPage.Color=Color:
118
CEditorPreferencePage.textFont.changeButton=C&hange...
117
CEditorPreferencePage.textFont.changeButton=C&hange...
119
118
119
# Smart typing block
120
SmartTypingConfigurationBlock_autoclose_title=Automatically close
121
SmartTypingConfigurationBlock_tabs_title=Tabulators
122
# The argument will be replaced by the tab display size
123
SmartTypingConfigurationBlock_tabs_message_tab_text=The tab display value (currently {0}) and whether spaces are used to indent lines are configured on the <a>code style preference page</a>. The current indentation mode uses tabs.
124
# The first argument will be replaced by the tab display size, the second by the indent size and the third by the NLSed string of 'SmartTypingConfigurationBlock_tabs_message_spaces' or 'SmartTypingConfigurationBlock_tabs_message_tabs' (see below)  
125
SmartTypingConfigurationBlock_tabs_message_others_text=The tab display value (currently {0}) and whether spaces are used to indent lines are configured on the <a>code style preference page</a>. The current indentation size is {1}, using {2}.
126
SmartTypingConfigurationBlock_tabs_message_tooltip=Go to the code style preference page
127
SmartTypingConfigurationBlock_tabs_message_spaces=spaces
128
SmartTypingConfigurationBlock_tabs_message_tabs=tabs
129
SmartTypingConfigurationBlock_tabs_message_tabsAndSpaces=tabs and spaces
130
SmartTypingConfigurationBlock_pasting_title=When pasting
131
SmartTypingConfigurationBlock_strings_title=In string literals
132
133
CEditorPreferencePage_empty_input=Empty input
134
CEditorPreferencePage_invalid_input="{0}" is not a valid input.
135
CEditorPreferencePage_typing_tabTitle=T&yping
136
CEditorPreferencePage_typing_description=Enable these typing aids in Smart Insert mode:
137
CEditorPreferencePage_closeStrings="&Strings"
138
CEditorPreferencePage_closeBrackets=(&Parentheses) and [square] brackets
139
CEditorPreferencePage_closeAngularBrackets=<A&ngle> brackets
140
CEditorPreferencePage_closeBraces={B&races}
141
CEditorPreferencePage_wrapStrings=&Wrap automatically
142
CEditorPreferencePage_escapeStrings=Escape text w&hen pasting into a string literal
143
CEditorPreferencePage_smartPaste=Adjust &indentation
144
145
CEditorPreferencePage_typing_smartTab= &Tab key indents the current line
146
147
# Code Formatting
148
CodeFormatterPreferencePage_title=Code Style
149
CodeFormatterPreferencePage_description=Sele&ct a profile:
150
120
TemplatePreferencePage.Viewer.preview=Preview:
151
TemplatePreferencePage.Viewer.preview=Preview:
121
152
122
CFileTypesPreferencePage.description=C/C++ File Types
153
CFileTypesPreferencePage.description=C/C++ File Types
Lines 196-207 Link Here
196
FoldingConfigurationBlock.info.no_preferences= The selected folding provider did not provide a preference control
227
FoldingConfigurationBlock.info.no_preferences= The selected folding provider did not provide a preference control
197
FoldingConfigurationBlock.error.not_exist= The selected folding provider does not exist
228
FoldingConfigurationBlock.error.not_exist= The selected folding provider does not exist
198
229
199
#Code Formatting
200
CodeFormatterPreferencePage.title=Code Formatter
201
CodeFormatterPreferencePage.selectionName=Formatters:
202
CodeFormatterPreferencePage.emptyName=(NONE)
203
CodeFormatterPreferencePage.description=Code Formatter
204
205
# --- Linked Resources ---
230
# --- Linked Resources ---
206
PathEntryVariablePreference.explanation = PathEntry variables.
231
PathEntryVariablePreference.explanation = PathEntry variables.
207
PathEntryVariablePreference.enableLinkedResources = &Enable linked resources
232
PathEntryVariablePreference.enableLinkedResources = &Enable linked resources
(-)src/org/eclipse/cdt/internal/ui/preferences/CodeFormatterPreferencePage.java (-49 / +111 lines)
Lines 7-91 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     QNX Software Systems - Initial API and implementation
9
 *     QNX Software Systems - Initial API and implementation
10
 *     Sergey Prigogin, Google
10
 *******************************************************************************/
11
 *******************************************************************************/
11
12
12
package org.eclipse.cdt.internal.ui.preferences;
13
package org.eclipse.cdt.internal.ui.preferences;
13
14
14
15
15
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
16
import org.eclipse.core.runtime.IAdaptable;
16
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
17
17
import org.eclipse.cdt.ui.CUIPlugin;
18
import org.eclipse.core.resources.IProject;
18
import org.eclipse.cdt.ui.dialogs.CodeFormatterBlock;
19
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.jface.preference.PreferencePage;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.layout.GridData;
23
import org.eclipse.swt.layout.GridLayout;
24
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Control;
21
import org.eclipse.swt.widgets.Control;
26
import org.eclipse.ui.IWorkbench;
22
27
import org.eclipse.ui.IWorkbenchPreferencePage;
23
import org.eclipse.jface.preference.IPreferencePageContainer;
24
28
import org.eclipse.ui.PlatformUI;
25
import org.eclipse.ui.PlatformUI;
26
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
27
import org.eclipse.ui.preferences.IWorkingCopyManager;
28
import org.eclipse.ui.preferences.WorkingCopyManager;
29
30
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
31
import org.eclipse.cdt.internal.ui.preferences.formatter.CodeFormatterConfigurationBlock;
29
32
30
/**
33
/*
31
 * 
34
 * The page to configure the code formatter options.
32
 */
35
 */
33
public class CodeFormatterPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
36
public class CodeFormatterPreferencePage extends PropertyAndPreferencePage {
34
37
35
	CodeFormatterBlock fCodeFormatterBlock;
38
	public static final String PREF_ID= "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"; //$NON-NLS-1$
39
	public static final String PROP_ID= "org.eclipse.cdt.ui.propertyPages.CodeFormatterPreferencePage"; //$NON-NLS-1$
36
	
40
	
41
	private CodeFormatterConfigurationBlock fConfigurationBlock;
42
37
	public CodeFormatterPreferencePage() {
43
	public CodeFormatterPreferencePage() {
38
		setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
44
		setDescription(PreferencesMessages.CodeFormatterPreferencePage_description); 
45
		
39
		// only used when page is shown programatically
46
		// only used when page is shown programatically
40
		setTitle(PreferencesMessages.getString("CodeFormatterPreferencePage.title"));		 //$NON-NLS-1$
47
		setTitle(PreferencesMessages.CodeFormatterPreferencePage_title);		 
41
		//setDescription(PreferencesMessages.getString("CodeFormatterPreferencePage.description")); //$NON-NLS-1$
42
		fCodeFormatterBlock= new CodeFormatterBlock(CUIPlugin.getDefault().getPluginPreferences());
43
	}
44
	
45
46
	/*
47
	 * @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
48
	 */	
49
	public void init(IWorkbench workbench) {
50
	}
48
	}
51
49
52
	/*
50
	/* (non-Javadoc)
53
	 * @see PreferencePage#createContents(Composite)
51
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
54
	 */
52
	 */
55
	protected Control createContents(Composite parent) {
53
	public void createControl(Composite parent) {
56
		Composite topPane = new Composite(parent, SWT.NONE);
54
		IPreferencePageContainer container= getContainer();
57
55
		IWorkingCopyManager workingCopyManager;
58
		topPane.setLayout(new GridLayout());
56
		if (container instanceof IWorkbenchPreferenceContainer) {
59
		topPane.setLayoutData(new GridData(GridData.FILL_BOTH));
57
			workingCopyManager= ((IWorkbenchPreferenceContainer) container).getWorkingCopyManager();
60
58
		} else {
59
			workingCopyManager= new WorkingCopyManager(); // non shared 
60
		}
61
		PreferencesAccess access= PreferencesAccess.getWorkingCopyPreferences(workingCopyManager);
62
		fConfigurationBlock= new CodeFormatterConfigurationBlock(getProject(), access);
61
		
63
		
62
		applyDialogFont(parent);
64
		super.createControl(parent);
63
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE);
65
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), ICHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE);
64
		return fCodeFormatterBlock.createControl(topPane);
65
	}
66
	}
66
67
67
	/*
68
	/* (non-Javadoc)
68
	 * @see IPreferencePage#performOk()
69
	 * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#createPreferenceContent(org.eclipse.swt.widgets.Composite)
69
	 */
70
	 */
70
	public boolean performOk() {
71
	protected Control createPreferenceContent(Composite composite) {
71
		fCodeFormatterBlock.performOk();
72
		return fConfigurationBlock.createContents(composite);
72
		return super.performOk();
73
	}
74
	
75
	/* (non-Javadoc)
76
	 * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#hasProjectSpecificOptions(org.eclipse.core.resources.IProject)
77
	 */
78
	protected boolean hasProjectSpecificOptions(IProject project) {
79
		return fConfigurationBlock.hasProjectSpecificOptions(project);
80
	}
81
	
82
//	/* (non-Javadoc)
83
//	 * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#enableProjectSpecificSettings(boolean)
84
//	 */
85
//	protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
86
//		super.enableProjectSpecificSettings(useProjectSpecificSettings);
87
//		if (fConfigurationBlock != null) {
88
//			fConfigurationBlock.enableProjectSpecificSettings(useProjectSpecificSettings);
89
//		}
90
//	}
91
	
92
	/* (non-Javadoc)
93
	 * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPreferencePageID()
94
	 */
95
	protected String getPreferencePageID() {
96
		return PREF_ID;
97
	}
98
	
99
	/* (non-Javadoc)
100
	 * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#getPropertyPageID()
101
	 */
102
	protected String getPropertyPageID() {
103
		return PROP_ID;
104
	}
105
	
106
	/* (non-Javadoc)
107
	 * @see org.eclipse.jface.dialogs.DialogPage#dispose()
108
	 */
109
	public void dispose() {
110
		if (fConfigurationBlock != null) {
111
			fConfigurationBlock.dispose();
112
		}
113
		super.dispose();
73
	}
114
	}
74
	
115
	
75
	/* (non-Javadoc)
116
	/* (non-Javadoc)
76
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
117
	 * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
77
	 */
118
	 */
78
	protected void performDefaults() {
119
	protected void performDefaults() {
79
		fCodeFormatterBlock.performDefaults();
120
		if (fConfigurationBlock != null) {
121
			fConfigurationBlock.performDefaults();
122
		}
80
		super.performDefaults();
123
		super.performDefaults();
81
	}
124
	}
82
		
125
83
	/* (non-Javadoc)
126
	/* (non-Javadoc)
84
	 * @see org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener#statusChanged(org.eclipse.core.runtime.IStatus)
127
	 * @see org.eclipse.jface.preference.IPreferencePage#performOk()
85
	 */
128
	 */
86
	public void statusChanged(IStatus status) {
129
	public boolean performOk() {
87
		setValid(!status.matches(IStatus.ERROR));
130
		if (fConfigurationBlock != null && !fConfigurationBlock.performOk()) {
88
		StatusUtil.applyToStatusLine(this, status);		
131
			return false;
132
		}	
133
		return super.performOk();
134
	}
135
	
136
	/* (non-Javadoc)
137
	 * @see org.eclipse.jface.preference.IPreferencePage#performOk()
138
	 */
139
	public void performApply() {
140
		if (fConfigurationBlock != null) {
141
			fConfigurationBlock.performApply();
142
		}	
143
		super.performApply();
144
	}
145
	
146
	/* (non-Javadoc)
147
	 * @see org.eclipse.cdt.internal.ui.preferences.PropertyAndPreferencePage#setElement(org.eclipse.core.runtime.IAdaptable)
148
	 */
149
	public void setElement(IAdaptable element) {
150
		super.setElement(element);
151
		setDescription(null); // no description for property page
89
	}
152
	}
90
91
}
153
}
(-)src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java (-6 lines)
Lines 125-131 Link Here
125
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.MATCHING_BRACKETS));
125
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.MATCHING_BRACKETS));
126
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.INACTIVE_CODE_COLOR));
126
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CEditor.INACTIVE_CODE_COLOR));
127
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.INACTIVE_CODE_ENABLE));
127
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.INACTIVE_CODE_ENABLE));
128
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CEditor.SPACES_FOR_TABS));
129
		
128
		
130
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
129
		overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR));
131
        overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
130
        overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD));
Lines 159-166 Link Here
159
		store.setDefault(CEditor.INACTIVE_CODE_ENABLE, true);
158
		store.setDefault(CEditor.INACTIVE_CODE_ENABLE, true);
160
		PreferenceConverter.setDefault(store, CEditor.INACTIVE_CODE_COLOR, new RGB(224, 224, 224));
159
		PreferenceConverter.setDefault(store, CEditor.INACTIVE_CODE_COLOR, new RGB(224, 224, 224));
161
160
162
		store.setDefault(CEditor.SPACES_FOR_TABS, false);
163
164
		PreferenceConverter.setDefault(store, ICColorConstants.C_MULTI_LINE_COMMENT, new RGB(63, 127, 95));
161
		PreferenceConverter.setDefault(store, ICColorConstants.C_MULTI_LINE_COMMENT, new RGB(63, 127, 95));
165
		store.setDefault(ICColorConstants.C_MULTI_LINE_COMMENT + "_bold", false); //$NON-NLS-1$
162
		store.setDefault(ICColorConstants.C_MULTI_LINE_COMMENT + "_bold", false); //$NON-NLS-1$
166
163
Lines 350-358 Link Here
350
		label = PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.inactiveCode"); //$NON-NLS-1$
347
		label = PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.inactiveCode"); //$NON-NLS-1$
351
		addCheckBox(behaviorComposite, label, CEditor.INACTIVE_CODE_ENABLE, 0);
348
		addCheckBox(behaviorComposite, label, CEditor.INACTIVE_CODE_ENABLE, 0);
352
349
353
		label = PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.tabSpace"); //$NON-NLS-1$
354
		addCheckBox(behaviorComposite, label, CEditor.SPACES_FOR_TABS, 0);
355
356
		label = PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.ensureNewline"); //$NON-NLS-1$
350
		label = PreferencesMessages.getString("CEditorPreferencePage.behaviorPage.ensureNewline"); //$NON-NLS-1$
357
		addCheckBox(behaviorComposite, label, PreferenceConstants.ENSURE_NEWLINE_AT_EOF, 0);
351
		addCheckBox(behaviorComposite, label, PreferenceConstants.ENSURE_NEWLINE_AT_EOF, 0);
358
352
(-)src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java (-6 / +43 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.ui.preferences;
12
package org.eclipse.cdt.internal.ui.preferences;
12
13
Lines 14-35 Link Here
14
import java.util.MissingResourceException;
15
import java.util.MissingResourceException;
15
import java.util.ResourceBundle;
16
import java.util.ResourceBundle;
16
17
17
public class PreferencesMessages {
18
import org.eclipse.osgi.util.NLS;
18
19
19
	private static final String RESOURCE_BUNDLE= "org.eclipse.cdt.internal.ui.preferences.PreferencesMessages";//$NON-NLS-1$
20
public class PreferencesMessages extends NLS {
20
21
22
	private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.ui.preferences.PreferencesMessages";//$NON-NLS-1$
23
24
	private PreferencesMessages() {
25
		// Do not instantiate
26
	}
27
28
	static {
29
		NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class);
30
	}
31
32
	public static String CEditorPreferencePage_empty_input;
33
	public static String CEditorPreferencePage_invalid_input;
34
	public static String CEditorPreferencePage_typing_tabTitle;
35
	public static String CEditorPreferencePage_typing_description;
36
	public static String CEditorPreferencePage_closeStrings;
37
	public static String CEditorPreferencePage_closeBrackets;
38
	public static String CEditorPreferencePage_closeAngularBrackets;
39
	public static String CEditorPreferencePage_closeBraces;
40
	public static String CEditorPreferencePage_wrapStrings;
41
	public static String CEditorPreferencePage_escapeStrings;
42
	public static String CEditorPreferencePage_smartPaste;
43
44
	public static String CEditorPreferencePage_typing_smartTab;
45
46
	public static String SmartTypingConfigurationBlock_autoclose_title;
47
	public static String SmartTypingConfigurationBlock_tabs_title;
48
	public static String SmartTypingConfigurationBlock_tabs_message_tab_text;
49
	public static String SmartTypingConfigurationBlock_tabs_message_others_text;
50
	public static String SmartTypingConfigurationBlock_tabs_message_tooltip;
51
	public static String SmartTypingConfigurationBlock_tabs_message_spaces;
52
	public static String SmartTypingConfigurationBlock_tabs_message_tabs;
53
	public static String SmartTypingConfigurationBlock_tabs_message_tabsAndSpaces;
54
	public static String SmartTypingConfigurationBlock_pasting_title;
55
	public static String SmartTypingConfigurationBlock_strings_title;
56
57
	public static String CodeFormatterPreferencePage_title;
58
	public static String CodeFormatterPreferencePage_description; 
59
	
60
	// Old style string resource access.
21
	private static ResourceBundle fgResourceBundle;
61
	private static ResourceBundle fgResourceBundle;
22
	static {
62
	static {
23
		try {
63
		try {
24
			fgResourceBundle = ResourceBundle.getBundle(RESOURCE_BUNDLE);
64
			fgResourceBundle = ResourceBundle.getBundle(BUNDLE_NAME);
25
		} catch (MissingResourceException x) {
65
		} catch (MissingResourceException x) {
26
			fgResourceBundle = null;
66
			fgResourceBundle = null;
27
		}
67
		}
28
	}
68
	}
29
69
30
	private PreferencesMessages() {
31
	}
32
33
	public static String getString(String key) {
70
	public static String getString(String key) {
34
		try {
71
		try {
35
			return fgResourceBundle.getString(key);
72
			return fgResourceBundle.getString(key);
(-)src/org/eclipse/cdt/internal/ui/text/CCommentScanner.java (+4 lines)
Lines 82-87 Link Here
82
    private String fDefaultTokenProperty;
82
    private String fDefaultTokenProperty;
83
    private String[] fTokenProperties;
83
    private String[] fTokenProperties;
84
84
85
    public CCommentScanner(IColorManager manager, IPreferenceStore store, String defaultTokenProperty) {
86
        this(manager, store, null, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG });
87
    }
88
85
    public CCommentScanner(IColorManager manager, IPreferenceStore store, Preferences coreStore, String defaultTokenProperty) {
89
    public CCommentScanner(IColorManager manager, IPreferenceStore store, Preferences coreStore, String defaultTokenProperty) {
86
        this(manager, store, coreStore, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG });
90
        this(manager, store, coreStore, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG });
87
    }
91
    }
(-)src/org/eclipse/cdt/internal/ui/text/CIndenter.java (-59 / +153 lines)
Lines 7-17 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.ui.text;
12
package org.eclipse.cdt.internal.ui.text;
12
13
13
import org.eclipse.cdt.core.CCorePlugin;
14
import org.eclipse.cdt.core.CCorePlugin;
14
import org.eclipse.cdt.core.formatter.CodeFormatterConstants;
15
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
15
import org.eclipse.cdt.core.model.ICProject;
16
import org.eclipse.cdt.core.model.ICProject;
16
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
17
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
17
18
Lines 45-52 Link Here
45
		final boolean prefTernaryDeepAlign;
46
		final boolean prefTernaryDeepAlign;
46
		final int prefTernaryIndent;
47
		final int prefTernaryIndent;
47
		final int prefCaseIndent;
48
		final int prefCaseIndent;
48
		final int prefAssignmentIndent;
49
		final int prefCaseBlockIndent;
49
		final int prefCaseBlockIndent;
50
		final int prefAssignmentIndent;
50
		final int prefSimpleIndent;
51
		final int prefSimpleIndent;
51
		final int prefBracketIndent;
52
		final int prefBracketIndent;
52
		final boolean prefMethodDeclDeepIndent;
53
		final boolean prefMethodDeclDeepIndent;
Lines 58-63 Link Here
58
		final int prefBlockIndent;
59
		final int prefBlockIndent;
59
		final int prefMethodBodyIndent;
60
		final int prefMethodBodyIndent;
60
		final int prefTypeIndent;
61
		final int prefTypeIndent;
62
		final int prefAccessSpecifierIndent;
61
		final boolean prefIndentBracesForBlocks;
63
		final boolean prefIndentBracesForBlocks;
62
		final boolean prefIndentBracesForArrays;
64
		final boolean prefIndentBracesForArrays;
63
		final boolean prefIndentBracesForMethods;
65
		final boolean prefIndentBracesForMethods;
Lines 93-100 Link Here
93
			prefTernaryDeepAlign= prefTernaryDeepAlign();
95
			prefTernaryDeepAlign= prefTernaryDeepAlign();
94
			prefTernaryIndent= prefTernaryIndent();
96
			prefTernaryIndent= prefTernaryIndent();
95
			prefCaseIndent= prefCaseIndent();
97
			prefCaseIndent= prefCaseIndent();
96
			prefAssignmentIndent= prefAssignmentIndent();
97
			prefCaseBlockIndent= prefCaseBlockIndent();
98
			prefCaseBlockIndent= prefCaseBlockIndent();
99
			prefAssignmentIndent= prefAssignmentIndent();
98
			prefIndentBracesForBlocks= prefIndentBracesForBlocks();
100
			prefIndentBracesForBlocks= prefIndentBracesForBlocks();
99
			prefSimpleIndent= prefSimpleIndent();
101
			prefSimpleIndent= prefSimpleIndent();
100
			prefBracketIndent= prefBracketIndent();
102
			prefBracketIndent= prefBracketIndent();
Lines 106-120 Link Here
106
			prefParenthesisIndent= prefParenthesisIndent();
108
			prefParenthesisIndent= prefParenthesisIndent();
107
			prefMethodBodyIndent= prefMethodBodyIndent();
109
			prefMethodBodyIndent= prefMethodBodyIndent();
108
			prefTypeIndent= prefTypeIndent();
110
			prefTypeIndent= prefTypeIndent();
111
			prefAccessSpecifierIndent= prefAccessSpecifierIndent();
109
			prefIndentBracesForArrays= prefIndentBracesForArrays();
112
			prefIndentBracesForArrays= prefIndentBracesForArrays();
110
			prefIndentBracesForMethods= prefIndentBracesForMethods();
113
			prefIndentBracesForMethods= prefIndentBracesForMethods();
111
			prefIndentBracesForTypes= prefIndentBracesForTypes();
114
			prefIndentBracesForTypes= prefIndentBracesForTypes();
112
			prefHasGenerics= hasGenerics();
115
			prefHasGenerics= hasGenerics();
113
			prefTabChar= getCoreFormatterOption(CodeFormatterConstants.FORMATTER_TAB_CHAR);
116
			prefTabChar= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
114
		}
117
		}
115
		
118
		
116
		private boolean prefUseTabs() {
119
		private boolean prefUseTabs() {
117
			return !CCorePlugin.SPACE.equals(getCoreFormatterOption(CodeFormatterConstants.FORMATTER_TAB_CHAR));
120
			return !CCorePlugin.SPACE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR));
118
		}
121
		}
119
122
120
		private int prefTabSize() {
123
		private int prefTabSize() {
Lines 130-138 Link Here
130
		}
133
		}
131
134
132
		private int prefArrayIndent() {
135
		private int prefArrayIndent() {
133
			String option= getCoreFormatterOption(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
136
			String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
134
			try {
137
			try {
135
				if (CodeFormatterConstants.getIndentStyle(option) == CodeFormatterConstants.INDENT_BY_ONE)
138
				if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
136
					return 1;
139
					return 1;
137
			} catch (IllegalArgumentException e) {
140
			} catch (IllegalArgumentException e) {
138
				// ignore and return default
141
				// ignore and return default
Lines 142-150 Link Here
142
		}
145
		}
143
146
144
		private boolean prefArrayDeepIndent() {
147
		private boolean prefArrayDeepIndent() {
145
			String option= getCoreFormatterOption(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
148
			String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_EXPRESSIONS_IN_ARRAY_INITIALIZER);
146
			try {
149
			try {
147
				return CodeFormatterConstants.getIndentStyle(option) == CodeFormatterConstants.INDENT_ON_COLUMN;
150
				return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
148
			} catch (IllegalArgumentException e) {
151
			} catch (IllegalArgumentException e) {
149
				// ignore and return default
152
				// ignore and return default
150
			}
153
			}
Lines 153-161 Link Here
153
		}
156
		}
154
157
155
		private boolean prefTernaryDeepAlign() {
158
		private boolean prefTernaryDeepAlign() {
156
			String option= getCoreFormatterOption(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
159
			String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
157
			try {
160
			try {
158
				return CodeFormatterConstants.getIndentStyle(option) == CodeFormatterConstants.INDENT_ON_COLUMN;
161
				return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
159
			} catch (IllegalArgumentException e) {
162
			} catch (IllegalArgumentException e) {
160
				// ignore and return default
163
				// ignore and return default
161
			}
164
			}
Lines 163-171 Link Here
163
		}
166
		}
164
167
165
		private int prefTernaryIndent() {
168
		private int prefTernaryIndent() {
166
			String option= getCoreFormatterOption(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
169
			String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_CONDITIONAL_EXPRESSION);
167
			try {
170
			try {
168
				if (CodeFormatterConstants.getIndentStyle(option) == CodeFormatterConstants.INDENT_BY_ONE)
171
				if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
169
					return 1;
172
					return 1;
170
				else
173
				else
171
					return prefContinuationIndent();
174
					return prefContinuationIndent();
Lines 177-202 Link Here
177
		}
180
		}
178
181
179
		private int prefCaseIndent() {
182
		private int prefCaseIndent() {
180
			if (CodeFormatterConstants.TRUE.equals(getCoreFormatterOption(CodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH)))
183
			if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH)))
181
				return prefBlockIndent();
184
				return prefBlockIndent();
182
			else
185
			else
183
				return 0;
186
				return 0;
184
		}
187
		}
185
188
186
		private int prefAssignmentIndent() {
187
			return prefBlockIndent();
188
		}
189
190
		private int prefCaseBlockIndent() {
189
		private int prefCaseBlockIndent() {
191
			if (true)
190
			if (true)
192
				return prefBlockIndent();
191
				return prefBlockIndent();
193
192
194
			if (CodeFormatterConstants.TRUE.equals(getCoreFormatterOption(CodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES)))
193
			if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES)))
195
				return prefBlockIndent();
194
				return prefBlockIndent();
196
			else
195
			else
197
				return 0;
196
				return 0;
198
		}
197
		}
199
198
199
		private int prefAssignmentIndent() {
200
			return prefBlockIndent();
201
		}
202
200
		private int prefSimpleIndent() {
203
		private int prefSimpleIndent() {
201
			if (prefIndentBracesForBlocks() && prefBlockIndent() == 0)
204
			if (prefIndentBracesForBlocks() && prefBlockIndent() == 0)
202
				return 1;
205
				return 1;
Lines 208-216 Link Here
208
		}
211
		}
209
212
210
		private boolean prefMethodDeclDeepIndent() {
213
		private boolean prefMethodDeclDeepIndent() {
211
			String option= getCoreFormatterOption(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
214
			String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
212
			try {
215
			try {
213
				return CodeFormatterConstants.getIndentStyle(option) == CodeFormatterConstants.INDENT_ON_COLUMN;
216
				return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
214
			} catch (IllegalArgumentException e) {
217
			} catch (IllegalArgumentException e) {
215
				// ignore and return default
218
				// ignore and return default
216
			}
219
			}
Lines 219-227 Link Here
219
		}
222
		}
220
223
221
		private int prefMethodDeclIndent() {
224
		private int prefMethodDeclIndent() {
222
			String option= getCoreFormatterOption(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
225
			String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_METHOD_DECLARATION);
223
			try {
226
			try {
224
				if (CodeFormatterConstants.getIndentStyle(option) == CodeFormatterConstants.INDENT_BY_ONE)
227
				if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
225
					return 1;
228
					return 1;
226
				else
229
				else
227
					return prefContinuationIndent();
230
					return prefContinuationIndent();
Lines 232-240 Link Here
232
		}
235
		}
233
236
234
		private boolean prefMethodCallDeepIndent() {
237
		private boolean prefMethodCallDeepIndent() {
235
			String option= getCoreFormatterOption(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
238
			String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
236
			try {
239
			try {
237
				return CodeFormatterConstants.getIndentStyle(option) == CodeFormatterConstants.INDENT_ON_COLUMN;
240
				return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
238
			} catch (IllegalArgumentException e) {
241
			} catch (IllegalArgumentException e) {
239
				// ignore and return default
242
				// ignore and return default
240
			}
243
			}
Lines 242-250 Link Here
242
		}
245
		}
243
246
244
		private int prefMethodCallIndent() {
247
		private int prefMethodCallIndent() {
245
			String option= getCoreFormatterOption(CodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
248
			String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION);
246
			try {
249
			try {
247
				if (CodeFormatterConstants.getIndentStyle(option) == CodeFormatterConstants.INDENT_BY_ONE)
250
				if (DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_BY_ONE)
248
					return 1;
251
					return 1;
249
				else
252
				else
250
					return prefContinuationIndent();
253
					return prefContinuationIndent();
Lines 259-267 Link Here
259
			if (true) // don't do parenthesis deep indentation
262
			if (true) // don't do parenthesis deep indentation
260
				return false;
263
				return false;
261
264
262
			String option= getCoreFormatterOption(CodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
265
			String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION);
263
			try {
266
			try {
264
				return CodeFormatterConstants.getIndentStyle(option) == CodeFormatterConstants.INDENT_ON_COLUMN;
267
				return DefaultCodeFormatterConstants.getIndentStyle(option) == DefaultCodeFormatterConstants.INDENT_ON_COLUMN;
265
			} catch (IllegalArgumentException e) {
268
			} catch (IllegalArgumentException e) {
266
				// ignore and return default
269
				// ignore and return default
267
			}
270
			}
Lines 274-326 Link Here
274
		}
277
		}
275
278
276
		private int prefBlockIndent() {
279
		private int prefBlockIndent() {
277
			String option= getCoreFormatterOption(CodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK);
280
			String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK);
278
			if (CodeFormatterConstants.FALSE.equals(option))
281
			if (DefaultCodeFormatterConstants.FALSE.equals(option))
279
				return 0;
282
				return 0;
280
283
281
			return 1; // sensible default
284
			return 1; // sensible default
282
		}
285
		}
283
286
284
		private int prefMethodBodyIndent() {
287
		private int prefMethodBodyIndent() {
285
			if (CodeFormatterConstants.FALSE.equals(getCoreFormatterOption(CodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY)))
288
			if (DefaultCodeFormatterConstants.FALSE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY)))
286
				return 0;
289
				return 0;
287
290
288
			return 1; // sensible default
291
			return 1; // sensible default
289
		}
292
		}
290
293
291
		private int prefTypeIndent() {
294
		private int prefTypeIndent() {
292
			String option= getCoreFormatterOption(CodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_TYPE_HEADER);
295
			String option= getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER);
293
			if (CodeFormatterConstants.FALSE.equals(option))
296
			if (DefaultCodeFormatterConstants.FALSE.equals(option))
294
				return 0;
297
				return 0;
295
298
296
			return 1; // sensible default
299
			return 1; // sensible default
297
		}
300
		}
301
		
302
		private int prefAccessSpecifierIndent() {
303
			if (DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER)))
304
				return prefBlockIndent();
305
			else
306
				return 0;
307
		}
298
308
299
		private boolean prefIndentBracesForBlocks() {
309
		private boolean prefIndentBracesForBlocks() {
300
			return CodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK));
310
			return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_BLOCK));
301
		}
311
		}
302
312
303
		private boolean prefIndentBracesForArrays() {
313
		private boolean prefIndentBracesForArrays() {
304
			return CodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER));
314
			return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_ARRAY_INITIALIZER));
305
		}
315
		}
306
316
307
		private boolean prefIndentBracesForMethods() {
317
		private boolean prefIndentBracesForMethods() {
308
			return CodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION));
318
			return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION));
309
		}
319
		}
310
320
311
		private boolean prefIndentBracesForTypes() {
321
		private boolean prefIndentBracesForTypes() {
312
			return CodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(CodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION));
322
			return DefaultCodeFormatterConstants.NEXT_LINE_SHIFTED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION));
313
		}
323
		}
314
324
315
		private int prefContinuationIndent() {
325
		private int prefContinuationIndent() {
316
			try {
326
			try {
317
				return Integer.parseInt(getCoreFormatterOption(CodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION));
327
				return Integer.parseInt(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_CONTINUATION_INDENTATION));
318
			} catch (NumberFormatException e) {
328
			} catch (NumberFormatException e) {
319
				// ignore and return default
329
				// ignore and return default
320
			}
330
			}
321
331
322
			return 2; // sensible default
332
			return 2; // sensible default
323
		}
333
		}
334
		
324
		private boolean hasGenerics() {
335
		private boolean hasGenerics() {
325
			return true;
336
			return true;
326
		}
337
		}
Lines 335-341 Link Here
335
	 * (method defs, array initializers)
346
	 * (method defs, array initializers)
336
	 */
347
	 */
337
	private int fAlign;
348
	private int fAlign;
338
	/** The stateful scanposition for the indentation methods. */
349
	/** The stateful scan position for the indentation methods. */
339
	private int fPosition;
350
	private int fPosition;
340
	/** The previous position. */
351
	/** The previous position. */
341
	private int fPreviousPos;
352
	private int fPreviousPos;
Lines 404-410 Link Here
404
	 *         if it cannot be determined
415
	 *         if it cannot be determined
405
	 */
416
	 */
406
	private StringBuffer getReferenceIndentation(int offset, boolean assumeOpeningBrace) {
417
	private StringBuffer getReferenceIndentation(int offset, boolean assumeOpeningBrace) {
407
408
		int unit;
418
		int unit;
409
		if (assumeOpeningBrace)
419
		if (assumeOpeningBrace)
410
			unit= findReferencePosition(offset, Symbols.TokenLBRACE);
420
			unit= findReferencePosition(offset, Symbols.TokenLBRACE);
Lines 416-422 Link Here
416
			return null;
426
			return null;
417
427
418
		return getLeadingWhitespace(unit);
428
		return getLeadingWhitespace(unit);
419
420
	}
429
	}
421
430
422
	/**
431
	/**
Lines 441-447 Link Here
441
	 *         determined
450
	 *         determined
442
	 */
451
	 */
443
	public StringBuffer computeIndentation(int offset, boolean assumeOpeningBrace) {
452
	public StringBuffer computeIndentation(int offset, boolean assumeOpeningBrace) {
444
445
		StringBuffer reference= getReferenceIndentation(offset, assumeOpeningBrace);
453
		StringBuffer reference= getReferenceIndentation(offset, assumeOpeningBrace);
446
454
447
		// handle special alignment
455
		// handle special alignment
Lines 459-469 Link Here
459
		if (reference == null)
467
		if (reference == null)
460
			return null;
468
			return null;
461
469
462
		// add additional indent
470
		// Add additional indent
463
		return createReusingIndent(reference, fIndent);
471
		return createReusingIndent(reference, fIndent);
464
	}
472
	}
465
473
466
	/**
474
	/**
475
	 * Computes the indentation for a continuation line at <code>offset</code>.
476
	 *
477
	 * @param offset the offset in the document
478
	 * @return a StringBuffer which reflects the correct indentation for
479
	 *         the line in  which offset resides, or <code>null</code> if it cannot be
480
	 *         determined.
481
	 * @throws BadLocationException
482
	 */
483
	public StringBuffer computeContinuationLineIndentation(int offset) throws BadLocationException {
484
		StringBuffer reference= getLeadingWhitespace(offset);
485
		IRegion line= fDocument.getLineInformationOfOffset(offset);
486
		String string= fDocument.get(line.getOffset(), offset - line.getOffset());
487
		if (string.trim().length() == 0)
488
			return reference;
489
		// Add additional indent
490
		return createReusingIndent(reference, fPrefs.prefContinuationIndent);
491
	}
492
	
493
	/**
467
	 * Computes the length of a <code>CharacterSequence</code>, counting
494
	 * Computes the length of a <code>CharacterSequence</code>, counting
468
	 * a tab character as the size until the next tab stop and every other
495
	 * a tab character as the size until the next tab stop and every other
469
	 * character as one.
496
	 * character as one.
Lines 572-578 Link Here
572
		try {
599
		try {
573
			int spaces= 0;
600
			int spaces= 0;
574
			while (start < indent) {
601
			while (start < indent) {
575
576
				char ch= fDocument.getChar(start);
602
				char ch= fDocument.getChar(start);
577
				if (ch == '\t') {
603
				if (ch == '\t') {
578
					ret.append('\t');
604
					ret.append('\t');
Lines 609-620 Link Here
609
	 * @return the modified <code>buffer</code> reflecting the indentation
635
	 * @return the modified <code>buffer</code> reflecting the indentation
610
	 *         adapted to <code>additional</code>
636
	 *         adapted to <code>additional</code>
611
	 */
637
	 */
612
	private StringBuffer createReusingIndent(StringBuffer buffer, int additional) {
638
	public StringBuffer createReusingIndent(StringBuffer buffer, int additional) {
613
		int refLength= computeVisualLength(buffer);
639
		int refLength= computeVisualLength(buffer);
614
		int addLength= fPrefs.prefIndentationSize * additional; // may be < 0
640
		int addLength= fPrefs.prefIndentationSize * additional; // may be < 0
615
		int totalLength= Math.max(0, refLength + addLength);
641
		int totalLength= Math.max(0, refLength + addLength);
616
642
617
618
		// copy the reference indentation for the indent up to the last tab
643
		// copy the reference indentation for the indent up to the last tab
619
		// stop within the maxCopy area
644
		// stop within the maxCopy area
620
		int minLength= Math.min(totalLength, refLength);
645
		int minLength= Math.min(totalLength, refLength);
Lines 622-628 Link Here
622
		int maxCopyLength= tabSize > 0 ? minLength - minLength % tabSize : minLength; // maximum indent to copy
647
		int maxCopyLength= tabSize > 0 ? minLength - minLength % tabSize : minLength; // maximum indent to copy
623
		stripExceedingChars(buffer, maxCopyLength);
648
		stripExceedingChars(buffer, maxCopyLength);
624
649
625
626
		// add additional indent
650
		// add additional indent
627
		int missing= totalLength - maxCopyLength;
651
		int missing= totalLength - maxCopyLength;
628
		final int tabs, spaces;
652
		final int tabs, spaces;
Lines 632-647 Link Here
632
		} else if (CCorePlugin.TAB.equals(fPrefs.prefTabChar)) {
656
		} else if (CCorePlugin.TAB.equals(fPrefs.prefTabChar)) {
633
			tabs= tabSize > 0 ? missing / tabSize : 0;
657
			tabs= tabSize > 0 ? missing / tabSize : 0;
634
			spaces= tabSize > 0 ? missing % tabSize : missing;
658
			spaces= tabSize > 0 ? missing % tabSize : missing;
635
		} else if (CodeFormatterConstants.MIXED.equals(fPrefs.prefTabChar)) {
659
		} else if (DefaultCodeFormatterConstants.MIXED.equals(fPrefs.prefTabChar)) {
636
			tabs= tabSize > 0 ? missing / tabSize : 0;
660
			tabs= tabSize > 0 ? missing / tabSize : 0;
637
			spaces= tabSize > 0 ? missing % tabSize : missing;
661
			spaces= tabSize > 0 ? missing % tabSize : missing;
638
		} else {
662
		} else {
639
			Assert.isTrue(false);
663
			Assert.isTrue(false);
640
			return null;
664
			return null;
641
		}
665
		}
642
		for(int i= 0; i < tabs; i++)
666
		for (int i= 0; i < tabs; i++)
643
			buffer.append('\t');
667
			buffer.append('\t');
644
		for(int i= 0; i < spaces; i++)
668
		for (int i= 0; i < spaces; i++)
645
			buffer.append(' ');
669
			buffer.append(' ');
646
		return buffer;
670
		return buffer;
647
	}
671
	}
Lines 713-718 Link Here
713
		boolean matchBrace= false;
737
		boolean matchBrace= false;
714
		boolean matchParen= false;
738
		boolean matchParen= false;
715
		boolean matchCase= false;
739
		boolean matchCase= false;
740
		boolean matchAccessSpecifier= false;
716
741
717
		// account for un-indentation characters already typed in, but after position
742
		// account for un-indentation characters already typed in, but after position
718
		// if they are on a line by themselves, the indentation gets adjusted
743
		// if they are on a line by themselves, the indentation gets adjusted
Lines 732-742 Link Here
732
					case Symbols.TokenELSE:
757
					case Symbols.TokenELSE:
733
						danglingElse= true;
758
						danglingElse= true;
734
						break;
759
						break;
760
						
735
					case Symbols.TokenCASE:
761
					case Symbols.TokenCASE:
736
					case Symbols.TokenDEFAULT:
762
					case Symbols.TokenDEFAULT:
737
						if (isFirstTokenOnLine)
763
						if (isFirstTokenOnLine)
738
							matchCase= true;
764
							matchCase= true;
739
						break;
765
						break;
766
						
767
					case Symbols.TokenPUBLIC:
768
					case Symbols.TokenPROTECTED:
769
					case Symbols.TokenPRIVATE:
770
						if (isFirstTokenOnLine)
771
							matchAccessSpecifier= true;
772
						break;
773
						
740
					case Symbols.TokenLBRACE: // for opening-brace-on-new-line style
774
					case Symbols.TokenLBRACE: // for opening-brace-on-new-line style
741
						if (bracelessBlockStart && !fPrefs.prefIndentBracesForBlocks)
775
						if (bracelessBlockStart && !fPrefs.prefIndentBracesForBlocks)
742
							unindent= true;
776
							unindent= true;
Lines 745-754 Link Here
745
						else if (!bracelessBlockStart && fPrefs.prefIndentBracesForMethods)
779
						else if (!bracelessBlockStart && fPrefs.prefIndentBracesForMethods)
746
							indent= true;
780
							indent= true;
747
						break;
781
						break;
782
						
748
					case Symbols.TokenRBRACE: // closing braces get unindented
783
					case Symbols.TokenRBRACE: // closing braces get unindented
749
						if (isFirstTokenOnLine)
784
						if (isFirstTokenOnLine)
750
							matchBrace= true;
785
							matchBrace= true;
751
						break;
786
						break;
787
						
752
					case Symbols.TokenRPAREN:
788
					case Symbols.TokenRPAREN:
753
						if (isFirstTokenOnLine)
789
						if (isFirstTokenOnLine)
754
							matchParen= true;
790
							matchParen= true;
Lines 761-767 Link Here
761
			danglingElse= false;
797
			danglingElse= false;
762
		}
798
		}
763
799
764
		int ref= findReferencePosition(offset, danglingElse, matchBrace, matchParen, matchCase);
800
		int ref= findReferencePosition(offset, danglingElse, matchBrace, matchParen, matchCase, matchAccessSpecifier);
765
		if (unindent)
801
		if (unindent)
766
			fIndent--;
802
			fIndent--;
767
		if (indent)
803
		if (indent)
Lines 787-796 Link Here
787
	 * @param matchCase whether the position of a switch statement reference
823
	 * @param matchCase whether the position of a switch statement reference
788
	 *            should be returned (either an earlier case statement or the
824
	 *            should be returned (either an earlier case statement or the
789
	 *            switch block brace)
825
	 *            switch block brace)
826
	 * @param matchAccessSpecifier whether the position of a class body reference
827
	 *            should be returned (either an earlier public/protected/private
828
	 *            or the class body brace)
790
	 * @return the reference statement relative to which <code>position</code>
829
	 * @return the reference statement relative to which <code>position</code>
791
	 *         should be indented, or {@link CHeuristicScanner#NOT_FOUND}
830
	 *         should be indented, or {@link CHeuristicScanner#NOT_FOUND}
792
	 */
831
	 */
793
	public int findReferencePosition(int offset, boolean danglingElse, boolean matchBrace, boolean matchParen, boolean matchCase) {
832
	public int findReferencePosition(int offset, boolean danglingElse, boolean matchBrace, boolean matchParen,
833
			                         boolean matchCase, boolean matchAccessSpecifier) {
794
		fIndent= 0; // the indentation modification
834
		fIndent= 0; // the indentation modification
795
		fAlign= CHeuristicScanner.NOT_FOUND;
835
		fAlign= CHeuristicScanner.NOT_FOUND;
796
		fPosition= offset;
836
		fPosition= offset;
Lines 816-822 Link Here
816
			} else {
856
			} else {
817
				// if we can't find the matching brace, the heuristic is to unindent
857
				// if we can't find the matching brace, the heuristic is to unindent
818
				// by one against the normal position
858
				// by one against the normal position
819
				int pos= findReferencePosition(offset, danglingElse, false, matchParen, matchCase);
859
				int pos= findReferencePosition(offset, danglingElse, false, matchParen, matchCase, matchAccessSpecifier);
820
				fIndent--;
860
				fIndent--;
821
				return pos;
861
				return pos;
822
			}
862
			}
Lines 829-835 Link Here
829
			else {
869
			else {
830
				// if we can't find the matching paren, the heuristic is to unindent
870
				// if we can't find the matching paren, the heuristic is to unindent
831
				// by one against the normal position
871
				// by one against the normal position
832
				int pos= findReferencePosition(offset, danglingElse, matchBrace, false, matchCase);
872
				int pos= findReferencePosition(offset, danglingElse, matchBrace, false, matchCase, matchAccessSpecifier);
833
				fIndent--;
873
				fIndent--;
834
				return pos;
874
				return pos;
835
			}
875
			}
Lines 841-846 Link Here
841
			return matchCaseAlignment();
881
			return matchCaseAlignment();
842
		}
882
		}
843
883
884
		// the only reliable way to get case labels aligned (due to many different styles of using braces in a block)
885
		// is to go for another case statement, or the scope opening brace
886
		if (matchAccessSpecifier) {
887
			return matchAccessSpecifierAlignment();
888
		}
889
		
844
		nextToken();
890
		nextToken();
845
		switch (fToken) {
891
		switch (fToken) {
846
			case Symbols.TokenGREATERTHAN:
892
			case Symbols.TokenGREATERTHAN:
Lines 930-936 Link Here
930
				// if we are inside a continued expression, then either align with a previous line that has indentation
976
				// if we are inside a continued expression, then either align with a previous line that has indentation
931
				// or indent from the expression start line (either a scope introducer or the start of the expr).
977
				// or indent from the expression start line (either a scope introducer or the start of the expr).
932
				return skipToPreviousListItemOrListStart();
978
				return skipToPreviousListItemOrListStart();
933
934
		}
979
		}
935
	}
980
	}
936
981
Lines 1060-1068 Link Here
1060
1105
1061
				default:
1106
				default:
1062
					// keep searching
1107
					// keep searching
1063
1064
			}
1108
			}
1065
1066
		}
1109
		}
1067
	}
1110
	}
1068
1111
Lines 1085-1096 Link Here
1085
		while (true) {
1128
		while (true) {
1086
			nextToken();
1129
			nextToken();
1087
			switch (fToken) {
1130
			switch (fToken) {
1088
1089
				// search for case labels, which consist of (possibly qualified) identifiers or numbers
1131
				// search for case labels, which consist of (possibly qualified) identifiers or numbers
1090
				case Symbols.TokenIDENT:
1132
				case Symbols.TokenIDENT:
1091
				case Symbols.TokenOTHER: // dots for qualified constants
1133
				case Symbols.TokenOTHER: // dots for qualified constants
1092
					continue;
1134
					continue;
1135
1093
				case Symbols.TokenCASE:
1136
				case Symbols.TokenCASE:
1137
				case Symbols.TokenDEFAULT:
1138
				case Symbols.TokenPUBLIC:
1139
				case Symbols.TokenPROTECTED:
1140
				case Symbols.TokenPRIVATE:
1094
					return false;
1141
					return false;
1095
1142
1096
				default:
1143
				default:
Lines 1117-1126 Link Here
1117
				case Symbols.TokenLBRACKET:
1164
				case Symbols.TokenLBRACKET:
1118
				case Symbols.TokenEOF:
1165
				case Symbols.TokenEOF:
1119
					return fPosition;
1166
					return fPosition;
1167
					
1120
				case Symbols.TokenLBRACE:
1168
				case Symbols.TokenLBRACE:
1121
					// opening brace of switch statement
1169
					// opening brace of switch statement
1122
					fIndent= fPrefs.prefCaseIndent;
1170
					fIndent= fPrefs.prefCaseIndent;
1123
					return fPosition;
1171
					return fPosition;
1172
					
1124
				case Symbols.TokenCASE:
1173
				case Symbols.TokenCASE:
1125
				case Symbols.TokenDEFAULT:
1174
				case Symbols.TokenDEFAULT:
1126
					// align with previous label
1175
					// align with previous label
Lines 1138-1144 Link Here
1138
				default:
1187
				default:
1139
					// keep searching
1188
					// keep searching
1140
					continue;
1189
					continue;
1190
			}
1191
		}
1192
	}
1193
1194
	/**
1195
	 * Returns as a reference any previous <code>switch</code> labels (<code>case</code>
1196
	 * or <code>default</code>) or the offset of the brace that scopes the class body.
1197
	 * Sets <code>fIndent</code> to <code>prefAccessSpecifierIndent</code> upon
1198
	 * a match.
1199
	 *
1200
	 * @return the reference offset for an access specifier (public/protected/private)
1201
	 */
1202
	private int matchAccessSpecifierAlignment() {
1203
		while (true) {
1204
			nextToken();
1205
			switch (fToken) {
1206
				// invalid cases: another case label or an LBRACE must come before a case
1207
				// -> bail out with the current position
1208
				case Symbols.TokenLPAREN:
1209
				case Symbols.TokenLBRACKET:
1210
				case Symbols.TokenEOF:
1211
					return fPosition;
1212
					
1213
				case Symbols.TokenLBRACE:
1214
					// opening brace of switch statement
1215
					fIndent= fPrefs.prefAccessSpecifierIndent;
1216
					return fPosition;
1217
					
1218
				case Symbols.TokenPUBLIC:
1219
				case Symbols.TokenPROTECTED:
1220
				case Symbols.TokenPRIVATE:
1221
					// align with previous label
1222
					fIndent= 0;
1223
					return fPosition;
1141
1224
1225
				// scopes: skip them
1226
				case Symbols.TokenRPAREN:
1227
				case Symbols.TokenRBRACKET:
1228
				case Symbols.TokenRBRACE:
1229
				case Symbols.TokenGREATERTHAN:
1230
					skipScope();
1231
					break;
1232
1233
				default:
1234
					// keep searching
1235
					continue;
1142
			}
1236
			}
1143
		}
1237
		}
1144
	}
1238
	}
(-)src/org/eclipse/cdt/internal/ui/text/Symbols.java (-8 / +10 lines)
Lines 41-53 Link Here
41
	int TokenRETURN= 1018;
41
	int TokenRETURN= 1018;
42
	int TokenSTATIC= 1019;
42
	int TokenSTATIC= 1019;
43
	int TokenSWITCH= 1020;
43
	int TokenSWITCH= 1020;
44
//	int TokenFINALLY= 1021;
44
	int TokenGOTO= 1021;
45
//	int TokenSYNCHRONIZED= 1022;
45
	int TokenDEFAULT= 1022;
46
	int TokenGOTO= 1023;
46
  int TokenPRIVATE= 1023;
47
	int TokenDEFAULT= 1024;
47
  int TokenPROTECTED= 1024;
48
	int TokenNEW= 1025;
48
  int TokenPUBLIC= 1025;
49
	int TokenCLASS= 1026;
49
	int TokenNEW= 1026;
50
//	int TokenINTERFACE= 1027;
50
  int TokenDELETE= 1027; 
51
	int TokenENUM= 1028;
51
	int TokenCLASS= 1028;
52
	int TokenSTRUCT= 1029;
53
	int TokenENUM= 1030;
52
	int TokenIDENT= 2000;
54
	int TokenIDENT= 2000;
53
}
55
}
(-)src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java (-3 / +3 lines)
Lines 16-22 Link Here
16
16
17
import org.eclipse.cdt.core.CCorePlugin;
17
import org.eclipse.cdt.core.CCorePlugin;
18
import org.eclipse.cdt.core.formatter.CodeFormatter;
18
import org.eclipse.cdt.core.formatter.CodeFormatter;
19
import org.eclipse.cdt.core.formatter.CodeFormatterConstants;
19
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
20
import org.eclipse.cdt.core.model.CoreModel;
20
import org.eclipse.cdt.core.model.CoreModel;
21
import org.eclipse.cdt.core.parser.ParserLanguage;
21
import org.eclipse.cdt.core.parser.ParserLanguage;
22
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
22
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
Lines 142-149 Link Here
142
		} else
142
		} else
143
            preferences= new HashMap(CCorePlugin.getOptions());
143
            preferences= new HashMap(CCorePlugin.getOptions());
144
144
145
        preferences.put(CodeFormatterConstants.FORMATTER_LANGUAGE, language);
145
        preferences.put(DefaultCodeFormatterConstants.FORMATTER_LANGUAGE, language);
146
		preferences.put(CodeFormatterConstants.FORMATTER_CURRENT_FILE, activeFile);
146
		preferences.put(DefaultCodeFormatterConstants.FORMATTER_CURRENT_FILE, activeFile);
147
	          
147
	          
148
		context.storeToMap(CUIPlugin.getDefault().getPreferenceStore(), preferences, false);
148
		context.storeToMap(CUIPlugin.getDefault().getPreferenceStore(), preferences, false);
149
        context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences);
149
        context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences);
(-)src/org/eclipse/cdt/internal/ui/text/COutlineInformationControl.java (-50 / +81 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     QNX Software Systems - initial API and implementation
9
 *     QNX Software Systems - initial API and implementation
10
 *     Sergey Prigogin, Google
10
 *******************************************************************************/
11
 *******************************************************************************/
11
/*
12
/*
12
 * COutlineInformationControl.java 2004-12-14 / 08:17:41
13
 * COutlineInformationControl.java 2004-12-14 / 08:17:41
Lines 20-33 Link Here
20
import org.eclipse.cdt.internal.core.model.CElement;
21
import org.eclipse.cdt.internal.core.model.CElement;
21
import org.eclipse.cdt.internal.ui.CPluginImages;
22
import org.eclipse.cdt.internal.ui.CPluginImages;
22
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
23
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
24
import org.eclipse.cdt.internal.ui.actions.OpenActionUtil;
23
import org.eclipse.cdt.internal.ui.editor.CContentOutlinerProvider;
25
import org.eclipse.cdt.internal.ui.editor.CContentOutlinerProvider;
24
import org.eclipse.cdt.internal.ui.editor.CEditor;
25
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
26
import org.eclipse.cdt.internal.ui.util.ProblemTreeViewer;
26
import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
27
import org.eclipse.cdt.internal.ui.viewsupport.DecoratingCLabelProvider;
27
import org.eclipse.cdt.internal.ui.viewsupport.StandardCElementLabelProvider;
28
import org.eclipse.cdt.internal.ui.viewsupport.StandardCElementLabelProvider;
29
30
import org.eclipse.cdt.core.model.ICElement;
31
import org.eclipse.cdt.core.model.ITranslationUnit;
28
import org.eclipse.cdt.ui.CElementGrouping;
32
import org.eclipse.cdt.ui.CElementGrouping;
29
import org.eclipse.cdt.ui.CUIPlugin;
33
import org.eclipse.cdt.ui.CUIPlugin;
30
import org.eclipse.cdt.ui.IWorkingCopyManager;
34
35
import org.eclipse.core.runtime.CoreException;
31
import org.eclipse.jface.action.Action;
36
import org.eclipse.jface.action.Action;
32
import org.eclipse.jface.action.IAction;
37
import org.eclipse.jface.action.IAction;
33
import org.eclipse.jface.action.MenuManager;
38
import org.eclipse.jface.action.MenuManager;
Lines 36-44 Link Here
36
import org.eclipse.jface.dialogs.IDialogSettings;
41
import org.eclipse.jface.dialogs.IDialogSettings;
37
import org.eclipse.jface.text.IInformationControl;
42
import org.eclipse.jface.text.IInformationControl;
38
import org.eclipse.jface.text.IInformationControlExtension;
43
import org.eclipse.jface.text.IInformationControlExtension;
44
import org.eclipse.jface.text.IInformationControlExtension2;
39
import org.eclipse.jface.text.IInformationControlExtension3;
45
import org.eclipse.jface.text.IInformationControlExtension3;
40
import org.eclipse.jface.viewers.AbstractTreeViewer;
46
import org.eclipse.jface.viewers.AbstractTreeViewer;
41
import org.eclipse.jface.viewers.IContentProvider;
47
import org.eclipse.jface.viewers.IContentProvider;
48
import org.eclipse.jface.viewers.IStructuredSelection;
49
import org.eclipse.jface.viewers.StructuredSelection;
42
import org.eclipse.jface.viewers.TreeViewer;
50
import org.eclipse.jface.viewers.TreeViewer;
43
import org.eclipse.jface.viewers.Viewer;
51
import org.eclipse.jface.viewers.Viewer;
44
import org.eclipse.jface.viewers.ViewerSorter;
52
import org.eclipse.jface.viewers.ViewerSorter;
Lines 95-101 Link Here
95
 * @author P.Tomaszewski
103
 * @author P.Tomaszewski
96
 */
104
 */
97
public class COutlineInformationControl implements IInformationControl,
105
public class COutlineInformationControl implements IInformationControl,
98
        IInformationControlExtension, IInformationControlExtension3 {
106
        IInformationControlExtension, IInformationControlExtension2,
107
        IInformationControlExtension3 {
99
108
100
    /** If this option is set, location is not restored. */
109
    /** If this option is set, location is not restored. */
101
    private static final String STORE_RESTORE_SIZE= "ENABLE_RESTORE_SIZE"; //$NON-NLS-1$
110
    private static final String STORE_RESTORE_SIZE= "ENABLE_RESTORE_SIZE"; //$NON-NLS-1$
Lines 111-118 Link Here
111
    /** Minimum width set by setSizeConstrains to tree viewer. */
120
    /** Minimum width set by setSizeConstrains to tree viewer. */
112
    private static final int MIN_WIDTH = 300;
121
    private static final int MIN_WIDTH = 300;
113
122
114
    /** Source viewer which shows this control. */
123
	private ICElement fInput = null;
115
    CEditor fEditor;
124
	
116
    /** Shell for this control. */
125
    /** Shell for this control. */
117
    Shell fShell;
126
    Shell fShell;
118
    /** Control's composite. */
127
    /** Control's composite. */
Lines 155-162 Link Here
155
    /**
164
    /**
156
     * Creates new outline control.
165
     * Creates new outline control.
157
     * 
166
     * 
158
     * @param editor
159
     *            CEditor editor which uses this control.
160
     * @param parent
167
     * @param parent
161
     *            Shell parent.
168
     *            Shell parent.
162
     * @param shellStyle
169
     * @param shellStyle
Lines 164-173 Link Here
164
     * @param treeStyle
171
     * @param treeStyle
165
     *            Style of the tree viewer.
172
     *            Style of the tree viewer.
166
     */
173
     */
167
    public COutlineInformationControl(CEditor editor, Shell parent,
174
    public COutlineInformationControl(Shell parent, int shellStyle, int treeStyle) {
168
            int shellStyle, int treeStyle) {
169
        super();
175
        super();
170
        this.fEditor = editor;
171
        createShell(parent, shellStyle);
176
        createShell(parent, shellStyle);
172
        createComposite();
177
        createComposite();
173
        createToolbar();
178
        createToolbar();
Lines 175-181 Link Here
175
        createTreeeViewer(treeStyle);
180
        createTreeeViewer(treeStyle);
176
    }
181
    }
177
182
178
    /**
183
	/**
184
	 * {@inheritDoc}
185
	 */
186
	public void setInput(Object information) {
187
		if (information == null || information instanceof String) {
188
			inputChanged(null, null);
189
			return;
190
		}
191
		ICElement ce = (ICElement)information;
192
		ITranslationUnit tu = (ITranslationUnit)ce.getAncestor(ICElement.C_UNIT);
193
		if (tu != null)
194
			fInput = tu;
195
196
		inputChanged(fInput, information);
197
	}
198
199
	protected void inputChanged(Object newInput, Object newSelection) {
200
		fFilterText.setText(""); //$NON-NLS-1$
201
		fTreeViewer.setInput(newInput);
202
		if (newSelection != null) {
203
			fTreeViewer.setSelection(new StructuredSelection(newSelection));
204
		}
205
	}
206
207
	/**
208
	 * @return the selected element
209
	 */
210
	protected Object getSelectedElement() {
211
		if (fTreeViewer == null)
212
			return null;
213
214
		return ((IStructuredSelection) fTreeViewer.getSelection()).getFirstElement();
215
	}
216
217
	private void gotoSelectedElement() {
218
		Object selectedElement= getSelectedElement();
219
		if (selectedElement != null) {
220
			try {
221
				dispose();
222
				OpenActionUtil.open(selectedElement, true);
223
			} catch (CoreException e) {
224
				CUIPlugin.getDefault().log(e);
225
			}
226
		}
227
	}
228
229
	/**
179
     * @see org.eclipse.jface.text.IInformationControl#setInformation(java.lang.String)
230
     * @see org.eclipse.jface.text.IInformationControl#setInformation(java.lang.String)
180
     */
231
     */
181
    public void setInformation(String information) {
232
    public void setInformation(String information) {
Lines 415-422 Link Here
415
     * @param treeStyle Tree style.
466
     * @param treeStyle Tree style.
416
     */
467
     */
417
    private void createTreeeViewer(int treeStyle) {
468
    private void createTreeeViewer(int treeStyle) {
418
        final IWorkingCopyManager manager = CUIPlugin.getDefault()
419
                .getWorkingCopyManager();
420
        fTreeViewer = new ProblemTreeViewer(fComposite, treeStyle);
469
        fTreeViewer = new ProblemTreeViewer(fComposite, treeStyle);
421
        final Tree tree = fTreeViewer.getTree();
470
        final Tree tree = fTreeViewer.getTree();
422
        tree.setLayoutData(new GridData(GridData.FILL_BOTH));
471
        tree.setLayoutData(new GridData(GridData.FILL_BOTH));
Lines 429-439 Link Here
429
        fTreeViewer.setLabelProvider(new DecoratingCLabelProvider(
478
        fTreeViewer.setLabelProvider(new DecoratingCLabelProvider(
430
                new StandardCElementLabelProvider(), true));
479
                new StandardCElementLabelProvider(), true));
431
        fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
480
        fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
432
        fTreeViewer.setInput(manager.getWorkingCopy(fEditor.getEditorInput()));
433
        tree.addKeyListener(createKeyListenerForTreeViewer());
481
        tree.addKeyListener(createKeyListenerForTreeViewer());
434
        tree.addSelectionListener(createSelectionListenerForTreeViewer());
482
        tree.addSelectionListener(createSelectionListenerForTreeViewer());
435
        tree.addMouseMoveListener(createMouseMoveListenerForTreeViewer());
483
        tree.addMouseMoveListener(createMouseMoveListenerForTreeViewer());
436
        tree.addMouseListener(createMouseListenerForTreeViewer());
484
        tree.addMouseListener(createMouseListenerForTreeViewer(tree));
437
    }
485
    }
438
486
439
    /**
487
    /**
Lines 522-553 Link Here
522
     * 
570
     * 
523
     * @return Created mouse listener.
571
     * @return Created mouse listener.
524
     */
572
     */
525
    private MouseListener createMouseListenerForTreeViewer() {
573
    private MouseListener createMouseListenerForTreeViewer(final Tree tree) {
526
        final MouseListener mouseListener = new MouseAdapter() {
574
        final MouseListener mouseListener = new MouseAdapter() {
527
            public void mouseUp(MouseEvent e) {
575
			public void mouseUp(MouseEvent e) {
528
                final Tree tree = fTreeViewer.getTree();
529
                if (tree.getSelectionCount() < 1) {
530
                    return;
531
                }
532
                if (e.button != 1) {
533
                    return;
534
                }
535
576
536
                if (tree.equals(e.getSource())) {
577
				if (tree.getSelectionCount() < 1)
537
                    Object o = tree.getItem(new Point(e.x, e.y));
578
					return;
538
                    final TreeItem selection = tree.getSelection()[0];
579
539
                    if (selection.equals(o)) {
580
				if (e.button != 1)
540
                        CElement selectedElement = (CElement) selection
581
					return;
541
                                .getData();
582
542
                        fEditor.setSelection(selectedElement);
583
				if (tree.equals(e.getSource())) {
543
                        dispose();
584
					Object o= tree.getItem(new Point(e.x, e.y));
544
                    }
585
					TreeItem selection= tree.getSelection()[0];
545
                    if (fComposite != null && !fComposite.isDisposed())
586
					if (selection.equals(o))
546
                    {
587
						gotoSelectedElement();
547
                        fBounds = fComposite.getBounds();
588
				}
548
                    }
589
			}
549
                }
550
            }
551
        };
590
        };
552
        return mouseListener;
591
        return mouseListener;
553
    }
592
    }
Lines 612-627 Link Here
612
            /**
651
            /**
613
             * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
652
             * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
614
             */
653
             */
615
            public void widgetDefaultSelected(SelectionEvent e) {
654
			public void widgetDefaultSelected(SelectionEvent e) {
616
                final TreeItem[] selection = ((Tree) fTreeViewer.getControl())
655
				gotoSelectedElement();
617
                        .getSelection();
656
			}
618
                if (selection.length > 0) {
619
                    CElement selectedElement = (CElement) selection[0]
620
                            .getData();
621
                    fEditor.setSelection(selectedElement);
622
                    dispose();
623
                }
624
            }
625
        };
657
        };
626
        return selectionListener;
658
        return selectionListener;
627
    }
659
    }
Lines 1017-1021 Link Here
1017
            fIsDeactivationActive = true;
1049
            fIsDeactivationActive = true;
1018
        }
1050
        }
1019
    }
1051
    }
1020
    
1021
}
1052
}
(-)src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java (-40 / +551 lines)
Lines 13-25 Link Here
13
 *******************************************************************************/
13
 *******************************************************************************/
14
package org.eclipse.cdt.internal.ui.text;
14
package org.eclipse.cdt.internal.ui.text;
15
15
16
import org.eclipse.core.runtime.Assert;
16
import org.eclipse.jface.preference.IPreferenceStore;
17
import org.eclipse.jface.preference.IPreferenceStore;
17
import org.eclipse.jface.text.BadLocationException;
18
import org.eclipse.jface.text.BadLocationException;
18
import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
19
import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
20
import org.eclipse.jface.text.Document;
19
import org.eclipse.jface.text.DocumentCommand;
21
import org.eclipse.jface.text.DocumentCommand;
22
import org.eclipse.jface.text.DocumentRewriteSession;
23
import org.eclipse.jface.text.DocumentRewriteSessionType;
20
import org.eclipse.jface.text.IDocument;
24
import org.eclipse.jface.text.IDocument;
21
import org.eclipse.jface.text.IRegion;
25
import org.eclipse.jface.text.IRegion;
22
import org.eclipse.jface.text.TextUtilities;
26
import org.eclipse.jface.text.TextUtilities;
27
import org.eclipse.jface.text.rules.FastPartitioner;
23
import org.eclipse.ui.IEditorPart;
28
import org.eclipse.ui.IEditorPart;
24
import org.eclipse.ui.IWorkbenchPage;
29
import org.eclipse.ui.IWorkbenchPage;
25
import org.eclipse.ui.texteditor.ITextEditorExtension3;
30
import org.eclipse.ui.texteditor.ITextEditorExtension3;
Lines 29-39 Link Here
29
import org.eclipse.cdt.ui.PreferenceConstants;
34
import org.eclipse.cdt.ui.PreferenceConstants;
30
import org.eclipse.cdt.ui.text.ICPartitions;
35
import org.eclipse.cdt.ui.text.ICPartitions;
31
36
37
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
38
32
/**
39
/**
33
 * Auto indent strategy sensitive to brackets.
40
 * Auto indent strategy sensitive to brackets.
34
 */
41
 */
35
public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
42
public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
36
	private static final String MULTILINE_COMMENT_CLOSE = "*/"; //$NON-NLS-1$
43
	private static final String MULTILINE_COMMENT_CLOSE = "*/"; //$NON-NLS-1$
44
	/** The line comment introducer. Value is "{@value}" */
45
	private static final String LINE_COMMENT= "//"; //$NON-NLS-1$
37
//	private static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
46
//	private static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
38
47
39
	private static class CompilationUnitInfo {
48
	private static class CompilationUnitInfo {
Lines 65-76 Link Here
65
74
66
	// evaluate the line with the opening bracket that matches the closing bracket on the given line
75
	// evaluate the line with the opening bracket that matches the closing bracket on the given line
67
	protected int findMatchingOpenBracket(IDocument d, int line, int end, int closingBracketIncrease) throws BadLocationException {
76
	protected int findMatchingOpenBracket(IDocument d, int line, int end, int closingBracketIncrease) throws BadLocationException {
68
69
70
		int start = d.getLineOffset(line);
77
		int start = d.getLineOffset(line);
71
		int brackcount = getBracketCount(d, start, end, false) - closingBracketIncrease;
78
		int brackcount = getBracketCount(d, start, end, false) - closingBracketIncrease;
72
79
73
74
		// sum up the brackets counts of each line (closing brackets count negative, 
80
		// sum up the brackets counts of each line (closing brackets count negative, 
75
		// opening positive) until we find a line the brings the count to zero
81
		// opening positive) until we find a line the brings the count to zero
76
		while (brackcount < 0) {
82
		while (brackcount < 0) {
Lines 85-91 Link Here
85
		return line;
91
		return line;
86
	}
92
	}
87
93
88
89
	private int getBracketCount(IDocument d, int start, int end, boolean ignoreCloseBrackets) throws BadLocationException {
94
	private int getBracketCount(IDocument d, int start, int end, boolean ignoreCloseBrackets) throws BadLocationException {
90
		int bracketcount = 0;
95
		int bracketcount = 0;
91
		while (start < end) {
96
		while (start < end) {
Lines 135-141 Link Here
135
140
136
	// ----------- bracket counting ------------------------------------------------------
141
	// ----------- bracket counting ------------------------------------------------------
137
142
138
139
	private int getCommentEnd(IDocument d, int pos, int end) throws BadLocationException {
143
	private int getCommentEnd(IDocument d, int pos, int end) throws BadLocationException {
140
		while (pos < end) {
144
		while (pos < end) {
141
			char curr = d.getChar(pos);
145
			char curr = d.getChar(pos);
Lines 183-189 Link Here
183
			int start = d.getLineOffset(line);
187
			int start = d.getLineOffset(line);
184
			int whiteend = findEndOfWhiteSpace(d, start, c.offset);
188
			int whiteend = findEndOfWhiteSpace(d, start, c.offset);
185
189
186
187
			// shift only when line does not contain any text up to the closing bracket
190
			// shift only when line does not contain any text up to the closing bracket
188
			if (whiteend == c.offset) {
191
			if (whiteend == c.offset) {
189
				// evaluate the line with the opening bracket that matches out closing bracket
192
				// evaluate the line with the opening bracket that matches out closing bracket
Lines 221-227 Link Here
221
			// shift only when line does not contain any text up to the closing bracket
224
			// shift only when line does not contain any text up to the closing bracket
222
			if (whiteend == c.offset) {
225
			if (whiteend == c.offset) {
223
				// evaluate the line with the opening bracket that matches out closing bracket
226
				// evaluate the line with the opening bracket that matches out closing bracket
224
				int reference = indenter.findReferencePosition(c.offset, false, true, false, false);
227
				int reference = indenter.findReferencePosition(c.offset, false, true, false, false, false);
225
				int indLine = d.getLineOfOffset(reference);
228
				int indLine = d.getLineOfOffset(reference);
226
				if (indLine != -1 && indLine != line) {
229
				if (indLine != -1 && indLine != line) {
227
					// take the indent of the found line
230
					// take the indent of the found line
Lines 257-269 Link Here
257
			if (d.get(lineOffset, p - lineOffset).trim().length() != 0)
260
			if (d.get(lineOffset, p - lineOffset).trim().length() != 0)
258
				return;
261
				return;
259
262
260
			// line of last javacode
263
			// Line of last C code
261
			int pos = scanner.findNonWhitespaceBackward(p, CHeuristicScanner.UNBOUND);
264
			int pos = scanner.findNonWhitespaceBackward(p, CHeuristicScanner.UNBOUND);
262
			if (pos == -1)
265
			if (pos == -1)
263
				return;
266
				return;
264
			int lastLine = d.getLineOfOffset(pos);
267
			int lastLine = d.getLineOfOffset(pos);
265
268
266
			// only shift if the last java line is further up and is a braceless block candidate
269
			// Only shift if the last C line is further up and is a braceless block candidate
267
			if (lastLine < line) {
270
			if (lastLine < line) {
268
				CIndenter indenter = new CIndenter(d, scanner, fProject);
271
				CIndenter indenter = new CIndenter(d, scanner, fProject);
269
				StringBuffer indent = indenter.computeIndentation(p, true);
272
				StringBuffer indent = indenter.computeIndentation(p, true);
Lines 405-411 Link Here
405
	 * Finds a closing parenthesis to the left of <code>position</code> in document, where that parenthesis is only
408
	 * Finds a closing parenthesis to the left of <code>position</code> in document, where that parenthesis is only
406
	 * separated by whitespace from <code>position</code>. If no such parenthesis can be found, <code>position</code> is returned.
409
	 * separated by whitespace from <code>position</code>. If no such parenthesis can be found, <code>position</code> is returned.
407
	 *
410
	 *
408
	 * @param scanner the java heuristic scanner set up on the document
411
	 * @param scanner the C heuristic scanner set up on the document
409
	 * @param position the first character position in <code>document</code> to be considered
412
	 * @param position the first character position in <code>document</code> to be considered
410
	 * @return the position of a closing parenthesis left to <code>position</code> separated only by whitespace, or <code>position</code> if no parenthesis can be found
413
	 * @return the position of a closing parenthesis left to <code>position</code> separated only by whitespace, or <code>position</code> if no parenthesis can be found
411
	 */
414
	 */
Lines 519-524 Link Here
519
		return false;
522
		return false;
520
	}
523
	}
521
524
525
	/**
526
	 * Installs a C partitioner with <code>document</code>.
527
	 *
528
	 * @param document the document
529
	 */
530
	private static void installCPartitioner(Document document) {
531
		String[] types= new String[] {
532
		    ICPartitions.C_MULTI_LINE_COMMENT,
533
			ICPartitions.C_SINGLE_LINE_COMMENT,
534
			ICPartitions.C_STRING,
535
			ICPartitions.C_CHARACTER,
536
			IDocument.DEFAULT_CONTENT_TYPE
537
		};
538
		FastPartitioner partitioner= new FastPartitioner(new FastCPartitionScanner(), types);
539
		partitioner.connect(document);
540
		document.setDocumentPartitioner(ICPartitions.C_PARTITIONING, partitioner);
541
	}
542
543
	/**
544
	 * Installs a C partitioner with <code>document</code>.
545
	 *
546
	 * @param document the document
547
	 */
548
	private static void removeCPartitioner(Document document) {
549
		document.setDocumentPartitioner(ICPartitions.C_PARTITIONING, null);
550
	}
551
	
552
	private void smartPaste(IDocument document, DocumentCommand command) {
553
		int newOffset= command.offset;
554
		int newLength= command.length;
555
		String newText= command.text;
556
557
		try {
558
			CHeuristicScanner scanner= new CHeuristicScanner(document);
559
			CIndenter indenter= new CIndenter(document, scanner, fProject);
560
			int offset= newOffset;
561
562
			// reference position to get the indent from
563
			int refOffset= indenter.findReferencePosition(offset);
564
			if (refOffset == CHeuristicScanner.NOT_FOUND)
565
				return;
566
			int peerOffset= getPeerPosition(document, command);
567
			peerOffset= indenter.findReferencePosition(peerOffset);
568
			refOffset= Math.min(refOffset, peerOffset);
569
570
			// eat any WS before the insertion to the beginning of the line
571
			int firstLine= 1; // don't format the first line per default, as it has other content before it
572
			IRegion line= document.getLineInformationOfOffset(offset);
573
			String notSelected= document.get(line.getOffset(), offset - line.getOffset());
574
			if (notSelected.trim().length() == 0) {
575
				newLength += notSelected.length();
576
				newOffset= line.getOffset();
577
				firstLine= 0;
578
			}
579
580
			// prefix: the part we need for formatting but won't paste
581
			IRegion refLine= document.getLineInformationOfOffset(refOffset);
582
			String prefix= document.get(refLine.getOffset(), newOffset - refLine.getOffset());
583
584
			// handle the indentation computation inside a temporary document
585
			Document temp= new Document(prefix + newText);
586
			DocumentRewriteSession session= temp.startRewriteSession(DocumentRewriteSessionType.STRICTLY_SEQUENTIAL);
587
			scanner= new CHeuristicScanner(temp);
588
			indenter= new CIndenter(temp, scanner, fProject);
589
			installCPartitioner(temp);
590
591
			// indent the first and second line
592
			// compute the relative indentation difference from the second line
593
			// (as the first might be partially selected) and use the value to
594
			// indent all other lines.
595
			boolean isIndentDetected= false;
596
			StringBuffer addition= new StringBuffer();
597
			int insertLength= 0;
598
			int first= document.computeNumberOfLines(prefix) + firstLine; // don't format first line
599
			int lines= temp.getNumberOfLines();
600
			boolean changed= false;
601
602
			for (int l= first; l < lines; l++) { // we don't change the number of lines while adding indents
603
				IRegion r= temp.getLineInformation(l);
604
				int lineOffset= r.getOffset();
605
				int lineLength= r.getLength();
606
607
				if (lineLength == 0) // don't modify empty lines
608
					continue;
609
610
				if (!isIndentDetected) {
611
					// indent the first pasted line
612
					String current= getCurrentIndent(temp, l);
613
					StringBuffer correct= indenter.computeIndentation(lineOffset);
614
					if (correct == null)
615
						return; // bail out
616
617
					insertLength= subtractIndent(correct, current, addition);
618
					if (l != first && temp.get(lineOffset, lineLength).trim().length() != 0) {
619
						isIndentDetected= true;
620
						if (insertLength == 0) {
621
							 // no adjustment needed, bail out
622
							if (firstLine == 0) {
623
								// but we still need to adjust the first line
624
								command.offset= newOffset;
625
								command.length= newLength;
626
								if (changed)
627
									break; // still need to get the leading indent of the first line
628
							}
629
							return;
630
						}
631
						removeCPartitioner(temp);
632
					} else {
633
						changed= insertLength != 0;
634
					}
635
				}
636
637
				// relatively indent all pasted lines
638
				if (insertLength > 0)
639
					addIndent(temp, l, addition);
640
				else if (insertLength < 0)
641
					cutIndent(temp, l, -insertLength);
642
			}
643
644
			temp.stopRewriteSession(session);
645
			newText= temp.get(prefix.length(), temp.getLength() - prefix.length());
646
647
			command.offset= newOffset;
648
			command.length= newLength;
649
			command.text= newText;
650
		} catch (BadLocationException e) {
651
			CUIPlugin.getDefault().log(e);
652
		}
653
	}
654
655
	/**
656
	 * Returns the indentation of the line <code>line</code> in <code>document</code>.
657
	 * The returned string may contain pairs of leading slashes that are considered
658
	 * part of the indentation. The space before the asterix in a javadoc-like
659
	 * comment is not considered part of the indentation.
660
	 *
661
	 * @param document the document
662
	 * @param line the line
663
	 * @return the indentation of <code>line</code> in <code>document</code>
664
	 * @throws BadLocationException if the document is changed concurrently
665
	 */
666
	private static String getCurrentIndent(Document document, int line) throws BadLocationException {
667
		IRegion region= document.getLineInformation(line);
668
		int from= region.getOffset();
669
		int endOffset= region.getOffset() + region.getLength();
670
671
		// go behind line comments
672
		int to= from;
673
		while (to < endOffset - 2 && document.get(to, 2).equals(LINE_COMMENT))
674
			to += 2;
675
676
		while (to < endOffset) {
677
			char ch= document.getChar(to);
678
			if (!Character.isWhitespace(ch))
679
				break;
680
			to++;
681
		}
682
683
		// don't count the space before javadoc like, asterix-style comment lines
684
		if (to > from && to < endOffset - 1 && document.get(to - 1, 2).equals(" *")) { //$NON-NLS-1$
685
			String type= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, to, true);
686
			if (type.equals(ICPartitions.C_MULTI_LINE_COMMENT))
687
				to--;
688
		}
689
690
		return document.get(from, to - from);
691
	}
692
693
	/**
694
	 * Computes the difference of two indentations and returns the difference in
695
	 * length of current and correct. If the return value is positive, <code>addition</code>
696
	 * is initialized with a substring of that length of <code>correct</code>.
697
	 *
698
	 * @param correct the correct indentation
699
	 * @param current the current indentation (migth contain non-whitespace)
700
	 * @param difference a string buffer - if the return value is positive, it will be cleared and set to the substring of <code>current</code> of that length
701
	 * @return the difference in lenght of <code>correct</code> and <code>current</code>
702
	 */
703
	private int subtractIndent(CharSequence correct, CharSequence current, StringBuffer difference) {
704
		int c1= computeVisualLength(correct);
705
		int c2= computeVisualLength(current);
706
		int diff= c1 - c2;
707
		if (diff <= 0)
708
			return diff;
709
710
		difference.setLength(0);
711
		int len= 0, i= 0;
712
		while (len < diff) {
713
			char c= correct.charAt(i++);
714
			difference.append(c);
715
			len += computeVisualLength(c);
716
		}
717
718
		return diff;
719
	}
720
721
	/**
722
	 * Indents line <code>line</code> in <code>document</code> with <code>indent</code>.
723
	 * Leaves leading comment signs alone.
724
	 *
725
	 * @param document the document
726
	 * @param line the line
727
	 * @param indent the indentation to insert
728
	 * @throws BadLocationException on concurrent document modification
729
	 */
730
	private static void addIndent(Document document, int line, CharSequence indent) throws BadLocationException {
731
		IRegion region= document.getLineInformation(line);
732
		int insert= region.getOffset();
733
		int endOffset= region.getOffset() + region.getLength();
734
735
		// go behind line comments
736
		while (insert < endOffset - 2 && document.get(insert, 2).equals(LINE_COMMENT))
737
			insert += 2;
738
739
		// insert indent
740
		document.replace(insert, 0, indent.toString());
741
	}
742
743
	/**
744
	 * Cuts the visual equivalent of <code>toDelete</code> characters out of the
745
	 * indentation of line <code>line</code> in <code>document</code>. Leaves
746
	 * leading comment signs alone.
747
	 *
748
	 * @param document the document
749
	 * @param line the line
750
	 * @param toDelete the number of space equivalents to delete.
751
	 * @throws BadLocationException on concurrent document modification
752
	 */
753
	private void cutIndent(Document document, int line, int toDelete) throws BadLocationException {
754
		IRegion region= document.getLineInformation(line);
755
		int from= region.getOffset();
756
		int endOffset= region.getOffset() + region.getLength();
757
758
		// go behind line comments
759
		while (from < endOffset - 2 && document.get(from, 2).equals(LINE_COMMENT))
760
			from += 2;
761
762
		int to= from;
763
		while (toDelete > 0 && to < endOffset) {
764
			char ch= document.getChar(to);
765
			if (!Character.isWhitespace(ch))
766
				break;
767
			toDelete -= computeVisualLength(ch);
768
			if (toDelete >= 0)
769
				to++;
770
			else
771
				break;
772
		}
773
774
		document.replace(from, to - from, null);
775
	}
776
777
	/**
778
	 * Returns the visual length of a given <code>CharSequence</code> taking into
779
	 * account the visual tabulator length.
780
	 *
781
	 * @param seq the string to measure
782
	 * @return the visual length of <code>seq</code>
783
	 */
784
	private int computeVisualLength(CharSequence seq) {
785
		int size= 0;
786
		int tablen= getVisualTabLengthPreference();
787
788
		for (int i= 0; i < seq.length(); i++) {
789
			char ch= seq.charAt(i);
790
			if (ch == '\t') {
791
				if (tablen != 0)
792
					size += tablen - size % tablen;
793
				// else: size stays the same
794
			} else {
795
				size++;
796
			}
797
		}
798
		return size;
799
	}
800
801
	/**
802
	 * Returns the visual length of a given character taking into
803
	 * account the visual tabulator length.
804
	 *
805
	 * @param ch the character to measure
806
	 * @return the visual length of <code>ch</code>
807
	 */
808
	private int computeVisualLength(char ch) {
809
		if (ch == '\t')
810
			return getVisualTabLengthPreference();
811
		else
812
			return 1;
813
	}
814
815
	/**
816
	 * The preference setting for the visual tabulator display.
817
	 *
818
	 * @return the number of spaces displayed for a tabulator in the editor
819
	 */
820
	private int getVisualTabLengthPreference() {
821
		return CodeFormatterUtil.getTabWidth(fProject);
822
	}
823
824
	private int getPeerPosition(IDocument document, DocumentCommand command) {
825
		if (document.getLength() == 0)
826
			return 0;
827
    	/*
828
    	 * Search for scope closers in the pasted text and find their opening peers
829
    	 * in the document.
830
    	 */
831
    	Document pasted= new Document(command.text);
832
    	installCPartitioner(pasted);
833
    	int firstPeer= command.offset;
834
835
    	CHeuristicScanner pScanner= new CHeuristicScanner(pasted);
836
    	CHeuristicScanner dScanner= new CHeuristicScanner(document);
837
838
    	// add scope relevant after context to peer search
839
    	int afterToken= dScanner.nextToken(command.offset + command.length, CHeuristicScanner.UNBOUND);
840
    	try {
841
			switch (afterToken) {
842
			case Symbols.TokenRBRACE:
843
				pasted.replace(pasted.getLength(), 0, "}"); //$NON-NLS-1$
844
				break;
845
			case Symbols.TokenRPAREN:
846
				pasted.replace(pasted.getLength(), 0, ")"); //$NON-NLS-1$
847
				break;
848
			case Symbols.TokenRBRACKET:
849
				pasted.replace(pasted.getLength(), 0, "]"); //$NON-NLS-1$
850
				break;
851
			}
852
		} catch (BadLocationException e) {
853
			// cannot happen
854
			Assert.isTrue(false);
855
		}
856
857
    	int pPos= 0; // paste text position (increasing from 0)
858
    	int dPos= Math.max(0, command.offset - 1); // document position (decreasing from paste offset)
859
    	while (true) {
860
    		int token= pScanner.nextToken(pPos, CHeuristicScanner.UNBOUND);
861
   			pPos= pScanner.getPosition();
862
    		switch (token) {
863
    			case Symbols.TokenLBRACE:
864
    			case Symbols.TokenLBRACKET:
865
    			case Symbols.TokenLPAREN:
866
    				pPos= skipScope(pScanner, pPos, token);
867
    				if (pPos == CHeuristicScanner.NOT_FOUND)
868
    					return firstPeer;
869
    				break; // closed scope -> keep searching
870
    			case Symbols.TokenRBRACE:
871
    				int peer= dScanner.findOpeningPeer(dPos, '{', '}');
872
    				dPos= peer - 1;
873
    				if (peer == CHeuristicScanner.NOT_FOUND)
874
    					return firstPeer;
875
    				firstPeer= peer;
876
    				break; // keep searching
877
    			case Symbols.TokenRBRACKET:
878
    				peer= dScanner.findOpeningPeer(dPos, '[', ']');
879
    				dPos= peer - 1;
880
    				if (peer == CHeuristicScanner.NOT_FOUND)
881
    					return firstPeer;
882
    				firstPeer= peer;
883
    				break; // keep searching
884
    			case Symbols.TokenRPAREN:
885
    				peer= dScanner.findOpeningPeer(dPos, '(', ')');
886
    				dPos= peer - 1;
887
    				if (peer == CHeuristicScanner.NOT_FOUND)
888
    					return firstPeer;
889
    				firstPeer= peer;
890
    				break; // keep searching
891
    				
892
    			case Symbols.TokenCASE:
893
    			case Symbols.TokenDEFAULT:
894
    			    {
895
    					CIndenter indenter= new CIndenter(document, dScanner, fProject);
896
    					peer= indenter.findReferencePosition(dPos, false, false, false, true, false);
897
    					if (peer == CHeuristicScanner.NOT_FOUND)
898
    						return firstPeer;
899
    					firstPeer= peer;
900
    				}
901
    				break; // keep searching
902
903
    			case Symbols.TokenPUBLIC:
904
    			case Symbols.TokenPROTECTED:
905
    			case Symbols.TokenPRIVATE:
906
				    {
907
						CIndenter indenter= new CIndenter(document, dScanner, fProject);
908
						peer= indenter.findReferencePosition(dPos, false, false, false, false, true);
909
						if (peer == CHeuristicScanner.NOT_FOUND)
910
							return firstPeer;
911
						firstPeer= peer;
912
					}
913
    				break; // keep searching
914
    				
915
    			case Symbols.TokenEOF:
916
    				return firstPeer;
917
    			default:
918
    				// keep searching
919
    		}
920
    	}
921
    }
922
923
    /**
924
     * Skips the scope opened by <code>token</code> in <code>document</code>,
925
     * returns either the position of the
926
     * @param pos
927
     * @param token
928
     * @return the position after the scope
929
     */
930
    private static int skipScope(CHeuristicScanner scanner, int pos, int token) {
931
    	int openToken= token;
932
    	int closeToken;
933
    	switch (token) {
934
    		case Symbols.TokenLPAREN:
935
    			closeToken= Symbols.TokenRPAREN;
936
    			break;
937
    		case Symbols.TokenLBRACKET:
938
    			closeToken= Symbols.TokenRBRACKET;
939
    			break;
940
    		case Symbols.TokenLBRACE:
941
    			closeToken= Symbols.TokenRBRACE;
942
    			break;
943
    		default:
944
    			Assert.isTrue(false);
945
    			return -1; // dummy
946
    	}
947
948
    	int depth= 1;
949
    	int p= pos;
950
951
    	while (true) {
952
    		int tok= scanner.nextToken(p, CHeuristicScanner.UNBOUND);
953
    		p= scanner.getPosition();
954
955
    		if (tok == openToken) {
956
    			depth++;
957
    		} else if (tok == closeToken) {
958
    			depth--;
959
    			if (depth == 0)
960
    				return p + 1;
961
    		} else if (tok == Symbols.TokenEOF) {
962
    			return CHeuristicScanner.NOT_FOUND;
963
    		}
964
    	}
965
    }
966
522
	private void smartIndentOnKeypress(IDocument document, DocumentCommand command) {
967
	private void smartIndentOnKeypress(IDocument document, DocumentCommand command) {
523
		switch (command.text.charAt(0)) {
968
		switch (command.text.charAt(0)) {
524
			case '}':
969
			case '}':
Lines 530-571 Link Here
530
			case 'e':
975
			case 'e':
531
				smartIndentUponE(document, command);
976
				smartIndentUponE(document, command);
532
				break;
977
				break;
978
			case ':':
979
				smartIndentAfterColumn(document, command);
980
				break;
533
		}
981
		}
534
	}
982
	}
535
983
536
	private void smartIndentUponE(IDocument d, DocumentCommand c) {
984
	private void smartIndentUponE(IDocument doc, DocumentCommand c) {
537
		if (c.offset < 4 || d.getLength() == 0)
985
		if (c.offset < 4 || doc.getLength() == 0)
538
			return;
986
			return;
539
987
540
		try {
988
		try {
541
			String content = d.get(c.offset - 3, 3);
989
			String content = doc.get(c.offset - 3, 3);
542
			if (content.equals("els")) { //$NON-NLS-1$
990
			if (content.equals("els")) { //$NON-NLS-1$
543
				CHeuristicScanner scanner = new CHeuristicScanner(d);
991
				CHeuristicScanner scanner = new CHeuristicScanner(doc);
544
				int p = c.offset - 3;
992
				int p = c.offset - 3;
545
993
546
				// current line
994
				// current line
547
				int line = d.getLineOfOffset(p);
995
				int line = doc.getLineOfOffset(p);
548
				int lineOffset = d.getLineOffset(line);
996
				int lineOffset = doc.getLineOffset(line);
549
997
550
				// make sure we don't have any leading comments etc.
998
				// make sure we don't have any leading comments etc.
551
				if (d.get(lineOffset, p - lineOffset).trim().length() != 0)
999
				if (doc.get(lineOffset, p - lineOffset).trim().length() != 0)
552
					return;
1000
					return;
553
1001
554
				// line of last javacode
1002
				// Line of last C code
555
				int pos = scanner.findNonWhitespaceBackward(p - 1, CHeuristicScanner.UNBOUND);
1003
				int pos = scanner.findNonWhitespaceBackward(p - 1, CHeuristicScanner.UNBOUND);
556
				if (pos == -1)
1004
				if (pos == -1)
557
					return;
1005
					return;
558
				int lastLine = d.getLineOfOffset(pos);
1006
				int lastLine = doc.getLineOfOffset(pos);
559
1007
560
				// only shift if the last java line is further up and is a braceless block candidate
1008
				// Only shift if the last C line is further up and is a braceless block candidate
561
				if (lastLine < line) {
1009
				if (lastLine < line) {
562
1010
					CIndenter indenter = new CIndenter(doc, scanner, fProject);
563
					CIndenter indenter = new CIndenter(d, scanner, fProject);
1011
					int ref = indenter.findReferencePosition(p, true, false, false, false, false);
564
					int ref = indenter.findReferencePosition(p, true, false, false, false);
565
					if (ref == CHeuristicScanner.NOT_FOUND)
1012
					if (ref == CHeuristicScanner.NOT_FOUND)
566
						return;
1013
						return;
567
					int refLine = d.getLineOfOffset(ref);
1014
					int refLine = doc.getLineOfOffset(ref);
568
					String indent = getIndentOfLine(d, refLine);
1015
					String indent = getIndentOfLine(doc, refLine);
569
1016
570
					if (indent != null) {
1017
					if (indent != null) {
571
						c.text = indent.toString() + "else"; //$NON-NLS-1$
1018
						c.text = indent.toString() + "else"; //$NON-NLS-1$
Lines 578-612 Link Here
578
			}
1025
			}
579
1026
580
			if (content.equals("cas")) { //$NON-NLS-1$
1027
			if (content.equals("cas")) { //$NON-NLS-1$
581
				CHeuristicScanner scanner = new CHeuristicScanner(d);
1028
				CHeuristicScanner scanner = new CHeuristicScanner(doc);
582
				int p = c.offset - 3;
1029
				int p = c.offset - 3;
583
1030
584
				// current line
1031
				// current line
585
				int line = d.getLineOfOffset(p);
1032
				int line = doc.getLineOfOffset(p);
586
				int lineOffset = d.getLineOffset(line);
1033
				int lineOffset = doc.getLineOffset(line);
587
1034
588
				// make sure we don't have any leading comments etc.
1035
				// make sure we don't have any leading comments etc.
589
				if (d.get(lineOffset, p - lineOffset).trim().length() != 0)
1036
				if (doc.get(lineOffset, p - lineOffset).trim().length() != 0)
590
					return;
1037
					return;
591
1038
592
				// line of last javacode
1039
				// Line of last C code
593
				int pos = scanner.findNonWhitespaceBackward(p - 1, CHeuristicScanner.UNBOUND);
1040
				int pos = scanner.findNonWhitespaceBackward(p - 1, CHeuristicScanner.UNBOUND);
594
				if (pos == -1)
1041
				if (pos == -1)
595
					return;
1042
					return;
596
				int lastLine = d.getLineOfOffset(pos);
1043
				int lastLine = doc.getLineOfOffset(pos);
597
1044
598
				// only shift if the last java line is further up and is a braceless block candidate
1045
				// Only shift if the last C line is further up and is a braceless block candidate
599
				if (lastLine < line) {
1046
				if (lastLine < line) {
600
1047
					CIndenter indenter = new CIndenter(doc, scanner, fProject);
601
					CIndenter indenter = new CIndenter(d, scanner, fProject);
1048
					int ref = indenter.findReferencePosition(p, false, false, false, true, false);
602
					int ref = indenter.findReferencePosition(p, false, false, false, true);
603
					if (ref == CHeuristicScanner.NOT_FOUND)
1049
					if (ref == CHeuristicScanner.NOT_FOUND)
604
						return;
1050
						return;
605
					int refLine = d.getLineOfOffset(ref);
1051
					int refLine = doc.getLineOfOffset(ref);
606
					int nextToken = scanner.nextToken(ref, CHeuristicScanner.UNBOUND);
1052
					int nextToken = scanner.nextToken(ref, CHeuristicScanner.UNBOUND);
607
					String indent;
1053
					String indent;
608
					if (nextToken == Symbols.TokenCASE || nextToken == Symbols.TokenDEFAULT)
1054
					if (nextToken == Symbols.TokenCASE || nextToken == Symbols.TokenDEFAULT)
609
						indent = getIndentOfLine(d, refLine);
1055
						indent = getIndentOfLine(doc, refLine);
610
					else // at the brace of the switch
1056
					else // at the brace of the switch
611
						indent = indenter.computeIndentation(p).toString();
1057
						indent = indenter.computeIndentation(p).toString();
612
1058
Lines 624-629 Link Here
624
		}
1070
		}
625
	}
1071
	}
626
1072
1073
	private void smartIndentAfterColumn(IDocument doc, DocumentCommand c) {
1074
		try {
1075
			int offset = c.offset;
1076
			// Current line
1077
			int line = doc.getLineOfOffset(offset);
1078
			IRegion startLine = doc.getLineInformationOfOffset(offset);
1079
			int lineOffset = startLine.getOffset();
1080
1081
			CHeuristicScanner scanner = new CHeuristicScanner(doc);
1082
			int prevToken = scanner.previousToken(offset - 1, lineOffset);
1083
			switch (prevToken) {
1084
				case Symbols.TokenDEFAULT:
1085
				case Symbols.TokenPUBLIC:
1086
				case Symbols.TokenPROTECTED:
1087
				case Symbols.TokenPRIVATE:
1088
					break;
1089
					
1090
				default:
1091
					return;
1092
			}
1093
			
1094
			int p = scanner.getPosition() + 1;
1095
1096
			// Make sure we don't have any leading comments etc.
1097
			if (doc.get(lineOffset, p - lineOffset).trim().length() != 0)
1098
				return;
1099
			
1100
			// Line of last C code
1101
			int pos = scanner.findNonWhitespaceBackward(p - 1, CHeuristicScanner.UNBOUND);
1102
			if (pos == -1)
1103
				return;
1104
			int lastLine = doc.getLineOfOffset(pos);
1105
1106
			// Only shift if the last C line is further up and is a braceless block candidate
1107
			if (lastLine < line) {
1108
				CIndenter indenter = new CIndenter(doc, scanner, fProject);
1109
				int ref;
1110
				if (prevToken == Symbols.TokenDEFAULT)
1111
					ref = indenter.findReferencePosition(p, false, false, false, true, false);
1112
				else
1113
					ref = indenter.findReferencePosition(p, false, false, false, false, true);
1114
				if (ref == CHeuristicScanner.NOT_FOUND)
1115
					return;
1116
				int refLine = doc.getLineOfOffset(ref);
1117
				int nextToken = scanner.nextToken(ref, CHeuristicScanner.UNBOUND);
1118
				String indent;
1119
				if (nextToken == Symbols.TokenCASE || nextToken == Symbols.TokenDEFAULT ||
1120
						nextToken == Symbols.TokenPUBLIC || nextToken == Symbols.TokenPROTECTED ||
1121
						nextToken == Symbols.TokenPRIVATE)
1122
					indent = getIndentOfLine(doc, refLine);
1123
				else // at the brace of the switch or the class
1124
					indent = indenter.computeIndentation(p).toString();
1125
1126
				if (indent != null) {
1127
					c.text = indent.toString() + doc.get(p, offset - p) + c.text;
1128
					c.length += c.offset - lineOffset;
1129
					c.offset = lineOffset;
1130
				}
1131
			}
1132
1133
			return;
1134
		} catch (BadLocationException e) {
1135
			CUIPlugin.getDefault().log(e);
1136
		}
1137
	}
1138
627
	/*
1139
	/*
628
	 * @see org.eclipse.jface.text.IAutoEditStrategy#customizeDocumentCommand(IDocument, DocumentCommand)
1140
	 * @see org.eclipse.jface.text.IAutoEditStrategy#customizeDocumentCommand(IDocument, DocumentCommand)
629
	 */
1141
	 */
Lines 649-657 Link Here
649
			CCommentAutoIndentStrategy.commentIndentForCommentEnd(d, c);
1161
			CCommentAutoIndentStrategy.commentIndentForCommentEnd(d, c);
650
		} else if (c.text.length() == 1) {
1162
		} else if (c.text.length() == 1) {
651
			smartIndentOnKeypress(d, c);
1163
			smartIndentOnKeypress(d, c);
652
// TODO Support smart paste.
1164
		} else if (c.text.length() > 1 && getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_PASTE)) {
653
//		} else if (c.text.length() > 1 && getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_PASTE)) {
1165
			smartPaste(d, c); // no smart backspace for paste
654
//			smartPaste(d, c); // no smart backspace for paste
655
		}
1166
		}
656
	}
1167
	}
657
	
1168
	
(-)src/org/eclipse/cdt/internal/ui/text/CReconcilingStrategy.java (-3 / +1 lines)
Lines 16-22 Link Here
16
import org.eclipse.cdt.core.model.ITranslationUnit;
16
import org.eclipse.cdt.core.model.ITranslationUnit;
17
import org.eclipse.cdt.core.model.IWorkingCopy;
17
import org.eclipse.cdt.core.model.IWorkingCopy;
18
import org.eclipse.cdt.internal.core.model.CModelManager;
18
import org.eclipse.cdt.internal.core.model.CModelManager;
19
import org.eclipse.cdt.internal.ui.editor.CEditor;
20
import org.eclipse.cdt.internal.ui.editor.IReconcilingParticipant;
19
import org.eclipse.cdt.internal.ui.editor.IReconcilingParticipant;
21
import org.eclipse.cdt.ui.CUIPlugin;
20
import org.eclipse.cdt.ui.CUIPlugin;
22
import org.eclipse.cdt.ui.IWorkingCopyManager;
21
import org.eclipse.cdt.ui.IWorkingCopyManager;
Lines 38-44 Link Here
38
	// used by tests
37
	// used by tests
39
	protected boolean fInitialProcessDone;
38
	protected boolean fInitialProcessDone;
40
	
39
	
41
	public CReconcilingStrategy(CEditor editor) {
40
	public CReconcilingStrategy(ITextEditor editor) {
42
		fEditor= editor;
41
		fEditor= editor;
43
		fManager= CUIPlugin.getDefault().getWorkingCopyManager();
42
		fManager= CUIPlugin.getDefault().getWorkingCopyManager();
44
	}
43
	}
Lines 49-55 Link Here
49
	public void setDocument(IDocument document) {
48
	public void setDocument(IDocument document) {
50
	}	
49
	}	
51
50
52
53
	/*
51
	/*
54
	 * @see IReconcilingStrategyExtension#setProgressMonitor(IProgressMonitor)
52
	 * @see IReconcilingStrategyExtension#setProgressMonitor(IProgressMonitor)
55
	 */
53
	 */
(-)src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java (-82 / +246 lines)
Lines 9-19 Link Here
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     QNX Software System
10
 *     QNX Software System
11
 *     Anton Leherbauer (Wind River Systems)
11
 *     Anton Leherbauer (Wind River Systems)
12
 *     Sergey Prigogin, Google
12
 *******************************************************************************/
13
 *******************************************************************************/
13
package org.eclipse.cdt.internal.ui.text;
14
package org.eclipse.cdt.internal.ui.text;
14
15
15
import java.util.Vector;
16
import java.util.Vector;
16
17
18
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IPath;
21
import org.eclipse.core.runtime.content.IContentType;
17
import org.eclipse.jface.dialogs.IDialogSettings;
22
import org.eclipse.jface.dialogs.IDialogSettings;
18
import org.eclipse.jface.preference.IPreferenceStore;
23
import org.eclipse.jface.preference.IPreferenceStore;
19
import org.eclipse.jface.text.DefaultInformationControl;
24
import org.eclipse.jface.text.DefaultInformationControl;
Lines 41-69 Link Here
41
import org.eclipse.jface.text.source.IAnnotationHover;
46
import org.eclipse.jface.text.source.IAnnotationHover;
42
import org.eclipse.jface.text.source.ISourceViewer;
47
import org.eclipse.jface.text.source.ISourceViewer;
43
import org.eclipse.jface.text.source.SourceViewerConfiguration;
48
import org.eclipse.jface.text.source.SourceViewerConfiguration;
49
import org.eclipse.jface.util.Assert;
44
import org.eclipse.jface.util.PropertyChangeEvent;
50
import org.eclipse.jface.util.PropertyChangeEvent;
45
import org.eclipse.swt.SWT;
51
import org.eclipse.swt.SWT;
46
import org.eclipse.swt.widgets.Shell;
52
import org.eclipse.swt.widgets.Shell;
47
import org.eclipse.ui.IEditorInput;
53
import org.eclipse.ui.IEditorInput;
54
import org.eclipse.ui.IPathEditorInput;
55
import org.eclipse.ui.editors.text.ILocationProvider;
48
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
56
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
57
import org.eclipse.ui.ide.ResourceUtil;
49
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
58
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
50
import org.eclipse.ui.texteditor.IDocumentProvider;
59
import org.eclipse.ui.texteditor.IDocumentProvider;
51
import org.eclipse.ui.texteditor.ITextEditor;
60
import org.eclipse.ui.texteditor.ITextEditor;
52
61
62
import org.eclipse.cdt.core.CCorePlugin;
53
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
63
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
54
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
64
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
65
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
55
import org.eclipse.cdt.core.model.ICElement;
66
import org.eclipse.cdt.core.model.ICElement;
56
import org.eclipse.cdt.core.model.ICProject;
67
import org.eclipse.cdt.core.model.ICProject;
57
import org.eclipse.cdt.core.model.ILanguage;
68
import org.eclipse.cdt.core.model.ILanguage;
69
import org.eclipse.cdt.core.model.ITranslationUnit;
70
import org.eclipse.cdt.core.model.LanguageManager;
58
import org.eclipse.cdt.ui.CElementContentProvider;
71
import org.eclipse.cdt.ui.CElementContentProvider;
59
import org.eclipse.cdt.ui.CUIPlugin;
72
import org.eclipse.cdt.ui.CUIPlugin;
60
import org.eclipse.cdt.ui.ILanguageUI;
73
import org.eclipse.cdt.ui.ILanguageUI;
61
import org.eclipse.cdt.ui.text.ICPartitions;
74
import org.eclipse.cdt.ui.text.ICPartitions;
62
75
76
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
77
63
import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
78
import org.eclipse.cdt.internal.ui.editor.CDocumentProvider;
64
import org.eclipse.cdt.internal.ui.editor.CEditor;
65
import org.eclipse.cdt.internal.ui.editor.CElementHyperlinkDetector;
79
import org.eclipse.cdt.internal.ui.editor.CElementHyperlinkDetector;
66
import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
67
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
80
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor;
68
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverProxy;
81
import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverProxy;
69
import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor2;
82
import org.eclipse.cdt.internal.ui.text.contentassist.CCompletionProcessor2;
Lines 71-152 Link Here
71
84
72
85
73
/**
86
/**
74
 * Configuration for an <code>SourceViewer</code> which shows C code.
87
 * Configuration for an <code>SourceViewer</code> which shows C/C++ code.
75
 */
88
 */
76
public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
89
public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
77
	
90
	
78
    private CTextTools fTextTools;
91
    private CTextTools fTextTools;
79
	private CEditor fEditor;
92
	private ITextEditor fTextEditor;
93
	/**
94
	 * The document partitioning.
95
	 */
96
	private String fDocumentPartitioning;
97
	/**
98
	 * The C++ source code scanner.
99
	 */
100
	private AbstractCScanner fCppCodeScanner;
101
	/**
102
	 * The C source code scanner.
103
	 */
104
	private AbstractCScanner fCCodeScanner;
105
	/**
106
	 * The C multi-line comment scanner.
107
	 */
108
	private AbstractCScanner fMultilineCommentScanner;
109
	/**
110
	 * The C single-line comment scanner.
111
	 */
112
	private AbstractCScanner fSinglelineCommentScanner;
113
	/**
114
	 * The C string scanner.
115
	 */
116
	private AbstractCScanner fStringScanner;
117
	/**
118
	 * The color manager.
119
	 */
120
	private IColorManager fColorManager;
80
	
121
	
81
	/**
122
	/**
123
	 * Creates a new C source viewer configuration for viewers in the given editor
124
	 * using the given preference store, the color manager and the specified document partitioning.
125
	 * <p>
126
	 * Creates a C source viewer configuration in the new setup without text tools. Clients are
127
	 * allowed to call {@link CSourceViewerConfiguration#handlePropertyChangeEvent(PropertyChangeEvent)}
128
	 * and disallowed to call {@link CSourceViewerConfiguration#getPreferenceStore()} on the resulting
129
	 * C source viewer configuration.
130
	 * </p>
131
	 *
132
	 * @param colorManager the color manager
133
	 * @param preferenceStore the preference store, can be read-only
134
	 * @param editor the editor in which the configured viewer(s) will reside, or <code>null</code> if none
135
	 * @param partitioning the document partitioning for this configuration, or <code>null</code> for the default partitioning
136
	 */
137
	public CSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, String partitioning) {
138
		super(preferenceStore);
139
		fColorManager= colorManager;
140
		fTextEditor= editor;
141
		fDocumentPartitioning= partitioning;
142
		initializeScanners();
143
	}
144
145
	/**
82
	 * Creates a new C source viewer configuration for viewers in the given editor using
146
	 * Creates a new C source viewer configuration for viewers in the given editor using
83
	 * the given C tools collection.
147
	 * the given C tools collection.
84
	 *
148
	 *
85
	 * @param tools the C text tools collection to be used
149
	 * @param tools the C text tools collection to be used
86
	 * @param editor the editor in which the configured viewer will reside
150
	 * @param editor the editor in which the configured viewer will reside
87
	 */
151
	 */
88
	public CSourceViewerConfiguration(CTextTools tools, CEditor editor) {
152
	public CSourceViewerConfiguration(CTextTools tools, ITextEditor editor) {
89
		super(CUIPlugin.getDefault().getCombinedPreferenceStore());
153
		super(CUIPlugin.getDefault().getCombinedPreferenceStore());
90
		fTextTools= tools;
154
		fTextTools= tools;
91
		fEditor= editor;
155
		fColorManager= tools.getColorManager();
156
		fTextEditor= editor;
157
		fDocumentPartitioning= fTextTools.getDocumentPartitioning();
158
		fCppCodeScanner= (AbstractCScanner) fTextTools.getCppCodeScanner();
159
		fCCodeScanner= (AbstractCScanner) fTextTools.getCCodeScanner();
160
		fMultilineCommentScanner= (AbstractCScanner) fTextTools.getMultilineCommentScanner();
161
		fSinglelineCommentScanner= (AbstractCScanner) fTextTools.getSinglelineCommentScanner();
162
		fStringScanner= (AbstractCScanner) fTextTools.getStringScanner();
92
	}
163
	}
93
164
94
	/**
165
	/**
95
	 * Returns the C multiline comment scanner for this configuration.
166
	 * Returns the C multi-line comment scanner for this configuration.
96
	 *
167
	 *
97
	 * @return the C multiline comment scanner
168
	 * @return the C multi-line comment scanner
98
	 */
169
	 */
99
	protected RuleBasedScanner getMultilineCommentScanner() {
170
	protected RuleBasedScanner getMultilineCommentScanner() {
100
		return fTextTools.getMultilineCommentScanner();
171
		return fMultilineCommentScanner;
101
	}
172
	}
102
	
173
103
	/**
174
	/**
104
	 * Returns the C singleline comment scanner for this configuration.
175
	 * Returns the C single-line comment scanner for this configuration.
105
	 *
176
	 *
106
	 * @return the C singleline comment scanner
177
	 * @return the C single-line comment scanner
107
	 */
178
	 */
108
	protected RuleBasedScanner getSinglelineCommentScanner() {
179
	protected RuleBasedScanner getSinglelineCommentScanner() {
109
		return fTextTools.getSinglelineCommentScanner();
180
		return fSinglelineCommentScanner;
110
	}
181
	}
111
	
182
112
	/**
183
	/**
113
	 * Returns the C string scanner for this configuration.
184
	 * Returns the C string scanner for this configuration.
114
	 *
185
	 *
115
	 * @return the C string scanner
186
	 * @return the C string scanner
116
	 */
187
	 */
117
	protected RuleBasedScanner getStringScanner() {
188
	protected RuleBasedScanner getStringScanner() {
118
		return fTextTools.getStringScanner();
189
		return fStringScanner;
119
	}	
190
	}
120
	
191
121
	/**
192
	/**
122
	 * Returns the color manager for this configuration.
193
	 * Returns the color manager for this configuration.
123
	 *
194
	 *
124
	 * @return the color manager
195
	 * @return the color manager
125
	 */
196
	 */
126
	protected IColorManager getColorManager() {
197
	protected IColorManager getColorManager() {
127
		return fTextTools.getColorManager();
198
		return fColorManager;
128
	}
199
	}
129
	
200
130
	/**
201
	/**
131
	 * Returns the editor in which the configured viewer(s) will reside.
202
	 * Returns the editor in which the configured viewer(s) will reside.
132
	 *
203
	 *
133
	 * @return the enclosing editor
204
	 * @return the enclosing editor
134
	 */
205
	 */
135
	protected ITextEditor getEditor() {
206
	public ITextEditor getEditor() {
136
		return fEditor;
207
		return fTextEditor;
137
	}
208
	}
138
209
139
	
140
    /**
210
    /**
141
     * Creates outline presenter. 
211
     * Creates outline presenter. 
142
     * @param editor Editor.
143
     * @return Presenter with outline view.
212
     * @return Presenter with outline view.
144
     */
213
     */
145
    public IInformationPresenter getOutlinePresenter(CEditor editor)
214
    public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer) {
146
    {
215
        final IInformationControlCreator outlineControlCreator = getOutlineContolCreator();
147
        final IInformationControlCreator outlineControlCreator = getOutlineContolCreator(editor);
148
        final InformationPresenter presenter = new InformationPresenter(outlineControlCreator);
216
        final InformationPresenter presenter = new InformationPresenter(outlineControlCreator);
149
        presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(null));
217
        presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
150
        final IInformationProvider provider = new CElementContentProvider(getEditor());
218
        final IInformationProvider provider = new CElementContentProvider(getEditor());
151
        presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
219
        presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
152
        presenter.setInformationProvider(provider, ICPartitions.C_MULTI_LINE_COMMENT);
220
        presenter.setInformationProvider(provider, ICPartitions.C_MULTI_LINE_COMMENT);
Lines 158-186 Link Here
158
        return presenter;
226
        return presenter;
159
    }
227
    }
160
228
229
	/**
230
	 * Initializes the scanners.
231
	 */
232
	private void initializeScanners() {
233
		Assert.isTrue(isNewSetup());
234
		fCppCodeScanner= new CppCodeScanner(getColorManager(), fPreferenceStore);
235
		fCCodeScanner= new CppCodeScanner(getColorManager(), fPreferenceStore);
236
		fMultilineCommentScanner= new CCommentScanner(getColorManager(), fPreferenceStore, ICColorConstants.C_MULTI_LINE_COMMENT);
237
		fSinglelineCommentScanner= new CCommentScanner(getColorManager(), fPreferenceStore, ICColorConstants.C_SINGLE_LINE_COMMENT);
238
		fStringScanner= new SingleTokenCScanner(getColorManager(), fPreferenceStore, ICColorConstants.C_STRING);
239
	}
240
161
    /**
241
    /**
162
     * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
242
     * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getPresentationReconciler(org.eclipse.jface.text.source.ISourceViewer)
163
	 */
243
	 */
164
    public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
244
    public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
165
166
		CPresentationReconciler reconciler= new CPresentationReconciler();
245
		CPresentationReconciler reconciler= new CPresentationReconciler();
167
		reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
246
		reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
168
247
169
		RuleBasedScanner scanner = null;
248
		RuleBasedScanner scanner = null;
170
		if(sourceViewer instanceof CSourceViewer) {
249
		ILanguage language = getLanguage();
171
			ILanguage language = ((CSourceViewer)sourceViewer).getLanguage();
250
		if (language instanceof GPPLanguage) {
172
			if (language instanceof GPPLanguage) {
251
			scanner = fCppCodeScanner;
173
				scanner = fTextTools.getCppCodeScanner();
252
		} else if (language instanceof GCCLanguage) {
174
			} else if (language instanceof GCCLanguage) {
253
			scanner = fCCodeScanner;
175
				scanner = fTextTools.getCCodeScanner();
254
		} else if (language != null) {
176
			} else if (language != null) {
255
			ILanguageUI languageUI = (ILanguageUI)language.getAdapter(ILanguageUI.class);
177
				ILanguageUI languageUI = (ILanguageUI)language.getAdapter(ILanguageUI.class);
256
			if (languageUI != null)
178
				if (languageUI != null)
257
				scanner = languageUI.getCodeScanner();
179
					scanner = languageUI.getCodeScanner();
180
			}
181
		}
258
		}
182
		if (scanner == null) {
259
		if (scanner == null) {
183
			scanner= fTextTools.getCCodeScanner();
260
			scanner= fCppCodeScanner;
184
		}
261
		}
185
262
186
		DefaultDamagerRepairer dr= new DefaultDamagerRepairer(scanner);
263
		DefaultDamagerRepairer dr= new DefaultDamagerRepairer(scanner);
Lines 238-247 Link Here
238
	 * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
315
	 * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
239
	 */
316
	 */
240
	public IReconciler getReconciler(ISourceViewer sourceViewer) {
317
	public IReconciler getReconciler(ISourceViewer sourceViewer) {
241
		if (fEditor != null && fEditor.isEditable()) {
318
		if (fTextEditor != null && fTextEditor.isEditable()) {
242
			//Delay changed and non-incremental reconciler used due to 
319
			//Delay changed and non-incremental reconciler used due to 
243
			//PR 130089
320
			//PR 130089
244
			MonoReconciler reconciler= new MonoReconciler(new CReconcilingStrategy(fEditor), false);
321
			MonoReconciler reconciler= new MonoReconciler(new CReconcilingStrategy(fTextEditor), false);
245
			reconciler.setDelay(500);
322
			reconciler.setDelay(500);
246
			return reconciler;
323
			return reconciler;
247
		}
324
		}
Lines 255-262 Link Here
255
		String partitioning= getConfiguredDocumentPartitioning(sourceViewer);
332
		String partitioning= getConfiguredDocumentPartitioning(sourceViewer);
256
		if (ICPartitions.C_MULTI_LINE_COMMENT.equals(contentType))
333
		if (ICPartitions.C_MULTI_LINE_COMMENT.equals(contentType))
257
			return new IAutoEditStrategy[] { new CCommentAutoIndentStrategy() };
334
			return new IAutoEditStrategy[] { new CCommentAutoIndentStrategy() };
258
//		else if (ICPartitions.C_STRING.equals(contentType))
335
		else if (ICPartitions.C_STRING.equals(contentType))
259
//			return new IAutoEditStrategy[] { new SmartSemicolonAutoEditStrategy(partitioning), new JavaStringAutoIndentStrategy(partitioning) };
336
			return new IAutoEditStrategy[] { /*new SmartSemicolonAutoEditStrategy(partitioning),*/ new CStringAutoIndentStrategy(partitioning, getProject()) };
260
		else
337
		else
261
			return new IAutoEditStrategy[] { new CAutoIndentStrategy(partitioning, getProject()) };
338
			return new IAutoEditStrategy[] { new CAutoIndentStrategy(partitioning, getProject()) };
262
	}
339
	}
Lines 283-313 Link Here
283
		Vector vector= new Vector();
360
		Vector vector= new Vector();
284
361
285
		// prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
362
		// prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
286
		int tabWidth= getTabWidth(sourceViewer);
287
		boolean useSpaces= getPreferenceStore().getBoolean(CEditor.SPACES_FOR_TABS); 
288
363
289
		for (int i= 0; i <= tabWidth; i++) {
364
		ICProject project= getProject();
365
		final int tabWidth= CodeFormatterUtil.getTabWidth(project);
366
		final int indentWidth= CodeFormatterUtil.getIndentWidth(project);
367
		int spaceEquivalents= Math.min(tabWidth, indentWidth);
368
		boolean useSpaces;
369
		if (project == null)
370
			useSpaces= CCorePlugin.SPACE.equals(CCorePlugin.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)) || tabWidth > indentWidth;
371
		else
372
			useSpaces= CCorePlugin.SPACE.equals(project.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, true)) || tabWidth > indentWidth;
373
374
		for (int i= 0; i <= spaceEquivalents; i++) {
290
		    StringBuffer prefix= new StringBuffer();
375
		    StringBuffer prefix= new StringBuffer();
291
376
292
			if (useSpaces) {
377
			if (useSpaces) {
293
			    for (int j= 0; j + i < tabWidth; j++)
378
			    for (int j= 0; j + i < spaceEquivalents; j++)
294
			    	prefix.append(' ');
379
			    	prefix.append(' ');
295
		    	
380
296
				if (i != 0)
381
				if (i != 0)
297
		    		prefix.append('\t');				
382
		    		prefix.append('\t');
298
			} else {    
383
			} else {
299
			    for (int j= 0; j < i; j++)
384
			    for (int j= 0; j < i; j++)
300
			    	prefix.append(' ');
385
			    	prefix.append(' ');
301
		    	
386
302
				if (i != tabWidth)
387
				if (i != spaceEquivalents)
303
		    		prefix.append('\t');
388
		    		prefix.append('\t');
304
			}
389
			}
305
			
390
306
			vector.add(prefix.toString());
391
			vector.add(prefix.toString());
307
		}
392
		}
308
393
309
		vector.add(""); //$NON-NLS-1$
394
		vector.add(""); //$NON-NLS-1$
310
		
395
311
		return (String[]) vector.toArray(new String[vector.size()]);
396
		return (String[]) vector.toArray(new String[vector.size()]);
312
	}
397
	}
313
398
Lines 330-335 Link Here
330
		return element.getCProject();
415
		return element.getCProject();
331
	}
416
	}
332
417
418
	/*
419
	 * @see SourceViewerConfiguration#getTabWidth(ISourceViewer)
420
	 */
421
	public int getTabWidth(ISourceViewer sourceViewer) {
422
		return CodeFormatterUtil.getTabWidth(getProject());
423
	}
424
333
	/**
425
	/**
334
	 * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
426
	 * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
335
	 */
427
	 */
Lines 337-344 Link Here
337
		return new CAnnotationHover();
429
		return new CAnnotationHover();
338
	}
430
	}
339
431
340
341
	
342
	/*
432
	/*
343
	 * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer, String)
433
	 * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer, String)
344
	 * @since 2.1
434
	 * @since 2.1
Lines 414-425 Link Here
414
		
504
		
415
		formatter.setMasterStrategy(new CFormattingStrategy());
505
		formatter.setMasterStrategy(new CFormattingStrategy());
416
		return formatter;
506
		return formatter;
417
		
418
		
419
	}
507
	}
420
	
508
	
421
	public boolean affectsBehavior(PropertyChangeEvent event) {
509
	public boolean affectsBehavior(PropertyChangeEvent event) {
422
		return fTextTools.affectsBehavior(event);
510
		return  fCppCodeScanner.affectsBehavior(event)
511
			|| fMultilineCommentScanner.affectsBehavior(event)
512
			|| fSinglelineCommentScanner.affectsBehavior(event)
513
			|| fStringScanner.affectsBehavior(event);
423
	}
514
	}
424
515
425
	/**
516
	/**
Lines 436-441 Link Here
436
		return CUIPlugin.getDefault().getPreferenceStore();
527
		return CUIPlugin.getDefault().getPreferenceStore();
437
	}
528
	}
438
	
529
	
530
	/**
531
	 * @return <code>true</code> iff the new setup without text tools is in use.
532
	 */
533
	private boolean isNewSetup() {
534
		return fTextTools == null;
535
	}
536
439
	/*
537
	/*
440
	 * @see SourceViewerConfiguration#getHoverControlCreator(ISourceViewer)
538
	 * @see SourceViewerConfiguration#getHoverControlCreator(ISourceViewer)
441
	 * @since 2.0
539
	 * @since 2.0
Lines 444-450 Link Here
444
		return getInformationControlCreator(sourceViewer, true);
542
		return getInformationControlCreator(sourceViewer, true);
445
	}
543
	}
446
	
544
	
447
448
	public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer, final boolean cutDown) {
545
	public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer, final boolean cutDown) {
449
			return new IInformationControlCreator() {
546
			return new IInformationControlCreator() {
450
			public IInformationControl createInformationControl(Shell parent) {
547
			public IInformationControl createInformationControl(Shell parent) {
Lines 463-468 Link Here
463
		return super.getInformationPresenter(sourceViewer);
560
		return super.getInformationPresenter(sourceViewer);
464
	}
561
	}
465
    
562
    
563
	/**
564
	 * Determines whether the preference change encoded by the given event
565
	 * changes the behavior of one of its contained components.
566
	 *
567
	 * @param event the event to be investigated
568
	 * @return <code>true</code> if event causes a behavioral change
569
	 */
570
	public boolean affectsTextPresentation(PropertyChangeEvent event) {
571
		return fCppCodeScanner.affectsBehavior(event)
572
		    || fCCodeScanner.affectsBehavior(event)
573
			|| fMultilineCommentScanner.affectsBehavior(event)
574
			|| fSinglelineCommentScanner.affectsBehavior(event)
575
			|| fStringScanner.affectsBehavior(event);
576
	}
577
578
	/**
579
	 * Adapts the behavior of the contained components to the change
580
	 * encoded in the given event.
581
	 * <p>
582
	 * Clients are not allowed to call this method if the old setup with
583
	 * text tools is in use.
584
	 * </p>
585
	 *
586
	 * @param event the event to which to adapt
587
	 * @see CSourceViewerConfiguration#CSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String)
588
	 */
589
	public void handlePropertyChangeEvent(PropertyChangeEvent event) {
590
		Assert.isTrue(isNewSetup());
591
		if (fCppCodeScanner.affectsBehavior(event))
592
			fCppCodeScanner.adaptToPreferenceChange(event);
593
		if (fCCodeScanner.affectsBehavior(event))
594
			fCCodeScanner.adaptToPreferenceChange(event);
595
		if (fMultilineCommentScanner.affectsBehavior(event))
596
			fMultilineCommentScanner.adaptToPreferenceChange(event);
597
		if (fSinglelineCommentScanner.affectsBehavior(event))
598
			fSinglelineCommentScanner.adaptToPreferenceChange(event);
599
		if (fStringScanner.affectsBehavior(event))
600
			fStringScanner.adaptToPreferenceChange(event);
601
	}
602
466
	/*
603
	/*
467
	 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
604
	 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
468
	 * @since 3.1
605
	 * @since 3.1
Lines 473-484 Link Here
473
		
610
		
474
		IHyperlinkDetector[] inheritedDetectors= super.getHyperlinkDetectors(sourceViewer);
611
		IHyperlinkDetector[] inheritedDetectors= super.getHyperlinkDetectors(sourceViewer);
475
		
612
		
476
		if (fEditor == null)
613
		if (fTextEditor == null)
477
			return inheritedDetectors;
614
			return inheritedDetectors;
478
		
615
		
479
		int inheritedDetectorsLength= inheritedDetectors != null ? inheritedDetectors.length : 0;
616
		int inheritedDetectorsLength= inheritedDetectors != null ? inheritedDetectors.length : 0;
480
		IHyperlinkDetector[] detectors= new IHyperlinkDetector[inheritedDetectorsLength + 1];
617
		IHyperlinkDetector[] detectors= new IHyperlinkDetector[inheritedDetectorsLength + 1];
481
		detectors[0]= new CElementHyperlinkDetector(fEditor); 
618
		detectors[0]= new CElementHyperlinkDetector(fTextEditor); 
482
		for (int i= 0; i < inheritedDetectorsLength; i++) {
619
		for (int i= 0; i < inheritedDetectorsLength; i++) {
483
			detectors[i+1]= inheritedDetectors[i];
620
			detectors[i+1]= inheritedDetectors[i];
484
		}
621
		}
Lines 489-515 Link Here
489
	/*
626
	/*
490
	 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
627
	 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
491
	 */
628
	 */
492
    public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
629
	public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
493
		return fTextTools.getDocumentPartitioning();
630
		if (fDocumentPartitioning != null)
631
			return fDocumentPartitioning;
632
		return super.getConfiguredDocumentPartitioning(sourceViewer);
494
	}
633
	}
495
634
496
	/**
635
	/**
497
     * Creates control for outline presentation in editor.
636
     * Creates control for outline presentation in editor.
498
     * @param editor Editor.
499
     * @return Control.
637
     * @return Control.
500
     */
638
     */
501
    private IInformationControlCreator getOutlineContolCreator(final CEditor editor)
639
    private IInformationControlCreator getOutlineContolCreator() {
502
    {
640
        final IInformationControlCreator conrolCreator = new IInformationControlCreator() {
503
        final IInformationControlCreator conrolCreator = new IInformationControlCreator()
504
        {
505
            /**
641
            /**
506
             * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
642
             * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
507
             */
643
             */
508
            public IInformationControl createInformationControl(Shell parent)
644
            public IInformationControl createInformationControl(Shell parent) {
509
            {
510
                int shellStyle= SWT.RESIZE;
645
                int shellStyle= SWT.RESIZE;
511
                int treeStyle= SWT.V_SCROLL | SWT.H_SCROLL;
646
                int treeStyle= SWT.V_SCROLL | SWT.H_SCROLL;
512
                return new COutlineInformationControl(editor, parent, shellStyle, treeStyle);   
647
                return new COutlineInformationControl(parent, shellStyle, treeStyle);   
513
            }
648
            }
514
        };
649
        };
515
        return conrolCreator;
650
        return conrolCreator;
Lines 529-542 Link Here
529
        
664
        
530
        return settings;
665
        return settings;
531
    }
666
    }
532
533
	/**
534
	 * Adapt to the given preference change event.
535
	 * 
536
	 * @param event
537
	 */
538
	public void handlePropertyChangeEvent(PropertyChangeEvent event) {
539
		fTextTools.adaptToPreferenceChange(event);
540
	}
541
    
667
    
668
	private ILanguage getLanguage() {
669
		if (fTextEditor == null) {
670
			return null;
671
		}
672
		ICElement element = CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(fTextEditor.getEditorInput());
673
		if (element instanceof ITranslationUnit) {
674
			try {
675
				return ((ITranslationUnit)element).getLanguage();
676
			} catch (CoreException e) {
677
				CUIPlugin.getDefault().log(e);
678
			}
679
		} else {
680
			// compute the language from the plain editor input
681
			IContentType contentType = null;
682
			IEditorInput input = fTextEditor.getEditorInput();
683
			IFile file = ResourceUtil.getFile(input);
684
			if (file != null) {
685
				contentType = CCorePlugin.getContentType(file.getProject(), file.getName());
686
			} else if (input instanceof IPathEditorInput) {
687
				IPath path = ((IPathEditorInput)input).getPath();
688
				contentType = CCorePlugin.getContentType(path.lastSegment());
689
			} else {
690
				ILocationProvider locationProvider = (ILocationProvider)input.getAdapter(ILocationProvider.class);
691
				if (locationProvider != null) {
692
					IPath path = locationProvider.getPath(input);
693
					contentType = CCorePlugin.getContentType(path.lastSegment());
694
				}
695
			}
696
			if (contentType != null) {
697
				try {
698
					return LanguageManager.getInstance().getLanguage(contentType);
699
				} catch (CoreException exc) {
700
					CUIPlugin.getDefault().log(exc.getStatus());
701
				}
702
			}
703
		}
704
		return null;
705
	}
542
}
706
}
(-)src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java (-1 / +12 lines)
Lines 268-274 Link Here
268
	}
268
	}
269
269
270
	/**
270
	/**
271
	 * Calls <code>this(document, IJavaPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE)</code>.
271
	 * Calls <code>this(document, ICPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE)</code>.
272
	 *
272
	 *
273
	 * @param document the document to scan.
273
	 * @param document the document to scan.
274
	 */
274
	 */
Lines 473-489 Link Here
473
					return TokenWHILE;
473
					return TokenWHILE;
474
				break;
474
				break;
475
			case 6:
475
			case 6:
476
				if ("delete".equals(s)) //$NON-NLS-1$
477
					return TokenDELETE;
478
				if ("public".equals(s)) //$NON-NLS-1$
479
					return TokenPUBLIC;
476
				if ("return".equals(s)) //$NON-NLS-1$
480
				if ("return".equals(s)) //$NON-NLS-1$
477
					return TokenRETURN;
481
					return TokenRETURN;
478
				if ("static".equals(s)) //$NON-NLS-1$
482
				if ("static".equals(s)) //$NON-NLS-1$
479
					return TokenSTATIC;
483
					return TokenSTATIC;
484
				if ("struct".equals(s)) //$NON-NLS-1$
485
					return TokenSTRUCT;
480
				if ("switch".equals(s)) //$NON-NLS-1$
486
				if ("switch".equals(s)) //$NON-NLS-1$
481
					return TokenSWITCH;
487
					return TokenSWITCH;
482
				break;
488
				break;
483
			case 7:
489
			case 7:
484
				if ("default".equals(s)) //$NON-NLS-1$
490
				if ("default".equals(s)) //$NON-NLS-1$
485
					return TokenDEFAULT;
491
					return TokenDEFAULT;
492
				if ("private".equals(s)) //$NON-NLS-1$
493
					return TokenPRIVATE;
486
				break;
494
				break;
495
			case 9:
496
				if ("protected".equals(s)) //$NON-NLS-1$
497
					return TokenPROTECTED;
487
		}
498
		}
488
		return TokenIDENT;
499
		return TokenIDENT;
489
	}
500
	}
(-)plugin.xml (-1 / +7 lines)
Lines 582-587 Link Here
582
            id="org.eclipse.cdt.ui.preferences.TemplatePreferencePage">
582
            id="org.eclipse.cdt.ui.preferences.TemplatePreferencePage">
583
      </page>
583
      </page>
584
      <page
584
      <page
585
            name="%SmartTypingPreferencePage.name"
586
            category="org.eclipse.cdt.ui.preferences.CEditorPreferencePage"
587
            class="org.eclipse.cdt.internal.ui.preferences.SmartTypingPreferencePage"
588
            id="org.eclipse.cdt.ui.preferences.SmartTypingPreferencePage">
589
      </page>
590
      <page
585
            name="%CodeFormatterPreferencePage.name"
591
            name="%CodeFormatterPreferencePage.name"
586
            category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
592
            category="org.eclipse.cdt.ui.preferences.CPluginPreferencePage"
587
            class="org.eclipse.cdt.internal.ui.preferences.CodeFormatterPreferencePage"
593
            class="org.eclipse.cdt.internal.ui.preferences.CodeFormatterPreferencePage"
Lines 1607-1610 Link Here
1607
          viewerId="org.eclipse.ui.navigator.ProjectExplorer"/>
1613
          viewerId="org.eclipse.ui.navigator.ProjectExplorer"/>
1608
 </extension>
1614
 </extension>
1609
1615
1610
</plugin>
1616
</plugin>
(-)plugin.properties (-1 / +2 lines)
Lines 132-139 Link Here
132
CPluginTemplatePreferencePage.name=Templates
132
CPluginTemplatePreferencePage.name=Templates
133
CPluginBuildConsolePreferencePage.name=Build Console
133
CPluginBuildConsolePreferencePage.name=Build Console
134
CPluginFileTypesPreferencePage.name=File Types
134
CPluginFileTypesPreferencePage.name=File Types
135
CodeFormatterPreferencePage.name=Code Formatter
135
CodeFormatterPreferencePage.name=Code Style
136
CodeAssistPreferencePage.name=Content Assist
136
CodeAssistPreferencePage.name=Content Assist
137
SmartTypingPreferencePage.name=Typing
137
138
138
todoPageName=C/C++ Task Tags
139
todoPageName=C/C++ Task Tags
139
todoTaskPrefName=Task Tags
140
todoTaskPrefName=Task Tags
(-)src/org/eclipse/cdt/internal/ui/editor/CSourceViewer.java (-84 / +38 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     QNX Software Systems - initial API and implementation
9
 *     QNX Software Systems - initial API and implementation
10
 *     Sergey Prigogin, Google
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.internal.ui.editor;
12
package org.eclipse.cdt.internal.ui.editor;
12
13
Lines 14-23 Link Here
14
import java.util.Iterator;
15
import java.util.Iterator;
15
import java.util.List;
16
import java.util.List;
16
17
17
import org.eclipse.core.resources.IFile;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.content.IContentType;
21
import org.eclipse.jface.text.Assert;
18
import org.eclipse.jface.text.Assert;
22
import org.eclipse.jface.text.DocumentCommand;
19
import org.eclipse.jface.text.DocumentCommand;
23
import org.eclipse.jface.text.ITextPresentationListener;
20
import org.eclipse.jface.text.ITextPresentationListener;
Lines 29-46 Link Here
29
import org.eclipse.jface.text.source.IVerticalRuler;
26
import org.eclipse.jface.text.source.IVerticalRuler;
30
import org.eclipse.jface.text.source.SourceViewerConfiguration;
27
import org.eclipse.jface.text.source.SourceViewerConfiguration;
31
import org.eclipse.jface.text.source.projection.ProjectionViewer;
28
import org.eclipse.jface.text.source.projection.ProjectionViewer;
29
import org.eclipse.swt.custom.StyledText;
30
import org.eclipse.swt.graphics.Color;
32
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Composite;
33
import org.eclipse.ui.IEditorInput;
34
import org.eclipse.ui.IPathEditorInput;
35
import org.eclipse.ui.editors.text.ILocationProvider;
36
import org.eclipse.ui.ide.ResourceUtil;
37
38
import org.eclipse.cdt.core.CCorePlugin;
39
import org.eclipse.cdt.core.model.ICElement;
40
import org.eclipse.cdt.core.model.ILanguage;
41
import org.eclipse.cdt.core.model.ITranslationUnit;
42
import org.eclipse.cdt.core.model.LanguageManager;
43
import org.eclipse.cdt.ui.CUIPlugin;
44
32
45
import org.eclipse.cdt.internal.ui.editor.CEditor.ITextConverter;
33
import org.eclipse.cdt.internal.ui.editor.CEditor.ITextConverter;
46
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
34
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
Lines 48-61 Link Here
48
/**
36
/**
49
 * Adapted source viewer for CEditor
37
 * Adapted source viewer for CEditor
50
 */
38
 */
51
52
public class CSourceViewer extends ProjectionViewer implements ITextViewerExtension {
39
public class CSourceViewer extends ProjectionViewer implements ITextViewerExtension {
53
40
54
    /** Show outline operation id. */
41
    /** Show outline operation id. */
55
    public static final int SHOW_OUTLINE = 101;
42
    public static final int SHOW_OUTLINE = 101;
56
    
43
    
57
	/** Editor. */
44
	/** Editor. */
58
    private final CEditor editor;
45
    private CEditor editor;
59
    /** Presents outline. */
46
    /** Presents outline. */
60
    private IInformationPresenter fOutlinePresenter;
47
    private IInformationPresenter fOutlinePresenter;
61
48
Lines 63-143 Link Here
63
    
50
    
64
	/**
51
	/**
65
     * Creates new source viewer. 
52
     * Creates new source viewer. 
66
     * @param editor
67
     * @param parent
53
     * @param parent
68
     * @param ruler
54
	 * @param ruler
69
     * @param styles
55
	 * @param fOverviewRuler
70
     * @param fOverviewRuler
56
	 * @param isOverviewRulerShowing
71
     * @param isOverviewRulerShowing
57
	 * @param styles
72
	 */
58
	 */
73
    public CSourceViewer(
59
    public CSourceViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler fOverviewRuler, boolean isOverviewRulerShowing,
74
    		CEditor editor, Composite parent,
60
    					 int styles) {
75
    		IVerticalRuler ruler,
76
    		int styles,
77
    		IOverviewRuler fOverviewRuler,
78
    		boolean isOverviewRulerShowing) {
79
		super(parent, ruler, fOverviewRuler, isOverviewRulerShowing, styles);
61
		super(parent, ruler, fOverviewRuler, isOverviewRulerShowing, styles);
80
        this.editor = editor;
81
	}
62
	}
82
    
63
    
83
	public IContentAssistant getContentAssistant() {
64
	public IContentAssistant getContentAssistant() {
84
		return fContentAssistant;
65
		return fContentAssistant;
85
	}
66
	}
86
    
67
	
87
	public ILanguage getLanguage() {
68
	/*
88
		ICElement element = editor.getInputCElement();
69
	 * @see ISourceViewer#configure(SourceViewerConfiguration)
89
		if (element instanceof ITranslationUnit) {
70
	 */
90
			try {
71
	public void configure(SourceViewerConfiguration configuration) {
91
				return ((ITranslationUnit)element).getLanguage();
72
		// Prevent access to colors disposed in unconfigure().
92
			} catch (CoreException e) {
73
		StyledText textWidget= getTextWidget();
93
				CUIPlugin.getDefault().log(e);
74
		if (textWidget != null && !textWidget.isDisposed()) {
94
			}
75
			Color foregroundColor= textWidget.getForeground();
95
		} else {
76
			if (foregroundColor != null && foregroundColor.isDisposed())
96
			// compute the language from the plain editor input
77
				textWidget.setForeground(null);
97
			IContentType contentType = null;
78
			Color backgroundColor= textWidget.getBackground();
98
			IEditorInput input = editor.getEditorInput();
79
			if (backgroundColor != null && backgroundColor.isDisposed())
99
			IFile file = ResourceUtil.getFile(input);
80
				textWidget.setBackground(null);
100
			if (file != null) {
81
		}
101
				contentType = CCorePlugin.getContentType(file.getProject(), file.getName());
82
102
			} else if (input instanceof IPathEditorInput) {
83
		super.configure(configuration);
103
				IPath path = ((IPathEditorInput)input).getPath();
84
		if (configuration instanceof CSourceViewerConfiguration) {
104
				contentType = CCorePlugin.getContentType(path.lastSegment());
85
			CSourceViewerConfiguration cConfiguration= (CSourceViewerConfiguration)configuration;
105
			} else {
86
			fOutlinePresenter= cConfiguration.getOutlinePresenter(this);
106
				ILocationProvider locationProvider = (ILocationProvider)input.getAdapter(ILocationProvider.class);
87
			if (fOutlinePresenter != null)
107
				if (locationProvider != null) {
88
				fOutlinePresenter.install(this);
108
					IPath path = locationProvider.getPath(input);
89
			editor = (CEditor) cConfiguration.getEditor();
109
					contentType = CCorePlugin.getContentType(path.lastSegment());
110
				}
111
			}
112
			if (contentType != null) {
113
				try {
114
					return LanguageManager.getInstance().getLanguage(contentType);
115
				} catch (CoreException exc) {
116
					CUIPlugin.getDefault().log(exc.getStatus());
117
				}
118
			}
119
		}
90
		}
120
		return null;
121
	}
91
	}
122
	
123
    /**
124
     * @see org.eclipse.jface.text.source.SourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
125
     */
126
    public void configure(SourceViewerConfiguration configuration)
127
    {
128
        super.configure(configuration);
129
        if (configuration instanceof CSourceViewerConfiguration)
130
        {            
131
            fOutlinePresenter = ((CSourceViewerConfiguration) configuration).getOutlinePresenter(editor);
132
            fOutlinePresenter.install(this);
133
        }
134
    }
135
92
136
    /**
93
    /**
137
     * @see org.eclipse.jface.text.source.SourceViewer#unconfigure()
94
     * @see org.eclipse.jface.text.source.SourceViewer#unconfigure()
138
     */
95
     */
139
    public void unconfigure()
96
    public void unconfigure() {
140
    {
141
        if (fOutlinePresenter != null) {
97
        if (fOutlinePresenter != null) {
142
            fOutlinePresenter.uninstall();  
98
            fOutlinePresenter.uninstall();  
143
            fOutlinePresenter= null;
99
            fOutlinePresenter= null;
Lines 157-163 Link Here
157
			case CONTENTASSIST_PROPOSALS:
113
			case CONTENTASSIST_PROPOSALS:
158
            {
114
            {
159
				String msg= fContentAssistant.showPossibleCompletions();
115
				String msg= fContentAssistant.showPossibleCompletions();
160
				this.editor.setStatusLineErrorMessage(msg);
116
				editor.setStatusLineErrorMessage(msg);
161
				return;
117
				return;
162
            }
118
            }
163
            case SHOW_OUTLINE:
119
            case SHOW_OUTLINE:
Lines 172-181 Link Here
172
    /**
128
    /**
173
     * @see org.eclipse.jface.text.source.projection.ProjectionViewer#canDoOperation(int)
129
     * @see org.eclipse.jface.text.source.projection.ProjectionViewer#canDoOperation(int)
174
     */
130
     */
175
    public boolean canDoOperation(int operation)
131
    public boolean canDoOperation(int operation) {
176
    {
132
        if (operation == SHOW_OUTLINE) {
177
        if (operation == SHOW_OUTLINE)
178
        {
179
            return fOutlinePresenter != null;
133
            return fOutlinePresenter != null;
180
        }
134
        }
181
        return super.canDoOperation(operation);
135
        return super.canDoOperation(operation);
(-)src/org/eclipse/cdt/internal/ui/editor/ICEditorActionDefinitionIds.java (+6 lines)
Lines 55-60 Link Here
55
	public static final String JOIN_LINES= "org.eclipse.cdt.ui.edit.text.c.join.lines"; //$NON-NLS-1$
55
	public static final String JOIN_LINES= "org.eclipse.cdt.ui.edit.text.c.join.lines"; //$NON-NLS-1$
56
	
56
	
57
	/**
57
	/**
58
	 * Action definition ID of the source -> indent action
59
	 * (value <code>"org.eclipse.cdt.ui.edit.text.c.indent"</code>).
60
	 */
61
	public static final String INDENT = "org.eclipse.cdt.ui.edit.text.c.indent"; //$NON-NLS-1$
62
	
63
	/**
58
	 * Action definition ID of the source -> format action
64
	 * Action definition ID of the source -> format action
59
	 * (value <code>"org.eclipse.cdt.ui.edit.text.c.format"</code>).
65
	 * (value <code>"org.eclipse.cdt.ui.edit.text.c.format"</code>).
60
	 */
66
	 */
(-)src/org/eclipse/cdt/internal/ui/editor/CEditor.java (-1367 / +2026 lines)
Lines 16-23 Link Here
16
16
17
17
18
import java.text.CharacterIterator;
18
import java.text.CharacterIterator;
19
import java.util.ArrayList;
20
import java.util.HashMap;
19
import java.util.Iterator;
21
import java.util.Iterator;
22
import java.util.List;
23
import java.util.Map;
20
import java.util.ResourceBundle;
24
import java.util.ResourceBundle;
25
import java.util.Stack;
21
26
22
import org.eclipse.core.resources.IFile;
27
import org.eclipse.core.resources.IFile;
23
import org.eclipse.core.runtime.CoreException;
28
import org.eclipse.core.runtime.CoreException;
Lines 31-65 Link Here
31
import org.eclipse.jface.preference.IPreferenceStore;
36
import org.eclipse.jface.preference.IPreferenceStore;
32
import org.eclipse.jface.text.AbstractInformationControlManager;
37
import org.eclipse.jface.text.AbstractInformationControlManager;
33
import org.eclipse.jface.text.BadLocationException;
38
import org.eclipse.jface.text.BadLocationException;
39
import org.eclipse.jface.text.BadPositionCategoryException;
34
import org.eclipse.jface.text.DefaultInformationControl;
40
import org.eclipse.jface.text.DefaultInformationControl;
35
import org.eclipse.jface.text.DefaultLineTracker;
41
import org.eclipse.jface.text.DefaultLineTracker;
36
import org.eclipse.jface.text.DocumentCommand;
42
import org.eclipse.jface.text.DocumentCommand;
43
import org.eclipse.jface.text.DocumentEvent;
37
import org.eclipse.jface.text.IDocument;
44
import org.eclipse.jface.text.IDocument;
45
import org.eclipse.jface.text.IDocumentExtension;
46
import org.eclipse.jface.text.IDocumentListener;
38
import org.eclipse.jface.text.IInformationControl;
47
import org.eclipse.jface.text.IInformationControl;
39
import org.eclipse.jface.text.IInformationControlCreator;
48
import org.eclipse.jface.text.IInformationControlCreator;
40
import org.eclipse.jface.text.ILineTracker;
49
import org.eclipse.jface.text.ILineTracker;
50
import org.eclipse.jface.text.IPositionUpdater;
41
import org.eclipse.jface.text.IRegion;
51
import org.eclipse.jface.text.IRegion;
42
import org.eclipse.jface.text.ITextHover;
52
import org.eclipse.jface.text.ITextHover;
43
import org.eclipse.jface.text.ITextSelection;
53
import org.eclipse.jface.text.ITextSelection;
44
import org.eclipse.jface.text.ITextViewer;
54
import org.eclipse.jface.text.ITextViewer;
55
import org.eclipse.jface.text.ITextViewerExtension;
45
import org.eclipse.jface.text.ITextViewerExtension2;
56
import org.eclipse.jface.text.ITextViewerExtension2;
46
import org.eclipse.jface.text.ITextViewerExtension4;
57
import org.eclipse.jface.text.ITextViewerExtension4;
47
import org.eclipse.jface.text.ITextViewerExtension5;
58
import org.eclipse.jface.text.ITextViewerExtension5;
59
import org.eclipse.jface.text.ITypedRegion;
60
import org.eclipse.jface.text.IWidgetTokenKeeper;
48
import org.eclipse.jface.text.Position;
61
import org.eclipse.jface.text.Position;
49
import org.eclipse.jface.text.Region;
62
import org.eclipse.jface.text.Region;
50
import org.eclipse.jface.text.TextUtilities;
63
import org.eclipse.jface.text.TextUtilities;
51
import org.eclipse.jface.text.contentassist.ContentAssistant;
64
import org.eclipse.jface.text.contentassist.ContentAssistant;
52
import org.eclipse.jface.text.contentassist.IContentAssistant;
65
import org.eclipse.jface.text.contentassist.IContentAssistant;
66
import org.eclipse.jface.text.formatter.FormattingContextProperties;
67
import org.eclipse.jface.text.formatter.IFormattingContext;
53
import org.eclipse.jface.text.information.IInformationProvider;
68
import org.eclipse.jface.text.information.IInformationProvider;
54
import org.eclipse.jface.text.information.IInformationProviderExtension;
69
import org.eclipse.jface.text.information.IInformationProviderExtension;
55
import org.eclipse.jface.text.information.IInformationProviderExtension2;
70
import org.eclipse.jface.text.information.IInformationProviderExtension2;
56
import org.eclipse.jface.text.information.InformationPresenter;
71
import org.eclipse.jface.text.information.InformationPresenter;
72
import org.eclipse.jface.text.link.ILinkedModeListener;
73
import org.eclipse.jface.text.link.LinkedModeModel;
74
import org.eclipse.jface.text.link.LinkedModeUI;
75
import org.eclipse.jface.text.link.LinkedPosition;
76
import org.eclipse.jface.text.link.LinkedPositionGroup;
77
import org.eclipse.jface.text.link.LinkedModeUI.ExitFlags;
78
import org.eclipse.jface.text.link.LinkedModeUI.IExitPolicy;
57
import org.eclipse.jface.text.source.Annotation;
79
import org.eclipse.jface.text.source.Annotation;
58
import org.eclipse.jface.text.source.IAnnotationHover;
80
import org.eclipse.jface.text.source.IAnnotationHover;
59
import org.eclipse.jface.text.source.IAnnotationHoverExtension;
81
import org.eclipse.jface.text.source.IAnnotationHoverExtension;
60
import org.eclipse.jface.text.source.IAnnotationModel;
82
import org.eclipse.jface.text.source.IAnnotationModel;
61
import org.eclipse.jface.text.source.ICharacterPairMatcher;
83
import org.eclipse.jface.text.source.ICharacterPairMatcher;
62
import org.eclipse.jface.text.source.ILineRange;
84
import org.eclipse.jface.text.source.ILineRange;
85
import org.eclipse.jface.text.source.IOverviewRuler;
63
import org.eclipse.jface.text.source.ISourceViewer;
86
import org.eclipse.jface.text.source.ISourceViewer;
64
import org.eclipse.jface.text.source.ISourceViewerExtension3;
87
import org.eclipse.jface.text.source.ISourceViewerExtension3;
65
import org.eclipse.jface.text.source.IVerticalRuler;
88
import org.eclipse.jface.text.source.IVerticalRuler;
Lines 78-89 Link Here
78
import org.eclipse.swt.SWT;
101
import org.eclipse.swt.SWT;
79
import org.eclipse.swt.custom.ST;
102
import org.eclipse.swt.custom.ST;
80
import org.eclipse.swt.custom.StyledText;
103
import org.eclipse.swt.custom.StyledText;
104
import org.eclipse.swt.custom.VerifyKeyListener;
81
import org.eclipse.swt.dnd.DND;
105
import org.eclipse.swt.dnd.DND;
82
import org.eclipse.swt.dnd.DragSource;
106
import org.eclipse.swt.dnd.DragSource;
83
import org.eclipse.swt.dnd.DragSourceListener;
107
import org.eclipse.swt.dnd.DragSourceListener;
84
import org.eclipse.swt.dnd.DropTarget;
108
import org.eclipse.swt.dnd.DropTarget;
85
import org.eclipse.swt.dnd.TextTransfer;
109
import org.eclipse.swt.dnd.TextTransfer;
86
import org.eclipse.swt.dnd.Transfer;
110
import org.eclipse.swt.dnd.Transfer;
111
import org.eclipse.swt.events.VerifyEvent;
87
import org.eclipse.swt.graphics.Image;
112
import org.eclipse.swt.graphics.Image;
88
import org.eclipse.swt.graphics.Point;
113
import org.eclipse.swt.graphics.Point;
89
import org.eclipse.swt.widgets.Composite;
114
import org.eclipse.swt.widgets.Composite;
Lines 102-108 Link Here
102
import org.eclipse.ui.part.IShowInSource;
127
import org.eclipse.ui.part.IShowInSource;
103
import org.eclipse.ui.part.IShowInTargetList;
128
import org.eclipse.ui.part.IShowInTargetList;
104
import org.eclipse.ui.part.ShowInContext;
129
import org.eclipse.ui.part.ShowInContext;
105
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
106
import org.eclipse.ui.texteditor.ContentAssistAction;
130
import org.eclipse.ui.texteditor.ContentAssistAction;
107
import org.eclipse.ui.texteditor.IDocumentProvider;
131
import org.eclipse.ui.texteditor.IDocumentProvider;
108
import org.eclipse.ui.texteditor.IEditorStatusLine;
132
import org.eclipse.ui.texteditor.IEditorStatusLine;
Lines 115-120 Link Here
115
import org.eclipse.ui.texteditor.TextEditorAction;
139
import org.eclipse.ui.texteditor.TextEditorAction;
116
import org.eclipse.ui.texteditor.TextNavigationAction;
140
import org.eclipse.ui.texteditor.TextNavigationAction;
117
import org.eclipse.ui.texteditor.TextOperationAction;
141
import org.eclipse.ui.texteditor.TextOperationAction;
142
import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
118
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
143
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
119
144
120
import com.ibm.icu.text.BreakIterator;
145
import com.ibm.icu.text.BreakIterator;
Lines 123-130 Link Here
123
import org.eclipse.cdt.core.CCorePreferenceConstants;
148
import org.eclipse.cdt.core.CCorePreferenceConstants;
124
import org.eclipse.cdt.core.IPositionConverter;
149
import org.eclipse.cdt.core.IPositionConverter;
125
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
150
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
151
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
126
import org.eclipse.cdt.core.model.CModelException;
152
import org.eclipse.cdt.core.model.CModelException;
127
import org.eclipse.cdt.core.model.ICElement;
153
import org.eclipse.cdt.core.model.ICElement;
154
import org.eclipse.cdt.core.model.ICProject;
128
import org.eclipse.cdt.core.model.ISourceRange;
155
import org.eclipse.cdt.core.model.ISourceRange;
129
import org.eclipse.cdt.core.model.ISourceReference;
156
import org.eclipse.cdt.core.model.ISourceReference;
130
import org.eclipse.cdt.core.model.ITranslationUnit;
157
import org.eclipse.cdt.core.model.ITranslationUnit;
Lines 136-141 Link Here
136
import org.eclipse.cdt.ui.text.ICPartitions;
163
import org.eclipse.cdt.ui.text.ICPartitions;
137
import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
164
import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
138
165
166
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
139
import org.eclipse.cdt.internal.corext.util.SimplePositionTracker;
167
import org.eclipse.cdt.internal.corext.util.SimplePositionTracker;
140
168
141
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
169
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
Lines 143-148 Link Here
143
import org.eclipse.cdt.internal.ui.actions.AddBlockCommentAction;
171
import org.eclipse.cdt.internal.ui.actions.AddBlockCommentAction;
144
import org.eclipse.cdt.internal.ui.actions.FoldingActionGroup;
172
import org.eclipse.cdt.internal.ui.actions.FoldingActionGroup;
145
import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
173
import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
174
import org.eclipse.cdt.internal.ui.actions.IndentAction;
146
import org.eclipse.cdt.internal.ui.actions.JoinLinesAction;
175
import org.eclipse.cdt.internal.ui.actions.JoinLinesAction;
147
import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction;
176
import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction;
148
import org.eclipse.cdt.internal.ui.dnd.TextEditorDropAdapter;
177
import org.eclipse.cdt.internal.ui.dnd.TextEditorDropAdapter;
Lines 150-155 Link Here
150
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
179
import org.eclipse.cdt.internal.ui.search.actions.OpenDeclarationsAction;
151
import org.eclipse.cdt.internal.ui.search.actions.OpenDefinitionAction;
180
import org.eclipse.cdt.internal.ui.search.actions.OpenDefinitionAction;
152
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
181
import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup;
182
import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
153
import org.eclipse.cdt.internal.ui.text.CPairMatcher;
183
import org.eclipse.cdt.internal.ui.text.CPairMatcher;
154
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
184
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
155
import org.eclipse.cdt.internal.ui.text.CTextTools;
185
import org.eclipse.cdt.internal.ui.text.CTextTools;
Lines 157-163 Link Here
157
import org.eclipse.cdt.internal.ui.text.DocumentCharacterIterator;
187
import org.eclipse.cdt.internal.ui.text.DocumentCharacterIterator;
158
import org.eclipse.cdt.internal.ui.text.HTMLTextPresenter;
188
import org.eclipse.cdt.internal.ui.text.HTMLTextPresenter;
159
import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
189
import org.eclipse.cdt.internal.ui.text.ICReconcilingListener;
190
import org.eclipse.cdt.internal.ui.text.Symbols;
160
import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl;
191
import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl;
192
import org.eclipse.cdt.internal.ui.text.comment.CommentFormattingContext;
161
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
193
import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference;
162
import org.eclipse.cdt.internal.ui.util.CUIHelp;
194
import org.eclipse.cdt.internal.ui.util.CUIHelp;
163
195
Lines 165-180 Link Here
165
/**
197
/**
166
 * C specific text editor.
198
 * C specific text editor.
167
 */
199
 */
168
public class CEditor extends TextEditor implements ISelectionChangedListener, IShowInSource, IReconcilingParticipant, ICReconcilingListener {
200
public class CEditor extends TextEditor implements ISelectionChangedListener, IShowInSource , IReconcilingParticipant{
201
202
	interface ITextConverter {
203
		void customizeDocumentCommand(IDocument document, DocumentCommand command);
204
	}
205
206
	class AdaptedSourceViewer extends CSourceViewer  {
207
208
		private List fTextConverters;
209
		private boolean fIgnoreTextConverters= false;
210
211
		public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
212
				                   boolean showAnnotationsOverview, int styles) {
213
			super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
214
		}
215
216
		public IContentAssistant getContentAssistant() {
217
			return fContentAssistant;
218
		}
219
220
		/*
221
		 * @see ITextOperationTarget#doOperation(int)
222
		 */
223
		public void doOperation(int operation) {
224
225
			if (getTextWidget() == null)
226
				return;
227
228
			switch (operation) {
229
				case CONTENTASSIST_PROPOSALS:
230
//					long time= CODE_ASSIST_DEBUG ? System.currentTimeMillis() : 0;
231
					String msg= fContentAssistant.showPossibleCompletions();
232
//					if (CODE_ASSIST_DEBUG) {
233
//						long delta= System.currentTimeMillis() - time;
234
//						System.err.println("Code Assist (total): " + delta); //$NON-NLS-1$
235
//					}
236
					setStatusLineErrorMessage(msg);
237
					return;
238
				case QUICK_ASSIST:
239
					/*
240
					 * XXX: We can get rid of this once the SourceViewer has a way to update the status line
241
					 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=133787
242
					 */
243
					msg= fQuickAssistAssistant.showPossibleQuickAssists();
244
					setStatusLineErrorMessage(msg);
245
					return;
246
				case UNDO:
247
					fIgnoreTextConverters= true;
248
					super.doOperation(operation);
249
					fIgnoreTextConverters= false;
250
					return;
251
				case REDO:
252
					fIgnoreTextConverters= true;
253
					super.doOperation(operation);
254
					fIgnoreTextConverters= false;
255
					return;
256
			}
257
258
			super.doOperation(operation);
259
		}
260
261
		public void insertTextConverter(ITextConverter textConverter, int index) {
262
			throw new UnsupportedOperationException();
263
		}
264
265
		public void addTextConverter(ITextConverter textConverter) {
266
			if (fTextConverters == null) {
267
				fTextConverters= new ArrayList(1);
268
				fTextConverters.add(textConverter);
269
			} else if (!fTextConverters.contains(textConverter))
270
				fTextConverters.add(textConverter);
271
		}
272
273
		public void removeTextConverter(ITextConverter textConverter) {
274
			if (fTextConverters != null) {
275
				fTextConverters.remove(textConverter);
276
				if (fTextConverters.size() == 0)
277
					fTextConverters= null;
278
			}
279
		}
280
281
		/*
282
		 * @see TextViewer#customizeDocumentCommand(DocumentCommand)
283
		 */
284
		protected void customizeDocumentCommand(DocumentCommand command) {
285
			super.customizeDocumentCommand(command);
286
			if (!fIgnoreTextConverters && fTextConverters != null) {
287
				for (Iterator e = fTextConverters.iterator(); e.hasNext();)
288
					((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command);
289
			}
290
		}
291
292
		public void updateIndentationPrefixes() {
293
			SourceViewerConfiguration configuration= getSourceViewerConfiguration();
294
			String[] types= configuration.getConfiguredContentTypes(this);
295
			for (int i= 0; i < types.length; i++) {
296
				String[] prefixes= configuration.getIndentPrefixes(this, types[i]);
297
				if (prefixes != null && prefixes.length > 0)
298
					setIndentPrefixes(prefixes, types[i]);
299
			}
300
301
			StyledText textWidget= getTextWidget();
302
			int tabWidth= configuration.getTabWidth(this);
303
			if (textWidget.getTabs() != tabWidth)
304
				textWidget.setTabs(tabWidth);
305
		}
306
307
		/*
308
		 * @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
309
		 */
310
		public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
311
			if (PlatformUI.getWorkbench().getHelpSystem().isContextHelpDisplayed())
312
				return false;
313
			return super.requestWidgetToken(requester);
314
		}
315
316
		/*
317
		 * @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper, int)
318
		 * @since 3.0
319
		 */
320
		public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) {
321
			if (PlatformUI.getWorkbench().getHelpSystem().isContextHelpDisplayed())
322
				return false;
323
			return super.requestWidgetToken(requester, priority);
324
		}
325
326
		/*
327
		 * @see org.eclipse.jface.text.source.SourceViewer#createFormattingContext()
328
		 * @since 3.0
329
		 */
330
		public IFormattingContext createFormattingContext() {
331
			IFormattingContext context= new CommentFormattingContext();
332
333
			Map preferences;
334
			ICElement inputCElement= getInputCElement();
335
			ICProject cProject= inputCElement != null ? inputCElement.getCProject() : null;
336
			if (cProject == null)
337
				preferences= new HashMap(CCorePlugin.getOptions());
338
			else
339
				preferences= new HashMap(cProject.getOptions(true));
340
341
			context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences);
342
343
			return context;
344
		}
345
	}
346
347
	static class TabConverter implements ITextConverter {
348
		private int fTabRatio;
349
		private ILineTracker fLineTracker;
350
		
351
		public TabConverter() {
352
		}
353
		
354
		public void setNumberOfSpacesPerTab(int ratio) {
355
			fTabRatio = ratio;
356
		}
357
		
358
		public void setLineTracker(ILineTracker lineTracker) {
359
			fLineTracker = lineTracker;
360
		}
361
		
362
		private int insertTabString(StringBuffer buffer, int offsetInLine) {
363
			
364
			if (fTabRatio == 0)
365
				return 0;
366
				
367
			int remainder = offsetInLine % fTabRatio;
368
			remainder = fTabRatio - remainder;
369
			for (int i = 0; i < remainder; i++)
370
				buffer.append(' ');
371
			return remainder;
372
		}
373
		
374
		public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
375
			String text = command.text;
376
			if (text == null)
377
				return;
378
				
379
			int index = text.indexOf('\t');
380
			if (index > -1) {
381
				StringBuffer buffer = new StringBuffer();
382
				
383
				fLineTracker.set(command.text);
384
				int lines = fLineTracker.getNumberOfLines();
385
				
386
				try {
387
					for (int i = 0; i < lines; i++) {
388
						int offset = fLineTracker.getLineOffset(i);
389
						int endOffset = offset + fLineTracker.getLineLength(i);
390
						String line = text.substring(offset, endOffset);
391
						
392
						int position = 0;
393
						if (i == 0) {
394
							IRegion firstLine = document.getLineInformationOfOffset(command.offset);
395
							position = command.offset - firstLine.getOffset();	
396
						}
397
						
398
						int length = line.length();
399
						for (int j = 0; j < length; j++) {
400
							char c = line.charAt(j);
401
							if (c == '\t') {
402
								int oldPosition = position;
403
								position += insertTabString(buffer, position);
404
								if (command.caretOffset > command.offset + oldPosition) {
405
									command.caretOffset += position - oldPosition - 1;
406
								}
407
							} else {
408
								buffer.append(c);
409
								++position;
410
							}
411
						}
412
					}
413
						
414
					command.text = buffer.toString();
415
				} catch (BadLocationException x) {
416
				}
417
			}
418
		}
419
	}
420
421
	private class ExitPolicy implements IExitPolicy {
422
423
		final char fExitCharacter;
424
		final char fEscapeCharacter;
425
		final Stack fStack;
426
		final int fSize;
427
428
		public ExitPolicy(char exitCharacter, char escapeCharacter, Stack stack) {
429
			fExitCharacter = exitCharacter;
430
			fEscapeCharacter = escapeCharacter;
431
			fStack = stack;
432
			fSize = fStack.size();
433
		}
434
435
		/*
436
		 * @see org.eclipse.jface.text.link.LinkedModeUI$IExitPolicy#doExit(org.eclipse.jface.text.link.LinkedModeModel, org.eclipse.swt.events.VerifyEvent, int, int)
437
		 */
438
		public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) {
439
440
			if (fSize == fStack.size() && !isMasked(offset)) {
441
				if (event.character == fExitCharacter) {
442
					BracketLevel level = (BracketLevel) fStack.peek();
443
					if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset)
444
						return null;
445
					if (level.fSecondPosition.offset == offset && length == 0)
446
						// don't enter the character if if its the closing peer
447
						return new ExitFlags(ILinkedModeListener.UPDATE_CARET, false);
448
				}
449
				// when entering an anonymous class between the parenthesis', we don't want
450
				// to jump after the closing parenthesis when return is pressed
451
				if (event.character == SWT.CR && offset > 0) {
452
					IDocument document = getSourceViewer().getDocument();
453
					try {
454
						if (document.getChar(offset - 1) == '{')
455
							return new ExitFlags(ILinkedModeListener.EXIT_ALL, true);
456
					} catch (BadLocationException e) {
457
					}
458
				}
459
			}
460
			return null;
461
		}
462
463
		private boolean isMasked(int offset) {
464
			IDocument document = getSourceViewer().getDocument();
465
			try {
466
				return fEscapeCharacter == document.getChar(offset - 1);
467
			} catch (BadLocationException e) {
468
			}
469
			return false;
470
		}
471
	}
472
473
	private static class BracketLevel {
474
		int fOffset;
475
		int fLength;
476
		LinkedModeUI fUI;
477
		Position fFirstPosition;
478
		Position fSecondPosition;
479
	}
169
480
170
	/**
481
	/**
171
	 * The information provider used to present focusable information
482
	 * Position updater that takes any changes at the borders of a position to not belong to the position.
172
	 * shells.
483
	 *
484
	 * @since 4.0
173
	 */
485
	 */
174
	private InformationPresenter fInformationPresenter;
486
	private static class ExclusivePositionUpdater implements IPositionUpdater {
175
	
487
488
		/** The position category. */
489
		private final String fCategory;
490
491
		/**
492
		 * Creates a new updater for the given <code>category</code>.
493
		 *
494
		 * @param category the new category.
495
		 */
496
		public ExclusivePositionUpdater(String category) {
497
			fCategory = category;
498
		}
499
500
		/*
501
		 * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
502
		 */
503
		public void update(DocumentEvent event) {
504
505
			int eventOffset = event.getOffset();
506
			int eventOldLength = event.getLength();
507
			int eventNewLength = event.getText() == null ? 0 : event.getText().length();
508
			int deltaLength = eventNewLength - eventOldLength;
509
510
			try {
511
				Position[] positions = event.getDocument().getPositions(fCategory);
512
513
				for (int i = 0; i != positions.length; i++) {
514
515
					Position position = positions[i];
516
517
					if (position.isDeleted())
518
						continue;
519
520
					int offset = position.getOffset();
521
					int length = position.getLength();
522
					int end = offset + length;
523
524
					if (offset >= eventOffset + eventOldLength)
525
						// position comes
526
						// after change - shift
527
						position.setOffset(offset + deltaLength);
528
					else if (end <= eventOffset) {
529
						// position comes way before change -
530
						// leave alone
531
					} else if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
532
						// event completely internal to the position - adjust length
533
						position.setLength(length + deltaLength);
534
					} else if (offset < eventOffset) {
535
						// event extends over end of position - adjust length
536
						int newEnd = eventOffset;
537
						position.setLength(newEnd - offset);
538
					} else if (end > eventOffset + eventOldLength) {
539
						// event extends from before position into it - adjust offset
540
						// and length
541
						// offset becomes end of event, length adjusted accordingly
542
						int newOffset = eventOffset + eventNewLength;
543
						position.setOffset(newOffset);
544
						position.setLength(end - newOffset);
545
					} else {
546
						// event consumes the position - delete it
547
						position.delete();
548
					}
549
				}
550
			} catch (BadPositionCategoryException e) {
551
				// ignore and return
552
			}
553
		}
554
555
		/**
556
		 * Returns the position category.
557
		 *
558
		 * @return the position category
559
		 */
560
		public String getCategory() {
561
			return fCategory;
562
		}
563
	}
564
565
	private class BracketInserter implements VerifyKeyListener, ILinkedModeListener {
566
567
		private boolean fCloseBrackets = true;
568
		private boolean fCloseStrings = true;
569
		private boolean fCloseAngularBrackets = true;
570
		private final String CATEGORY = toString();
571
		private IPositionUpdater fUpdater = new ExclusivePositionUpdater(CATEGORY);
572
		private Stack fBracketLevelStack = new Stack();
573
574
		public void setCloseBracketsEnabled(boolean enabled) {
575
			fCloseBrackets = enabled;
576
		}
577
578
		public void setCloseStringsEnabled(boolean enabled) {
579
			fCloseStrings = enabled;
580
		}
581
582
		public void setCloseAngularBracketsEnabled(boolean enabled) {
583
			fCloseAngularBrackets = enabled;
584
		}
585
586
		private boolean isAngularIntroducer(String identifier) {
587
			return identifier.length() > 0
588
				&& (Character.isUpperCase(identifier.charAt(0))
589
					|| identifier.equals("template") //$NON-NLS-1$
590
					|| identifier.equals("vector") //$NON-NLS-1$
591
					|| identifier.equals("list") //$NON-NLS-1$
592
					|| identifier.equals("slist") //$NON-NLS-1$
593
					|| identifier.equals("map") //$NON-NLS-1$
594
					|| identifier.equals("set") //$NON-NLS-1$
595
					|| identifier.equals("multimap") //$NON-NLS-1$
596
					|| identifier.equals("multiset") //$NON-NLS-1$
597
					|| identifier.equals("hash_map") //$NON-NLS-1$
598
					|| identifier.equals("hash_set") //$NON-NLS-1$
599
					|| identifier.equals("hash_multimap") //$NON-NLS-1$
600
					|| identifier.equals("hash_multiset") //$NON-NLS-1$
601
					|| identifier.equals("pair") //$NON-NLS-1$
602
					|| identifier.endsWith("_ptr") //$NON-NLS-1$
603
					|| identifier.endsWith("include")); //$NON-NLS-1$
604
		}
605
606
		/*
607
		 * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
608
		 */
609
		public void verifyKey(VerifyEvent event) {
610
611
			// early pruning to slow down normal typing as little as possible
612
			if (!event.doit || getInsertMode() != SMART_INSERT)
613
				return;
614
			switch (event.character) {
615
				case '(':
616
				case '<':
617
				case '[':
618
				case '\'':
619
				case '\"':
620
					break;
621
				default:
622
					return;
623
			}
624
625
			final ISourceViewer sourceViewer = getSourceViewer();
626
			IDocument document = sourceViewer.getDocument();
627
628
			final Point selection = sourceViewer.getSelectedRange();
629
			final int offset = selection.x;
630
			final int length = selection.y;
631
632
			try {
633
				IRegion startLine = document.getLineInformationOfOffset(offset);
634
				IRegion endLine = document.getLineInformationOfOffset(offset + length);
635
636
				CHeuristicScanner scanner = new CHeuristicScanner(document);
637
				int nextToken = scanner.nextToken(offset + length, endLine.getOffset() + endLine.getLength());
638
				String next = nextToken == Symbols.TokenEOF ? null : document.get(offset, scanner.getPosition() - offset).trim();
639
				int prevToken = scanner.previousToken(offset - 1, startLine.getOffset());
640
				int prevTokenOffset = scanner.getPosition() + 1;
641
				String previous = prevToken == Symbols.TokenEOF ? null : document.get(prevTokenOffset, offset - prevTokenOffset).trim();
642
643
				switch (event.character) {
644
					case '(':
645
						if (!fCloseBrackets
646
								|| nextToken == Symbols.TokenLPAREN
647
								|| nextToken == Symbols.TokenIDENT
648
								|| next != null && next.length() > 1)
649
							return;
650
						break;
651
652
					case '<':
653
						if (!(fCloseAngularBrackets && fCloseBrackets)
654
								|| nextToken == Symbols.TokenLESSTHAN
655
								|| 		   prevToken != Symbols.TokenLBRACE
656
										&& prevToken != Symbols.TokenRBRACE
657
										&& prevToken != Symbols.TokenSEMICOLON
658
										&& prevToken != Symbols.TokenSTATIC
659
										&& (prevToken != Symbols.TokenIDENT || !isAngularIntroducer(previous))
660
										&& prevToken != Symbols.TokenEOF)
661
							return;
662
						break;
663
664
					case '[':
665
						if (!fCloseBrackets
666
								|| nextToken == Symbols.TokenIDENT
667
								|| next != null && next.length() > 1)
668
							return;
669
						break;
670
671
					case '\'':
672
					case '"':
673
						if (!fCloseStrings
674
								|| nextToken == Symbols.TokenIDENT
675
								|| next != null && next.length() > 1
676
								|| (!("include".equals(previous) && event.character == '"') //$NON-NLS-1$
677
										&& (prevToken == Symbols.TokenIDENT
678
												|| previous != null && previous.length() > 1)))
679
							return;
680
						break;
681
682
					default:
683
						return;
684
				}
685
686
				ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
687
				if (!IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()))
688
					return;
689
690
				if (!validateEditorInputState())
691
					return;
692
693
				final char character = event.character;
694
				final char closingCharacter = getPeerCharacter(character);
695
				final StringBuffer buffer = new StringBuffer();
696
				buffer.append(character);
697
				buffer.append(closingCharacter);
698
				if (closingCharacter == '>' && nextToken != Symbols.TokenEOF
699
						&& document.getChar(offset + length) == '>') {
700
					// Insert a space to avoid two consequtive closing angular brackets. 
701
					buffer.append(' ');
702
				}
703
704
				document.replace(offset, length, buffer.toString());
705
706
				BracketLevel level = new BracketLevel();
707
				fBracketLevelStack.push(level);
708
709
				LinkedPositionGroup group = new LinkedPositionGroup();
710
				group.addPosition(new LinkedPosition(document, offset + 1, 0, LinkedPositionGroup.NO_STOP));
711
712
				LinkedModeModel model = new LinkedModeModel();
713
				model.addLinkingListener(this);
714
				model.addGroup(group);
715
				model.forceInstall();
716
717
				level.fOffset = offset;
718
				level.fLength = 2;
719
720
				// set up position tracking for our magic peers
721
				if (fBracketLevelStack.size() == 1) {
722
					document.addPositionCategory(CATEGORY);
723
					document.addPositionUpdater(fUpdater);
724
				}
725
				level.fFirstPosition = new Position(offset, 1);
726
				level.fSecondPosition = new Position(offset + 1, 1);
727
				document.addPosition(CATEGORY, level.fFirstPosition);
728
				document.addPosition(CATEGORY, level.fSecondPosition);
729
730
				level.fUI = new EditorLinkedModeUI(model, sourceViewer);
731
				level.fUI.setSimpleMode(true);
732
				level.fUI.setExitPolicy(new ExitPolicy(closingCharacter, getEscapeCharacter(closingCharacter), fBracketLevelStack));
733
				level.fUI.setExitPosition(sourceViewer, offset + 2, 0, Integer.MAX_VALUE);
734
				level.fUI.setCyclingMode(LinkedModeUI.CYCLE_NEVER);
735
				level.fUI.enter();
736
737
				IRegion newSelection = level.fUI.getSelectedRegion();
738
				sourceViewer.setSelectedRange(newSelection.getOffset(), newSelection.getLength());
739
740
				event.doit = false;
741
742
			} catch (BadLocationException e) {
743
				CUIPlugin.getDefault().log(e);
744
			} catch (BadPositionCategoryException e) {
745
				CUIPlugin.getDefault().log(e);
746
			}
747
		}
748
749
		/*
750
		 * @see org.eclipse.jface.text.link.ILinkedModeListener#left(org.eclipse.jface.text.link.LinkedModeModel, int)
751
		 */
752
		public void left(LinkedModeModel environment, int flags) {
753
754
			final BracketLevel level = (BracketLevel) fBracketLevelStack.pop();
755
756
			if (flags != ILinkedModeListener.EXTERNAL_MODIFICATION)
757
				return;
758
759
			// remove brackets
760
			final ISourceViewer sourceViewer = getSourceViewer();
761
			final IDocument document = sourceViewer.getDocument();
762
			if (document instanceof IDocumentExtension) {
763
				IDocumentExtension extension = (IDocumentExtension) document;
764
				extension.registerPostNotificationReplace(null, new IDocumentExtension.IReplace() {
765
766
					public void perform(IDocument d, IDocumentListener owner) {
767
						if ((level.fFirstPosition.isDeleted || level.fFirstPosition.length == 0)
768
								&& !level.fSecondPosition.isDeleted
769
								&& level.fSecondPosition.offset == level.fFirstPosition.offset)
770
						{
771
							try {
772
								document.replace(level.fSecondPosition.offset,
773
												 level.fSecondPosition.length,
774
												 null);
775
							} catch (BadLocationException e) {
776
								CUIPlugin.getDefault().log(e);
777
							}
778
						}
779
780
						if (fBracketLevelStack.size() == 0) {
781
							document.removePositionUpdater(fUpdater);
782
							try {
783
								document.removePositionCategory(CATEGORY);
784
							} catch (BadPositionCategoryException e) {
785
								CUIPlugin.getDefault().log(e);
786
							}
787
						}
788
					}
789
				});
790
			}
791
		}
792
793
		/*
794
		 * @see org.eclipse.jface.text.link.ILinkedModeListener#suspend(org.eclipse.jface.text.link.LinkedModeModel)
795
		 */
796
		public void suspend(LinkedModeModel environment) {
797
		}
798
799
		/*
800
		 * @see org.eclipse.jface.text.link.ILinkedModeListener#resume(org.eclipse.jface.text.link.LinkedModeModel, int)
801
		 */
802
		public void resume(LinkedModeModel environment, int flags) {
803
		}
804
	}
805
176
	/**
806
	/**
177
	 * Updates the Java outline page selection and this editor's range indicator.
807
	 * Updates the C outline page selection and this editor's range indicator.
178
	 * 
808
	 * 
179
	 * @since 3.0
809
	 * @since 3.0
180
	 */
810
	 */
Lines 228-234 Link Here
228
		/*
858
		/*
229
		 * @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer,
859
		 * @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer,
230
		 *      org.eclipse.jface.text.IRegion)
860
		 *      org.eclipse.jface.text.IRegion)
231
		 * @since 3.2
232
		 */
861
		 */
233
		public Object getInformation2(ITextViewer textViewer, IRegion subject) {
862
		public Object getInformation2(ITextViewer textViewer, IRegion subject) {
234
			return fHoverInfo;
863
			return fHoverInfo;
Lines 491-2149 Link Here
491
			} catch (IllegalArgumentException e) {
1120
			} catch (IllegalArgumentException e) {
492
				return -1;
1121
				return -1;
493
			}
1122
			}
494
495
		}
1123
		}
496
	}
1124
	}
497
	
1125
	
498
	/**
1126
	/**
499
	 * The editor selection changed listener.
1127
	 * Text navigation action to navigate to the next sub-word.
500
	 * 
1128
	 *
501
	 * @since 3.0
1129
	 * @since 4.0
502
	 */
1130
	 */
503
	private EditorSelectionChangedListener fEditorSelectionChangedListener;
1131
	protected abstract class NextSubWordAction extends TextNavigationAction {
504
	
505
1132
506
	/** The outline page */
1133
		protected CWordIterator fIterator = new CWordIterator();
507
	protected CContentOutlinePage fOutlinePage;
508
	
509
	/** Search actions **/
510
	private ActionGroup fSelectionSearchGroup;
511
	private ActionGroup fTextSearchGroup;
512
	private CRefactoringActionGroup fRefactoringActionGroup;
513
	
514
    /** Action which shows selected element in CView. */
515
	private ShowInCViewAction fShowInCViewAction;
516
	
517
	/** Activity Listeners **/
518
	protected ISelectionChangedListener fStatusLineClearer;
519
    protected ISelectionChangedListener fSelectionUpdateListener;
520
	
521
	/** Pairs of brackets, used to match. */
522
    protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' };
523
524
	/** Matches the brackets. */
525
    protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS);
526
527
	/** The editor's tab converter */
528
	private TabConverter fTabConverter;
529
1134
530
	/** Listener to annotation model changes that updates the error tick in the tab image */
1135
		/**
531
	private CEditorErrorTickUpdater fCEditorErrorTickUpdater;
1136
		 * Creates a new next sub-word action.
1137
		 *
1138
		 * @param code Action code for the default operation. Must be an action code from @see org.eclipse.swt.custom.ST.
1139
		 */
1140
		protected NextSubWordAction(int code) {
1141
			super(getSourceViewer().getTextWidget(), code);
1142
		}
532
1143
533
	/** Preference key for sub-word navigation, aka smart caret positioning */
1144
		/*
534
	public final static String SUB_WORD_NAVIGATION= "subWordNavigation"; //$NON-NLS-1$
1145
		 * @see org.eclipse.jface.action.IAction#run()
535
	/** Preference key for matching brackets */
1146
		 */
536
	public final static String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$
1147
		public void run() {
537
	/** Preference key for matching brackets color */
1148
			// Check whether sub word navigation is enabled.
538
	public final static String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$
1149
			final IPreferenceStore store = getPreferenceStore();
539
	/** Preference key for inactive code painter enablement */
1150
			if (!store.getBoolean(SUB_WORD_NAVIGATION)) {
540
	public static final String INACTIVE_CODE_ENABLE = "inactiveCodeEnable"; //$NON-NLS-1$
1151
				super.run();
541
	/** Preference key for inactive code painter color */
1152
				return;
542
	public static final String INACTIVE_CODE_COLOR = "inactiveCodeColor"; //$NON-NLS-1$
1153
			}
543
	/** Preference key for inserting spaces rather than tabs */
544
	public final static String SPACES_FOR_TABS = "spacesForTabs"; //$NON-NLS-1$
545
1154
546
    /** Preference key for compiler task tags */
1155
			final ISourceViewer viewer = getSourceViewer();
547
    private final static String TRANSLATION_TASK_TAGS= CCorePreferenceConstants.TRANSLATION_TASK_TAGS;
1156
			final IDocument document = viewer.getDocument();
1157
			fIterator.setText((CharacterIterator) new DocumentCharacterIterator(document));
1158
			int position = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
1159
			if (position == -1)
1160
				return;
548
1161
549
	/** 
1162
			int next = findNextPosition(position);
550
	 * This editor's projection support 
1163
			if (next != BreakIterator.DONE) {
551
	 */
1164
				setCaretPosition(next);
552
	private ProjectionSupport fProjectionSupport;
1165
				getTextWidget().showSelection();
553
	/** 
1166
				fireSelectionChanged();
554
	 * This editor's projection model updater 
1167
			}
555
	 */
1168
		}
556
	private ICFoldingStructureProvider fProjectionModelUpdater;
557
1169
558
	/**
1170
		/**
559
	 * The action group for folding.
1171
		 * Finds the next position after the given position.
560
	 */
1172
		 *
561
	private FoldingActionGroup fFoldingGroup;
1173
		 * @param position the current position
1174
		 * @return the next position
1175
		 */
1176
		protected int findNextPosition(int position) {
1177
			ISourceViewer viewer = getSourceViewer();
1178
			int widget = -1;
1179
			while (position != BreakIterator.DONE && widget == -1) { // TODO: optimize
1180
				position = fIterator.following(position);
1181
				if (position != BreakIterator.DONE)
1182
					widget = modelOffset2WidgetOffset(viewer, position);
1183
			}
1184
			return position;
1185
		}
562
1186
563
	/**
1187
		/**
564
	 * AST reconciling listeners.
1188
		 * Sets the caret position to the sub-word boundary given with <code>position</code>.
565
	 * @since 4.0
1189
		 *
566
	 */
1190
		 * @param position Position where the action should move the caret
567
	private ListenerList fReconcilingListeners= new ListenerList(ListenerList.IDENTITY);
1191
		 */
1192
		protected abstract void setCaretPosition(int position);
1193
	}
568
1194
569
	/**
1195
	/**
570
	 * Semantic highlighting manager
1196
	 * Text navigation action to navigate to the next sub-word.
1197
	 *
571
	 * @since 4.0
1198
	 * @since 4.0
572
	 */
1199
	 */
573
	private SemanticHighlightingManager fSemanticManager;
1200
	protected class NavigateNextSubWordAction extends NextSubWordAction {
574
1201
1202
		/**
1203
		 * Creates a new navigate next sub-word action.
1204
		 */
1205
		public NavigateNextSubWordAction() {
1206
			super(ST.WORD_NEXT);
1207
		}
575
1208
576
	/**
1209
		/*
577
	 * Default constructor.
1210
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#setCaretPosition(int)
578
	 */
1211
		 */
579
	public CEditor() {
1212
		protected void setCaretPosition(final int position) {
580
		super();
1213
			getTextWidget().setCaretOffset(modelOffset2WidgetOffset(getSourceViewer(), position));
1214
		}
581
	}
1215
	}
582
1216
583
	/**
1217
	/**
584
	 * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeEditor()
1218
	 * Text operation action to delete the next sub-word.
1219
	 *
1220
	 * @since 4.0
585
	 */
1221
	 */
586
	protected void initializeEditor() {
1222
	protected class DeleteNextSubWordAction extends NextSubWordAction implements IUpdate {
587
		CTextTools textTools = CUIPlugin.getDefault().getTextTools();
588
		setSourceViewerConfiguration(new CSourceViewerConfiguration(textTools, this));
589
		setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider());
590
	
591
		setEditorContextMenuId("#CEditorContext"); //$NON-NLS-1$
592
		setRulerContextMenuId("#CEditorRulerContext"); //$NON-NLS-1$
593
		setOutlinerContextMenuId("#CEditorOutlinerContext"); //$NON-NLS-1$
594
1223
595
		setPreferenceStore(CUIPlugin.getDefault().getCombinedPreferenceStore());
1224
		/**
596
		fCEditorErrorTickUpdater = new CEditorErrorTickUpdater(this);          
1225
		 * Creates a new delete next sub-word action.
597
	}
1226
		 */
1227
		public DeleteNextSubWordAction() {
1228
			super(ST.DELETE_WORD_NEXT);
1229
		}
598
1230
599
	/**
1231
		/*
600
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#doSetInput(org.eclipse.ui.IEditorInput)
1232
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#setCaretPosition(int)
601
	 */
1233
		 */
602
	protected void doSetInput(IEditorInput input) throws CoreException {
1234
		protected void setCaretPosition(final int position) {
603
		super.doSetInput(input);
1235
			if (!validateEditorInputState())
604
		setOutlinePageInput(fOutlinePage, input);
1236
				return;
605
1237
606
		if (fProjectionModelUpdater != null) {
1238
			final ISourceViewer viewer = getSourceViewer();
607
			fProjectionModelUpdater.initialize();
1239
			final int caret, length;
1240
			Point selection = viewer.getSelectedRange();
1241
			if (selection.y != 0) {
1242
				caret = selection.x;
1243
				length = selection.y;
1244
			} else {
1245
				caret = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
1246
				length = position - caret;
1247
			}
1248
1249
			try {
1250
				viewer.getDocument().replace(caret, length, ""); //$NON-NLS-1$
1251
			} catch (BadLocationException exception) {
1252
				// Should not happen
1253
			}
608
		}
1254
		}
609
		if (fCEditorErrorTickUpdater != null) {
1255
610
			fCEditorErrorTickUpdater.updateEditorImage(getInputCElement());
1256
		/*
1257
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#findNextPosition(int)
1258
		 */
1259
		protected int findNextPosition(int position) {
1260
			return fIterator.following(position);
611
		}
1261
		}
612
	}
613
1262
614
	/**
1263
		/*
615
	 * Update the title image.
1264
		 * @see org.eclipse.ui.texteditor.IUpdate#update()
616
     * @param image Title image.
1265
		 */
617
	 */
1266
		public void update() {
618
	public void updatedTitleImage(Image image) {
1267
			setEnabled(isEditorInputModifiable());
619
		setTitleImage(image);
1268
		}
620
	}
1269
	}
621
1270
622
	/**
1271
	/**
623
	 * Returns the C element wrapped by this editors input.
1272
	 * Text operation action to select the next sub-word.
624
	 *
1273
	 *
625
	 * @return the C element wrapped by this editors input.
1274
	 * @since 4.0
626
	 * @since 3.0
627
	 */
1275
	 */
628
	public ICElement getInputCElement () {
1276
	protected class SelectNextSubWordAction extends NextSubWordAction {
629
		return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput());
630
	}
631
1277
632
	/**
1278
		/**
633
	 * Gets the current IFile input.
1279
		 * Creates a new select next sub-word action.
634
	 * This method will be remove after cdt-3.0.
1280
		 */
635
	 * We can not guaranty that the input is an IFile, it may
1281
		public SelectNextSubWordAction() {
636
	 * an external file.  Clients should test for <code>null<code> or use getInputCElement()
1282
			super(ST.SELECT_WORD_NEXT);
637
	 * @deprecated use <code>CEditor.getInputCElement()</code>.
1283
		}
638
     * @return IFile Input file or null if input is not and IFileEditorInput.
1284
639
	 */
1285
		/*
640
	public IFile getInputFile() {		
1286
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#setCaretPosition(int)
641
		IEditorInput editorInput = getEditorInput();
1287
		 */
642
		if (editorInput != null) {
1288
		protected void setCaretPosition(final int position) {
643
			if ((editorInput instanceof IFileEditorInput)) {
1289
			final ISourceViewer viewer = getSourceViewer();
644
				return ((IFileEditorInput) editorInput).getFile();
1290
1291
			final StyledText text = viewer.getTextWidget();
1292
			if (text != null && !text.isDisposed()) {
1293
1294
				final Point selection = text.getSelection();
1295
				final int caret = text.getCaretOffset();
1296
				final int offset = modelOffset2WidgetOffset(viewer, position);
1297
1298
				if (caret == selection.x)
1299
					text.setSelectionRange(selection.y, offset - selection.y);
1300
				else
1301
					text.setSelectionRange(selection.x, offset - selection.x);
645
			}
1302
			}
646
		}
1303
		}
647
		return null;
648
	}
1304
	}
649
1305
650
	/**
1306
	/**
651
     * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
1307
	 * Text navigation action to navigate to the previous sub-word.
1308
	 *
1309
	 * @since 4.0
652
	 */
1310
	 */
653
    public boolean isSaveAsAllowed() {
1311
	protected abstract class PreviousSubWordAction extends TextNavigationAction {
654
		return true;
655
	}
656
	/**
657
	 * Gets the outline page of the c-editor.
658
     * @return Outline page.
659
	 */
660
	public CContentOutlinePage getOutlinePage() {
661
		if (fOutlinePage == null) {
662
			fOutlinePage = new CContentOutlinePage(this);
663
			fOutlinePage.addSelectionChangedListener(this);
664
		}
665
		setOutlinePageInput(fOutlinePage, getEditorInput());
666
		return fOutlinePage;
667
	}
668
1312
669
	/**
1313
		protected CWordIterator fIterator = new CWordIterator();
670
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
671
	 */
672
	public Object getAdapter(Class required) {
673
		if (IContentOutlinePage.class.equals(required)) {
674
			return getOutlinePage();
675
		}
676
		if (required == IShowInTargetList.class) {
677
			return new IShowInTargetList() {
678
				public String[] getShowInTargetIds() {
679
					return new String[] { CUIPlugin.CVIEW_ID, IPageLayout.ID_OUTLINE, IPageLayout.ID_RES_NAV };
680
				}
681
1314
682
			};
1315
		/**
683
		}
1316
		 * Creates a new previous sub-word action.
684
		if (ProjectionAnnotationModel.class.equals(required)) {
1317
		 *
685
			if (fProjectionSupport != null) {
1318
		 * @param code Action code for the default operation. Must be an action code from @see org.eclipse.swt.custom.ST.
686
				Object adapter= fProjectionSupport.getAdapter(getSourceViewer(), required);
1319
		 */
687
				if (adapter != null)
1320
		protected PreviousSubWordAction(final int code) {
688
					return adapter;
1321
			super(getSourceViewer().getTextWidget(), code);
689
			}
690
		}
1322
		}
691
		return super.getAdapter(required);
692
	}
693
	/**
694
	 * Handles a property change event describing a change
695
	 * of the editor's preference store and updates the preference
696
	 * related editor properties.
697
	 * 
698
	 * @param event the property change event
699
	 */
700
	protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
701
		CSourceViewer asv = (CSourceViewer) getSourceViewer();
702
703
		try {
704
			if (asv != null) {
705
706
				String property = event.getProperty();
707
708
				if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) {
709
					SourceViewerConfiguration configuration = getSourceViewerConfiguration();
710
					String[] types = configuration.getConfiguredContentTypes(asv);
711
					for (int i = 0; i < types.length; i++) {
712
						asv.setIndentPrefixes(configuration.getIndentPrefixes(asv, types[i]), types[i]);
713
					}
714
715
					if (fTabConverter != null) {
716
						fTabConverter.setNumberOfSpacesPerTab(configuration.getTabWidth(asv));
717
					}
718
					// the super class handles the reset of the tabsize.
719
					return;
720
				}
721
722
				if (SPACES_FOR_TABS.equals(property)) {
723
					if (isTabConversionEnabled())
724
						startTabConversion();
725
					else
726
						stopTabConversion();
727
					return;
728
				}
729
				
730
				// Not implemented ... for the future.
731
				if (TRANSLATION_TASK_TAGS.equals(event.getProperty())) {
732
					ISourceViewer sourceViewer= getSourceViewer();
733
					if (sourceViewer != null && affectsTextPresentation(event))
734
						sourceViewer.invalidateTextPresentation();
735
				}
736
1323
737
				if (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
1324
		/*
738
					if (fProjectionModelUpdater != null) {
1325
		 * @see org.eclipse.jface.action.IAction#run()
739
						fProjectionModelUpdater.uninstall();
1326
		 */
740
					}
1327
		public void run() {
741
					// either freshly enabled or provider changed
1328
			// Check whether sub word navigation is enabled.
742
					fProjectionModelUpdater= CUIPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
1329
			final IPreferenceStore store = getPreferenceStore();
743
					if (fProjectionModelUpdater != null) {
1330
			if (!store.getBoolean(SUB_WORD_NAVIGATION)) {
744
						fProjectionModelUpdater.install(this, asv);
1331
				super.run();
745
					}
1332
				return;
746
					return;
1333
			}
747
				}
748
1334
749
				if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event)) {
1335
			final ISourceViewer viewer = getSourceViewer();
750
					if (isSemanticHighlightingEnabled()) {
1336
			final IDocument document = viewer.getDocument();
751
						installSemanticHighlighting();
1337
			fIterator.setText((CharacterIterator) new DocumentCharacterIterator(document));
752
						fSemanticManager.refresh();
1338
			int position = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
753
					} else {
1339
			if (position == -1)
754
						uninstallSemanticHighlighting();
1340
				return;
755
					}
756
					return;
757
				}
758
1341
759
				IContentAssistant c= asv.getContentAssistant();
1342
			int previous = findPreviousPosition(position);
760
				if (c instanceof ContentAssistant) {
1343
			if (previous != BreakIterator.DONE) {
761
					ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
1344
				setCaretPosition(previous);
762
				}
1345
				getTextWidget().showSelection();
763
				
1346
				fireSelectionChanged();
764
			}
1347
			}
765
		} finally {
766
			super.handlePreferenceStoreChanged(event);
767
		}
1348
		}
768
	}
769
770
	/**
771
	 * React to changed selection.
772
	 * 
773
	 * @since 3.0
774
	 */
775
	protected void selectionChanged() {
776
		if (getSelectionProvider() == null)
777
			return;
778
		updateStatusLine();
779
	}
780
1349
781
	/**
1350
		/**
782
	 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
1351
		 * Finds the previous position before the given position.
783
	 */
1352
		 *
784
	public void selectionChanged(SelectionChangedEvent event) {
1353
		 * @param position the current position
785
		ISelection sel = event.getSelection();
1354
		 * @return the previous position
786
		if (sel instanceof IStructuredSelection) {
1355
		 */
787
			IStructuredSelection selection = (IStructuredSelection) sel;
1356
		protected int findPreviousPosition(int position) {
788
			Object obj = selection.getFirstElement();
1357
			ISourceViewer viewer = getSourceViewer();
789
			if (obj instanceof ISourceReference) {
1358
			int widget = -1;
790
				try {
1359
			while (position != BreakIterator.DONE && widget == -1) { // TODO: optimize
791
					ISourceRange range = ((ISourceReference) obj).getSourceRange();
1360
				position = fIterator.preceding(position);
792
					if (range != null) {
1361
				if (position != BreakIterator.DONE)
793
						setSelection(range, !isActivePart());
1362
					widget = modelOffset2WidgetOffset(viewer, position);
794
					}
795
				} catch (CModelException e) {
796
                    // Selection change not applied.
797
				}
798
			}
1363
			}
1364
			return position;
799
		}
1365
		}
1366
1367
		/**
1368
		 * Sets the caret position to the sub-word boundary given with <code>position</code>.
1369
		 *
1370
		 * @param position Position where the action should move the caret
1371
		 */
1372
		protected abstract void setCaretPosition(int position);
800
	}
1373
	}
801
1374
802
	/**
1375
	/**
803
     * Sets selection for C element. 
1376
	 * Text navigation action to navigate to the previous sub-word.
804
     * @param element Element to select.
1377
	 *
1378
	 * @since 4.0
805
	 */
1379
	 */
806
    public void setSelection(ICElement element) {
1380
	protected class NavigatePreviousSubWordAction extends PreviousSubWordAction {
807
1381
808
		if (element == null || element instanceof ITranslationUnit) {
1382
		/**
809
			/*
1383
		 * Creates a new navigate previous sub-word action.
810
			 * If the element is an ITranslationUnit this unit is either the input
1384
		 */
811
			 * of this editor or not being displayed. In both cases, nothing should
1385
		public NavigatePreviousSubWordAction() {
812
			 * happened.
1386
			super(ST.WORD_PREVIOUS);
813
			 */
814
			return;
815
		}
816
		if (element instanceof ISourceReference) {
817
			ISourceReference reference = (ISourceReference) element;
818
			// set hightlight range
819
			setSelection(reference, true);
820
		}
1387
		}
821
	}
822
823
    /**
824
     * Sets selection for source reference.
825
     * @param element Source reference to set.
826
     * @param moveCursor Should cursor be moved.
827
     */
828
    public void setSelection(ISourceReference element, boolean moveCursor) {
829
		if (element != null) {
830
			StyledText  textWidget= null;
831
			
832
			ISourceViewer sourceViewer= getSourceViewer();
833
			if (sourceViewer != null)
834
				textWidget= sourceViewer.getTextWidget();
835
			
836
			if (textWidget == null)
837
				return;
838
1388
839
			try {
1389
		/*
840
				setSelection(element.getSourceRange(), moveCursor);
1390
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#setCaretPosition(int)
841
			} catch (CModelException e) {
1391
		 */
842
                // Selection not applied.
1392
		protected void setCaretPosition(final int position) {
843
			}
1393
			getTextWidget().setCaretOffset(modelOffset2WidgetOffset(getSourceViewer(), position));
844
		}
1394
		}
845
	}
1395
	}
846
1396
847
	/**
1397
	/**
848
	 * Sets the current editor selection to the source range. Optionally
1398
	 * Text operation action to delete the previous sub-word.
849
	 * sets the current editor position.
850
	 *
1399
	 *
851
	 * @param element the source range to be shown in the editor, can be null.
1400
	 * @since 4.0
852
	 * @param moveCursor if true the editor is scrolled to show the range.
853
	 */
1401
	 */
854
	public void setSelection(ISourceRange element, boolean moveCursor) {
1402
	protected class DeletePreviousSubWordAction extends PreviousSubWordAction implements IUpdate {
855
1403
856
		if (element == null) {
1404
		/**
857
			return;
1405
		 * Creates a new delete previous sub-word action.
1406
		 */
1407
		public DeletePreviousSubWordAction() {
1408
			super(ST.DELETE_WORD_PREVIOUS);
858
		}
1409
		}
859
1410
860
		try {
1411
		/*
861
			IRegion alternateRegion = null;
1412
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#setCaretPosition(int)
862
			int start = element.getStartPos();
1413
		 */
863
			int length = element.getLength();
1414
		protected void setCaretPosition(int position) {
1415
			if (!validateEditorInputState())
1416
				return;
864
1417
865
			// Sanity check sometimes the parser may throw wrong numbers.
1418
			final int length;
866
			if (start < 0 || length < 0) {
1419
			final ISourceViewer viewer = getSourceViewer();
867
				start = 0;
1420
			Point selection = viewer.getSelectedRange();
868
				length = 0;
1421
			if (selection.y != 0) {
1422
				position = selection.x;
1423
				length = selection.y;
1424
			} else {
1425
				length = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset()) - position;
869
			}
1426
			}
870
1427
871
			// 0 length and start and non-zero start line says we know
1428
			try {
872
			// the line for some reason, but not the offset.
1429
				viewer.getDocument().replace(position, length, ""); //$NON-NLS-1$
873
			if (length == 0 && start == 0 && element.getStartLine() > 0) {
1430
			} catch (BadLocationException exception) {
874
				// We have the information in term of lines, we can work it out.
1431
				// Should not happen
875
				// Binary elements return the first executable statement so we have to substract -1
876
				start = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getStartLine() - 1);
877
				if (element.getEndLine() > 0) {
878
					length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine()) - start;
879
				} else {
880
					length = start;
881
				}
882
				// create an alternate region for the keyword highlight.
883
				alternateRegion = getDocumentProvider().getDocument(getEditorInput()).getLineInformation(element.getStartLine() - 1);
884
				if (start == length || length < 0) {
885
					if (alternateRegion != null) {
886
						start = alternateRegion.getOffset();
887
						length = alternateRegion.getLength();
888
					}
889
				}
890
			}
1432
			}
891
			setHighlightRange(start, length, moveCursor);
1433
		}
892
1434
893
			if (moveCursor) {
1435
		/*
894
				start = element.getIdStartPos();
1436
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#findPreviousPosition(int)
895
				length = element.getIdLength();
1437
		 */
896
				if (start == 0 && length == 0 && alternateRegion != null) {
1438
		protected int findPreviousPosition(int position) {
897
					start = alternateRegion.getOffset();
1439
			return fIterator.preceding(position);
898
					length = alternateRegion.getLength();
899
				}
900
				if (start > -1 && getSourceViewer() != null) {
901
					getSourceViewer().revealRange(start, length);
902
					getSourceViewer().setSelectedRange(start, length);
903
				}
904
				updateStatusField(CTextEditorActionConstants.STATUS_CURSOR_POS);
905
			}
906
			return;
907
		} catch (IllegalArgumentException x) {
908
            // No information to the user
909
		} catch (BadLocationException e) {
910
            // No information to the user
911
		}
1440
		}
912
1441
913
		if (moveCursor)
1442
		/*
914
			resetHighlightRange();
1443
		 * @see org.eclipse.ui.texteditor.IUpdate#update()
1444
		 */
1445
		public void update() {
1446
			setEnabled(isEditorInputModifiable());
1447
		}
915
	}
1448
	}
916
1449
917
	/**
1450
	/**
918
     * Checks is the editor active part. 
1451
	 * Text operation action to select the previous sub-word.
919
     * @return <code>true</code> if editor is the active part of the workbench.
1452
	 *
1453
	 * @since 4.0
920
	 */
1454
	 */
921
    private boolean isActivePart() {
1455
	protected class SelectPreviousSubWordAction extends PreviousSubWordAction {
922
		IWorkbenchWindow window = getSite().getWorkbenchWindow();
923
		IPartService service = window.getPartService();
924
		return (this == service.getActivePart());
925
	}
926
927
    /**
928
     * @see org.eclipse.ui.IWorkbenchPart#dispose()
929
     */
930
    public void dispose() {
931
1456
932
		if (fProjectionModelUpdater != null) {
1457
		/**
933
			fProjectionModelUpdater.uninstall();
1458
		 * Creates a new select previous sub-word action.
934
			fProjectionModelUpdater= null;
1459
		 */
935
		}
1460
		public SelectPreviousSubWordAction() {
936
		
1461
			super(ST.SELECT_WORD_PREVIOUS);
937
		if (fProjectionSupport != null) {
938
			fProjectionSupport.dispose();
939
			fProjectionSupport= null;
940
		}
1462
		}
941
1463
942
		if (fCEditorErrorTickUpdater != null) {
1464
		/*
943
			fCEditorErrorTickUpdater.dispose();
1465
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#setCaretPosition(int)
944
			fCEditorErrorTickUpdater = null;
1466
		 */
945
		}
1467
		protected void setCaretPosition(final int position) {
946
		
1468
			final ISourceViewer viewer = getSourceViewer();
947
        if (fSelectionUpdateListener != null) {
948
			getSelectionProvider().addSelectionChangedListener(fSelectionUpdateListener);
949
			fSelectionUpdateListener = null;
950
        }
951
        
952
       	if (fStatusLineClearer != null) {
953
			ISelectionProvider provider = getSelectionProvider();
954
       		provider.removeSelectionChangedListener(fStatusLineClearer);
955
			fStatusLineClearer = null;
956
		}
957
        
958
        if (fBracketMatcher != null) {
959
			fBracketMatcher.dispose();
960
			fBracketMatcher = null;
961
		}
962
		
963
		if (fOutlinePage != null) {
964
			fOutlinePage.dispose();
965
			fOutlinePage = null;
966
		}
967
		
968
		if (fShowInCViewAction != null) {
969
			fShowInCViewAction.dispose();
970
			fShowInCViewAction = null;
971
		}
972
		
973
		if (fSelectionSearchGroup != null) {
974
			fSelectionSearchGroup.dispose();
975
			fSelectionSearchGroup = null;
976
		}
977
1469
978
		if (fTextSearchGroup != null) {
1470
			final StyledText text = viewer.getTextWidget();
979
			fTextSearchGroup.dispose();
1471
			if (text != null && !text.isDisposed()) {
980
			fTextSearchGroup = null;
981
		}
982
1472
983
		if (fRefactoringActionGroup != null) {
1473
				final Point selection = text.getSelection();
984
			fRefactoringActionGroup.dispose();
1474
				final int caret = text.getCaretOffset();
985
			fRefactoringActionGroup = null;
1475
				final int offset = modelOffset2WidgetOffset(viewer, position);
986
		}
987
1476
988
		if (fEditorSelectionChangedListener != null)  {
1477
				if (caret == selection.x)
989
			fEditorSelectionChangedListener.uninstall(getSelectionProvider());
1478
					text.setSelectionRange(selection.y, offset - selection.y);
990
			fEditorSelectionChangedListener= null;
1479
				else
1480
					text.setSelectionRange(selection.x, offset - selection.x);
1481
			}
991
		}
1482
		}
992
993
		stopTabConversion();
994
		
995
		super.dispose();
996
	}
1483
	}
1484
	
997
1485
998
	/**
1486
	/**
999
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#canHandleMove(org.eclipse.ui.IEditorInput, org.eclipse.ui.IEditorInput)
1487
	 * The information provider used to present focusable information
1488
	 * shells.
1000
	 */
1489
	 */
1001
	protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
1490
	private InformationPresenter fInformationPresenter;
1002
		String oldLanguage = ""; //$NON-NLS-1$
1491
	
1003
		if (originalElement instanceof IFileEditorInput) {
1004
			IFile file= ((IFileEditorInput) originalElement).getFile();
1005
			if (file != null) {
1006
				IContentType type = CCorePlugin.getContentType(file.getProject(), file.getName());
1007
				if (type != null) {
1008
					oldLanguage = type.getId();
1009
				}
1010
				if (oldLanguage == null) {
1011
					return false;
1012
				}
1013
			}
1014
		}
1015
1016
		String newLanguage = ""; //$NON-NLS-1$
1017
		if (movedElement instanceof IFileEditorInput) {
1018
			IFile file = ((IFileEditorInput) movedElement).getFile();
1019
			if (file != null) {
1020
				IContentType type = CCorePlugin.getContentType(file.getProject(), file.getName());
1021
				if (type != null) {
1022
					newLanguage = type.getId();
1023
				}
1024
				if (newLanguage == null) {
1025
					return false;
1026
				}
1027
			}
1028
		}
1029
		return oldLanguage.equals(newLanguage);
1030
	}
1031
1032
	/**
1492
	/**
1033
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions()
1493
	 * The editor selection changed listener.
1494
	 * 
1495
	 * @since 3.0
1034
	 */
1496
	 */
1035
	protected void createActions() {
1497
	private EditorSelectionChangedListener fEditorSelectionChangedListener;
1036
		super.createActions();
1037
1498
1038
		fFoldingGroup= new FoldingActionGroup(this, getSourceViewer());
1499
	/** The outline page */
1500
	protected CContentOutlinePage fOutlinePage;
1501
	
1502
	/** Search actions **/
1503
	private ActionGroup fSelectionSearchGroup;
1504
	private ActionGroup fTextSearchGroup;
1505
	private CRefactoringActionGroup fRefactoringActionGroup;
1039
1506
1040
		// Sticky hover support
1507
	/** Action which shows selected element in CView. */
1041
		ResourceAction resAction= new TextOperationAction(CEditorMessages.getResourceBundle(), "ShowToolTip.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
1508
	private ShowInCViewAction fShowInCViewAction;
1042
		ResourceAction resAction2= new InformationDispatchAction(CEditorMessages.getResourceBundle(), "ShowToolTip.", (TextOperationAction) resAction); //$NON-NLS-1$
1509
	
1043
		resAction2.setActionDefinitionId(ICEditorActionDefinitionIds.SHOW_TOOLTIP);
1510
	/** Activity Listeners **/
1044
		setAction("ShowToolTip", resAction2); //$NON-NLS-1$
1511
	protected ISelectionChangedListener fStatusLineClearer;
1045
		PlatformUI.getWorkbench().getHelpSystem().setHelp(resAction2, ICHelpContextIds.SHOW_TOOLTIP_ACTION);
1512
    protected ISelectionChangedListener fSelectionUpdateListener;
1046
		
1513
	
1047
		// Default text editing menu items
1514
	/** Pairs of brackets, used to match. */
1048
		Action action= new GotoMatchingBracketAction(this);
1515
    protected final static char[] BRACKETS = { '{', '}', '(', ')', '[', ']', '<', '>' };
1049
		action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);				
1050
		setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);
1051
		
1052
		action = new JoinLinesAction(CEditorMessages.getResourceBundle(), "JoinLines.", this); //$NON-NLS-1$
1053
		action.setActionDefinitionId(ICEditorActionDefinitionIds.JOIN_LINES);
1054
		setAction("Join Lines", action); //$NON-NLS-1$
1055
		
1056
		action= new ToggleCommentAction(CEditorMessages.getResourceBundle(), "ToggleComment.", this); //$NON-NLS-1$
1057
		action.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_COMMENT);
1058
		setAction("ToggleComment", action); //$NON-NLS-1$
1059
		markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
1060
		configureToggleCommentAction();
1061
		
1062
		action= new AddBlockCommentAction(CEditorMessages.getResourceBundle(), "AddBlockComment.", this);  //$NON-NLS-1$
1063
		action.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_BLOCK_COMMENT);		
1064
		setAction("AddBlockComment", action); //$NON-NLS-1$
1065
		markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
1066
		markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$		
1067
		//WorkbenchHelp.setHelp(action, ICHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
1068
1516
1069
		action= new RemoveBlockCommentAction(CEditorMessages.getResourceBundle(), "RemoveBlockComment.", this);  //$NON-NLS-1$
1517
	/** Matches the brackets. */
1070
		action.setActionDefinitionId(ICEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);		
1518
    protected CPairMatcher fBracketMatcher = new CPairMatcher(BRACKETS);
1071
		setAction("RemoveBlockComment", action); //$NON-NLS-1$
1072
		markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
1073
		markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$		
1074
		//WorkbenchHelp.setHelp(action, ICHelpContextIds.REMOVE_BLOCK_COMMENT_ACTION);
1075
1519
1076
		action = new TextOperationAction(CEditorMessages.getResourceBundle(), "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
1520
	/** The bracket inserter. */
1077
		action.setActionDefinitionId(ICEditorActionDefinitionIds.FORMAT);
1521
	private BracketInserter fBracketInserter = new BracketInserter();
1078
		setAction("Format", action); //$NON-NLS-1$
1079
		markAsStateDependentAction("Format", true); //$NON-NLS-1$
1080
1522
1081
		action = new ContentAssistAction(CEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
1523
	/** The editor's tab converter */
1082
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
1524
	private TabConverter fTabConverter;
1083
		setAction("ContentAssistProposal", action); //$NON-NLS-1$
1084
		markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
1085
1525
1086
		action = new TextOperationAction(CEditorMessages.getResourceBundle(), "ContentAssistTip.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
1526
	/** Listener to annotation model changes that updates the error tick in the tab image */
1087
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
1527
	private CEditorErrorTickUpdater fCEditorErrorTickUpdater;
1088
		setAction("ContentAssistTip", action); //$NON-NLS-1$
1089
1528
1090
		action = new AddIncludeOnSelectionAction(this);
1529
	/** Preference key for sub-word navigation, aka smart caret positioning */
1091
		action.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE);
1530
	public final static String SUB_WORD_NAVIGATION = "subWordNavigation"; //$NON-NLS-1$
1092
		setAction("AddIncludeOnSelection", action); //$NON-NLS-1$
1531
	/** Preference key for matching brackets */
1093
	
1532
	public final static String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$
1094
		action = new OpenDeclarationsAction(this);
1533
	/** Preference key for matching brackets color */
1095
		action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
1534
	public final static String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$
1096
		setAction("OpenDeclarations", action); //$NON-NLS-1$
1535
	/** Preference key for inactive code painter enablement */
1097
1536
	public static final String INACTIVE_CODE_ENABLE = "inactiveCodeEnable"; //$NON-NLS-1$
1098
        action = new OpenDefinitionAction(this);
1537
	/** Preference key for inactive code painter color */
1099
        action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DEF);
1538
	public static final String INACTIVE_CODE_COLOR = "inactiveCodeColor"; //$NON-NLS-1$
1100
        setAction("OpenDefinition", action); //$NON-NLS-1$
1539
	/** Preference key for code formatter tab size */
1101
        
1540
	private final static String CODE_FORMATTER_TAB_SIZE = DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
1102
//		action = new OpenTypeHierarchyAction(this);
1541
	/** Preference key for inserting spaces rather than tabs */
1103
//		action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
1542
	public final static String SPACES_FOR_TABS = DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR;
1104
//		setAction("OpenTypeHierarchy", action); //$NON-NLS-1$
1543
	/** Preference key for automatically closing strings */
1105
1544
	private final static String CLOSE_STRINGS = PreferenceConstants.EDITOR_CLOSE_STRINGS;
1106
		fShowInCViewAction = new ShowInCViewAction(this);
1545
	/** Preference key for automatically closing brackets and parenthesis */
1107
		action = fShowInCViewAction;
1546
	private final static String CLOSE_BRACKETS = PreferenceConstants.EDITOR_CLOSE_BRACKETS;
1108
		action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CVIEW);
1547
	/** Preference key for automatically closing angular brackets */
1109
		setAction("ShowInCView", action); //$NON-NLS-1$
1548
	private final static String CLOSE_ANGULAR_BRACKETS = PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS;
1110
        
1111
        action = new TextOperationAction(CEditorMessages.getResourceBundle(), "OpenOutline.", this, CSourceViewer.SHOW_OUTLINE, true); //$NON-NLS-1$
1112
        action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_OUTLINE);
1113
        setAction("OpenOutline", action); //$NON-NLS-1$*/
1114
        
1115
        action = new GoToNextPreviousMemberAction(CEditorMessages.getResourceBundle(), "GotoNextMember.", this, true); //$NON-NLS-1$
1116
        action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
1117
        setAction("GotoNextMember", action); //$NON-NLS-1$*/
1118
1549
1119
        action = new GoToNextPreviousMemberAction(CEditorMessages.getResourceBundle(), "GotoPrevMember.", this, false); //$NON-NLS-1$
1550
    /** Preference key for compiler task tags */
1120
        action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
1551
    private final static String TRANSLATION_TASK_TAGS = CCorePreferenceConstants.TRANSLATION_TASK_TAGS;
1121
        setAction("GotoPrevMember", action); //$NON-NLS-1$*/
1122
1552
1123
        //Assorted action groupings
1553
	/** 
1124
		fSelectionSearchGroup = new SelectionSearchGroup(this);
1554
	 * This editor's projection support 
1125
		fTextSearchGroup= new TextSearchGroup(this);
1555
	 */
1126
		fRefactoringActionGroup= new CRefactoringActionGroup(this);
1556
	private ProjectionSupport fProjectionSupport;
1127
	}
1557
	/** 
1558
	 * This editor's projection model updater 
1559
	 */
1560
	private ICFoldingStructureProvider fProjectionModelUpdater;
1128
1561
1129
	/**
1562
	/**
1130
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
1563
	 * The action group for folding.
1131
	 */
1564
	 */
1132
	public void editorContextMenuAboutToShow(IMenuManager menu) {
1565
	private FoldingActionGroup fFoldingGroup;
1133
		super.editorContextMenuAboutToShow(menu);
1134
1135
		addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_REORGANIZE);
1136
		addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_GENERATE);
1137
		addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_NEW);
1138
1139
		// Code formatting menu items -- only show in C perspective
1140
		addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "ToggleComment"); //$NON-NLS-1$
1141
		addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "AddBlockComment"); //$NON-NLS-1$
1142
		addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "RemoveBlockComment"); //$NON-NLS-1$
1143
1144
		addAction(menu, ITextEditorActionConstants.GROUP_FIND, "OpenDeclarations"); //$NON-NLS-1$
1145
        addAction(menu, ITextEditorActionConstants.GROUP_FIND, "OpenDefinition"); //$NON-NLS-1$
1146
1147
		addAction(menu, ITextEditorActionConstants.GROUP_FIND, "OpenTypeHierarchy"); //$NON-NLS-1$
1148
        addAction(menu, ITextEditorActionConstants.GROUP_FIND, "GotoNextMember"); //$NON-NLS-1$
1149
        addAction(menu, ITextEditorActionConstants.GROUP_FIND, "GotoPrevMember"); //$NON-NLS-1$
1150
1151
		addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ContentAssistProposal"); //$NON-NLS-1$
1152
		addAction(menu, IContextMenuConstants.GROUP_GENERATE, "AddIncludeOnSelection"); //$NON-NLS-1$
1153
		addAction(menu, IContextMenuConstants.GROUP_GENERATE, "Format"); //$NON-NLS-1$
1154
		
1155
		addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ShowInCView"); //$NON-NLS-1$
1156
1157
		fSelectionSearchGroup.fillContextMenu(menu);
1158
		fTextSearchGroup.fillContextMenu(menu);
1159
		fRefactoringActionGroup.fillContextMenu(menu);
1160
	}
1161
1566
1162
	/**
1567
	/**
1163
     * Sets an input for the outline page.
1568
	 * AST reconciling listeners.
1164
	 * @param page Page to set the input.
1569
	 * @since 4.0
1165
	 * @param input Input to set.
1166
	 */
1570
	 */
1167
	public static void setOutlinePageInput(CContentOutlinePage page, IEditorInput input) {
1571
	private ListenerList fReconcilingListeners= new ListenerList(ListenerList.IDENTITY);
1168
		if (page != null) {
1169
			IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
1170
			page.setInput(manager.getWorkingCopy(input));
1171
		}
1172
	}
1173
1572
1174
	/**
1573
	/**
1175
     * Determines is folding enabled.
1574
	 * Semantic highlighting manager
1176
	 * @return <code>true</code> if folding is enabled, <code>false</code> otherwise.
1575
	 * @since 4.0
1177
	 */
1576
	 */
1178
	boolean isFoldingEnabled() {
1577
	private SemanticHighlightingManager fSemanticManager;
1179
		return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
1180
	}
1181
1578
1182
1579
1183
	/**
1580
	/**
1184
	 * The <code>AbstractTextEditor</code> implementation of this 
1581
	 * Default constructor.
1185
	 * <code>IWorkbenchPart</code> method creates the vertical ruler and
1582
	 */
1186
	 * source viewer. Subclasses may extend.
1583
	public CEditor() {
1187
	 * 
1584
		super();
1188
	 * We attach our own mouseDown listener on the menu bar, 
1585
	}
1189
	 * and our own listener for cursor/key/selection events to update cursor position in
1190
	 * status bar.
1191
1586
1192
     * @param parent Parent composite of the control.
1587
	/**
1588
	 * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeEditor()
1193
	 */
1589
	 */
1194
	public void createPartControl(Composite parent) {
1590
	protected void initializeEditor() {
1195
		super.createPartControl(parent);
1591
		CTextTools textTools = CUIPlugin.getDefault().getTextTools();
1592
		setSourceViewerConfiguration(new CSourceViewerConfiguration(textTools, this));
1593
		setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider());
1196
	
1594
	
1197
		// Sticky hover support
1595
		setEditorContextMenuId("#CEditorContext"); //$NON-NLS-1$
1198
		IInformationControlCreator informationControlCreator = new IInformationControlCreator() {
1596
		setRulerContextMenuId("#CEditorRulerContext"); //$NON-NLS-1$
1199
			public IInformationControl createInformationControl(Shell shell) {
1597
		setOutlinerContextMenuId("#CEditorOutlinerContext"); //$NON-NLS-1$
1200
				boolean cutDown = false;
1201
				int style = cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL);
1202
				return new DefaultInformationControl(shell, SWT.RESIZE
1203
						| SWT.TOOL, style, new HTMLTextPresenter(cutDown));
1204
			}
1205
		};
1206
1207
		fInformationPresenter = new InformationPresenter(
1208
				informationControlCreator);
1209
		fInformationPresenter.setSizeConstraints(60, 10, true, true);
1210
		fInformationPresenter.install(getSourceViewer());
1211
		fInformationPresenter
1212
				.setDocumentPartitioning(ICPartitions.C_PARTITIONING);
1213
				
1214
		
1215
		ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer();
1216
		
1217
		fProjectionSupport= new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
1218
		fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
1219
		fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
1220
		fProjectionSupport.install();
1221
		
1222
		fProjectionModelUpdater= CUIPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
1223
		if (fProjectionModelUpdater != null)
1224
			fProjectionModelUpdater.install(this, projectionViewer);
1225
1226
		if (isFoldingEnabled())
1227
			projectionViewer.doOperation(ProjectionViewer.TOGGLE);
1228
		
1229
1230
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICHelpContextIds.CEDITOR_VIEW);
1231
1232
		fEditorSelectionChangedListener= new EditorSelectionChangedListener();
1233
		fEditorSelectionChangedListener.install(getSelectionProvider());
1234
		
1235
1598
1236
		if (isTabConversionEnabled())
1599
		setPreferenceStore(CUIPlugin.getDefault().getCombinedPreferenceStore());
1237
			startTabConversion();
1600
		fCEditorErrorTickUpdater = new CEditorErrorTickUpdater(this);          
1601
	}
1238
1602
1239
		if (isSemanticHighlightingEnabled())
1603
	/**
1240
			installSemanticHighlighting();
1604
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#doSetInput(org.eclipse.ui.IEditorInput)
1605
	 */
1606
	protected void doSetInput(IEditorInput input) throws CoreException {
1607
		super.doSetInput(input);
1608
		setOutlinePageInput(fOutlinePage, input);
1241
1609
1610
		if (fProjectionModelUpdater != null) {
1611
			fProjectionModelUpdater.initialize();
1612
		}
1613
		if (fCEditorErrorTickUpdater != null) {
1614
			fCEditorErrorTickUpdater.updateEditorImage(getInputCElement());
1615
		}
1242
	}
1616
	}
1243
1617
1244
	/*
1618
	/**
1245
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#initializeDragAndDrop(org.eclipse.jface.text.source.ISourceViewer)
1619
	 * Update the title image.
1620
     * @param image Title image.
1246
	 */
1621
	 */
1247
	protected void initializeDragAndDrop(ISourceViewer viewer) {
1622
	public void updatedTitleImage(Image image) {
1248
		Control control= viewer.getTextWidget();
1623
		setTitleImage(image);
1249
		int operations= DND.DROP_MOVE | DND.DROP_COPY;
1624
	}
1250
1251
		DropTarget dropTarget= new DropTarget(control, operations);
1252
		ITextEditorDropTargetListener dropTargetListener= new TextEditorDropAdapter(viewer, this);
1253
		dropTarget.setTransfer(dropTargetListener.getTransfers());
1254
		dropTarget.addDropListener(dropTargetListener);
1255
1625
1256
		DragSource dragSource= new DragSource(control, operations);
1626
	/**
1257
		Transfer[] dragTypes= new Transfer[] { TextTransfer.getInstance() };
1627
	 * Returns the C element wrapped by this editors input.
1258
		dragSource.setTransfer(dragTypes);
1628
	 *
1259
		DragSourceListener dragSourceListener= new TextViewerDragAdapter(viewer, this);
1629
	 * @return the C element wrapped by this editors input.
1260
		dragSource.addDragListener(dragSourceListener);
1630
	 * @since 3.0
1631
	 */
1632
	public ICElement getInputCElement () {
1633
		return CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput());
1261
	}
1634
	}
1262
1635
1263
	/*
1636
	/**
1264
	 * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#getSourceViewerDecorationSupport(ISourceViewer)
1637
	 * Gets the current IFile input.
1638
	 * This method will be remove after cdt-3.0.
1639
	 * We can not guaranty that the input is an IFile, it may
1640
	 * an external file.  Clients should test for <code>null<code> or use getInputCElement()
1641
	 * @deprecated use <code>CEditor.getInputCElement()</code>.
1642
     * @return IFile Input file or null if input is not and IFileEditorInput.
1265
	 */
1643
	 */
1266
	protected SourceViewerDecorationSupport getSourceViewerDecorationSupport(
1644
	public IFile getInputFile() {		
1267
			ISourceViewer viewer) {
1645
		IEditorInput editorInput = getEditorInput();
1268
		if (fSourceViewerDecorationSupport == null) {
1646
		if (editorInput != null) {
1269
			fSourceViewerDecorationSupport= new CSourceViewerDecorationSupport(this, viewer, getOverviewRuler(), getAnnotationAccess(), getSharedColors());
1647
			if ((editorInput instanceof IFileEditorInput)) {
1270
			configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport);
1648
				return ((IFileEditorInput) editorInput).getFile();
1649
			}
1271
		}
1650
		}
1272
		return fSourceViewerDecorationSupport;
1651
		return null;
1273
	}
1652
	}
1274
	
1653
1275
	/*
1654
	/**
1276
	 * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#configureSourceViewerDecorationSupport(org.eclipse.ui.texteditor.SourceViewerDecorationSupport)
1655
     * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
1277
	 */
1656
	 */
1278
	protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
1657
    public boolean isSaveAsAllowed() {
1279
		super.configureSourceViewerDecorationSupport(support);
1658
		return true;
1280
		//Enhance the stock source viewer decorator with a bracket matcher
1281
		support.setCharacterPairMatcher(fBracketMatcher);
1282
		support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR);
1283
		((CSourceViewerDecorationSupport)support).setInactiveCodePainterPreferenceKeys(INACTIVE_CODE_ENABLE, INACTIVE_CODE_COLOR);
1284
	}
1659
	}
1285
	
1286
	/**
1660
	/**
1287
	 * Jumps to the matching bracket.
1661
	 * Gets the outline page of the c-editor.
1662
     * @return Outline page.
1288
	 */
1663
	 */
1289
	public void gotoMatchingBracket() {
1664
	public CContentOutlinePage getOutlinePage() {
1290
		
1665
		if (fOutlinePage == null) {
1291
		ISourceViewer sourceViewer= getSourceViewer();
1666
			fOutlinePage = new CContentOutlinePage(this);
1292
		IDocument document= sourceViewer.getDocument();
1667
			fOutlinePage.addSelectionChangedListener(this);
1293
		if (document == null)
1294
			return;
1295
		
1296
		IRegion selection= getSignedSelection(sourceViewer);
1297
1298
		int selectionLength= Math.abs(selection.getLength());
1299
		if (selectionLength > 1) {
1300
			setStatusLineErrorMessage(CEditorMessages.getString("GotoMatchingBracket.error.invalidSelection"));	//$NON-NLS-1$		
1301
			sourceViewer.getTextWidget().getDisplay().beep();
1302
			return;
1303
		}
1668
		}
1669
		setOutlinePageInput(fOutlinePage, getEditorInput());
1670
		return fOutlinePage;
1671
	}
1304
1672
1305
		// #26314
1673
	/**
1306
		int sourceCaretOffset= selection.getOffset() + selection.getLength();
1674
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
1307
		if (isSurroundedByBrackets(document, sourceCaretOffset))
1675
	 */
1308
			sourceCaretOffset -= selection.getLength();
1676
	public Object getAdapter(Class required) {
1309
1677
		if (IContentOutlinePage.class.equals(required)) {
1310
		IRegion region= fBracketMatcher.match(document, sourceCaretOffset);
1678
			return getOutlinePage();
1311
		if (region == null) {
1312
			setStatusLineErrorMessage(CEditorMessages.getString("GotoMatchingBracket.error.noMatchingBracket"));	//$NON-NLS-1$		
1313
			sourceViewer.getTextWidget().getDisplay().beep();
1314
			return;		
1315
		}
1679
		}
1316
		
1680
		if (required == IShowInTargetList.class) {
1317
		int offset= region.getOffset();
1681
			return new IShowInTargetList() {
1318
		int length= region.getLength();
1682
				public String[] getShowInTargetIds() {
1319
		
1683
					return new String[] { CUIPlugin.CVIEW_ID, IPageLayout.ID_OUTLINE, IPageLayout.ID_RES_NAV };
1320
		if (length < 1)
1684
				}
1321
			return;
1685
1322
			
1686
			};
1323
		int anchor= fBracketMatcher.getAnchor();
1324
		// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
1325
		int targetOffset= (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1: offset + length;
1326
		
1327
		boolean visible= false;
1328
		if (sourceViewer instanceof ITextViewerExtension5) {
1329
			ITextViewerExtension5 extension= (ITextViewerExtension5) sourceViewer;
1330
			visible= (extension.modelOffset2WidgetOffset(targetOffset) > -1);
1331
		} else {
1332
			IRegion visibleRegion= sourceViewer.getVisibleRegion();
1333
			// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
1334
			visible= (targetOffset >= visibleRegion.getOffset() && targetOffset <= visibleRegion.getOffset() + visibleRegion.getLength());
1335
		}
1687
		}
1336
		
1688
		if (ProjectionAnnotationModel.class.equals(required)) {
1337
		if (!visible) {
1689
			if (fProjectionSupport != null) {
1338
			setStatusLineErrorMessage(CEditorMessages.getString("GotoMatchingBracket.error.bracketOutsideSelectedElement"));	//$NON-NLS-1$		
1690
				Object adapter = fProjectionSupport.getAdapter(getSourceViewer(), required);
1339
			sourceViewer.getTextWidget().getDisplay().beep();
1691
				if (adapter != null)
1340
			return;
1692
					return adapter;
1693
			}
1341
		}
1694
		}
1342
		
1695
		return super.getAdapter(required);
1343
		if (selection.getLength() < 0)
1344
			targetOffset -= selection.getLength();
1345
			
1346
		sourceViewer.setSelectedRange(targetOffset, selection.getLength());
1347
		sourceViewer.revealRange(targetOffset, selection.getLength());
1348
	}
1696
	}
1697
	/**
1698
	 * Handles a property change event describing a change
1699
	 * of the editor's preference store and updates the preference
1700
	 * related editor properties.
1701
	 * 
1702
	 * @param event the property change event
1703
	 */
1704
	protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
1705
		try {
1706
			AdaptedSourceViewer asv = (AdaptedSourceViewer) getSourceViewer();
1349
1707
1350
	protected void updateStatusLine() {
1708
			if (asv != null) {
1351
		ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
1709
				String property = event.getProperty();
1352
		Annotation annotation= getAnnotation(selection.getOffset(), selection.getLength());
1710
1353
		setStatusLineErrorMessage(null);
1711
				if (CLOSE_BRACKETS.equals(property)) {
1354
		setStatusLineMessage(null);
1712
					fBracketInserter.setCloseBracketsEnabled(getPreferenceStore().getBoolean(property));
1355
		if (annotation != null) {
1713
					return;
1356
			updateMarkerViews(annotation);
1714
				}
1357
			if (annotation instanceof ICAnnotation && ((ICAnnotation) annotation).isProblem())
1715
1358
				setStatusLineMessage(annotation.getText());
1716
				if (CLOSE_ANGULAR_BRACKETS.equals(property)) {
1717
					fBracketInserter.setCloseAngularBracketsEnabled(getPreferenceStore().getBoolean(property));
1718
					return;
1719
				}
1720
				
1721
				if (CLOSE_STRINGS.equals(property)) {
1722
					fBracketInserter.setCloseStringsEnabled(getPreferenceStore().getBoolean(property));
1723
					return;
1724
				}
1725
1726
				if (SPACES_FOR_TABS.equals(property)) {
1727
					if (isTabConversionEnabled())
1728
						startTabConversion();
1729
					else
1730
						stopTabConversion();
1731
					return;
1732
				}
1733
1734
				if (PreferenceConstants.EDITOR_SMART_TAB.equals(property)) {
1735
					if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
1736
						setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
1737
					} else {
1738
						removeActionActivationCode("IndentOnTab"); //$NON-NLS-1$
1739
					}
1740
				}
1741
1742
				if (CODE_FORMATTER_TAB_SIZE.equals(property)) {
1743
					asv.updateIndentationPrefixes();
1744
					if (fTabConverter != null)
1745
						fTabConverter.setNumberOfSpacesPerTab(getTabSize());
1746
				}
1747
1748
				// Not implemented ... for the future.
1749
				if (TRANSLATION_TASK_TAGS.equals(event.getProperty())) {
1750
					ISourceViewer sourceViewer = getSourceViewer();
1751
					if (sourceViewer != null && affectsTextPresentation(event))
1752
						sourceViewer.invalidateTextPresentation();
1753
				}
1754
1755
				if (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
1756
					if (fProjectionModelUpdater != null) {
1757
						fProjectionModelUpdater.uninstall();
1758
					}
1759
					// either freshly enabled or provider changed
1760
					fProjectionModelUpdater = CUIPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
1761
					if (fProjectionModelUpdater != null) {
1762
						fProjectionModelUpdater.install(this, asv);
1763
					}
1764
					return;
1765
				}
1766
1767
				if (SemanticHighlightings.affectsEnablement(getPreferenceStore(), event)) {
1768
					if (isSemanticHighlightingEnabled()) {
1769
						installSemanticHighlighting();
1770
						fSemanticManager.refresh();
1771
					} else {
1772
						uninstallSemanticHighlighting();
1773
					}
1774
					return;
1775
				}
1776
1777
				IContentAssistant c = asv.getContentAssistant();
1778
				if (c instanceof ContentAssistant) {
1779
					ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
1780
				}
1781
			}
1782
		} finally {
1783
			super.handlePreferenceStoreChanged(event);
1359
		}
1784
		}
1360
	}
1785
	}
1361
1786
1362
	/**
1787
	/**
1363
	 * Returns the annotation overlapping with the given range or <code>null</code>.
1788
	 * React to changed selection.
1364
	 * 
1789
	 * 
1365
	 * @param offset the region offset
1366
	 * @param length the region length
1367
	 * @return the found annotation or <code>null</code>
1368
	 * @since 3.0
1790
	 * @since 3.0
1369
	 */
1791
	 */
1370
	private Annotation getAnnotation(int offset, int length) {
1792
	protected void selectionChanged() {
1371
		IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
1793
		if (getSelectionProvider() == null)
1372
		Iterator e= new CAnnotationIterator(model, true, true);
1794
			return;
1373
		while (e.hasNext()) {
1795
		updateStatusLine();
1374
			Annotation a= (Annotation) e.next();
1375
			if (!isNavigationTarget(a))
1376
				continue;
1377
				
1378
			Position p= model.getPosition(a);
1379
			if (p != null && p.overlapsWith(offset, length))
1380
				return a;
1381
		}
1382
		
1383
		return null;
1384
	}
1385
	/* (non-Javadoc)
1386
	 * @see org.eclipse.ui.part.IShowInSource#getShowInContext()
1387
	 *
1388
	 * This is required by the IShowInSource interface for the "ShowIn"
1389
 	 * navigation menu generalized in Eclipse.
1390
	 */
1391
	public ShowInContext getShowInContext() {
1392
		return new ShowInContext( getEditorInput(), null );
1393
	}
1796
	}
1394
1797
1395
	/*
1798
	/**
1396
	 * Get the dektop's StatusLineManager
1799
	 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
1397
	 */
1800
	 */
1398
	protected IStatusLineManager getStatusLineManager() {
1801
	public void selectionChanged(SelectionChangedEvent event) {
1399
		IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor();
1802
		ISelection sel = event.getSelection();
1400
		if (contributor instanceof EditorActionBarContributor) {
1803
		if (sel instanceof IStructuredSelection) {
1401
			return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();
1804
			IStructuredSelection selection = (IStructuredSelection) sel;
1805
			Object obj = selection.getFirstElement();
1806
			if (obj instanceof ISourceReference) {
1807
				try {
1808
					ISourceRange range = ((ISourceReference) obj).getSourceRange();
1809
					if (range != null) {
1810
						setSelection(range, !isActivePart());
1811
					}
1812
				} catch (CModelException e) {
1813
                    // Selection change not applied.
1814
				}
1815
			}
1402
		}
1816
		}
1403
		return null;
1404
	}
1817
	}
1405
	
1818
1406
	/**
1819
	/**
1407
	 * Configures the toggle comment action
1820
     * Sets selection for C element. 
1408
	 *
1821
     * @param element Element to select.
1409
	 * @since 4.0.0
1410
	 */
1822
	 */
1411
	private void configureToggleCommentAction() {
1823
    public void setSelection(ICElement element) {
1412
		IAction action= getAction("ToggleComment"); //$NON-NLS-1$
1413
		if (action instanceof ToggleCommentAction) {
1414
			ISourceViewer sourceViewer= getSourceViewer();
1415
			SourceViewerConfiguration configuration= getSourceViewerConfiguration();
1416
			((ToggleCommentAction)action).configure(sourceViewer, configuration);
1417
		}
1418
	}
1419
1824
1420
	private void configureTabConverter() {
1825
		if (element == null || element instanceof ITranslationUnit) {
1421
		if (fTabConverter != null) {
1826
			/*
1422
			IDocumentProvider provider= getDocumentProvider();
1827
			 * If the element is an ITranslationUnit this unit is either the input
1423
			if (provider instanceof CDocumentProvider) {
1828
			 * of this editor or not being displayed. In both cases, nothing should
1424
				CDocumentProvider prov= (CDocumentProvider) provider;
1829
			 * happened.
1425
				fTabConverter.setLineTracker(prov.createLineTracker(getEditorInput()));
1830
			 */
1426
			} else {
1831
			return;
1427
				fTabConverter.setLineTracker(new DefaultLineTracker());
1428
			}
1429
		}
1832
		}
1430
	}
1833
		if (element instanceof ISourceReference) {
1431
1834
			ISourceReference reference = (ISourceReference) element;
1432
	private void startTabConversion() {
1835
			// set hightlight range
1433
		if (fTabConverter == null) {
1836
			setSelection(reference, true);
1434
			CSourceViewer asv = (CSourceViewer) getSourceViewer();
1435
			SourceViewerConfiguration configuration = getSourceViewerConfiguration();
1436
			fTabConverter = new TabConverter();
1437
			configureTabConverter();
1438
			fTabConverter.setNumberOfSpacesPerTab(configuration.getTabWidth(asv));
1439
			asv.addTextConverter(fTabConverter);
1440
		}
1837
		}
1441
	}
1838
	}
1442
1839
1443
	private void stopTabConversion() {
1840
    /**
1444
		if (fTabConverter != null) {
1841
     * Sets selection for source reference.
1445
			CSourceViewer asv = (CSourceViewer) getSourceViewer();
1842
     * @param element Source reference to set.
1446
			asv.removeTextConverter(fTabConverter);
1843
     * @param moveCursor Should cursor be moved.
1447
			fTabConverter = null;
1844
     */
1448
		}
1845
    public void setSelection(ISourceReference element, boolean moveCursor) {
1449
	}
1846
		if (element != null) {
1847
			StyledText  textWidget = null;
1848
			
1849
			ISourceViewer sourceViewer = getSourceViewer();
1850
			if (sourceViewer != null)
1851
				textWidget = sourceViewer.getTextWidget();
1852
			
1853
			if (textWidget == null)
1854
				return;
1450
1855
1451
	private boolean isTabConversionEnabled() {
1856
			try {
1452
		IPreferenceStore store = getPreferenceStore();
1857
				setSelection(element.getSourceRange(), moveCursor);
1453
		return store.getBoolean(SPACES_FOR_TABS);
1858
			} catch (CModelException e) {
1859
                // Selection not applied.
1860
			}
1861
		}
1454
	}
1862
	}
1455
1863
1456
	/*
1864
	/**
1457
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#createNavigationActions()
1865
	 * Sets the current editor selection to the source range. Optionally
1866
	 * sets the current editor position.
1867
	 *
1868
	 * @param element the source range to be shown in the editor, can be null.
1869
	 * @param moveCursor if true the editor is scrolled to show the range.
1458
	 */
1870
	 */
1459
	protected void createNavigationActions() {
1871
	public void setSelection(ISourceRange element, boolean moveCursor) {
1460
		super.createNavigationActions();
1461
1872
1462
		final StyledText textWidget = getSourceViewer().getTextWidget();
1873
		if (element == null) {
1874
			return;
1875
		}
1463
1876
1464
		IAction action = new NavigatePreviousSubWordAction();
1877
		try {
1465
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_PREVIOUS);
1878
			IRegion alternateRegion = null;
1466
		setAction(ITextEditorActionDefinitionIds.WORD_PREVIOUS, action);
1879
			int start = element.getStartPos();
1467
		textWidget.setKeyBinding(SWT.CTRL | SWT.ARROW_LEFT, SWT.NULL);
1880
			int length = element.getLength();
1468
1881
1469
		action = new NavigateNextSubWordAction();
1882
			// Sanity check sometimes the parser may throw wrong numbers.
1470
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_NEXT);
1883
			if (start < 0 || length < 0) {
1471
		setAction(ITextEditorActionDefinitionIds.WORD_NEXT, action);
1884
				start = 0;
1472
		textWidget.setKeyBinding(SWT.CTRL | SWT.ARROW_RIGHT, SWT.NULL);
1885
				length = 0;
1886
			}
1473
1887
1474
		action = new SelectPreviousSubWordAction();
1888
			// 0 length and start and non-zero start line says we know
1475
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS);
1889
			// the line for some reason, but not the offset.
1476
		setAction(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS, action);
1890
			if (length == 0 && start == 0 && element.getStartLine() > 0) {
1477
		textWidget.setKeyBinding(SWT.CTRL | SWT.SHIFT | SWT.ARROW_LEFT, SWT.NULL);
1891
				// We have the information in term of lines, we can work it out.
1892
				// Binary elements return the first executable statement so we have to substract -1
1893
				start = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getStartLine() - 1);
1894
				if (element.getEndLine() > 0) {
1895
					length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine()) - start;
1896
				} else {
1897
					length = start;
1898
				}
1899
				// create an alternate region for the keyword highlight.
1900
				alternateRegion = getDocumentProvider().getDocument(getEditorInput()).getLineInformation(element.getStartLine() - 1);
1901
				if (start == length || length < 0) {
1902
					if (alternateRegion != null) {
1903
						start = alternateRegion.getOffset();
1904
						length = alternateRegion.getLength();
1905
					}
1906
				}
1907
			}
1908
			setHighlightRange(start, length, moveCursor);
1478
1909
1479
		action = new SelectNextSubWordAction();
1910
			if (moveCursor) {
1480
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT);
1911
				start = element.getIdStartPos();
1481
		setAction(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT, action);
1912
				length = element.getIdLength();
1482
		textWidget.setKeyBinding(SWT.CTRL | SWT.SHIFT | SWT.ARROW_RIGHT, SWT.NULL);
1913
				if (start == 0 && length == 0 && alternateRegion != null) {
1483
		
1914
					start = alternateRegion.getOffset();
1484
		action= new DeletePreviousSubWordAction();
1915
					length = alternateRegion.getLength();
1485
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD);
1916
				}
1486
		setAction(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD, action);
1917
				if (start > -1 && getSourceViewer() != null) {
1487
		textWidget.setKeyBinding(SWT.CTRL | SWT.BS, SWT.NULL);
1918
					getSourceViewer().revealRange(start, length);
1488
		markAsStateDependentAction(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD, true);
1919
					getSourceViewer().setSelectedRange(start, length);
1920
				}
1921
				updateStatusField(CTextEditorActionConstants.STATUS_CURSOR_POS);
1922
			}
1923
			return;
1924
		} catch (IllegalArgumentException x) {
1925
            // No information to the user
1926
		} catch (BadLocationException e) {
1927
            // No information to the user
1928
		}
1489
1929
1490
		action= new DeleteNextSubWordAction();
1930
		if (moveCursor)
1491
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD);
1931
			resetHighlightRange();
1492
		setAction(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD, action);
1493
		textWidget.setKeyBinding(SWT.CTRL | SWT.DEL, SWT.NULL);
1494
		markAsStateDependentAction(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD, true);
1495
	}
1932
	}
1496
1933
1497
	interface ITextConverter {
1934
	/**
1498
		void customizeDocumentCommand(IDocument document, DocumentCommand command);
1935
     * Checks is the editor active part. 
1936
     * @return <code>true</code> if editor is the active part of the workbench.
1937
	 */
1938
    private boolean isActivePart() {
1939
		IWorkbenchWindow window = getSite().getWorkbenchWindow();
1940
		IPartService service = window.getPartService();
1941
		return (this == service.getActivePart());
1499
	}
1942
	}
1500
1943
1501
	static class TabConverter implements ITextConverter {
1944
    /**
1502
		private int fTabRatio;
1945
     * @see org.eclipse.ui.IWorkbenchPart#dispose()
1503
		private ILineTracker fLineTracker;
1946
     */
1947
    public void dispose() {
1948
1949
		ISourceViewer sourceViewer = getSourceViewer();
1950
		if (sourceViewer instanceof ITextViewerExtension)
1951
			((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter);
1952
1953
		if (fProjectionModelUpdater != null) {
1954
			fProjectionModelUpdater.uninstall();
1955
			fProjectionModelUpdater = null;
1956
		}
1504
		
1957
		
1505
		public TabConverter() {
1958
		if (fProjectionSupport != null) {
1506
		} 
1959
			fProjectionSupport.dispose();
1960
			fProjectionSupport = null;
1961
		}
1962
1963
		if (fCEditorErrorTickUpdater != null) {
1964
			fCEditorErrorTickUpdater.dispose();
1965
			fCEditorErrorTickUpdater = null;
1966
		}
1507
		
1967
		
1508
		public void setNumberOfSpacesPerTab(int ratio) {
1968
        if (fSelectionUpdateListener != null) {
1509
			fTabRatio= ratio;
1969
			getSelectionProvider().addSelectionChangedListener(fSelectionUpdateListener);
1970
			fSelectionUpdateListener = null;
1971
        }
1972
        
1973
       	if (fStatusLineClearer != null) {
1974
			ISelectionProvider provider = getSelectionProvider();
1975
       		provider.removeSelectionChangedListener(fStatusLineClearer);
1976
			fStatusLineClearer = null;
1977
		}
1978
        
1979
        if (fBracketMatcher != null) {
1980
			fBracketMatcher.dispose();
1981
			fBracketMatcher = null;
1510
		}
1982
		}
1511
		
1983
		
1512
		public void setLineTracker(ILineTracker lineTracker) {
1984
		if (fOutlinePage != null) {
1513
			fLineTracker= lineTracker;
1985
			fOutlinePage.dispose();
1986
			fOutlinePage = null;
1514
		}
1987
		}
1515
		
1988
		
1516
		private int insertTabString(StringBuffer buffer, int offsetInLine) {
1989
		if (fShowInCViewAction != null) {
1517
			
1990
			fShowInCViewAction.dispose();
1518
			if (fTabRatio == 0)
1991
			fShowInCViewAction = null;
1519
				return 0;
1520
				
1521
			int remainder= offsetInLine % fTabRatio;
1522
			remainder= fTabRatio - remainder;
1523
			for (int i= 0; i < remainder; i++)
1524
				buffer.append(' ');
1525
			return remainder;
1526
		}
1992
		}
1527
		
1993
		
1528
		public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
1994
		if (fSelectionSearchGroup != null) {
1529
			String text = command.text;
1995
			fSelectionSearchGroup.dispose();
1530
			if (text == null)
1996
			fSelectionSearchGroup = null;
1531
				return;
1532
				
1533
			int index = text.indexOf('\t');
1534
			if (index > -1) {
1535
				StringBuffer buffer = new StringBuffer();
1536
				
1537
				fLineTracker.set(command.text);
1538
				int lines = fLineTracker.getNumberOfLines();
1539
				
1540
				try {
1541
					for (int i = 0; i < lines; i++) {
1542
						int offset = fLineTracker.getLineOffset(i);
1543
						int endOffset = offset + fLineTracker.getLineLength(i);
1544
						String line = text.substring(offset, endOffset);
1545
						
1546
						int position= 0;
1547
						if (i == 0) {
1548
							IRegion firstLine = document.getLineInformationOfOffset(command.offset);
1549
							position = command.offset - firstLine.getOffset();	
1550
						}
1551
						
1552
						int length = line.length();
1553
						for (int j = 0; j < length; j++) {
1554
							char c = line.charAt(j);
1555
							if (c == '\t') {
1556
								int oldPosition = position;
1557
								position += insertTabString(buffer, position);
1558
								if (command.caretOffset > command.offset + oldPosition) {
1559
									command.caretOffset += position - oldPosition - 1;
1560
								}
1561
							} else {
1562
								buffer.append(c);
1563
								++position;
1564
							}
1565
						}
1566
					}
1567
						
1568
					command.text = buffer.toString();
1569
				} catch (BadLocationException x) {
1570
				}
1571
			}
1572
		}
1997
		}
1573
	}
1574
1998
1575
	/*
1999
		if (fTextSearchGroup != null) {
1576
	 * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, int)
2000
			fTextSearchGroup.dispose();
1577
	 */
2001
			fTextSearchGroup = null;
1578
	protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
2002
		}
1579
		ISourceViewer sourceViewer =
1580
			new CSourceViewer(
1581
				this, parent,
1582
				ruler,
1583
				styles,
1584
				getOverviewRuler(),
1585
				isOverviewRulerVisible());
1586
2003
1587
		CUIHelp.setHelp(this, sourceViewer.getTextWidget(), ICHelpContextIds.CEDITOR_VIEW);
2004
		if (fRefactoringActionGroup != null) {
2005
			fRefactoringActionGroup.dispose();
2006
			fRefactoringActionGroup = null;
2007
		}
1588
2008
1589
		getSourceViewerDecorationSupport(sourceViewer);
2009
		if (fEditorSelectionChangedListener != null)  {
2010
			fEditorSelectionChangedListener.uninstall(getSelectionProvider());
2011
			fEditorSelectionChangedListener = null;
2012
		}
2013
2014
		stopTabConversion();
1590
		
2015
		
1591
		return sourceViewer;
2016
		super.dispose();
1592
	}
2017
	}
1593
2018
1594
	/** Outliner context menu Id */
1595
	protected String fOutlinerContextMenuId;
1596
1597
	/**
2019
	/**
1598
	 * Sets the outliner's context menu ID.
2020
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#canHandleMove(org.eclipse.ui.IEditorInput, org.eclipse.ui.IEditorInput)
1599
	 */
1600
	protected void setOutlinerContextMenuId(String menuId) {
1601
		fOutlinerContextMenuId = menuId;
1602
	}
1603
	
1604
	/* (non-Javadoc)
1605
	 * @see org.eclipse.ui.editors.text.TextEditor#initializeKeyBindingScopes()
1606
	 */
2021
	 */
1607
	protected void initializeKeyBindingScopes() {
2022
	protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
1608
		setKeyBindingScopes(new String [] { "org.eclipse.cdt.ui.cEditorScope" } ); //$NON-NLS-1$
2023
		String oldLanguage = ""; //$NON-NLS-1$
1609
	}
2024
		if (originalElement instanceof IFileEditorInput) {
2025
			IFile file = ((IFileEditorInput) originalElement).getFile();
2026
			if (file != null) {
2027
				IContentType type = CCorePlugin.getContentType(file.getProject(), file.getName());
2028
				if (type != null) {
2029
					oldLanguage = type.getId();
2030
				}
2031
				if (oldLanguage == null) {
2032
					return false;
2033
				}
2034
			}
2035
		}
1610
2036
1611
	/* (non-Javadoc)
2037
		String newLanguage = ""; //$NON-NLS-1$
1612
	 * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
2038
		if (movedElement instanceof IFileEditorInput) {
1613
	 */
2039
			IFile file = ((IFileEditorInput) movedElement).getFile();
1614
	protected boolean affectsTextPresentation(PropertyChangeEvent event) {
2040
			if (file != null) {
1615
		SourceViewerConfiguration configuration = getSourceViewerConfiguration();
2041
				IContentType type = CCorePlugin.getContentType(file.getProject(), file.getName());
1616
		if (configuration instanceof CSourceViewerConfiguration) {
2042
				if (type != null) {
1617
			return ((CSourceViewerConfiguration)configuration).affectsBehavior(event);
2043
					newLanguage = type.getId();
2044
				}
2045
				if (newLanguage == null) {
2046
					return false;
2047
				}
2048
			}
1618
		}
2049
		}
1619
		return false;
2050
		return oldLanguage.equals(newLanguage);
1620
	}
2051
	}
1621
2052
1622
	/**
2053
	/**
1623
	 * Returns the folding action group, or <code>null</code> if there is none.
2054
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions()
1624
	 * 
1625
	 * @return the folding action group, or <code>null</code> if there is none
1626
	 */
2055
	 */
1627
	protected FoldingActionGroup getFoldingActionGroup() {
2056
	protected void createActions() {
1628
		return fFoldingGroup;
2057
		super.createActions();
1629
	}
1630
2058
1631
	/*
2059
		fFoldingGroup = new FoldingActionGroup(this, getSourceViewer());
1632
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#performRevert()
2060
1633
	 */
2061
		// Sticky hover support
1634
	protected void performRevert() {
2062
		ResourceAction resAction = new TextOperationAction(CEditorMessages.getResourceBundle(), "ShowToolTip.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
1635
		ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer();
2063
		ResourceAction resAction2 = new InformationDispatchAction(CEditorMessages.getResourceBundle(), "ShowToolTip.", (TextOperationAction) resAction); //$NON-NLS-1$
1636
		projectionViewer.setRedraw(false);
2064
		resAction2.setActionDefinitionId(ICEditorActionDefinitionIds.SHOW_TOOLTIP);
1637
		try {
2065
		setAction("ShowToolTip", resAction2); //$NON-NLS-1$
1638
			
2066
		PlatformUI.getWorkbench().getHelpSystem().setHelp(resAction2, ICHelpContextIds.SHOW_TOOLTIP_ACTION);
1639
			boolean projectionMode= projectionViewer.isProjectionMode();
2067
		
1640
			if (projectionMode) {
2068
		// Default text editing menu items
1641
				projectionViewer.disableProjection();				
2069
		Action action = new GotoMatchingBracketAction(this);
1642
				if (fProjectionModelUpdater != null)
2070
		action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);				
1643
					fProjectionModelUpdater.uninstall();
2071
		setAction(GotoMatchingBracketAction.GOTO_MATCHING_BRACKET, action);
1644
			}
2072
		
1645
			
2073
		action = new JoinLinesAction(CEditorMessages.getResourceBundle(), "JoinLines.", this); //$NON-NLS-1$
1646
			super.performRevert();
2074
		action.setActionDefinitionId(ICEditorActionDefinitionIds.JOIN_LINES);
1647
			
2075
		setAction("Join Lines", action); //$NON-NLS-1$
1648
			if (projectionMode) {
2076
		
1649
				if (fProjectionModelUpdater != null)
2077
		action = new ToggleCommentAction(CEditorMessages.getResourceBundle(), "ToggleComment.", this); //$NON-NLS-1$
1650
					fProjectionModelUpdater.install(this, projectionViewer);	
2078
		action.setActionDefinitionId(ICEditorActionDefinitionIds.TOGGLE_COMMENT);
1651
				projectionViewer.enableProjection();
2079
		setAction("ToggleComment", action); //$NON-NLS-1$
1652
			}
2080
		markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
1653
			
2081
		configureToggleCommentAction();
1654
		} finally {
2082
		
1655
			projectionViewer.setRedraw(true);
2083
		action = new AddBlockCommentAction(CEditorMessages.getResourceBundle(), "AddBlockComment.", this);  //$NON-NLS-1$
2084
		action.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_BLOCK_COMMENT);		
2085
		setAction("AddBlockComment", action); //$NON-NLS-1$
2086
		markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
2087
		markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$		
2088
		//WorkbenchHelp.setHelp(action, ICHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
2089
2090
		action = new RemoveBlockCommentAction(CEditorMessages.getResourceBundle(), "RemoveBlockComment.", this);  //$NON-NLS-1$
2091
		action.setActionDefinitionId(ICEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);		
2092
		setAction("RemoveBlockComment", action); //$NON-NLS-1$
2093
		markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
2094
		markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$		
2095
		//WorkbenchHelp.setHelp(action, ICHelpContextIds.REMOVE_BLOCK_COMMENT_ACTION);
2096
2097
		action = new IndentAction(CEditorMessages.getResourceBundle(), "Indent.", this, false); //$NON-NLS-1$
2098
		action.setActionDefinitionId(ICEditorActionDefinitionIds.INDENT);
2099
		setAction("Indent", action); //$NON-NLS-1$
2100
		markAsStateDependentAction("Indent", true); //$NON-NLS-1$
2101
		markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
2102
//		PlatformUI.getWorkbench().getHelpSystem().setHelp(action, ICHelpContextIds.INDENT_ACTION);
2103
2104
		action = new IndentAction(CEditorMessages.getResourceBundle(), "Indent.", this, true); //$NON-NLS-1$
2105
		setAction("IndentOnTab", action); //$NON-NLS-1$
2106
		markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
2107
		markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$
2108
		
2109
		if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
2110
			setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
1656
		}
2111
		}
2112
		
2113
		action = new TextOperationAction(CEditorMessages.getResourceBundle(), "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
2114
		action.setActionDefinitionId(ICEditorActionDefinitionIds.FORMAT);
2115
		setAction("Format", action); //$NON-NLS-1$
2116
		markAsStateDependentAction("Format", true); //$NON-NLS-1$
2117
2118
		action = new ContentAssistAction(CEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
2119
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
2120
		setAction("ContentAssistProposal", action); //$NON-NLS-1$
2121
		markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
2122
2123
		action = new TextOperationAction(CEditorMessages.getResourceBundle(), "ContentAssistTip.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
2124
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
2125
		setAction("ContentAssistTip", action); //$NON-NLS-1$
2126
2127
		action = new AddIncludeOnSelectionAction(this);
2128
		action.setActionDefinitionId(ICEditorActionDefinitionIds.ADD_INCLUDE);
2129
		setAction("AddIncludeOnSelection", action); //$NON-NLS-1$
2130
	
2131
		action = new OpenDeclarationsAction(this);
2132
		action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
2133
		setAction("OpenDeclarations", action); //$NON-NLS-1$
2134
2135
        action = new OpenDefinitionAction(this);
2136
        action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DEF);
2137
        setAction("OpenDefinition", action); //$NON-NLS-1$
2138
        
2139
//		action = new OpenTypeHierarchyAction(this);
2140
//		action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_TYPE_HIERARCHY);
2141
//		setAction("OpenTypeHierarchy", action); //$NON-NLS-1$
2142
2143
		fShowInCViewAction = new ShowInCViewAction(this);
2144
		action = fShowInCViewAction;
2145
		action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CVIEW);
2146
		setAction("ShowInCView", action); //$NON-NLS-1$
2147
        
2148
        action = new TextOperationAction(CEditorMessages.getResourceBundle(), "OpenOutline.", this, CSourceViewer.SHOW_OUTLINE, true); //$NON-NLS-1$
2149
        action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_OUTLINE);
2150
        setAction("OpenOutline", action); //$NON-NLS-1$*/
2151
        
2152
        action = new GoToNextPreviousMemberAction(CEditorMessages.getResourceBundle(), "GotoNextMember.", this, true); //$NON-NLS-1$
2153
        action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_NEXT_MEMBER);
2154
        setAction("GotoNextMember", action); //$NON-NLS-1$*/
2155
2156
        action = new GoToNextPreviousMemberAction(CEditorMessages.getResourceBundle(), "GotoPrevMember.", this, false); //$NON-NLS-1$
2157
        action.setActionDefinitionId(ICEditorActionDefinitionIds.GOTO_PREVIOUS_MEMBER);
2158
        setAction("GotoPrevMember", action); //$NON-NLS-1$*/
2159
2160
        //Assorted action groupings
2161
		fSelectionSearchGroup = new SelectionSearchGroup(this);
2162
		fTextSearchGroup = new TextSearchGroup(this);
2163
		fRefactoringActionGroup= new CRefactoringActionGroup(this);
1657
	}
2164
	}
1658
2165
1659
    /**
2166
	/**
1660
     * Sets the given message as error message to this editor's status line.
2167
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
1661
     * 
2168
	 */
1662
     * @param msg message to be set
2169
	public void editorContextMenuAboutToShow(IMenuManager menu) {
1663
     */
2170
		super.editorContextMenuAboutToShow(menu);
1664
    protected void setStatusLineErrorMessage(String msg) {
1665
    	IEditorStatusLine statusLine= (IEditorStatusLine) getAdapter(IEditorStatusLine.class);
1666
    	if (statusLine != null)
1667
    		statusLine.setMessage(true, msg, null);	
1668
2171
1669
    }  
2172
		addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_REORGANIZE);
2173
		addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_GENERATE);
2174
		addGroup(menu, ITextEditorActionConstants.GROUP_EDIT, IContextMenuConstants.GROUP_NEW);
2175
2176
		// Code formatting menu items -- only show in C perspective
2177
		addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "ToggleComment"); //$NON-NLS-1$
2178
		addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "AddBlockComment"); //$NON-NLS-1$
2179
		addAction(menu, ITextEditorActionConstants.GROUP_EDIT, "RemoveBlockComment"); //$NON-NLS-1$
2180
2181
		addAction(menu, ITextEditorActionConstants.GROUP_FIND, "OpenDeclarations"); //$NON-NLS-1$
2182
        addAction(menu, ITextEditorActionConstants.GROUP_FIND, "OpenDefinition"); //$NON-NLS-1$
2183
2184
		addAction(menu, ITextEditorActionConstants.GROUP_FIND, "OpenTypeHierarchy"); //$NON-NLS-1$
2185
        addAction(menu, ITextEditorActionConstants.GROUP_FIND, "GotoNextMember"); //$NON-NLS-1$
2186
        addAction(menu, ITextEditorActionConstants.GROUP_FIND, "GotoPrevMember"); //$NON-NLS-1$
2187
2188
		addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ContentAssistProposal"); //$NON-NLS-1$
2189
		addAction(menu, IContextMenuConstants.GROUP_GENERATE, "AddIncludeOnSelection"); //$NON-NLS-1$
2190
		addAction(menu, IContextMenuConstants.GROUP_GENERATE, "Format"); //$NON-NLS-1$
2191
		
2192
		addAction(menu, IContextMenuConstants.GROUP_GENERATE, "ShowInCView"); //$NON-NLS-1$
2193
2194
		fSelectionSearchGroup.fillContextMenu(menu);
2195
		fTextSearchGroup.fillContextMenu(menu);
2196
		fRefactoringActionGroup.fillContextMenu(menu);
2197
	}
2198
2199
	/**
2200
     * Sets an input for the outline page.
2201
	 * @param page Page to set the input.
2202
	 * @param input Input to set.
2203
	 */
2204
	public static void setOutlinePageInput(CContentOutlinePage page, IEditorInput input) {
2205
		if (page != null) {
2206
			IWorkingCopyManager manager = CUIPlugin.getDefault().getWorkingCopyManager();
2207
			page.setInput(manager.getWorkingCopy(input));
2208
		}
2209
	}
1670
2210
1671
	/**
2211
	/**
1672
	 * Sets the given message as message to this editor's status line.
2212
     * Determines is folding enabled.
1673
	 * 
2213
	 * @return <code>true</code> if folding is enabled, <code>false</code> otherwise.
1674
	 * @param msg message to be set
1675
	 * @since 3.0
1676
	 */
2214
	 */
1677
	protected void setStatusLineMessage(String msg) {
2215
	boolean isFoldingEnabled() {
1678
		IEditorStatusLine statusLine= (IEditorStatusLine) getAdapter(IEditorStatusLine.class);
2216
		return CUIPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
1679
		if (statusLine != null)
1680
			statusLine.setMessage(false, msg, null);	
1681
	}
2217
	}
1682
2218
2219
1683
	/**
2220
	/**
1684
	 * Returns the signed current selection.
2221
	 * The <code>AbstractTextEditor</code> implementation of this 
1685
	 * The length will be negative if the resulting selection
2222
	 * <code>IWorkbenchPart</code> method creates the vertical ruler and
1686
	 * is right-to-left (RtoL).
2223
	 * source viewer. Subclasses may extend.
1687
	 * <p>
1688
	 * The selection offset is model based.
1689
	 * </p>
1690
	 * 
2224
	 * 
1691
	 * @param sourceViewer the source viewer
2225
	 * We attach our own mouseDown listener on the menu bar, 
1692
	 * @return a region denoting the current signed selection, for a resulting RtoL selections length is < 0 
2226
	 * and our own listener for cursor/key/selection events to update cursor position in
2227
	 * status bar.
2228
2229
     * @param parent Parent composite of the control.
1693
	 */
2230
	 */
1694
	protected IRegion getSignedSelection(ISourceViewer sourceViewer) {
2231
	public void createPartControl(Composite parent) {
1695
		StyledText text= sourceViewer.getTextWidget();
2232
		super.createPartControl(parent);
1696
		Point selection= text.getSelectionRange();
2233
	
2234
		// Sticky hover support
2235
		IInformationControlCreator informationControlCreator = new IInformationControlCreator() {
2236
			public IInformationControl createInformationControl(Shell shell) {
2237
				boolean cutDown = false;
2238
				int style = cutDown ? SWT.NONE : (SWT.V_SCROLL | SWT.H_SCROLL);
2239
				return new DefaultInformationControl(shell, SWT.RESIZE
2240
						| SWT.TOOL, style, new HTMLTextPresenter(cutDown));
2241
			}
2242
		};
2243
2244
		fInformationPresenter = new InformationPresenter(
2245
				informationControlCreator);
2246
		fInformationPresenter.setSizeConstraints(60, 10, true, true);
2247
		fInformationPresenter.install(getSourceViewer());
2248
		fInformationPresenter
2249
				.setDocumentPartitioning(ICPartitions.C_PARTITIONING);
2250
				
1697
		
2251
		
1698
		if (text.getCaretOffset() == selection.x) {
2252
		ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer();
1699
			selection.x= selection.x + selection.y;
1700
			selection.y= -selection.y;
1701
		}
1702
		
2253
		
1703
		selection.x= widgetOffset2ModelOffset(sourceViewer, selection.x);
2254
		fProjectionSupport = new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
2255
		fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
2256
		fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
2257
		fProjectionSupport.install();
1704
		
2258
		
1705
		return new Region(selection.x, selection.y);
2259
		fProjectionModelUpdater = CUIPlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
1706
	}
2260
		if (fProjectionModelUpdater != null)
1707
	
2261
			fProjectionModelUpdater.install(this, projectionViewer);
1708
	private static boolean isBracket(char character) {
1709
		for (int i= 0; i != BRACKETS.length; ++i)
1710
			if (character == BRACKETS[i])
1711
				return true;
1712
		return false;
1713
	}
1714
2262
1715
	private static boolean isSurroundedByBrackets(IDocument document, int offset) {
2263
		if (isFoldingEnabled())
1716
		if (offset == 0 || offset == document.getLength())
2264
			projectionViewer.doOperation(ProjectionViewer.TOGGLE);
1717
			return false;
2265
		
2266
		PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICHelpContextIds.CEDITOR_VIEW);
1718
2267
1719
		try {
2268
		fEditorSelectionChangedListener = new EditorSelectionChangedListener();
1720
			return
2269
		fEditorSelectionChangedListener.install(getSelectionProvider());
1721
				isBracket(document.getChar(offset - 1)) &&
2270
		
1722
				isBracket(document.getChar(offset));
2271
		if (isTabConversionEnabled())
2272
			startTabConversion();
2273
2274
		if (isSemanticHighlightingEnabled())
2275
			installSemanticHighlighting();
1723
			
2276
			
1724
		} catch (BadLocationException e) {
2277
		IPreferenceStore preferenceStore = getPreferenceStore();
1725
			return false;	
2278
		boolean closeBrackets = preferenceStore.getBoolean(CLOSE_BRACKETS);
1726
		}
2279
		boolean closeAngularBrackets = preferenceStore.getBoolean(CLOSE_ANGULAR_BRACKETS);
2280
		boolean closeStrings = preferenceStore.getBoolean(CLOSE_STRINGS);
2281
2282
		fBracketInserter.setCloseBracketsEnabled(closeBrackets);
2283
		fBracketInserter.setCloseStringsEnabled(closeStrings);
2284
		fBracketInserter.setCloseAngularBracketsEnabled(closeAngularBrackets);
2285
2286
		ISourceViewer sourceViewer = getSourceViewer();
2287
		if (sourceViewer instanceof ITextViewerExtension)
2288
			((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
1727
	}
2289
	}
1728
		
1729
2290
1730
	/*
2291
	/*
1731
	 * @see org.eclipse.cdt.internal.ui.editor.IReconcilingParticipant#reconciled()
2292
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#initializeDragAndDrop(org.eclipse.jface.text.source.ISourceViewer)
1732
	 */
2293
	 */
1733
	public void reconciled(boolean somethingHasChanged) {
2294
	protected void initializeDragAndDrop(ISourceViewer viewer) {
1734
		if (getSourceViewer() == null) {
2295
		Control control = viewer.getTextWidget();
1735
			return;
2296
		int operations = DND.DROP_MOVE | DND.DROP_COPY;
1736
		}
1737
		// this method must be called in a background thread
1738
		assert getSourceViewer().getTextWidget().getDisplay().getThread() != Thread.currentThread();
1739
		
1740
		if (fReconcilingListeners.size() > 0) {
1741
			// create AST and notify ICReconcilingListeners
1742
			ICElement cElement= getInputCElement();
1743
			if (cElement == null) {
1744
				return;
1745
			}
1746
			
1747
			aboutToBeReconciled();
1748
2297
1749
			// track changes to the document while parsing
2298
		DropTarget dropTarget = new DropTarget(control, operations);
1750
			IDocument doc= getDocumentProvider().getDocument(getEditorInput());
2299
		ITextEditorDropTargetListener dropTargetListener = new TextEditorDropAdapter(viewer, this);
1751
			SimplePositionTracker positionTracker= new SimplePositionTracker();
2300
		dropTarget.setTransfer(dropTargetListener.getTransfers());
1752
			positionTracker.startTracking(doc);
2301
		dropTarget.addDropListener(dropTargetListener);
1753
			
2302
1754
			try {
2303
		DragSource dragSource = new DragSource(control, operations);
1755
				IASTTranslationUnit ast= CUIPlugin.getDefault().getASTProvider().createAST(cElement, null);
2304
		Transfer[] dragTypes = new Transfer[] { TextTransfer.getInstance() };
1756
				reconciled(ast, positionTracker, null);
2305
		dragSource.setTransfer(dragTypes);
1757
			} finally {
2306
		DragSourceListener dragSourceListener = new TextViewerDragAdapter(viewer, this);
1758
				positionTracker.stopTracking();
2307
		dragSource.addDragListener(dragSourceListener);
1759
			}
1760
		}
1761
	}
2308
	}
1762
	
2309
1763
	public CSourceViewer getCSourceViewer()  {
2310
	/*
1764
		ISourceViewer viewer = getSourceViewer();
2311
	 * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#getSourceViewerDecorationSupport(org.eclipse.jface.text.source.ISourceViewer)
1765
		CSourceViewer cViewer = null ;
2312
	 */
1766
		if (viewer instanceof CSourceViewer) {
2313
	protected SourceViewerDecorationSupport getSourceViewerDecorationSupport(
1767
			cViewer = (CSourceViewer) viewer;
2314
			ISourceViewer viewer) {
2315
		if (fSourceViewerDecorationSupport == null) {
2316
			fSourceViewerDecorationSupport= new CSourceViewerDecorationSupport(this, viewer, getOverviewRuler(), getAnnotationAccess(), getSharedColors());
2317
			configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport);
1768
		}
2318
		}
1769
		return cViewer ;
2319
		return fSourceViewerDecorationSupport;
1770
	}
2320
	}
1771
	
2321
	
1772
	/*
2322
	/*
1773
	 * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#collectContextMenuPreferencePages()
2323
	 * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#configureSourceViewerDecorationSupport(org.eclipse.ui.texteditor.SourceViewerDecorationSupport)
1774
	 */
2324
	 */
1775
	protected String[] collectContextMenuPreferencePages() {
2325
	protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
1776
		// Add C/C++ Editor relevant pages
2326
		super.configureSourceViewerDecorationSupport(support);
1777
		String[] parentPrefPageIds = super.collectContextMenuPreferencePages();
2327
		//Enhance the stock source viewer decorator with a bracket matcher
1778
		String[] prefPageIds = new String[parentPrefPageIds.length + 4];
2328
		support.setCharacterPairMatcher(fBracketMatcher);
1779
		int nIds = 0;
2329
		support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR);
1780
		prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CEditorPreferencePage"; //$NON-NLS-1$
2330
		((CSourceViewerDecorationSupport)support).setInactiveCodePainterPreferenceKeys(INACTIVE_CODE_ENABLE, INACTIVE_CODE_COLOR);
1781
		prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeAssistPreferencePage"; //$NON-NLS-1$
1782
		prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$
1783
		prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"; //$NON-NLS-1$
1784
		System.arraycopy(parentPrefPageIds, 0, prefPageIds, nIds, parentPrefPageIds.length);
1785
		return prefPageIds;
1786
	}
2331
	}
1787
2332
	
1788
	/**
2333
	/**
1789
	 * Text navigation action to navigate to the next sub-word.
2334
	 * Jumps to the matching bracket.
1790
	 *
1791
	 * @since 4.0
1792
	 */
2335
	 */
1793
	protected abstract class NextSubWordAction extends TextNavigationAction {
2336
	public void gotoMatchingBracket() {
1794
2337
		
1795
		protected CWordIterator fIterator = new CWordIterator();
2338
		ISourceViewer sourceViewer = getSourceViewer();
2339
		IDocument document = sourceViewer.getDocument();
2340
		if (document == null)
2341
			return;
2342
		
2343
		IRegion selection = getSignedSelection(sourceViewer);
1796
2344
1797
		/**
2345
		int selectionLength = Math.abs(selection.getLength());
1798
		 * Creates a new next sub-word action.
2346
		if (selectionLength > 1) {
1799
		 *
2347
			setStatusLineErrorMessage(CEditorMessages.getString("GotoMatchingBracket.error.invalidSelection"));	//$NON-NLS-1$		
1800
		 * @param code Action code for the default operation. Must be an action code from @see org.eclipse.swt.custom.ST.
2348
			sourceViewer.getTextWidget().getDisplay().beep();
1801
		 */
2349
			return;
1802
		protected NextSubWordAction(int code) {
1803
			super(getSourceViewer().getTextWidget(), code);
1804
		}
2350
		}
1805
2351
1806
		/*
2352
		// #26314
1807
		 * @see org.eclipse.jface.action.IAction#run()
2353
		int sourceCaretOffset = selection.getOffset() + selection.getLength();
1808
		 */
2354
		if (isSurroundedByBrackets(document, sourceCaretOffset))
1809
		public void run() {
2355
			sourceCaretOffset -= selection.getLength();
1810
			// Check whether sub word navigation is enabled.
1811
			final IPreferenceStore store = getPreferenceStore();
1812
			if (!store.getBoolean(SUB_WORD_NAVIGATION)) {
1813
				super.run();
1814
				return;
1815
			}
1816
1817
			final ISourceViewer viewer = getSourceViewer();
1818
			final IDocument document = viewer.getDocument();
1819
			fIterator.setText((CharacterIterator) new DocumentCharacterIterator(document));
1820
			int position = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
1821
			if (position == -1)
1822
				return;
1823
1824
			int next = findNextPosition(position);
1825
			if (next != BreakIterator.DONE) {
1826
				setCaretPosition(next);
1827
				getTextWidget().showSelection();
1828
				fireSelectionChanged();
1829
			}
1830
2356
2357
		IRegion region = fBracketMatcher.match(document, sourceCaretOffset);
2358
		if (region == null) {
2359
			setStatusLineErrorMessage(CEditorMessages.getString("GotoMatchingBracket.error.noMatchingBracket"));	//$NON-NLS-1$		
2360
			sourceViewer.getTextWidget().getDisplay().beep();
2361
			return;		
2362
		}
2363
		
2364
		int offset = region.getOffset();
2365
		int length = region.getLength();
2366
		
2367
		if (length < 1)
2368
			return;
2369
			
2370
		int anchor = fBracketMatcher.getAnchor();
2371
		// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
2372
		int targetOffset = (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1: offset + length;
2373
		
2374
		boolean visible = false;
2375
		if (sourceViewer instanceof ITextViewerExtension5) {
2376
			ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
2377
			visible = (extension.modelOffset2WidgetOffset(targetOffset) > -1);
2378
		} else {
2379
			IRegion visibleRegion = sourceViewer.getVisibleRegion();
2380
			// http://dev.eclipse.org/bugs/show_bug.cgi?id=34195
2381
			visible = (targetOffset >= visibleRegion.getOffset() && targetOffset <= visibleRegion.getOffset() + visibleRegion.getLength());
2382
		}
2383
		
2384
		if (!visible) {
2385
			setStatusLineErrorMessage(CEditorMessages.getString("GotoMatchingBracket.error.bracketOutsideSelectedElement"));	//$NON-NLS-1$		
2386
			sourceViewer.getTextWidget().getDisplay().beep();
2387
			return;
1831
		}
2388
		}
2389
		
2390
		if (selection.getLength() < 0)
2391
			targetOffset -= selection.getLength();
2392
			
2393
		sourceViewer.setSelectedRange(targetOffset, selection.getLength());
2394
		sourceViewer.revealRange(targetOffset, selection.getLength());
2395
	}
1832
2396
1833
		/**
2397
	protected void updateStatusLine() {
1834
		 * Finds the next position after the given position.
2398
		ITextSelection selection = (ITextSelection) getSelectionProvider().getSelection();
1835
		 *
2399
		Annotation annotation = getAnnotation(selection.getOffset(), selection.getLength());
1836
		 * @param position the current position
2400
		setStatusLineErrorMessage(null);
1837
		 * @return the next position
2401
		setStatusLineMessage(null);
1838
		 */
2402
		if (annotation != null) {
1839
		protected int findNextPosition(int position) {
2403
			updateMarkerViews(annotation);
1840
			ISourceViewer viewer = getSourceViewer();
2404
			if (annotation instanceof ICAnnotation && ((ICAnnotation) annotation).isProblem())
1841
			int widget = -1;
2405
				setStatusLineMessage(annotation.getText());
1842
			while (position != BreakIterator.DONE && widget == -1) { // TODO: optimize
1843
				position = fIterator.following(position);
1844
				if (position != BreakIterator.DONE)
1845
					widget = modelOffset2WidgetOffset(viewer, position);
1846
			}
1847
			return position;
1848
		}
2406
		}
1849
1850
		/**
1851
		 * Sets the caret position to the sub-word boundary given with <code>position</code>.
1852
		 *
1853
		 * @param position Position where the action should move the caret
1854
		 */
1855
		protected abstract void setCaretPosition(int position);
1856
	}
2407
	}
1857
2408
1858
	/**
2409
	/**
1859
	 * Text navigation action to navigate to the next sub-word.
2410
	 * Returns the annotation overlapping with the given range or <code>null</code>.
1860
	 *
2411
	 * 
1861
	 * @since 4.0
2412
	 * @param offset the region offset
2413
	 * @param length the region length
2414
	 * @return the found annotation or <code>null</code>
2415
	 * @since 3.0
1862
	 */
2416
	 */
1863
	protected class NavigateNextSubWordAction extends NextSubWordAction {
2417
	private Annotation getAnnotation(int offset, int length) {
1864
2418
		IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
1865
		/**
2419
		Iterator e = new CAnnotationIterator(model, true, true);
1866
		 * Creates a new navigate next sub-word action.
2420
		while (e.hasNext()) {
1867
		 */
2421
			Annotation a = (Annotation) e.next();
1868
		public NavigateNextSubWordAction() {
2422
			if (!isNavigationTarget(a))
1869
			super(ST.WORD_NEXT);
2423
				continue;
2424
				
2425
			Position p = model.getPosition(a);
2426
			if (p != null && p.overlapsWith(offset, length))
2427
				return a;
1870
		}
2428
		}
2429
		
2430
		return null;
2431
	}
2432
	/* (non-Javadoc)
2433
	 * @see org.eclipse.ui.part.IShowInSource#getShowInContext()
2434
	 *
2435
	 * This is required by the IShowInSource interface for the "ShowIn"
2436
 	 * navigation menu generalized in Eclipse.
2437
	 */
2438
	public ShowInContext getShowInContext() {
2439
		return new ShowInContext( getEditorInput(), null );
2440
	}
1871
2441
1872
		/*
2442
	/*
1873
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#setCaretPosition(int)
2443
	 * Get the dektop's StatusLineManager
1874
		 */
2444
	 */
1875
		protected void setCaretPosition(final int position) {
2445
	protected IStatusLineManager getStatusLineManager() {
1876
			getTextWidget().setCaretOffset(modelOffset2WidgetOffset(getSourceViewer(), position));
2446
		IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor();
2447
		if (contributor instanceof EditorActionBarContributor) {
2448
			return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();
1877
		}
2449
		}
2450
		return null;
1878
	}
2451
	}
1879
2452
	
1880
	/**
2453
	/**
1881
	 * Text operation action to delete the next sub-word.
2454
	 * Configures the toggle comment action
1882
	 *
2455
	 *
1883
	 * @since 4.0
2456
	 * @since 4.0.0
1884
	 */
2457
	 */
1885
	protected class DeleteNextSubWordAction extends NextSubWordAction implements IUpdate {
2458
	private void configureToggleCommentAction() {
1886
2459
		IAction action = getAction("ToggleComment"); //$NON-NLS-1$
1887
		/**
2460
		if (action instanceof ToggleCommentAction) {
1888
		 * Creates a new delete next sub-word action.
2461
			ISourceViewer sourceViewer = getSourceViewer();
1889
		 */
2462
			SourceViewerConfiguration configuration = getSourceViewerConfiguration();
1890
		public DeleteNextSubWordAction() {
2463
			((ToggleCommentAction)action).configure(sourceViewer, configuration);
1891
			super(ST.DELETE_WORD_NEXT);
1892
		}
2464
		}
2465
	}
1893
2466
1894
		/*
2467
	private void configureTabConverter() {
1895
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#setCaretPosition(int)
2468
		if (fTabConverter != null) {
1896
		 */
2469
			IDocumentProvider provider = getDocumentProvider();
1897
		protected void setCaretPosition(final int position) {
2470
			if (provider instanceof CDocumentProvider) {
1898
			if (!validateEditorInputState())
2471
				CDocumentProvider prov = (CDocumentProvider) provider;
1899
				return;
2472
				fTabConverter.setLineTracker(prov.createLineTracker(getEditorInput()));
1900
1901
			final ISourceViewer viewer = getSourceViewer();
1902
			final int caret, length;
1903
			Point selection = viewer.getSelectedRange();
1904
			if (selection.y != 0) {
1905
				caret = selection.x;
1906
				length = selection.y;
1907
			} else {
2473
			} else {
1908
				caret = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
2474
				fTabConverter.setLineTracker(new DefaultLineTracker());
1909
				length = position - caret;
1910
			}
1911
1912
			try {
1913
				viewer.getDocument().replace(caret, length, ""); //$NON-NLS-1$
1914
			} catch (BadLocationException exception) {
1915
				// Should not happen
1916
			}
2475
			}
1917
		}
2476
		}
2477
	}
1918
2478
1919
		/*
2479
	private int getTabSize() {
1920
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#findNextPosition(int)
2480
		ICElement element = getInputCElement();
1921
		 */
2481
		ICProject project = element == null ? null : element.getCProject();
1922
		protected int findNextPosition(int position) {
2482
		return CodeFormatterUtil.getTabWidth(project);
1923
			return fIterator.following(position);
2483
	}
2484
2485
	private void startTabConversion() {
2486
		if (fTabConverter == null) {
2487
			fTabConverter= new TabConverter();
2488
			configureTabConverter();
2489
			fTabConverter.setNumberOfSpacesPerTab(getTabSize());
2490
			AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer();
2491
			asv.addTextConverter(fTabConverter);
2492
			asv.updateIndentationPrefixes();
1924
		}
2493
		}
2494
	}
1925
2495
1926
		/*
2496
	private void stopTabConversion() {
1927
		 * @see org.eclipse.ui.texteditor.IUpdate#update()
2497
		if (fTabConverter != null) {
1928
		 */
2498
			AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer();
1929
		public void update() {
2499
			asv.removeTextConverter(fTabConverter);
1930
			setEnabled(isEditorInputModifiable());
2500
			asv.updateIndentationPrefixes();
2501
			fTabConverter= null;
1931
		}
2502
		}
1932
	}
2503
	}
1933
2504
1934
	/**
2505
	private boolean isTabConversionEnabled() {
1935
	 * Text operation action to select the next sub-word.
2506
		ICElement element= getInputCElement();
1936
	 *
2507
		ICProject project= element == null ? null : element.getCProject();
1937
	 * @since 4.0
2508
		String option;
2509
		if (project == null)
2510
			option= CCorePlugin.getOption(SPACES_FOR_TABS);
2511
		else
2512
			option= project.getOption(SPACES_FOR_TABS, true);
2513
		return CCorePlugin.SPACE.equals(option);
2514
	}
2515
2516
	/*
2517
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#createNavigationActions()
1938
	 */
2518
	 */
1939
	protected class SelectNextSubWordAction extends NextSubWordAction {
2519
	protected void createNavigationActions() {
2520
		super.createNavigationActions();
1940
2521
1941
		/**
2522
		final StyledText textWidget = getSourceViewer().getTextWidget();
1942
		 * Creates a new select next sub-word action.
1943
		 */
1944
		public SelectNextSubWordAction() {
1945
			super(ST.SELECT_WORD_NEXT);
1946
		}
1947
2523
1948
		/*
2524
		IAction action = new NavigatePreviousSubWordAction();
1949
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#setCaretPosition(int)
2525
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_PREVIOUS);
1950
		 */
2526
		setAction(ITextEditorActionDefinitionIds.WORD_PREVIOUS, action);
1951
		protected void setCaretPosition(final int position) {
2527
		textWidget.setKeyBinding(SWT.CTRL | SWT.ARROW_LEFT, SWT.NULL);
1952
			final ISourceViewer viewer = getSourceViewer();
1953
2528
1954
			final StyledText text = viewer.getTextWidget();
2529
		action = new NavigateNextSubWordAction();
1955
			if (text != null && !text.isDisposed()) {
2530
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.WORD_NEXT);
2531
		setAction(ITextEditorActionDefinitionIds.WORD_NEXT, action);
2532
		textWidget.setKeyBinding(SWT.CTRL | SWT.ARROW_RIGHT, SWT.NULL);
1956
2533
1957
				final Point selection = text.getSelection();
2534
		action = new SelectPreviousSubWordAction();
1958
				final int caret = text.getCaretOffset();
2535
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS);
1959
				final int offset = modelOffset2WidgetOffset(viewer, position);
2536
		setAction(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS, action);
2537
		textWidget.setKeyBinding(SWT.CTRL | SWT.SHIFT | SWT.ARROW_LEFT, SWT.NULL);
1960
2538
1961
				if (caret == selection.x)
2539
		action = new SelectNextSubWordAction();
1962
					text.setSelectionRange(selection.y, offset - selection.y);
2540
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT);
1963
				else
2541
		setAction(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT, action);
1964
					text.setSelectionRange(selection.x, offset - selection.x);
2542
		textWidget.setKeyBinding(SWT.CTRL | SWT.SHIFT | SWT.ARROW_RIGHT, SWT.NULL);
2543
		
2544
		action = new DeletePreviousSubWordAction();
2545
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD);
2546
		setAction(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD, action);
2547
		textWidget.setKeyBinding(SWT.CTRL | SWT.BS, SWT.NULL);
2548
		markAsStateDependentAction(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD, true);
2549
2550
		action = new DeleteNextSubWordAction();
2551
		action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD);
2552
		setAction(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD, action);
2553
		textWidget.setKeyBinding(SWT.CTRL | SWT.DEL, SWT.NULL);
2554
		markAsStateDependentAction(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD, true);
2555
	}
2556
2557
	public final ISourceViewer getViewer() {
2558
		return getSourceViewer();
2559
	}
2560
2561
	/*
2562
	 * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, int)
2563
	 */
2564
	protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
2565
		ISourceViewer sourceViewer =
2566
				new AdaptedSourceViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
2567
2568
		CUIHelp.setHelp(this, sourceViewer.getTextWidget(), ICHelpContextIds.CEDITOR_VIEW);
2569
2570
		getSourceViewerDecorationSupport(sourceViewer);
2571
		
2572
		return sourceViewer;
2573
	}
2574
2575
	/** Outliner context menu Id */
2576
	protected String fOutlinerContextMenuId;
2577
2578
	/**
2579
	 * Sets the outliner's context menu ID.
2580
	 */
2581
	protected void setOutlinerContextMenuId(String menuId) {
2582
		fOutlinerContextMenuId = menuId;
2583
	}
2584
	
2585
	/* (non-Javadoc)
2586
	 * @see org.eclipse.ui.editors.text.TextEditor#initializeKeyBindingScopes()
2587
	 */
2588
	protected void initializeKeyBindingScopes() {
2589
		setKeyBindingScopes(new String [] { "org.eclipse.cdt.ui.cEditorScope" } ); //$NON-NLS-1$
2590
	}
2591
2592
	/* (non-Javadoc)
2593
	 * @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
2594
	 */
2595
	protected boolean affectsTextPresentation(PropertyChangeEvent event) {
2596
		SourceViewerConfiguration configuration = getSourceViewerConfiguration();
2597
		if (configuration instanceof CSourceViewerConfiguration) {
2598
			return ((CSourceViewerConfiguration)configuration).affectsBehavior(event);
2599
		}
2600
		return false;
2601
	}
2602
2603
	/**
2604
	 * Returns the folding action group, or <code>null</code> if there is none.
2605
	 * 
2606
	 * @return the folding action group, or <code>null</code> if there is none
2607
	 */
2608
	protected FoldingActionGroup getFoldingActionGroup() {
2609
		return fFoldingGroup;
2610
	}
2611
2612
	/*
2613
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#performRevert()
2614
	 */
2615
	protected void performRevert() {
2616
		ProjectionViewer projectionViewer = (ProjectionViewer) getSourceViewer();
2617
		projectionViewer.setRedraw(false);
2618
		try {
2619
			
2620
			boolean projectionMode = projectionViewer.isProjectionMode();
2621
			if (projectionMode) {
2622
				projectionViewer.disableProjection();				
2623
				if (fProjectionModelUpdater != null)
2624
					fProjectionModelUpdater.uninstall();
2625
			}
2626
			
2627
			super.performRevert();
2628
			
2629
			if (projectionMode) {
2630
				if (fProjectionModelUpdater != null)
2631
					fProjectionModelUpdater.install(this, projectionViewer);	
2632
				projectionViewer.enableProjection();
1965
			}
2633
			}
2634
			
2635
		} finally {
2636
			projectionViewer.setRedraw(true);
1966
		}
2637
		}
1967
	}
2638
	}
1968
2639
2640
    /**
2641
     * Sets the given message as error message to this editor's status line.
2642
     * 
2643
     * @param msg message to be set
2644
     */
2645
    protected void setStatusLineErrorMessage(String msg) {
2646
    	IEditorStatusLine statusLine = (IEditorStatusLine) getAdapter(IEditorStatusLine.class);
2647
    	if (statusLine != null)
2648
    		statusLine.setMessage(true, msg, null);	
2649
    }  
2650
1969
	/**
2651
	/**
1970
	 * Text navigation action to navigate to the previous sub-word.
2652
	 * Sets the given message as message to this editor's status line.
1971
	 *
2653
	 * 
1972
	 * @since 4.0
2654
	 * @param msg message to be set
2655
	 * @since 3.0
1973
	 */
2656
	 */
1974
	protected abstract class PreviousSubWordAction extends TextNavigationAction {
2657
	protected void setStatusLineMessage(String msg) {
2658
		IEditorStatusLine statusLine = (IEditorStatusLine) getAdapter(IEditorStatusLine.class);
2659
		if (statusLine != null)
2660
			statusLine.setMessage(false, msg, null);	
2661
	}
1975
2662
1976
		protected CWordIterator fIterator = new CWordIterator();
2663
	/**
2664
	 * Returns the signed current selection.
2665
	 * The length will be negative if the resulting selection
2666
	 * is right-to-left (RtoL).
2667
	 * <p>
2668
	 * The selection offset is model based.
2669
	 * </p>
2670
	 * 
2671
	 * @param sourceViewer the source viewer
2672
	 * @return a region denoting the current signed selection, for a resulting RtoL selections length is < 0 
2673
	 */
2674
	protected IRegion getSignedSelection(ISourceViewer sourceViewer) {
2675
		StyledText text = sourceViewer.getTextWidget();
2676
		Point selection = text.getSelectionRange();
2677
		
2678
		if (text.getCaretOffset() == selection.x) {
2679
			selection.x = selection.x + selection.y;
2680
			selection.y = -selection.y;
2681
		}
2682
		
2683
		selection.x = widgetOffset2ModelOffset(sourceViewer, selection.x);
2684
		
2685
		return new Region(selection.x, selection.y);
2686
	}
2687
	
2688
	private static boolean isBracket(char character) {
2689
		for (int i = 0; i != BRACKETS.length; ++i) {
2690
			if (character == BRACKETS[i])
2691
				return true;
2692
		}
2693
		return false;
2694
	}
1977
2695
1978
		/**
2696
	private static boolean isSurroundedByBrackets(IDocument document, int offset) {
1979
		 * Creates a new previous sub-word action.
2697
		if (offset == 0 || offset == document.getLength())
1980
		 *
2698
			return false;
1981
		 * @param code Action code for the default operation. Must be an action code from @see org.eclipse.swt.custom.ST.
2699
1982
		 */
2700
		try {
1983
		protected PreviousSubWordAction(final int code) {
2701
			return isBracket(document.getChar(offset - 1)) &&
1984
			super(getSourceViewer().getTextWidget(), code);
2702
					isBracket(document.getChar(offset));
2703
		} catch (BadLocationException e) {
2704
			return false;	
2705
		}
2706
	}
2707
		
2708
	private static char getEscapeCharacter(char character) {
2709
		switch (character) {
2710
			case '"':
2711
			case '\'':
2712
				return '\\';
2713
			default:
2714
				return 0;
1985
		}
2715
		}
2716
	}
1986
2717
1987
		/*
2718
	private static char getPeerCharacter(char character) {
1988
		 * @see org.eclipse.jface.action.IAction#run()
2719
		switch (character) {
1989
		 */
2720
			case '(':
1990
		public void run() {
2721
				return ')';
1991
			// Check whether sub word navigation is enabled.
1992
			final IPreferenceStore store = getPreferenceStore();
1993
			if (!store.getBoolean(SUB_WORD_NAVIGATION)) {
1994
				super.run();
1995
				return;
1996
			}
1997
2722
1998
			final ISourceViewer viewer = getSourceViewer();
2723
			case ')':
1999
			final IDocument document = viewer.getDocument();
2724
				return '(';
2000
			fIterator.setText((CharacterIterator) new DocumentCharacterIterator(document));
2001
			int position = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
2002
			if (position == -1)
2003
				return;
2004
2725
2005
			int previous = findPreviousPosition(position);
2726
			case '<':
2006
			if (previous != BreakIterator.DONE) {
2727
				return '>';
2007
				setCaretPosition(previous);
2008
				getTextWidget().showSelection();
2009
				fireSelectionChanged();
2010
			}
2011
2728
2012
		}
2729
			case '>':
2730
				return '<';
2013
2731
2014
		/**
2732
			case '[':
2015
		 * Finds the previous position before the given position.
2733
				return ']';
2016
		 *
2017
		 * @param position the current position
2018
		 * @return the previous position
2019
		 */
2020
		protected int findPreviousPosition(int position) {
2021
			ISourceViewer viewer = getSourceViewer();
2022
			int widget = -1;
2023
			while (position != BreakIterator.DONE && widget == -1) { // TODO: optimize
2024
				position = fIterator.preceding(position);
2025
				if (position != BreakIterator.DONE)
2026
					widget = modelOffset2WidgetOffset(viewer, position);
2027
			}
2028
			return position;
2029
		}
2030
2734
2031
		/**
2735
			case ']':
2032
		 * Sets the caret position to the sub-word boundary given with <code>position</code>.
2736
				return '[';
2033
		 *
2034
		 * @param position Position where the action should move the caret
2035
		 */
2036
		protected abstract void setCaretPosition(int position);
2037
	}
2038
2737
2039
	/**
2738
			case '"':
2040
	 * Text navigation action to navigate to the previous sub-word.
2739
				return character;
2041
	 *
2042
	 * @since 4.0
2043
	 */
2044
	protected class NavigatePreviousSubWordAction extends PreviousSubWordAction {
2045
2740
2046
		/**
2741
			case '\'':
2047
		 * Creates a new navigate previous sub-word action.
2742
				return character;
2048
		 */
2049
		public NavigatePreviousSubWordAction() {
2050
			super(ST.WORD_PREVIOUS);
2051
		}
2052
2743
2053
		/*
2744
			default:
2054
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#setCaretPosition(int)
2745
				throw new IllegalArgumentException();
2055
		 */
2056
		protected void setCaretPosition(final int position) {
2057
			getTextWidget().setCaretOffset(modelOffset2WidgetOffset(getSourceViewer(), position));
2058
		}
2746
		}
2059
	}
2747
	}
2060
2748
2061
	/**
2749
	/*
2062
	 * Text operation action to delete the previous sub-word.
2750
	 * @see org.eclipse.cdt.internal.ui.editor.IReconcilingParticipant#reconciled()
2063
	 *
2064
	 * @since 4.0
2065
	 */
2751
	 */
2066
	protected class DeletePreviousSubWordAction extends PreviousSubWordAction implements IUpdate {
2752
	public void reconciled(boolean somethingHasChanged) {
2067
2753
		if (getSourceViewer() == null) {
2068
		/**
2754
			return;
2069
		 * Creates a new delete previous sub-word action.
2070
		 */
2071
		public DeletePreviousSubWordAction() {
2072
			super(ST.DELETE_WORD_PREVIOUS);
2073
		}
2755
		}
2074
2756
		// this method must be called in a background thread
2075
		/*
2757
		assert getSourceViewer().getTextWidget().getDisplay().getThread() != Thread.currentThread();
2076
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#setCaretPosition(int)
2758
		
2077
		 */
2759
		if (fReconcilingListeners.size() > 0) {
2078
		protected void setCaretPosition(int position) {
2760
			// create AST and notify ICReconcilingListeners
2079
			if (!validateEditorInputState())
2761
			ICElement cElement= getInputCElement();
2762
			if (cElement == null) {
2080
				return;
2763
				return;
2081
2082
			final int length;
2083
			final ISourceViewer viewer = getSourceViewer();
2084
			Point selection = viewer.getSelectedRange();
2085
			if (selection.y != 0) {
2086
				position = selection.x;
2087
				length = selection.y;
2088
			} else {
2089
				length = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset()) - position;
2090
			}
2764
			}
2765
			
2766
			aboutToBeReconciled();
2091
2767
2768
			// track changes to the document while parsing
2769
			IDocument doc= getDocumentProvider().getDocument(getEditorInput());
2770
			SimplePositionTracker positionTracker= new SimplePositionTracker();
2771
			positionTracker.startTracking(doc);
2772
			
2092
			try {
2773
			try {
2093
				viewer.getDocument().replace(position, length, ""); //$NON-NLS-1$
2774
				IASTTranslationUnit ast= CUIPlugin.getDefault().getASTProvider().createAST(cElement, null);
2094
			} catch (BadLocationException exception) {
2775
				reconciled(ast, positionTracker, null);
2095
				// Should not happen
2776
			} finally {
2777
				positionTracker.stopTracking();
2096
			}
2778
			}
2097
		}
2779
		}
2098
2780
	}
2099
		/*
2781
	
2100
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#findPreviousPosition(int)
2782
	public CSourceViewer getCSourceViewer()  {
2101
		 */
2783
		ISourceViewer viewer = getSourceViewer();
2102
		protected int findPreviousPosition(int position) {
2784
		CSourceViewer cViewer = null ;
2103
			return fIterator.preceding(position);
2785
		if (viewer instanceof CSourceViewer) {
2104
		}
2786
			cViewer = (CSourceViewer) viewer;
2105
2106
		/*
2107
		 * @see org.eclipse.ui.texteditor.IUpdate#update()
2108
		 */
2109
		public void update() {
2110
			setEnabled(isEditorInputModifiable());
2111
		}
2787
		}
2788
		return cViewer ;
2112
	}
2789
	}
2113
2790
	
2114
	/**
2791
	/*
2115
	 * Text operation action to select the previous sub-word.
2792
	 * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#collectContextMenuPreferencePages()
2116
	 *
2117
	 * @since 4.0
2118
	 */
2793
	 */
2119
	protected class SelectPreviousSubWordAction extends PreviousSubWordAction {
2794
	protected String[] collectContextMenuPreferencePages() {
2120
2795
		// Add C/C++ Editor relevant pages
2121
		/**
2796
		String[] parentPrefPageIds = super.collectContextMenuPreferencePages();
2122
		 * Creates a new select previous sub-word action.
2797
		String[] prefPageIds = new String[parentPrefPageIds.length + 5];
2123
		 */
2798
		int nIds = 0;
2124
		public SelectPreviousSubWordAction() {
2799
		prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CEditorPreferencePage"; //$NON-NLS-1$
2125
			super(ST.SELECT_WORD_PREVIOUS);
2800
		prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeAssistPreferencePage"; //$NON-NLS-1$
2126
		}
2801
		prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.TemplatePreferencePage"; //$NON-NLS-1$
2127
2802
		prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.SmartTypingPreferencePage"; //$NON-NLS-1$
2128
		/*
2803
		prefPageIds[nIds++] = "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage"; //$NON-NLS-1$
2129
		 * @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#setCaretPosition(int)
2804
		System.arraycopy(parentPrefPageIds, 0, prefPageIds, nIds, parentPrefPageIds.length);
2130
		 */
2805
		return prefPageIds;
2131
		protected void setCaretPosition(final int position) {
2132
			final ISourceViewer viewer = getSourceViewer();
2133
2134
			final StyledText text = viewer.getTextWidget();
2135
			if (text != null && !text.isDisposed()) {
2136
2137
				final Point selection = text.getSelection();
2138
				final int caret = text.getCaretOffset();
2139
				final int offset = modelOffset2WidgetOffset(viewer, position);
2140
2141
				if (caret == selection.x)
2142
					text.setSelectionRange(selection.y, offset - selection.y);
2143
				else
2144
					text.setSelectionRange(selection.x, offset - selection.x);
2145
			}
2146
		}
2147
	}
2806
	}
2148
2807
2149
	/*
2808
	/*
(-)META-INF/MANIFEST.MF (+1 lines)
Lines 60-65 Link Here
60
 org.eclipse.ui.workbench.texteditor,
60
 org.eclipse.ui.workbench.texteditor,
61
 org.eclipse.ui.editors,
61
 org.eclipse.ui.editors,
62
 org.eclipse.ui,
62
 org.eclipse.ui,
63
 org.eclipse.ui.forms,
63
 org.eclipse.core.resources,
64
 org.eclipse.core.resources,
64
 org.eclipse.search,
65
 org.eclipse.search,
65
 org.eclipse.compare,
66
 org.eclipse.compare,
(-)src/org/eclipse/cdt/internal/ui/ICHelpContextIds.java (+1 lines)
Lines 54-59 Link Here
54
	public static final String C_EDITOR_CONTENT_ASSIST_PREF_PAGE = PREFIX + "c_editor_con_assist"; //$NON-NLS-1$
54
	public static final String C_EDITOR_CONTENT_ASSIST_PREF_PAGE = PREFIX + "c_editor_con_assist"; //$NON-NLS-1$
55
	public static final String C_EDITOR_NAVIGATION_PAGE = PREFIX + "c_editor_navigation"; //$NON-NLS-1$
55
	public static final String C_EDITOR_NAVIGATION_PAGE = PREFIX + "c_editor_navigation"; //$NON-NLS-1$
56
	public static final String C_EDITOR_HOVERS_PAGE = PREFIX + "c_editor_hov"; //$NON-NLS-1$
56
	public static final String C_EDITOR_HOVERS_PAGE = PREFIX + "c_editor_hov"; //$NON-NLS-1$
57
	public static final String C_EDITOR_TYPING_PAGE = PREFIX + "c_editor_typing"; //$NON-NLS-1$;
57
	public static final String FILE_TYPES_STD_PAGE = PREFIX + "std_prop_file_types"; //$NON-NLS-1$
58
	public static final String FILE_TYPES_STD_PAGE = PREFIX + "std_prop_file_types"; //$NON-NLS-1$
58
	public static final String FILE_TYPES_MAN_PAGE = PREFIX + "std_prop_file_types"; //$NON-NLS-1$
59
	public static final String FILE_TYPES_MAN_PAGE = PREFIX + "std_prop_file_types"; //$NON-NLS-1$
59
	public static final String FILE_TYPES_PREF_PAGE = PREFIX + "c_file_types"; //$NON-NLS-1$
60
	public static final String FILE_TYPES_PREF_PAGE = PREFIX + "c_file_types"; //$NON-NLS-1$
(-)utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java (-73 / +51 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.cdt.utils.ui.controls;
11
package org.eclipse.cdt.utils.ui.controls;
12
12
13
14
import java.util.StringTokenizer;
13
import java.util.StringTokenizer;
15
14
16
import org.eclipse.jface.viewers.CellEditor;
15
import org.eclipse.jface.viewers.CellEditor;
Lines 56-62 Link Here
56
	 *
55
	 *
57
	 * @param parent  the parent of the new composite
56
	 * @param parent  the parent of the new composite
58
	 * @param numColumns  the number of columns for the new composite
57
	 * @param numColumns  the number of columns for the new composite
59
	 * @return the newly-created coposite
58
	 * @return the newly-created composite
60
	 */
59
	 */
61
	public static Composite createComposite(Composite parent, int numColumns) {
60
	public static Composite createComposite(Composite parent, int numColumns) {
62
		return createCompositeEx(parent, numColumns, GridData.FILL_HORIZONTAL);
61
		return createCompositeEx(parent, numColumns, GridData.FILL_HORIZONTAL);
Lines 68-77 Link Here
68
	 * @param parent  the parent of the new composite
67
	 * @param parent  the parent of the new composite
69
	 * @param numColumns  the number of columns for the new composite
68
	 * @param numColumns  the number of columns for the new composite
70
	 * @param layoutMode - GridData modes that should be applied to this control
69
	 * @param layoutMode - GridData modes that should be applied to this control
71
	 * @return the newly-created coposite
70
	 * @return the newly-created composite
72
	 */
71
	 */
73
	public static Composite createCompositeEx(Composite parent, int numColumns, int layoutMode) {
72
	public static Composite createCompositeEx(Composite parent, int numColumns, int layoutMode) {
74
		Composite composite = new Composite(parent, SWT.NULL);
73
		Composite composite = new Composite(parent, SWT.NULL);
74
		composite.setFont(parent.getFont());
75
	
75
	
76
		composite.setLayout(new GridLayout(numColumns, true));
76
		composite.setLayout(new GridLayout(numColumns, true));
77
		composite.setLayoutData(new GridData(layoutMode));
77
		composite.setLayoutData(new GridData(layoutMode));
Lines 108-113 Link Here
108
		separator.setLayoutData(data);
108
		separator.setLayoutData(data);
109
		return separator;
109
		return separator;
110
	}
110
	}
111
111
	/**
112
	/**
112
	 * Creates a spacer control.
113
	 * Creates a spacer control.
113
	 * @param parent The parent composite
114
	 * @param parent The parent composite
Lines 115-120 Link Here
115
	public static Control createEmptySpace(Composite parent) {
116
	public static Control createEmptySpace(Composite parent) {
116
		return createEmptySpace(parent, 1);
117
		return createEmptySpace(parent, 1);
117
	}
118
	}
119
118
	/**
120
	/**
119
	 * Creates a spacer control with the given span.
121
	 * Creates a spacer control with the given span.
120
	 * The composite is assumed to have <code>MGridLayout</code> as
122
	 * The composite is assumed to have <code>MGridLayout</code> as
Lines 136-142 Link Here
136
138
137
	/**
139
	/**
138
	 * Creates an new label (basic method)
140
	 * Creates an new label (basic method)
139
	 * 
140
	 *
141
	 *
141
	 * @param parent  parent object
142
	 * @param parent  parent object
142
	 * @param text  the label text
143
	 * @param text  the label text
Lines 148-153 Link Here
148
	public static Label createLabel(Composite parent, String text, int widthHint, int heightHint, int style) {
149
	public static Label createLabel(Composite parent, String text, int widthHint, int heightHint, int style) {
149
150
150
		Label label = new Label(parent, style);		
151
		Label label = new Label(parent, style);		
152
		label.setFont(parent.getFont());
151
		label.setText(text);
153
		label.setText(text);
152
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
154
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
153
		gd.horizontalSpan = 1;
155
		gd.horizontalSpan = 1;
Lines 187-193 Link Here
187
		return label;
189
		return label;
188
	}
190
	}
189
191
190
191
	/**
192
	/**
192
	 * Creates an new Wrapped label 
193
	 * Creates an new Wrapped label 
193
	 * 
194
	 * 
Lines 202-208 Link Here
202
		return createLabel(parent, text, widthHint, heightHint, SWT.LEFT | SWT.WRAP);
203
		return createLabel(parent, text, widthHint, heightHint, SWT.LEFT | SWT.WRAP);
203
	}
204
	}
204
205
205
206
	/**
206
	/**
207
	 * Creates an new checkbox instance and sets the default
207
	 * Creates an new checkbox instance and sets the default
208
	 * layout data.
208
	 * layout data.
Lines 213-218 Link Here
213
	 */ 
213
	 */ 
214
	public static Button createCheckBox(Composite group, String label) {
214
	public static Button createCheckBox(Composite group, String label) {
215
		Button button = new Button(group, SWT.CHECK | SWT.LEFT);
215
		Button button = new Button(group, SWT.CHECK | SWT.LEFT);
216
		button.setFont(group.getFont());
216
		button.setText(label);
217
		button.setText(label);
217
		GridData data = new GridData();
218
		GridData data = new GridData();
218
		button.setLayoutData(data);
219
		button.setLayoutData(data);
Lines 231-236 Link Here
231
	 */ 
232
	 */ 
232
	public static Button createCheckBoxEx(Composite group, String label, int style) {
233
	public static Button createCheckBoxEx(Composite group, String label, int style) {
233
		Button button = new Button(group, SWT.CHECK | style);
234
		Button button = new Button(group, SWT.CHECK | style);
235
		button.setFont(group.getFont());
234
		button.setText(label);
236
		button.setText(label);
235
		GridData data = new GridData();
237
		GridData data = new GridData();
236
		button.setLayoutData(data);
238
		button.setLayoutData(data);
Lines 250-262 Link Here
250
	 */ 
252
	 */ 
251
	public static Button createRadioButton(Composite group, String label, String value, SelectionListener listener) {
253
	public static Button createRadioButton(Composite group, String label, String value, SelectionListener listener) {
252
		Button button = new Button(group, SWT.RADIO | SWT.LEFT);
254
		Button button = new Button(group, SWT.RADIO | SWT.LEFT);
255
		button.setFont(group.getFont());
253
		button.setText(label);
256
		button.setText(label);
254
		button.setData((null == value) ? label : value);
257
		button.setData((null == value) ? label : value);
255
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
258
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
256
		data.horizontalAlignment = GridData.FILL;
259
		data.horizontalAlignment = GridData.FILL;
257
		data.verticalAlignment = GridData.BEGINNING;
260
		data.verticalAlignment = GridData.BEGINNING;
258
		button.setLayoutData(data);
261
		button.setLayoutData(data);
259
		if(null != listener)
262
		if (null != listener)
260
			button.addSelectionListener(listener);
263
			button.addSelectionListener(listener);
261
		return button;
264
		return button;
262
	}
265
	}
Lines 271-276 Link Here
271
	 */
274
	 */
272
	public static Button createPushButton(Composite parent, String label) {
275
	public static Button createPushButton(Composite parent, String label) {
273
		Button button = new Button(parent, SWT.PUSH);
276
		Button button = new Button(parent, SWT.PUSH);
277
		button.setFont(parent.getFont());
274
		button.setText(label);
278
		button.setText(label);
275
//		button.addSelectionListener(this);
279
//		button.addSelectionListener(this);
276
		GridData data = new GridData();
280
		GridData data = new GridData();
Lines 278-284 Link Here
278
		button.setLayoutData(data);
282
		button.setLayoutData(data);
279
		return button;
283
		return button;
280
	}
284
	}
281
282
    	
285
    	
283
	/**
286
	/**
284
	 * Create a text field specific for this application
287
	 * Create a text field specific for this application
Lines 312-317 Link Here
312
	 */
315
	 */
313
    public static Group createGroup(Composite parent, String label, int nColumns) {
316
    public static Group createGroup(Composite parent, String label, int nColumns) {
314
		Group group = new Group(parent, SWT.NONE);
317
		Group group = new Group(parent, SWT.NONE);
318
		group.setFont(parent.getFont());
315
		group.setText(label);
319
		group.setText(label);
316
		GridLayout layout = new GridLayout();
320
		GridLayout layout = new GridLayout();
317
		layout.numColumns = nColumns;
321
		layout.numColumns = nColumns;
Lines 321-327 Link Here
321
        return group;    	
325
        return group;    	
322
    }
326
    }
323
327
324
325
	/**
328
	/**
326
	 * Create a List box
329
	 * Create a List box
327
	 *
330
	 *
Lines 332-361 Link Here
332
	 */
335
	 */
333
    public static List createList(Composite parent, String strdata, String selData) {
336
    public static List createList(Composite parent, String strdata, String selData) {
334
		List list = new List(parent, SWT.SINGLE);
337
		List list = new List(parent, SWT.SINGLE);
338
		list.setFont(parent.getFont());
335
		GridData data = new GridData();
339
		GridData data = new GridData();
336
		list.setLayoutData(data);
340
		list.setLayoutData(data);
337
		StringTokenizer st = new StringTokenizer(strdata, ","); //$NON-NLS-1$
341
		StringTokenizer st = new StringTokenizer(strdata, ","); //$NON-NLS-1$
338
		while(st.hasMoreTokens())
342
		while (st.hasMoreTokens())
339
			list.add(st.nextToken());
343
			list.add(st.nextToken());
340
	    if(selData == null) {
344
	    if (selData == null) {
341
	    	if(list.getItemCount() > 0)
345
	    	if (list.getItemCount() > 0)
342
				list.select(0);
346
				list.select(0);
347
	    } else {
348
			selectList(list, selData);
343
	    }
349
	    }
344
	    else
345
			selectList(list, selData);	    
346
		return list;
350
		return list;
347
	}
351
	}
348
352
349
	public static void selectList(List list, String selData)	{
353
	public static void selectList(List list, String selData)	{
350
		int n_sel = list.indexOf(selData);
354
		int n_sel = list.indexOf(selData);
351
		if(0 > n_sel)
355
		if (0 > n_sel)
352
			n_sel = 0;
356
			n_sel = 0;
353
	    list.select(n_sel);
357
	    list.select(n_sel);
354
	}
358
	}
355
	
359
	
356
357
358
359
	/**
360
	/**
360
	 *	Create this group's list viewer.
361
	 *	Create this group's list viewer.
361
	 */
362
	 */
Lines 366-377 Link Here
366
		data.widthHint = width;
367
		data.widthHint = width;
367
		data.heightHint = height;
368
		data.heightHint = height;
368
		listViewer.getTable().setLayoutData(data);
369
		listViewer.getTable().setLayoutData(data);
369
		if(null != opt_list)
370
		if (null != opt_list)
370
			listViewer.add(opt_list);
371
			listViewer.add(opt_list);
371
        return listViewer; 
372
        return listViewer; 
372
	}
373
	}
373
374
374
375
	/**
375
	/**
376
	 *	Create this group's list viewer.
376
	 *	Create this group's list viewer.
377
	 */
377
	 */
Lines 391-401 Link Here
391
		tableLayout.addColumnData(new ColumnWeightData(colWidths[0], false));
391
		tableLayout.addColumnData(new ColumnWeightData(colWidths[0], false));
392
*/		
392
*/		
393
		TableColumn column;
393
		TableColumn column;
394
		for(int i = 0; i < columns.length; ++i) {
394
		for (int i = 0; i < columns.length; ++i) {
395
			column= new TableColumn(table, SWT.NULL);
395
			column= new TableColumn(table, SWT.NULL);
396
			column.setText(columns[i]); 	
396
			column.setText(columns[i]); 	
397
			tableLayout.addColumnData(new ColumnWeightData(colWidths[i], true));
397
			tableLayout.addColumnData(new ColumnWeightData(colWidths[i], true));
398
			
399
		}
398
		}
400
399
401
		table.setLayout(tableLayout);
400
		table.setLayout(tableLayout);
Lines 404-418 Link Here
404
	}
403
	}
405
404
406
	public static void deactivateCellEditor(TableViewer viewer) {
405
	public static void deactivateCellEditor(TableViewer viewer) {
407
		if(null == viewer)
406
		if (null == viewer)
408
			return;
407
			return;
409
		CellEditor[] es = viewer.getCellEditors();
408
		CellEditor[] es = viewer.getCellEditors();
410
		TableItem[] items = viewer.getTable().getSelection();
409
		TableItem[] items = viewer.getTable().getSelection();
411
		if(items.length >= 0)  {
410
		if (items.length >= 0)  {
412
			for(int i = 0; i < es.length; ++i) {
411
			for (int i = 0; i < es.length; ++i) {
413
				CellEditor e = es[i];
412
				CellEditor e = es[i];
414
				if(e.isActivated()) {
413
				if (e.isActivated()) {
415
					if(e.isValueValid()) {
414
					if (e.isValueValid()) {
416
						Object[] properties = viewer.getColumnProperties();
415
						Object[] properties = viewer.getColumnProperties();
417
						Object value = e.getValue();
416
						Object value = e.getValue();
418
						viewer.cancelEditing();
417
						viewer.cancelEditing();
Lines 432-457 Link Here
432
	    int width, int height, int style) {
431
	    int width, int height, int style) {
433
	    	
432
	    	
434
	    Table table = new Table(parent, SWT.BORDER | SWT.CHECK);
433
	    Table table = new Table(parent, SWT.BORDER | SWT.CHECK);
434
		table.setFont(parent.getFont());
435
	    CheckboxTableViewer listViewer = new CheckboxTableViewer(table);
435
	    CheckboxTableViewer listViewer = new CheckboxTableViewer(table);
436
		GridData data = new GridData(style);
436
		GridData data = new GridData(style);
437
		data.widthHint = width;
437
		data.widthHint = width;
438
		data.heightHint = height;
438
		data.heightHint = height;
439
		listViewer.getTable().setLayoutData(data);
439
		listViewer.getTable().setLayoutData(data);
440
		if(null != opt_list)
440
		if (null != opt_list)
441
			listViewer.add(opt_list);
441
			listViewer.add(opt_list);
442
//		listViewer.setLabelProvider(listLabelProvider);
442
//		listViewer.setLabelProvider(listLabelProvider);
443
//		listViewer.addCheckStateListener(this);
443
//		listViewer.addCheckStateListener(this);
444
        return listViewer; 
444
        return listViewer; 
445
	}
445
	}
446
446
447
448
449
	public static CheckboxTableViewer createListViewer(Composite parent,  
447
	public static CheckboxTableViewer createListViewer(Composite parent,  
450
	    int width, int height, int style, String[] columns, int[] colWidths) {
448
	    int width, int height, int style, String[] columns, int[] colWidths) {
451
	    CheckboxTableViewer listViewer = createListViewer(parent, null, 
449
	    CheckboxTableViewer listViewer = createListViewer(parent, null, 
452
	    	width, height, style);
450
	    	width, height, style);
453
		
451
		
454
		Table table= listViewer.getTable();
452
		Table table= listViewer.getTable();
453
		table.setFont(parent.getFont());
455
		
454
		
456
		table.setHeaderVisible(true);
455
		table.setHeaderVisible(true);
457
		table.setLinesVisible(true);
456
		table.setLinesVisible(true);
Lines 463-469 Link Here
463
		column.setText(columns[0]); 	    
462
		column.setText(columns[0]); 	    
464
		tableLayout.addColumnData(new ColumnWeightData(colWidths[0], false));
463
		tableLayout.addColumnData(new ColumnWeightData(colWidths[0], false));
465
		
464
		
466
		for(int i = 1; i < columns.length; ++i) {
465
		for (int i = 1; i < columns.length; ++i) {
467
			column= new TableColumn(table, SWT.NULL);
466
			column= new TableColumn(table, SWT.NULL);
468
			column.setText(columns[i]); 	
467
			column.setText(columns[i]); 	
469
			tableLayout.addColumnData(new ColumnWeightData(colWidths[i], false));
468
			tableLayout.addColumnData(new ColumnWeightData(colWidths[i], false));
Lines 472-478 Link Here
472
	    
471
	    
473
        return listViewer; 
472
        return listViewer; 
474
	}
473
	}
475
476
  
474
  
477
	/**
475
	/**
478
	 * Create a selection combo
476
	 * Create a selection combo
Lines 489-509 Link Here
489
		
487
		
490
	public static CCombo createSelectCCombo(Composite parent, String strdata, String selData, int style) {
488
	public static CCombo createSelectCCombo(Composite parent, String strdata, String selData, int style) {
491
		CCombo combo = new CCombo(parent, style);
489
		CCombo combo = new CCombo(parent, style);
490
		combo.setFont(parent.getFont());
492
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
491
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
493
		combo.setLayoutData(data);
492
		combo.setLayoutData(data);
494
		StringTokenizer st = new StringTokenizer(strdata, ","); //$NON-NLS-1$
493
		StringTokenizer st = new StringTokenizer(strdata, ","); //$NON-NLS-1$
495
		while(st.hasMoreTokens())
494
		while (st.hasMoreTokens())
496
			combo.add(st.nextToken());
495
			combo.add(st.nextToken());
497
	    if(selData == null || selData.length() == 0) {
496
	    if (selData == null || selData.length() == 0) {
498
	    	if(combo.getItemCount() > 0)
497
	    	if (combo.getItemCount() > 0)
499
				combo.select(0);
498
				combo.select(0);
499
	    } else {
500
			selectCCombo(combo, selData);
500
	    }
501
	    }
501
	    else
502
			selectCCombo(combo, selData);	    
503
		return combo;
502
		return combo;
504
	}
503
	}
505
504
506
507
	/**
505
	/**
508
	 * Create a selection combo
506
	 * Create a selection combo
509
	 *
507
	 *
Lines 518-529 Link Here
518
	
516
	
519
	public static CCombo createSelectCCombo(Composite parent, String[] strdata, String selData, int style) {
517
	public static CCombo createSelectCCombo(Composite parent, String[] strdata, String selData, int style) {
520
		CCombo combo = new CCombo(parent, style);
518
		CCombo combo = new CCombo(parent, style);
519
		combo.setFont(parent.getFont());
521
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
520
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
522
		combo.setLayoutData(data);
521
		combo.setLayoutData(data);
523
		for(int i = 0; i < strdata.length; ++i) {
522
		for (int i = 0; i < strdata.length; ++i) {
524
			combo.add(strdata[i]);
523
			combo.add(strdata[i]);
525
		}
524
		}
526
	    if(selData == null)
525
	    if (selData == null)
527
			combo.select(0);
526
			combo.select(0);
528
	    else
527
	    else
529
			selectCCombo(combo, selData);	    
528
			selectCCombo(combo, selData);	    
Lines 532-551 Link Here
532
531
533
	public static void selectCCombo(CCombo combo, String selData)	{
532
	public static void selectCCombo(CCombo combo, String selData)	{
534
		int n_sel = combo.indexOf(selData);
533
		int n_sel = combo.indexOf(selData);
535
		if(0 > n_sel)
534
		if (0 > n_sel)
536
			n_sel = 0;
535
			n_sel = 0;
537
	    combo.select(n_sel);
536
	    combo.select(n_sel);
538
	} 
537
	} 
539
538
540
541
542
543
544
545
546
547
548
549
	/**
539
	/**
550
	 * Create a selection combo
540
	 * Create a selection combo
551
	 *
541
	 *
Lines 561-581 Link Here
561
		
551
		
562
	public static Combo createSelectCombo(Composite parent, String strdata, String selData, int style) {
552
	public static Combo createSelectCombo(Composite parent, String strdata, String selData, int style) {
563
		Combo combo = new Combo(parent, style);
553
		Combo combo = new Combo(parent, style);
554
		combo.setFont(parent.getFont());
564
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
555
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
565
		combo.setLayoutData(data);
556
		combo.setLayoutData(data);
566
		StringTokenizer st = new StringTokenizer(strdata, ","); //$NON-NLS-1$
557
		StringTokenizer st = new StringTokenizer(strdata, ","); //$NON-NLS-1$
567
		while(st.hasMoreTokens())
558
		while (st.hasMoreTokens())
568
			combo.add(st.nextToken());
559
			combo.add(st.nextToken());
569
	    if(selData == null || selData.length() == 0) {
560
	    if (selData == null || selData.length() == 0) {
570
	    	if(combo.getItemCount() > 0)
561
	    	if (combo.getItemCount() > 0)
571
				combo.select(0);
562
				combo.select(0);
563
	    } else {
564
			selectCombo(combo, selData);
572
	    }
565
	    }
573
	    else
574
			selectCombo(combo, selData);	    
575
		return combo;
566
		return combo;
576
	}
567
	}
577
568
578
579
	/**
569
	/**
580
	 * Create a selection combo
570
	 * Create a selection combo
581
	 *
571
	 *
Lines 590-601 Link Here
590
	
580
	
591
	public static Combo createSelectCombo(Composite parent, String[] strdata, String selData, int style) {
581
	public static Combo createSelectCombo(Composite parent, String[] strdata, String selData, int style) {
592
		Combo combo = new Combo(parent, style);
582
		Combo combo = new Combo(parent, style);
583
		combo.setFont(parent.getFont());
593
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
584
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
594
		combo.setLayoutData(data);
585
		combo.setLayoutData(data);
595
		for(int i = 0; i < strdata.length; ++i) {
586
		for (int i = 0; i < strdata.length; ++i) {
596
			combo.add(strdata[i]);
587
			combo.add(strdata[i]);
597
		}
588
		}
598
	    if(selData == null)
589
	    if (selData == null)
599
			combo.select(0);
590
			combo.select(0);
600
	    else
591
	    else
601
			selectCombo(combo, selData);	    
592
			selectCombo(combo, selData);	    
Lines 604-611 Link Here
604
595
605
	public static void selectCombo(Combo combo, String selData)	{
596
	public static void selectCombo(Combo combo, String selData)	{
606
		int n_sel = combo.indexOf(selData);
597
		int n_sel = combo.indexOf(selData);
607
		if(0 > n_sel) {
598
		if (0 > n_sel) {
608
			if( ( combo.getStyle() & SWT.READ_ONLY ) == 0 ) {
599
			if ((combo.getStyle() & SWT.READ_ONLY) == 0) {
609
				combo.setText( selData );
600
				combo.setText( selData );
610
				return;
601
				return;
611
			}
602
			}
Lines 614-629 Link Here
614
	    combo.select(n_sel);
605
	    combo.select(n_sel);
615
	} 
606
	} 
616
607
617
618
619
620
621
622
623
624
625
626
627
    /**
608
    /**
628
	 * Create a dialog shell, child to the top level workbench shell.
609
	 * Create a dialog shell, child to the top level workbench shell.
629
	 *
610
	 *
Lines 637-644 Link Here
637
        return new Shell( parent, SWT.DIALOG_TRIM );
618
        return new Shell( parent, SWT.DIALOG_TRIM );
638
    }
619
    }
639
620
640
	
641
642
	public static Composite insertSpace(Composite parent, int nSpan, int height) {
621
	public static Composite insertSpace(Composite parent, int nSpan, int height) {
643
		Composite space = ControlFactory.createCompositeSeparator(parent, parent.getBackground(),
622
		Composite space = ControlFactory.createCompositeSeparator(parent, parent.getBackground(),
644
			 (SWT.DEFAULT != height ? height : 5));
623
			 (SWT.DEFAULT != height ? height : 5));
Lines 664-668 Link Here
664
    public static MessageBox createOkCancelDialog( String title, String message ) {
643
    public static MessageBox createOkCancelDialog( String title, String message ) {
665
        return createDialog( title, message, SWT.OK | SWT.CANCEL | SWT.ICON_INFORMATION );
644
        return createDialog( title, message, SWT.OK | SWT.CANCEL | SWT.ICON_INFORMATION );
666
    }
645
    }
667
	
668
}
646
}
(-)src/org/eclipse/cdt/internal/ui/util/Strings.java (-11 / +20 lines)
Lines 147-175 Link Here
147
	 * 
147
	 * 
148
	 * @param line the text line
148
	 * @param line the text line
149
	 * @param tabWidth the width of the '\t' character.
149
	 * @param tabWidth the width of the '\t' character.
150
	 * @return the indentation level of the given string
151
	 * 
152
	 * @deprecated use {@link #computeIndent(String, int, int)} instead.
150
	 */
153
	 */
151
	public static int computeIndent(String line, int tabWidth) {
154
	public static int computeIndent(String line, int tabWidth) {
155
		return computeIndent(line, tabWidth, tabWidth);
156
	}
157
158
	/**
159
	 * Returns the indent level of the given string.
160
	 * 
161
	 * @param line the text line
162
	 * @param tabWidth the width of the '\t' character.
163
	 * @param indentSize the space-equivalent of an indent level
164
	 * @return the indentation level of the given string
165
	 */
166
	public static int computeIndent(String line, int tabWidth, int indentSize) {
152
		int result= 0;
167
		int result= 0;
153
		int blanks= 0;
154
		int size= line.length();
168
		int size= line.length();
155
		for (int i= 0; i < size; i++) {
169
		for (int i= 0; i < size; i++) {
156
			char c= line.charAt(i);
170
			char c= line.charAt(i);
157
			if (c == '\t') {
171
			if (c == '\t') {
158
				result++;
172
				result+= tabWidth;
159
				blanks= 0;
160
			} else if (isIndentChar(c)) {
173
			} else if (isIndentChar(c)) {
161
				blanks++;
174
				result++;
162
				if (blanks == tabWidth) {
163
					result++;
164
					blanks= 0;
165
				}
166
			} else {
175
			} else {
167
				return result;
176
				break;
168
			}
177
			}
169
		}
178
		}
170
		return result;
179
		return result / indentSize;
171
	}
180
	}
172
	
181
173
	/**
182
	/**
174
	 * Removes the given number of idents from the line. Asserts that the given line 
183
	 * Removes the given number of idents from the line. Asserts that the given line 
175
	 * has the requested number of indents. If <code>indentsToRemove <= 0</code>
184
	 * has the requested number of indents. If <code>indentsToRemove <= 0</code>
(-)src/org/eclipse/cdt/internal/corext/util/CodeFormatterUtil.java (-21 / +27 lines)
Lines 15-44 Link Here
15
import org.eclipse.cdt.core.CCorePlugin;
15
import org.eclipse.cdt.core.CCorePlugin;
16
import org.eclipse.cdt.core.ToolFactory;
16
import org.eclipse.cdt.core.ToolFactory;
17
import org.eclipse.cdt.core.formatter.CodeFormatter;
17
import org.eclipse.cdt.core.formatter.CodeFormatter;
18
import org.eclipse.cdt.core.formatter.CodeFormatterConstants;
18
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
19
import org.eclipse.cdt.core.model.ICProject;
19
import org.eclipse.cdt.core.model.ICProject;
20
import org.eclipse.cdt.ui.CUIPlugin;
20
import org.eclipse.cdt.ui.CUIPlugin;
21
21
22
import org.eclipse.core.runtime.Assert;
22
import org.eclipse.core.runtime.Assert;
23
import org.eclipse.jface.preference.IPreferenceStore;
24
import org.eclipse.jface.text.BadLocationException;
23
import org.eclipse.jface.text.BadLocationException;
25
import org.eclipse.jface.text.BadPositionCategoryException;
24
import org.eclipse.jface.text.BadPositionCategoryException;
26
import org.eclipse.jface.text.DefaultPositionUpdater;
25
import org.eclipse.jface.text.DefaultPositionUpdater;
27
import org.eclipse.jface.text.Document;
26
import org.eclipse.jface.text.Document;
28
import org.eclipse.jface.text.Position;
27
import org.eclipse.jface.text.Position;
29
import org.eclipse.text.edits.TextEdit;
28
import org.eclipse.text.edits.TextEdit;
30
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
31
29
32
public class CodeFormatterUtil {
30
public class CodeFormatterUtil {
33
31
34
//	/**
32
	/**
35
//	 * Creates a string that represents the given number of indents (can be spaces or tabs..)
33
	 * Creates a string that represents the given number of indentation units.
36
//	 */
34
	 * The returned string can contain tabs and/or spaces depending on the core
37
//	public static String createIndentString(int indent) {
35
	 * formatter preferences.
38
//		String str= format(CodeFormatter.K_EXPRESSION, "x", indent, null, "", (Map) null); //$NON-NLS-1$ //$NON-NLS-2$
36
	 * 
39
//		return str.substring(0, str.indexOf('x'));
37
	 * @param indentationUnits the number of indentation units to generate
40
//	} 
38
	 * @param project the project from which to get the formatter settings,
41
39
	 *        <code>null</code> if the workspace default should be used
40
	 * @return the indent string
41
	 */
42
	public static String createIndentString(int indentationUnits, ICProject project) {
43
		Map options= project != null ? project.getOptions(true) : CCorePlugin.getOptions();		
44
		return ToolFactory.createDefaultCodeFormatter(options).createIndentationString(indentationUnits);
45
	} 
46
		
42
	/**
47
	/**
43
	 * Gets the current tab width.
48
	 * Gets the current tab width.
44
	 * 
49
	 * 
Lines 55-64 Link Here
55
		 * that case.
60
		 * that case.
56
		 */
61
		 */
57
		String key;
62
		String key;
58
		if (CCorePlugin.SPACE.equals(getCoreOption(project, CodeFormatterConstants.FORMATTER_TAB_CHAR)))
63
		if (CCorePlugin.SPACE.equals(getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
59
			key= CodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
64
			key= DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
60
		else
65
		else
61
			key= CodeFormatterConstants.FORMATTER_TAB_SIZE;
66
			key= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
62
		
67
		
63
		return getCoreOption(project, key, 4);
68
		return getCoreOption(project, key, 4);
64
	}
69
	}
Lines 72-81 Link Here
72
	 */
77
	 */
73
	public static int getIndentWidth(ICProject project) {
78
	public static int getIndentWidth(ICProject project) {
74
		String key;
79
		String key;
75
		if (CodeFormatterConstants.MIXED.equals(getCoreOption(project, CodeFormatterConstants.FORMATTER_TAB_CHAR)))
80
		if (DefaultCodeFormatterConstants.MIXED.equals(getCoreOption(project, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)))
76
			key= CodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
81
			key= DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE;
77
		else
82
		else
78
			key= CodeFormatterConstants.FORMATTER_TAB_SIZE;
83
			key= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
79
		
84
		
80
		return getCoreOption(project, key, 4);
85
		return getCoreOption(project, key, 4);
81
	}
86
	}
Lines 131-137 Link Here
131
			return doc.get();
136
			return doc.get();
132
		} catch (BadLocationException e) {
137
		} catch (BadLocationException e) {
133
			CUIPlugin.getDefault().log(e); // bug in the formatter
138
			CUIPlugin.getDefault().log(e); // bug in the formatter
134
			Assert.isTrue(false, "Fromatter created edits with wrong positions: " + e.getMessage()); //$NON-NLS-1$
139
			Assert.isTrue(false, "Formatter created edits with wrong positions: " + e.getMessage()); //$NON-NLS-1$
135
		}
140
		}
136
		return null;
141
		return null;
137
	}
142
	}
Lines 213-221 Link Here
213
		return doc;
218
		return doc;
214
	}
219
	}
215
	
220
	
221
	/**
222
	 * @return The formatter tab width on workspace level.
223
	 */
216
	public static int getTabWidth() {
224
	public static int getTabWidth() {
217
		IPreferenceStore store = CUIPlugin.getDefault().getCombinedPreferenceStore();
225
		return getTabWidth(null);
218
		return store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
219
	}
226
	}
220
221
}
227
}
(-)src/org/eclipse/cdt/ui/PreferenceConstants.java (-1 / +43 lines)
Lines 12-18 Link Here
12
package org.eclipse.cdt.ui;
12
package org.eclipse.cdt.ui;
13
13
14
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
14
import org.eclipse.cdt.internal.ui.text.ICColorConstants;
15
16
import org.eclipse.jface.action.Action;
15
import org.eclipse.jface.action.Action;
17
import org.eclipse.jface.preference.IPreferenceStore;
16
import org.eclipse.jface.preference.IPreferenceStore;
18
import org.eclipse.jface.preference.PreferenceConverter;
17
import org.eclipse.jface.preference.PreferenceConverter;
Lines 147-152 Link Here
147
	public final static String EDITOR_EVALUATE_TEMPORARY_PROBLEMS= "handleTemporaryProblems"; //$NON-NLS-1$
146
	public final static String EDITOR_EVALUATE_TEMPORARY_PROBLEMS= "handleTemporaryProblems"; //$NON-NLS-1$
148
147
149
	/**
148
	/**
149
	 * The symbolic font name for the C editor text font 
150
	 * (value <code>"org.eclipse.cdt.ui.editors.textfont"</code>).
151
	 */
152
	public final static String EDITOR_TEXT_FONT= "org.eclipse.cdt.ui.editors.textfont"; //$NON-NLS-1$
153
154
	/**
150
	 * A named preference that defines the key for the hover modifiers.
155
	 * A named preference that defines the key for the hover modifiers.
151
	 *
156
	 *
152
	 */
157
	 */
Lines 198-203 Link Here
198
	public final static String EDITOR_CLOSE_BRACKETS= "closeBrackets"; //$NON-NLS-1$
203
	public final static String EDITOR_CLOSE_BRACKETS= "closeBrackets"; //$NON-NLS-1$
199
204
200
	/**
205
	/**
206
	 * A named preference that controls whether the 'close angular brackets' feature is
207
	 * enabled.
208
	 * <p>
209
	 * Value is of type <code>Boolean</code>.
210
	 * </p>
211
	 */
212
	public final static String EDITOR_CLOSE_ANGULAR_BRACKETS= "closeAngularBrackets"; //$NON-NLS-1$
213
214
	/**
201
	 * A named preference that controls whether the 'close braces' feature is
215
	 * A named preference that controls whether the 'close braces' feature is
202
	 * enabled.
216
	 * enabled.
203
	 * <p>
217
	 * <p>
Lines 207-212 Link Here
207
	public final static String EDITOR_CLOSE_BRACES= "closeBraces"; //$NON-NLS-1$
221
	public final static String EDITOR_CLOSE_BRACES= "closeBraces"; //$NON-NLS-1$
208
222
209
	/**
223
	/**
224
	 * A named preference that controls whether the 'smart paste' feature is
225
	 * enabled.
226
	 * <p>
227
	 * Value is of type <code>Boolean</code>.
228
	 * </p>
229
	 */
230
	public final static String EDITOR_SMART_PASTE= "smartPaste"; //$NON-NLS-1$
231
232
	/**
233
	 * A named preference that controls the smart tab behavior.
234
	 * <p>
235
	 * Value is of type <code>Boolean</code>.
236
	 */
237
	public static final String EDITOR_SMART_TAB= "smart_tab"; //$NON-NLS-1$
238
239
	/**
210
	 * The id of the best match hover contributed for extension point
240
	 * The id of the best match hover contributed for extension point
211
	 * <code>javaEditorTextHovers</code>.
241
	 * <code>javaEditorTextHovers</code>.
212
	 *
242
	 *
Lines 409-414 Link Here
409
	 */	
439
	 */	
410
	public static final String TEMPLATES_USE_CODEFORMATTER= "org.eclipse.cdt.ui.text.templates.format"; //$NON-NLS-1$
440
	public static final String TEMPLATES_USE_CODEFORMATTER= "org.eclipse.cdt.ui.text.templates.format"; //$NON-NLS-1$
411
441
442
	/**
443
	 * A named preference that controls which profile is used by the code formatter.
444
	 * <p>
445
	 * Value is of type <code>String</code>.
446
	 * </p>
447
	 *
448
	 * @since 4.0
449
	 */	
450
	public static final String FORMATTER_PROFILE = "formatter_profile"; //$NON-NLS-1$
412
451
413
	/** 
452
	/** 
414
	 * Preference key for whether to ensure a newline at the end of files when saving.
453
	 * Preference key for whether to ensure a newline at the end of files when saving.
Lines 548-554 Link Here
548
587
549
		store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS, true);
588
		store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS, true);
550
		store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true);
589
		store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true);
590
		store.setDefault(PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS, true);
551
		store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACES, true);
591
		store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACES, true);
592
		store.setDefault(PreferenceConstants.EDITOR_SMART_PASTE, true);
593
		store.setDefault(PreferenceConstants.EDITOR_SMART_TAB, true);
552
		store.setDefault(PreferenceConstants.EDITOR_WRAP_STRINGS, true);
594
		store.setDefault(PreferenceConstants.EDITOR_WRAP_STRINGS, true);
553
		store.setDefault(PreferenceConstants.EDITOR_ESCAPE_STRINGS, false);
595
		store.setDefault(PreferenceConstants.EDITOR_ESCAPE_STRINGS, false);
554
		
596
		
(-)src/org/eclipse/cdt/internal/ui/preferences/IPreferenceConfigurationBlock.java (+64 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.preferences;
14
15
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.swt.widgets.Control;
17
18
19
/**
20
 * Interface for preference configuration blocks which can either be
21
 * wrapped by a {@link org.eclipse.cdt.internal.ui.preferences.AbstractConfigurationBlockPreferencePage}
22
 * or be included some preference page.
23
 * <p>
24
 * Clients may implement this interface.
25
 * </p>
26
 * 
27
 * @since 3.0
28
 */
29
public interface IPreferenceConfigurationBlock {
30
	
31
	/**
32
	 * Creates the preference control.
33
	 * 
34
	 * @param parent the parent composite to which to add the preferences control
35
	 * @return the control that was added to <code>parent</code> 
36
	 */
37
	Control createControl(Composite parent);
38
	
39
	/**
40
	 * Called after creating the control. Implementations should load the 
41
	 * preferences values and update the controls accordingly.
42
	 */
43
	void initialize();
44
	
45
	/**
46
	 * Called when the <code>OK</code> button is pressed on the preference
47
	 * page. Implementations should commit the configured preference settings
48
	 * into their form of preference storage.
49
	 */
50
	void performOk();
51
	
52
	/**
53
	 * Called when the <code>Defaults</code> button is pressed on the
54
	 * preference page. Implementation should reset any preference settings to
55
	 * their default values and adjust the controls accordingly.
56
	 */
57
	void performDefaults();
58
	
59
	/**
60
	 * Called when the preference page is being disposed. Implementations should
61
	 * free any resources they are holding on to.
62
	 */
63
	void dispose();
64
}
(-)src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java (+187 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.text;
13
14
import org.eclipse.jface.preference.IPreferenceStore;
15
16
import org.eclipse.jface.text.BadLocationException;
17
import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
18
import org.eclipse.jface.text.DocumentCommand;
19
import org.eclipse.jface.text.IDocument;
20
import org.eclipse.jface.text.ITypedRegion;
21
import org.eclipse.jface.text.TextUtilities;
22
23
import org.eclipse.ui.IEditorPart;
24
import org.eclipse.ui.IWorkbenchPage;
25
import org.eclipse.ui.texteditor.ITextEditorExtension3;
26
27
import org.eclipse.cdt.core.model.ICProject;
28
import org.eclipse.cdt.ui.CUIPlugin;
29
import org.eclipse.cdt.ui.PreferenceConstants;
30
31
/**
32
 * Auto indent strategy for C strings
33
 */
34
public class CStringAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
35
36
	private String fPartitioning;
37
	private final ICProject fProject;
38
39
	/**
40
	 * The input string doesn't contain any line delimiter.
41
	 *
42
	 * @param inputString the given input string
43
	 * @return the displayable string.
44
	 */
45
	private String displayString(String inputString, CharSequence indentation, String delimiter) {
46
		int length = inputString.length();
47
		StringBuffer buffer = new StringBuffer(length);
48
		java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(inputString, "\n\r", true); //$NON-NLS-1$
49
		while (tokenizer.hasMoreTokens()) {
50
			String token = tokenizer.nextToken();
51
			if (token.equals("\r")) { //$NON-NLS-1$
52
				buffer.append("\\r"); //$NON-NLS-1$
53
				if (tokenizer.hasMoreTokens()) {
54
					token = tokenizer.nextToken();
55
					if (token.equals("\n")) { //$NON-NLS-1$
56
						buffer.append("\\n"); //$NON-NLS-1$
57
						buffer.append("\"" + delimiter); //$NON-NLS-1$
58
						buffer.append(indentation);
59
						buffer.append("\""); //$NON-NLS-1$
60
						continue;
61
					} else {
62
						buffer.append("\"" + delimiter); //$NON-NLS-1$
63
						buffer.append(indentation);
64
						buffer.append("\""); //$NON-NLS-1$
65
					}
66
				} else {
67
					continue;
68
				}
69
			} else if (token.equals("\n")) { //$NON-NLS-1$
70
				buffer.append("\\n"); //$NON-NLS-1$
71
				buffer.append("\"" + delimiter); //$NON-NLS-1$
72
				buffer.append(indentation);
73
				buffer.append("\""); //$NON-NLS-1$
74
				continue;
75
			}
76
77
			StringBuffer tokenBuffer = new StringBuffer();
78
			for (int i = 0; i < token.length(); i++){
79
				char c = token.charAt(i);
80
				switch (c) {
81
					case '\r' :
82
						tokenBuffer.append("\\r"); //$NON-NLS-1$
83
						break;
84
					case '\n' :
85
						tokenBuffer.append("\\n"); //$NON-NLS-1$
86
						break;
87
					case '\b' :
88
						tokenBuffer.append("\\b"); //$NON-NLS-1$
89
						break;
90
					case '\t' :
91
						// keep tabs verbatim
92
						tokenBuffer.append("\t"); //$NON-NLS-1$
93
						break;
94
					case '\f' :
95
						tokenBuffer.append("\\f"); //$NON-NLS-1$
96
						break;
97
					case '\"' :
98
						tokenBuffer.append("\\\""); //$NON-NLS-1$
99
						break;
100
					case '\'' :
101
						tokenBuffer.append("\\'"); //$NON-NLS-1$
102
						break;
103
					case '\\' :
104
						tokenBuffer.append("\\\\"); //$NON-NLS-1$
105
						break;
106
					default :
107
						tokenBuffer.append(c);
108
				}
109
			}
110
			buffer.append(tokenBuffer);
111
		}
112
		return buffer.toString();
113
	}
114
115
	/**
116
	 * Creates a new C string auto indent strategy for the given document partitioning.
117
	 *
118
	 * @param partitioning the document partitioning
119
	 */
120
	public CStringAutoIndentStrategy(String partitioning, ICProject project) {
121
		super();
122
		fPartitioning = partitioning;
123
		fProject = project;
124
	}
125
126
	private boolean isLineDelimiter(IDocument document, String text) {
127
		String[] delimiters= document.getLegalLineDelimiters();
128
		if (delimiters != null)
129
			return TextUtilities.equals(delimiters, text) > -1;
130
		return false;
131
	}
132
133
	private String getModifiedText(String string, CharSequence indentation, String delimiter) {
134
		return displayString(string, indentation, delimiter);
135
	}
136
137
	private void indentStringAfterNewLine(IDocument document, DocumentCommand command) throws BadLocationException {
138
		ITypedRegion partition= TextUtilities.getPartition(document, fPartitioning, command.offset, true);
139
		int offset= partition.getOffset();
140
		int length= partition.getLength();
141
142
		if (command.offset == offset + length && document.getChar(offset + length - 1) == '\"')
143
			return;
144
		
145
		CHeuristicScanner scanner = new CHeuristicScanner(document);
146
		CIndenter indenter = new CIndenter(document, scanner, fProject);
147
		StringBuffer indentation = indenter.computeContinuationLineIndentation(offset);
148
		if (indentation == null)
149
			indentation = new StringBuffer(); 
150
151
		String delimiter= TextUtilities.getDefaultLineDelimiter(document);
152
		IPreferenceStore preferenceStore= CUIPlugin.getDefault().getPreferenceStore();
153
		if (isLineDelimiter(document, command.text))
154
			command.text= "\"" + command.text + indentation + "\"";  //$NON-NLS-1$//$NON-NLS-2$
155
		else if (command.text.length() > 1 && preferenceStore.getBoolean(PreferenceConstants.EDITOR_ESCAPE_STRINGS))
156
			command.text= getModifiedText(command.text, indentation, delimiter);
157
	}
158
159
	private boolean isSmartMode() {
160
		IWorkbenchPage page= CUIPlugin.getActivePage();
161
		if (page != null)  {
162
			IEditorPart part= page.getActiveEditor();
163
			if (part instanceof ITextEditorExtension3) {
164
				ITextEditorExtension3 extension= (ITextEditorExtension3) part;
165
				return extension.getInsertMode() == ITextEditorExtension3.SMART_INSERT;
166
			}
167
		}
168
		return false;
169
	}
170
171
	/*
172
	 * @see org.eclipse.jface.text.IAutoIndentStrategy#customizeDocumentCommand(IDocument, DocumentCommand)
173
	 */
174
	public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
175
		try {
176
			if (command.length != 0 || command.text == null)
177
				return;
178
179
			IPreferenceStore preferenceStore= CUIPlugin.getDefault().getPreferenceStore();
180
181
			if (preferenceStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS) && isSmartMode()) {
182
				indentStringAfterNewLine(document, command);
183
			}
184
		} catch (BadLocationException e) {
185
		}
186
	}
187
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileStore.java (+427 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.preferences.formatter;
14
15
import java.io.ByteArrayInputStream;
16
import java.io.ByteArrayOutputStream;
17
import java.io.File;
18
import java.io.FileInputStream;
19
import java.io.FileOutputStream;
20
import java.io.FileReader;
21
import java.io.IOException;
22
import java.io.InputStream;
23
import java.io.OutputStream;
24
import java.io.UnsupportedEncodingException;
25
import java.util.ArrayList;
26
import java.util.Collection;
27
import java.util.Collections;
28
import java.util.HashMap;
29
import java.util.Iterator;
30
import java.util.List;
31
import java.util.Map;
32
33
import javax.xml.parsers.DocumentBuilder;
34
import javax.xml.parsers.DocumentBuilderFactory;
35
import javax.xml.parsers.ParserConfigurationException;
36
import javax.xml.parsers.SAXParser;
37
import javax.xml.parsers.SAXParserFactory;
38
import javax.xml.transform.OutputKeys;
39
import javax.xml.transform.Transformer;
40
import javax.xml.transform.TransformerException;
41
import javax.xml.transform.TransformerFactory;
42
import javax.xml.transform.dom.DOMSource;
43
import javax.xml.transform.stream.StreamResult;
44
45
import org.eclipse.core.runtime.CoreException;
46
import org.eclipse.core.runtime.IStatus;
47
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
48
import org.eclipse.core.runtime.preferences.IScopeContext;
49
50
import org.eclipse.core.resources.IProject;
51
import org.eclipse.core.resources.ResourcesPlugin;
52
53
import org.eclipse.cdt.core.CCorePlugin;
54
55
import org.eclipse.cdt.ui.CUIPlugin;
56
import org.eclipse.cdt.internal.ui.CUIException;
57
import org.eclipse.cdt.internal.ui.CUIStatus;
58
import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
59
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
60
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
61
62
import org.osgi.service.prefs.BackingStoreException;
63
import org.w3c.dom.Document;
64
import org.w3c.dom.Element;
65
import org.xml.sax.Attributes;
66
import org.xml.sax.InputSource;
67
import org.xml.sax.SAXException;
68
import org.xml.sax.helpers.DefaultHandler;
69
70
71
72
public class ProfileStore {
73
	
74
	/**
75
	 * A SAX event handler to parse the xml format for profiles. 
76
	 */
77
	private final static class ProfileDefaultHandler extends DefaultHandler {
78
		
79
		private List fProfiles;
80
		private int fVersion;
81
		
82
		private String fName;
83
		private Map fSettings;
84
85
86
		public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
87
88
			if (qName.equals(XML_NODE_SETTING)) {
89
90
				final String key= attributes.getValue(XML_ATTRIBUTE_ID);
91
				final String value= attributes.getValue(XML_ATTRIBUTE_VALUE);
92
				fSettings.put(key, value);
93
94
			} else if (qName.equals(XML_NODE_PROFILE)) {
95
96
				fName= attributes.getValue(XML_ATTRIBUTE_NAME);
97
				fSettings= new HashMap(200);
98
99
			}
100
			else if (qName.equals(XML_NODE_ROOT)) {
101
102
				fProfiles= new ArrayList();
103
				try {
104
					fVersion= Integer.parseInt(attributes.getValue(XML_ATTRIBUTE_VERSION));
105
				} catch (NumberFormatException ex) {
106
					throw new SAXException(ex);
107
				}
108
109
			}
110
		}
111
		
112
		public void endElement(String uri, String localName, String qName) {
113
			if (qName.equals(XML_NODE_PROFILE)) {
114
				fProfiles.add(new CustomProfile(fName, fSettings, fVersion));
115
				fName= null;
116
				fSettings= null;
117
			}
118
		}
119
		
120
		public List getProfiles() {
121
			return fProfiles;
122
		}
123
		
124
	}
125
126
	/**
127
	 * Preference key where all profiles are stored
128
	 */
129
	private static final String PREF_FORMATTER_PROFILES= "org.eclipse.cdt.ui.formatterprofiles"; //$NON-NLS-1$
130
	
131
	/**
132
	 * Preference key where all profiles are stored
133
	 */
134
	private static final String PREF_FORMATTER_PROFILES_VERSION= "org.eclipse.cdt.ui.formatterprofiles.version"; //$NON-NLS-1$
135
	
136
	
137
	/**
138
	 * Identifiers for the XML file.
139
	 */
140
	private final static String XML_NODE_ROOT= "profiles"; //$NON-NLS-1$
141
	private final static String XML_NODE_PROFILE= "profile"; //$NON-NLS-1$
142
	private final static String XML_NODE_SETTING= "setting"; //$NON-NLS-1$
143
	
144
	private final static String XML_ATTRIBUTE_VERSION= "version"; //$NON-NLS-1$
145
	private final static String XML_ATTRIBUTE_ID= "id"; //$NON-NLS-1$
146
	private final static String XML_ATTRIBUTE_NAME= "name"; //$NON-NLS-1$
147
	private final static String XML_ATTRIBUTE_VALUE= "value"; //$NON-NLS-1$
148
		
149
	private ProfileStore() {
150
	}
151
	
152
	/**
153
	 * @return Returns the collection of profiles currently stored in the preference store or
154
	 * <code>null</code> if the loading failed. The elements are of type {@link CustomProfile}
155
	 * and are all updated to the latest version.
156
	 * @throws CoreException
157
	 */
158
	public static List readProfiles(IScopeContext scope) throws CoreException {
159
		List res= readProfilesFromPreferences(scope);
160
		if (res == null) {
161
			return readOldForCompatibility(scope);
162
		}
163
		return res;
164
	}
165
	
166
	public static void writeProfiles(Collection profiles, IScopeContext instanceScope) throws CoreException {
167
		ByteArrayOutputStream stream= new ByteArrayOutputStream(2000);
168
		try {
169
			writeProfilesToStream(profiles, stream);
170
			String val;
171
			try {
172
				val= stream.toString("UTF-8"); //$NON-NLS-1$
173
			} catch (UnsupportedEncodingException e) {
174
				val= stream.toString(); 
175
			}
176
			IEclipsePreferences uiPreferences = instanceScope.getNode(CUIPlugin.PLUGIN_ID);
177
			uiPreferences.put(PREF_FORMATTER_PROFILES, val);
178
			uiPreferences.putInt(PREF_FORMATTER_PROFILES_VERSION, ProfileVersioner.CURRENT_VERSION);
179
		} finally {
180
			try { stream.close(); } catch (IOException e) { /* ignore */ }
181
		}
182
	}
183
	
184
	public static List readProfilesFromPreferences(IScopeContext scope) throws CoreException {
185
		String string= scope.getNode(CUIPlugin.PLUGIN_ID).get(PREF_FORMATTER_PROFILES, null);
186
		if (string != null && string.length() > 0) {
187
			byte[] bytes;
188
			try {
189
				bytes= string.getBytes("UTF-8"); //$NON-NLS-1$
190
			} catch (UnsupportedEncodingException e) {
191
				bytes= string.getBytes();
192
			}
193
			InputStream is= new ByteArrayInputStream(bytes);
194
			try {
195
				List res= readProfilesFromStream(new InputSource(is));
196
				if (res != null) {
197
					for (int i= 0; i < res.size(); i++) {
198
						ProfileVersioner.updateAndComplete((CustomProfile) res.get(i));
199
					}
200
				}
201
				return res;
202
			} finally {
203
				try { is.close(); } catch (IOException e) { /* ignore */ }
204
			}
205
		}
206
		return null;
207
	}	
208
209
	/**
210
	 * Read the available profiles from the internal XML file and return them
211
	 * as collection.
212
	 * @return returns a list of <code>CustomProfile</code> or <code>null</code>
213
	 */
214
	private static List readOldForCompatibility(IScopeContext instanceScope) {
215
		
216
		// in 3.0 M9 and less the profiles were stored in a file in the plugin's meta data
217
		final String STORE_FILE= "code_formatter_profiles.xml"; //$NON-NLS-1$
218
219
		File file= CUIPlugin.getDefault().getStateLocation().append(STORE_FILE).toFile();
220
		if (!file.exists())
221
			return null;
222
		
223
		try {
224
			// note that it's wrong to use a file reader when XML declares UTF-8: Kept for compatibility
225
			final FileReader reader= new FileReader(file);
226
			try {
227
				List res= readProfilesFromStream(new InputSource(reader));
228
				if (res != null) {
229
					for (int i= 0; i < res.size(); i++) {
230
						ProfileVersioner.updateAndComplete((CustomProfile) res.get(i));
231
					}
232
					writeProfiles(res, instanceScope);
233
				}
234
				file.delete(); // remove after successful write
235
				return res;
236
			} finally {
237
				reader.close();
238
			}
239
		} catch (CoreException e) {
240
			CUIPlugin.getDefault().log(e); // log but ignore
241
		} catch (IOException e) {
242
			CUIPlugin.getDefault().log(e); // log but ignore
243
		}
244
		return null;
245
	}
246
	
247
	
248
	/**
249
	 * Read the available profiles from the internal XML file and return them
250
	 * as collection or <code>null</code> if the file is not a profile file.
251
	 * @param file The file to read from
252
	 * @return returns a list of <code>CustomProfile</code> or <code>null</code>
253
	 * @throws CoreException
254
	 */
255
	public static List readProfilesFromFile(File file) throws CoreException {
256
		try {
257
			final FileInputStream reader= new FileInputStream(file); 
258
			try {
259
				return readProfilesFromStream(new InputSource(reader));
260
			} finally {
261
				try { reader.close(); } catch (IOException e) { /* ignore */ }
262
			}
263
		} catch (IOException e) {
264
			throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);  
265
		}
266
	}
267
	
268
	/**
269
	 * Load profiles from a XML stream and add them to a map or <code>null</code> if the source is not a profile store.
270
	 * @param inputSource The input stream
271
	 * @return returns a list of <code>CustomProfile</code> or <code>null</code>
272
	 * @throws CoreException
273
	 */
274
	private static List readProfilesFromStream(InputSource inputSource) throws CoreException {
275
		
276
		final ProfileDefaultHandler handler= new ProfileDefaultHandler();
277
		try {
278
		    final SAXParserFactory factory= SAXParserFactory.newInstance();
279
			final SAXParser parser= factory.newSAXParser();
280
			parser.parse(inputSource, handler);
281
		} catch (SAXException e) {
282
			throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);  
283
		} catch (IOException e) {
284
			throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);  
285
		} catch (ParserConfigurationException e) {
286
			throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_reading_xml_message);  
287
		}
288
		return handler.getProfiles();
289
	}
290
	
291
	/**
292
	 * Write the available profiles to the internal XML file.
293
	 * @param profiles List of <code>CustomProfile</code>
294
	 * @param file File to write
295
	 * @throws CoreException
296
	 */
297
	public static void writeProfilesToFile(Collection profiles, File file) throws CoreException {
298
		final OutputStream writer;
299
		try {
300
			writer= new FileOutputStream(file);
301
			try {
302
				writeProfilesToStream(profiles, writer);
303
			} finally {
304
				try { writer.close(); } catch (IOException e) { /* ignore */ }
305
			}
306
		} catch (IOException e) {
307
			throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);  
308
		}
309
	}
310
	
311
	/**
312
	 * Save profiles to an XML stream
313
	 * @param profiles List of <code>CustomProfile</code>
314
	 * @param stream Stream to write
315
	 * @throws CoreException
316
	 */
317
	private static void writeProfilesToStream(Collection profiles, OutputStream stream) throws CoreException {
318
319
		try {
320
			final DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance();
321
			final DocumentBuilder builder= factory.newDocumentBuilder();		
322
			final Document document= builder.newDocument();
323
			
324
			final Element rootElement = document.createElement(XML_NODE_ROOT);
325
			rootElement.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(ProfileVersioner.CURRENT_VERSION));
326
327
			document.appendChild(rootElement);
328
			
329
			for(final Iterator iter= profiles.iterator(); iter.hasNext();) {
330
				final Profile profile= (Profile)iter.next();
331
				if (profile.isProfileToSave()) {
332
					final Element profileElement= createProfileElement(profile, document);
333
					rootElement.appendChild(profileElement);
334
				}
335
			}
336
337
			Transformer transformer=TransformerFactory.newInstance().newTransformer();
338
			transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
339
			transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
340
			transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
341
			transformer.transform(new DOMSource(document), new StreamResult(stream));
342
		} catch (TransformerException e) {
343
			throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);  
344
		} catch (ParserConfigurationException e) {
345
			throw createException(e, FormatterMessages.CodingStyleConfigurationBlock_error_serializing_xml_message);  
346
		}
347
	}
348
349
	
350
	/*
351
	 * Create a new profile element in the specified document. The profile is not added
352
	 * to the document by this method. 
353
	 */
354
	private static Element createProfileElement(Profile profile, Document document) {
355
		final Element element= document.createElement(XML_NODE_PROFILE);
356
		element.setAttribute(XML_ATTRIBUTE_NAME, profile.getName());
357
		element.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profile.getVersion()));
358
		
359
		final Iterator keyIter= ProfileManager.getKeys().iterator();
360
		
361
		while (keyIter.hasNext()) {
362
			final String key= (String)keyIter.next();
363
			final String value= (String)profile.getSettings().get(key);
364
			if (value != null) {
365
				final Element setting= document.createElement(XML_NODE_SETTING);
366
				setting.setAttribute(XML_ATTRIBUTE_ID, key);
367
				setting.setAttribute(XML_ATTRIBUTE_VALUE, value);
368
				element.appendChild(setting);
369
			} else {
370
				CUIPlugin.getDefault().logErrorMessage("ProfileStore: Profile does not contain value for key " + key); //$NON-NLS-1$
371
			}
372
		}
373
		return element;
374
	}
375
	
376
	public static void checkCurrentOptionsVersion() {
377
		PreferencesAccess access= PreferencesAccess.getOriginalPreferences();
378
		
379
		IScopeContext instanceScope= access.getInstanceScope();
380
		IEclipsePreferences uiPreferences= instanceScope.getNode(CUIPlugin.PLUGIN_ID);
381
		int version= uiPreferences.getInt(PREF_FORMATTER_PROFILES_VERSION, 0);
382
		if (version >= ProfileVersioner.CURRENT_VERSION) {
383
			return; // is up to date
384
		}
385
		try {
386
			List profiles= ProfileStore.readProfiles(instanceScope);
387
			if (profiles == null) {
388
				profiles= Collections.EMPTY_LIST;
389
			}
390
			ProfileManager manager= new ProfileManager(profiles, instanceScope, access);
391
			if (manager.getSelected() instanceof CustomProfile) {
392
				manager.commitChanges(instanceScope); // updates CCorePlugin options
393
			}
394
			uiPreferences.putInt(PREF_FORMATTER_PROFILES_VERSION, ProfileVersioner.CURRENT_VERSION);
395
			savePreferences(instanceScope);
396
						
397
			IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
398
			for (int i= 0; i < projects.length; i++) {
399
				IScopeContext scope= access.getProjectScope(projects[i]);
400
				if (ProfileManager.hasProjectSpecificSettings(scope)) {
401
					manager= new ProfileManager(profiles, scope, access);
402
					manager.commitChanges(scope); // updates CCorePlugin project options
403
					savePreferences(scope);
404
				}
405
			}
406
		} catch (CoreException e) {
407
			CUIPlugin.getDefault().log(e);
408
		} catch (BackingStoreException e) {
409
			CUIPlugin.getDefault().log(e);
410
		}
411
	}
412
	
413
	private static void savePreferences(final IScopeContext context) throws BackingStoreException {
414
		try {
415
			context.getNode(CUIPlugin.PLUGIN_ID).flush();
416
		} finally {
417
			context.getNode(CCorePlugin.PLUGIN_ID).flush();
418
		}
419
	}
420
	
421
	/*
422
	 * Creates a UI exception for logging purposes
423
	 */
424
	private static CUIException createException(Throwable t, String message) {
425
		return new CUIException(CUIStatus.createError(IStatus.ERROR, message, t));
426
	}
427
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/CreateProfileDialog.java (+197 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.preferences.formatter;
13
14
import java.util.HashMap;
15
import java.util.List;
16
import java.util.Map;
17
18
import org.eclipse.core.runtime.IStatus;
19
20
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.events.ModifyEvent;
22
import org.eclipse.swt.events.ModifyListener;
23
import org.eclipse.swt.events.SelectionEvent;
24
import org.eclipse.swt.events.SelectionListener;
25
import org.eclipse.swt.layout.GridData;
26
import org.eclipse.swt.layout.GridLayout;
27
import org.eclipse.swt.widgets.Button;
28
import org.eclipse.swt.widgets.Combo;
29
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Control;
31
import org.eclipse.swt.widgets.Label;
32
import org.eclipse.swt.widgets.Shell;
33
import org.eclipse.swt.widgets.Text;
34
35
import org.eclipse.jface.dialogs.IDialogConstants;
36
import org.eclipse.jface.dialogs.IDialogSettings;
37
import org.eclipse.jface.dialogs.StatusDialog;
38
39
import org.eclipse.cdt.ui.CUIPlugin;
40
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
41
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
42
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
43
44
/**
45
 * The dialog to create a new profile. 
46
 */
47
public class CreateProfileDialog extends StatusDialog {
48
    
49
    private static final String PREF_OPEN_EDIT_DIALOG= CUIPlugin.PLUGIN_ID + ".codeformatter.create_profile_dialog.open_edit"; //$NON-NLS-1$
50
    
51
	private Text fNameText;
52
	private Combo fProfileCombo;
53
	private Button fEditCheckbox;
54
	
55
	private final static StatusInfo fOk= new StatusInfo();
56
	private final static StatusInfo fEmpty= new StatusInfo(IStatus.ERROR, FormatterMessages.CreateProfileDialog_status_message_profile_name_is_empty); 
57
	private final static StatusInfo fDuplicate= new StatusInfo(IStatus.ERROR, FormatterMessages.CreateProfileDialog_status_message_profile_with_this_name_already_exists); 
58
59
	private final ProfileManager fProfileManager;
60
	private final List fSortedProfiles;
61
	private final String [] fSortedNames;
62
	
63
	private CustomProfile fCreatedProfile;
64
	protected boolean fOpenEditDialog;
65
	
66
	public CreateProfileDialog(Shell parentShell, ProfileManager profileManager) {
67
		super(parentShell);
68
		fProfileManager= profileManager;
69
		fSortedProfiles= fProfileManager.getSortedProfiles();
70
		fSortedNames= fProfileManager.getSortedDisplayNames();
71
	}
72
	
73
	
74
	public void create() {
75
		super.create();
76
		setTitle(FormatterMessages.CreateProfileDialog_dialog_title); 
77
	}
78
	
79
	public Control createDialogArea(Composite parent) {
80
				
81
		final int numColumns= 2;
82
		
83
		GridData gd;
84
		
85
		final GridLayout layout= new GridLayout(numColumns, false);
86
		layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
87
		layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
88
		layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
89
		layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
90
91
		final Composite composite= new Composite(parent, SWT.NONE);
92
		composite.setLayout(layout);
93
		
94
		// Create "Profile name:" label
95
		gd = new GridData(GridData.FILL_HORIZONTAL);
96
		gd.horizontalSpan = numColumns;
97
		gd.widthHint= convertWidthInCharsToPixels(60);
98
		final Label nameLabel = new Label(composite, SWT.WRAP);
99
		nameLabel.setText(FormatterMessages.CreateProfileDialog_profile_name_label_text); 
100
		nameLabel.setLayoutData(gd);
101
		
102
		// Create text field to enter name
103
		gd = new GridData( GridData.FILL_HORIZONTAL);
104
		gd.horizontalSpan= numColumns;
105
		fNameText= new Text(composite, SWT.SINGLE | SWT.BORDER);
106
		fNameText.setLayoutData(gd);
107
		fNameText.addModifyListener( new ModifyListener() {
108
			public void modifyText(ModifyEvent e) {
109
				doValidation();
110
			}
111
		});
112
		
113
		// Create "Initialize settings ..." label
114
		gd = new GridData();
115
		gd.horizontalSpan = numColumns;
116
		Label profileLabel = new Label(composite, SWT.WRAP);
117
		profileLabel.setText(FormatterMessages.CreateProfileDialog_base_profile_label_text); 
118
		profileLabel.setLayoutData(gd);
119
		
120
		gd= new GridData(GridData.FILL_HORIZONTAL);
121
		gd.horizontalSpan= numColumns;
122
		fProfileCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
123
		fProfileCombo.setLayoutData(gd);
124
		
125
		
126
		// "Open the edit dialog now" checkbox
127
		gd= new GridData();
128
		gd.horizontalSpan= numColumns;
129
		fEditCheckbox= new Button(composite, SWT.CHECK);
130
		fEditCheckbox.setText(FormatterMessages.CreateProfileDialog_open_edit_dialog_checkbox_text); 
131
		fEditCheckbox.addSelectionListener(new SelectionListener() {
132
			public void widgetSelected(SelectionEvent e) {
133
				fOpenEditDialog= ((Button)e.widget).getSelection();
134
			}
135
			public void widgetDefaultSelected(SelectionEvent e) {
136
			}
137
		});
138
		
139
		final IDialogSettings dialogSettings= CUIPlugin.getDefault().getDialogSettings();//.get(PREF_OPEN_EDIT_DIALOG);
140
		if (dialogSettings.get(PREF_OPEN_EDIT_DIALOG) != null) {
141
		    fOpenEditDialog= dialogSettings.getBoolean(PREF_OPEN_EDIT_DIALOG);
142
		} else {
143
		    fOpenEditDialog= true;
144
		}
145
		fEditCheckbox.setSelection(fOpenEditDialog);
146
		
147
		fProfileCombo.setItems(fSortedNames);
148
		fProfileCombo.setText(fProfileManager.getProfile(ProfileManager.DEFAULT_PROFILE).getName());
149
		updateStatus(fEmpty);
150
		
151
		applyDialogFont(composite);
152
		
153
		fNameText.setFocus();
154
		
155
		return composite;
156
	}
157
158
159
	/**
160
	 * Validate the current settings
161
	 */
162
	protected void doValidation() {
163
		final String name= fNameText.getText().trim();
164
		
165
		if (fProfileManager.containsName(name)) {
166
			updateStatus(fDuplicate);
167
			return;
168
		}
169
		if (name.length() == 0) {
170
			updateStatus(fEmpty);
171
			return;
172
		}
173
		updateStatus(fOk);
174
	}
175
	
176
	protected void okPressed() {
177
		if (!getStatus().isOK()) 
178
			return;
179
180
		CUIPlugin.getDefault().getDialogSettings().put(PREF_OPEN_EDIT_DIALOG, fOpenEditDialog);
181
182
		final Map baseSettings= new HashMap(((Profile)fSortedProfiles.get(fProfileCombo.getSelectionIndex())).getSettings());
183
		final String profileName= fNameText.getText();
184
		
185
		fCreatedProfile= new CustomProfile(profileName, baseSettings, ProfileVersioner.CURRENT_VERSION);
186
		fProfileManager.addProfile(fCreatedProfile);
187
		super.okPressed();
188
	}
189
	
190
	public final CustomProfile getCreatedProfile() {
191
		return fCreatedProfile;
192
	}
193
	
194
	public final boolean openEditDialog() {
195
		return fOpenEditDialog;
196
	}
197
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.properties (+537 lines)
Added Link Here
1
###############################################################################
2
# Copyright (c) 2000, 2006 IBM Corporation and others.
3
# All rights reserved. This program and the accompanying materials
4
# are made available under the terms of the Eclipse Public License v1.0
5
# which accompanies this distribution, and is available at
6
# http://www.eclipse.org/legal/epl-v10.html
7
#
8
# Contributors:
9
#     IBM Corporation - initial API and implementation
10
#     istvan@benedek-home.de - 103706 [formatter] indent empty lines
11
#     Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting Unnamed profile fails silently
12
#     Sergey Prigogin, Google
13
###############################################################################
14
15
16
#WhiteSpaceTabPage_assignments=Assignments
17
#WhiteSpaceTabPage_assignments_before_assignment_operator=before assignment operator
18
#WhiteSpaceTabPage_assignments_after_assignment_operator=after assignment operator
19
20
#WhiteSpaceTabPage_operators=Operators
21
#WhiteSpaceTabPage_operators_before_binary_operators=before binary operators
22
#WhiteSpaceTabPage_operators_after_binary_operators=after binary operators
23
#WhiteSpaceTabPage_operators_before_unary_operators=before unary operators
24
#WhiteSpaceTabPage_operators_after_unary_operators=after unary operators
25
#WhiteSpaceTabPage_operators_before_prefix_operators=before prefix operators
26
#WhiteSpaceTabPage_operators_after_prefix_operators=after prefix operators
27
#WhiteSpaceTabPage_operators_before_postfix_operators=before postfix operators
28
#WhiteSpaceTabPage_operators_after_postfix_operators=after postfix operators
29
30
#WhiteSpaceTabPage_classes=Classes
31
#WhiteSpaceTabPage_classes_before_opening_brace_of_a_class=before opening brace of a class
32
#WhiteSpaceTabPage_classes_before_opening_brace_of_anon_class=before opening brace of an anonymous class
33
#WhiteSpaceTabPage_classes_before_comma_implements=before comma in implements clause
34
#WhiteSpaceTabPage_classes_after_comma_implements=after comma in implements clause
35
36
#WhiteSpaceTabPage_methods=Methods
37
#WhiteSpaceTabPage_constructors=Constructors
38
39
#WhiteSpaceTabPage_fields=Fields
40
#WhiteSpaceTabPage_fields_before_comma=before comma in multiple field declarations
41
#WhiteSpaceTabPage_fields_after_comma=after comma in multiple field declarations
42
43
#WhiteSpaceTabPage_localvars=Local variables
44
#WhiteSpaceTabPage_localvars_before_comma=before comma in multiple local declarations
45
#WhiteSpaceTabPage_localvars_after_comma=after comma in multiple local declarations
46
47
#WhiteSpaceTabPage_arrayinit=Array initializers
48
#WhiteSpaceTabPage_arraydecls=Array declarations
49
#WhiteSpaceTabPage_arrayelem=Array element access
50
#WhiteSpaceTabPage_arrayalloc=Array allocation
51
52
#WhiteSpaceTabPage_calls=Function invocations
53
54
#WhiteSpaceTabPage_calls_before_comma_in_method_args=before comma in method arguments
55
#WhiteSpaceTabPage_calls_after_comma_in_method_args=after comma in method arguments
56
#WhiteSpaceTabPage_calls_before_comma_in_alloc=before comma in object allocation arguments
57
#WhiteSpaceTabPage_calls_after_comma_in_alloc=after comma in object allocation arguments
58
#WhiteSpaceTabPage_calls_before_comma_in_qalloc=before comma in explicit constructor call
59
#WhiteSpaceTabPage_calls_after_comma_in_qalloc=after comma in explicit constructor call
60
61
#WhiteSpaceTabPage_statements=Control statements
62
63
#WhiteSpaceTabPage_blocks=Blocks
64
65
#WhiteSpaceTabPage_switch='switch'
66
#WhiteSpaceTabPage_switch_before_case_colon=before colon in case
67
#WhiteSpaceTabPage_switch_before_default_colon=before colon in default
68
69
#WhiteSpaceTabPage_do='while' & 'do while'
70
71
#WhiteSpaceTabPage_synchronized='synchronized'
72
73
#WhiteSpaceTabPage_try='catch'
74
75
#WhiteSpaceTabPage_if='if else'
76
#WhiteSpaceTabPage_assert='assert'
77
78
#WhiteSpaceTabPage_for='for'
79
#WhiteSpaceTabPage_for_before_comma_init=before comma in initialization
80
#WhiteSpaceTabPage_for_after_comma_init=after comma in initialization
81
#WhiteSpaceTabPage_for_before_comma_inc=before comma in increments
82
#WhiteSpaceTabPage_for_after_comma_inc=after comma in increments
83
84
85
#WhiteSpaceTabPage_labels=Labels
86
#WhiteSpaceTabPage_annotations=Annotations
87
#WhiteSpaceTabPage_annotation_types=Annotation types
88
#WhiteSpaceTabPage_enums=Enum types
89
#WhiteSpaceTabPage_wildcardtype=Wildcard type
90
#WhiteSpaceTabPage_param_type_ref=Type reference
91
#WhiteSpaceTabPage_type_arguments=Type arguments
92
#WhiteSpaceTabPage_type_parameters=Type parameters
93
94
#WhiteSpaceTabPage_conditionals=Conditionals
95
96
#WhiteSpaceTabPage_typecasts=Type casts
97
98
#WhiteSpaceTabPage_parenexpr=Parenthesized expressions
99
#WhiteSpaceTabPage_declarations=Declarations
100
#WhiteSpaceTabPage_expressions=Expressions
101
#WhiteSpaceTabPage_arrays=Arrays
102
#WhiteSpaceTabPage_parameterized_types=Parameterized types
103
104
#WhiteSpaceTabPage_after_opening_brace=after opening brace
105
#WhiteSpaceTabPage_after_closing_brace=after closing brace
106
#WhiteSpaceTabPage_before_opening_brace=before opening brace
107
#WhiteSpaceTabPage_before_closing_brace=before closing brace
108
#WhiteSpaceTabPage_between_empty_braces=between empty braces
109
110
111
#WhiteSpaceTabPage_after_opening_paren=after opening parenthesis
112
#WhiteSpaceTabPage_after_closing_paren=after closing parenthesis
113
#WhiteSpaceTabPage_before_opening_paren=before opening parenthesis
114
#WhiteSpaceTabPage_before_closing_paren=before closing parenthesis
115
#WhiteSpaceTabPage_between_empty_parens=between empty parenthesis
116
117
#WhiteSpaceTabPage_after_opening_bracket=after opening bracket
118
#WhiteSpaceTabPage_before_opening_bracket=before opening bracket
119
#WhiteSpaceTabPage_before_closing_bracket=before closing bracket
120
#WhiteSpaceTabPage_between_empty_brackets=between empty brackets
121
122
#WhiteSpaceTabPage_before_comma_in_params=before comma in parameters
123
#WhiteSpaceTabPage_after_comma_in_params=after comma in parameters
124
#WhiteSpaceTabPage_before_comma_in_throws=before comma in 'throws' clause
125
#WhiteSpaceTabPage_after_comma_in_throws=after comma in 'throws' clause
126
127
#WhiteSpaceTabPage_before_ellipsis=before ellipsis in vararg parameters
128
#WhiteSpaceTabPage_after_ellipsis=after ellipsis in vararg parameters
129
130
#WhiteSpaceTabPage_before_comma=before comma
131
#WhiteSpaceTabPage_after_comma=after comma
132
133
#WhiteSpaceTabPage_after_semicolon=after semicolon
134
#WhiteSpaceTabPage_before_semicolon=before semicolon
135
136
#WhiteSpaceTabPage_before_colon=before colon
137
#WhiteSpaceTabPage_after_colon=after colon
138
139
#WhiteSpaceTabPage_before_question=before question mark
140
#WhiteSpaceTabPage_after_question=after question mark
141
142
#WhiteSpaceTabPage_before_at=before @
143
#WhiteSpaceTabPage_after_at=after @
144
145
#WhiteSpaceTabPage_after_opening_angle_bracket=after opening angle bracket
146
#WhiteSpaceTabPage_after_closing_angle_bracket=after closing angle bracket
147
#WhiteSpaceTabPage_before_opening_angle_bracket=before opening angle bracket
148
#WhiteSpaceTabPage_before_closing_angle_bracket=before closing angle bracket
149
#WhiteSpaceTabPage_before_parenthesized_expressions=before parenthesized expressions
150
151
#WhiteSpaceTabPage_before_and_list=before '&' in type bounds
152
#WhiteSpaceTabPage_after_and_list=after '&' in type bounds
153
154
#WhiteSpaceTabPage_enum_decl_before_opening_brace=before opening brace in declaration
155
#WhiteSpaceTabPage_enum_decl_before_comma=before comma between constants
156
#WhiteSpaceTabPage_enum_decl_after_comma=after comma between constants
157
158
#WhiteSpaceTabPage_enum_const_arg_before_opening_paren=before opening parenthesis in constant arguments
159
#WhiteSpaceTabPage_enum_const_arg_after_opening_paren=after opening parenthesis in constant arguments
160
#WhiteSpaceTabPage_enum_const_arg_between_empty_parens=between empty parenthesis in constant arguments
161
#WhiteSpaceTabPage_enum_const_arg_before_comma=before comma in constant arguments
162
#WhiteSpaceTabPage_enum_const_arg_after_comma=after comma in constant arguments
163
#WhiteSpaceTabPage_enum_const_arg_before_closing_paren=before closing parenthesis in constant arguments
164
165
#WhiteSpaceTabPage_enum_const_before_opening_brace=before opening brace of constant body
166
167
#WhiteSpaceTabPage_annot_type_method_before_opening_paren=before opening parenthesis in annotation type members
168
#WhiteSpaceTabPage_annot_type_method_between_empty_parens=between parenthesis in annotation type members
169
170
#WhiteSpaceTabPage_sort_by_c_element=Sort options by C element
171
#WhiteSpaceTabPage_sort_by_syntax_element=Sort options by Syntax element
172
173
#WhiteSpaceOptions_before=Before
174
#WhiteSpaceOptions_after=After
175
176
#WhiteSpaceOptions_operator=Operator
177
#WhiteSpaceOptions_assignment_operator=Assignment operator
178
#WhiteSpaceOptions_binary_operator=Binary operator
179
#WhiteSpaceOptions_unary_operator=Unary operator
180
#WhiteSpaceOptions_prefix_operator=Prefix operator
181
#WhiteSpaceOptions_postfix_operator=Postfix operator
182
183
184
#WhiteSpaceOptions_opening_paren=Opening parenthesis
185
#WhiteSpaceOptions_catch='catch'
186
#WhiteSpaceOptions_for='for'
187
#WhiteSpaceOptions_if='if'
188
#WhiteSpaceOptions_switch='switch'
189
#WhiteSpaceOptions_synchronized='synchronized'
190
#WhiteSpaceOptions_while='while'
191
#WhiteSpaceOptions_assert='assert'
192
#WhiteSpaceOptions_member_function_declaration=Member function declaration
193
#WhiteSpaceOptions_constructor=Constructor
194
#WhiteSpaceOptions_method=Method
195
#WhiteSpaceOptions_method_call=Method call
196
#WhiteSpaceOptions_paren_expr=Parenthesized expression
197
#WhiteSpaceOptions_enum_constant_body=Enum constant body
198
#WhiteSpaceOptions_enum_constant_arguments=Enum constant arguments
199
#WhiteSpaceOptions_enum_declaration=Enum declaration
200
#WhiteSpaceOptions_annotation_modifier=Annotation
201
#WhiteSpaceOptions_annotation_modifier_args=Annotation arguments
202
#WhiteSpaceOptions_annotation_type_member=Annotation type member
203
#WhiteSpaceOptions_annotation_type=Annotation type
204
205
#WhiteSpaceOptions_type_cast=Type cast
206
#WhiteSpaceOptions_parameterized_type=Parameterized type
207
#WhiteSpaceOptions_type_arguments=Type arguments
208
#WhiteSpaceOptions_type_parameters=Type parameters
209
#WhiteSpaceOptions_vararg_parameter=Vararg parameters
210
211
#WhiteSpaceOptions_closing_paren=Closing parenthesis
212
213
#WhiteSpaceOptions_opening_brace=Opening brace
214
#WhiteSpaceOptions_closing_brace=Closing brace
215
#WhiteSpaceOptions_opening_bracket=Opening bracket
216
#WhiteSpaceOptions_closing_bracket=Closing bracket
217
#WhiteSpaceOptions_class_decl=Type declaration
218
#WhiteSpaceOptions_anon_class_decl=Anonymous type declaration
219
#WhiteSpaceOptions_initializer=Array initializer
220
#WhiteSpaceOptions_block=Block
221
222
#WhiteSpaceOptions_array_decl=Array declaration
223
#WhiteSpaceOptions_array_element_access=Array element access
224
#WhiteSpaceOptions_array_alloc=Array allocation
225
#WhiteSpaceOptions_array_init=Array initializer
226
227
#WhiteSpaceOptions_arguments=Arguments
228
#WhiteSpaceOptions_initialization=Initialization
229
#WhiteSpaceOptions_incrementation=Increment
230
#WhiteSpaceOptions_parameters=Parameters
231
232
#WhiteSpaceOptions_explicit_constructor_call=Explicit constructor call
233
#WhiteSpaceOptions_alloc_expr=Allocation expression
234
#WhiteSpaceOptions_throws='throws' clause
235
#WhiteSpaceOptions_mult_decls=Multiple declarations
236
#WhiteSpaceOptions_local_vars=Local variables
237
#WhiteSpaceOptions_fields=Fields
238
#WhiteSpaceOptions_return='return'
239
#WhiteSpaceOptions_implements_clause='extends'/'implements' clause
240
#WhiteSpaceOptions_colon=Colon
241
#WhiteSpaceOptions_conditional=Conditional
242
#WhiteSpaceOptions_wildcard=Wildcard type
243
#WhiteSpaceOptions_label=Label
244
#WhiteSpaceOptions_comma=Comma
245
246
#WhiteSpaceOptions_semicolon=Semicolon
247
#WhiteSpaceOptions_question_mark=Question mark
248
#WhiteSpaceOptions_between_empty_parens=Between empty parenthesis
249
#WhiteSpaceOptions_between_empty_braces=Between empty braces
250
#WhiteSpaceOptions_between_empty_brackets=Between empty brackets
251
#WhiteSpaceOptions_constructor_decl=Constructor declaration
252
#WhiteSpaceOptions_method_decl=Method declaration
253
#WhiteSpaceOptions_case='case'
254
#WhiteSpaceOptions_default='default'
255
#WhiteSpaceOptions_statements=Statements
256
257
258
259
#WhiteSpaceOptions_before_opening_paren=Before opening parenthesis
260
#WhiteSpaceOptions_after_opening_paren=After opening parenthesis
261
#WhiteSpaceOptions_before_closing_paren=Before closing parenthesis
262
263
#WhiteSpaceOptions_after_closing_paren=After closing parenthesis
264
#WhiteSpaceOptions_before_opening_brace=Before opening brace
265
#WhiteSpaceOptions_after_opening_brace=After opening brace
266
#WhiteSpaceOptions_after_closing_brace=After closing brace
267
#WhiteSpaceOptions_before_closing_brace=Before closing brace
268
#WhiteSpaceOptions_before_opening_bracket=Before opening bracket
269
#WhiteSpaceOptions_after_opening_bracket=After opening bracket
270
#WhiteSpaceOptions_before_closing_bracket=Before closing bracket
271
272
#WhiteSpaceOptions_before_opening_angle_bracket=Before opening angle bracket
273
#WhiteSpaceOptions_after_opening_angle_bracket=After opening angle bracket
274
#WhiteSpaceOptions_before_closing_angle_bracket=Before closing angle bracket
275
#WhiteSpaceOptions_return_with_parenthesized_expression=parenthesized expression
276
#WhiteSpaceOptions_after_closing_angle_bracket=After closing angle bracket
277
278
#WhiteSpaceOptions_before_operator=Before operator
279
#WhiteSpaceOptions_after_operator=After operator
280
#WhiteSpaceOptions_before_comma=Before comma
281
#WhiteSpaceOptions_after_comma=After comma
282
#WhiteSpaceOptions_after_colon=After colon
283
#WhiteSpaceOptions_before_colon=Before colon
284
#WhiteSpaceOptions_before_semicolon=Before semicolon
285
#WhiteSpaceOptions_after_semicolon=After semicolon
286
#WhiteSpaceOptions_before_question_mark=Before question mark
287
#WhiteSpaceOptions_after_question_mark=After question mark
288
#WhiteSpaceOptions_before_at=Before @
289
#WhiteSpaceOptions_after_at=After @
290
291
#WhiteSpaceOptions_before_and=Before & list
292
#WhiteSpaceOptions_after_and=After & list
293
294
#WhiteSpaceOptions_before_ellipsis=Before Ellipsis
295
#WhiteSpaceOptions_after_ellipsis=After Ellipsis
296
297
#WhiteSpaceTabPage_insert_space=&Insert space:
298
299
300
#LineWrappingTabPage_compact_if_else=Compact 'if else'
301
#LineWrappingTabPage_extends_clause='extends' clause
302
#LineWrappingTabPage_enum_constant_arguments=Constant arguments
303
#LineWrappingTabPage_enum_constants=Constants
304
#LineWrappingTabPage_implements_clause='implements' clause
305
#LineWrappingTabPage_parameters=Parameters
306
#LineWrappingTabPage_arguments=Arguments
307
#LineWrappingTabPage_qualified_invocations=Qualified invocations
308
#LineWrappingTabPage_throws_clause='throws' clause
309
#LineWrappingTabPage_object_allocation=Object allocation arguments
310
#LineWrappingTabPage_qualified_object_allocation=Qualified object allocation arguments
311
#LineWrappingTabPage_array_init=Array initializers
312
#LineWrappingTabPage_explicit_constructor_invocations=Explicit constructor invocations
313
#LineWrappingTabPage_conditionals=Conditionals
314
#LineWrappingTabPage_binary_exprs=Binary expressions
315
#LineWrappingTabPage_indentation_default=Default indentation
316
#LineWrappingTabPage_indentation_on_column=Indent on column
317
#LineWrappingTabPage_indentation_by_one=Indent by one
318
#LineWrappingTabPage_class_decls=Class Declarations
319
#LineWrappingTabPage_method_decls=Method Declarations
320
#LineWrappingTabPage_constructor_decls=Constructor declarations
321
#LineWrappingTabPage_function_calls=Function Calls
322
#LineWrappingTabPage_expressions=Expressions
323
#LineWrappingTabPage_statements=Statements
324
#LineWrappingTabPage_enum_decls='enum' declaration
325
#LineWrappingTabPage_wrapping_policy_label_text=Lin&e wrapping policy:
326
#LineWrappingTabPage_indentation_policy_label_text=Indent&ation policy:
327
#LineWrappingTabPage_force_split_checkbox_text=&Force split
328
#LineWrappingTabPage_force_split_checkbox_multi_text=&Force split
329
#LineWrappingTabPage_line_width_for_preview_label_text=&Set line width for preview window:
330
#LineWrappingTabPage_group=Settings for {0}
331
#LineWrappingTabPage_multi_group=Settings for {0} ({1} items)
332
#LineWrappingTabPage_multiple_selections=Settings for multiple selections ({0} items)
333
#LineWrappingTabPage_occurences={0} ({1} of {2})
334
#LineWrappingTabPage_splitting_do_not_split=Do not wrap
335
#LineWrappingTabPage_splitting_wrap_when_necessary=Wrap only when necessary
336
#LineWrappingTabPage_splitting_always_wrap_first_others_when_necessary=Always wrap first element, others when necessary
337
#LineWrappingTabPage_splitting_wrap_always=Wrap all elements, every element on a new line
338
#LineWrappingTabPage_splitting_wrap_always_indent_all_but_first=Wrap all elements, indent all but the first element
339
#LineWrappingTabPage_splitting_wrap_always_except_first_only_if_necessary=Wrap all elements, except first element if not necessary
340
#LineWrappingTabPage_width_indent=Line width and indentation levels
341
#LineWrappingTabPage_width_indent_option_max_line_width=Ma&ximum line width:
342
#LineWrappingTabPage_width_indent_option_default_indent_wrapped=Defa&ult indentation for wrapped lines:
343
#LineWrappingTabPage_width_indent_option_default_indent_array=Default indentation for arra&y initializers:
344
#LineWrappingTabPage_error_invalid_value=The key ''{0}'' contained an invalid value; resetting to defaults.
345
#LineWrappingTabPage_enum_superinterfaces='implements' clause
346
#LineWrappingTabPage_assignment_alignment=Assignments
347
348
349
AlreadyExistsDialog_message_profile_already_exists=A profile with this name already exists.
350
AlreadyExistsDialog_message_profile_name_empty=Profile name is empty
351
AlreadyExistsDialog_dialog_title=Load Profile
352
AlreadyExistsDialog_dialog_label=A profile with the name ''{0}'' already exists in this workspace. What would you like to do?
353
AlreadyExistsDialog_rename_radio_button_desc=&Rename the imported profile:
354
AlreadyExistsDialog_overwrite_radio_button_desc=&Overwrite the existing profile.
355
356
357
#BlankLinesTabPage_preview_header=Blank Lines
358
#BlankLinesTabPage_compilation_unit_group_title=Blank lines in compilation unit
359
#BlankLinesTabPage_compilation_unit_option_before_package=Before p&ackage declaration:
360
#BlankLinesTabPage_compilation_unit_option_after_package=After packa&ge declaration:
361
#BlankLinesTabPage_compilation_unit_option_before_import=&Before import declaration:
362
#BlankLinesTabPage_compilation_unit_option_after_import=After import de&claration:
363
#BlankLinesTabPage_compilation_unit_option_between_type_declarations=Between class declarat&ions:
364
365
#BlankLinesTabPage_class_group_title=Blank lines within class declarations
366
#BlankLinesTabPage_class_option_before_first_decl=Before &first declaration:
367
#BlankLinesTabPage_class_option_before_decls_of_same_kind=Before declarations of the same &kind:
368
#BlankLinesTabPage_class_option_before_member_class_decls=Before member cla&ss declarations:
369
#BlankLinesTabPage_class_option_before_field_decls=B&efore field declarations:
370
#BlankLinesTabPage_class_option_before_method_decls=Before met&hod declarations:
371
#BlankLinesTabPage_class_option_at_beginning_of_method_body= At beginning of method bod&y:
372
373
#BlankLinesTabPage_blank_lines_group_title=Existing blank lines
374
#BlankLinesTabPage_blank_lines_option_empty_lines_to_preserve=N&umber of empty lines to preserve:
375
376
#BracesTabPage_preview_header=Braces
377
#BracesTabPage_position_same_line=Same line
378
#BracesTabPage_position_next_line=Next line
379
#BracesTabPage_position_next_line_indented=Next line indented
380
#BracesTabPage_position_next_line_on_wrap=Next line on wrap
381
382
#BracesTabPage_group_brace_positions_title=Brace positions
383
#BracesTabPage_option_class_declaration=&Class or interface declaration:
384
#BracesTabPage_option_anonymous_class_declaration=Anon&ymous class declaration:
385
#BracesTabPage_option_method_declaration=Met&hod declaration:
386
#BracesTabPage_option_constructor_declaration=Constr&uctor declaration:
387
#BracesTabPage_option_blocks=&Blocks:
388
#BracesTabPage_option_blocks_in_case=Bloc&ks in case statement:
389
#BracesTabPage_option_switch_case='&switch' statement:
390
#BracesTabPage_option_array_initializer=Array initiali&zer:
391
#BracesTabPage_option_keep_empty_array_initializer_on_one_line=Keep empty array &initializer on one line
392
#BracesTabPage_option_enum_declaration=&Enum declaration:
393
#BracesTabPage_option_enumconst_declaration=Enum c&onstant body:
394
#BracesTabPage_option_annotation_type_declaration=&Annotation type declaration:
395
CodingStyleConfigurationBlock_save_profile_dialog_title=Export Profile
396
CodingStyleConfigurationBlock_save_profile_error_title=Export Profile
397
CodingStyleConfigurationBlock_save_profile_error_message=Could not export the profiles.
398
CodingStyleConfigurationBlock_load_profile_dialog_title=Import Profile
399
CodingStyleConfigurationBlock_load_profile_error_title=Import Profile
400
CodingStyleConfigurationBlock_load_profile_error_message=Import failed. Not a valid profile.
401
CodingStyleConfigurationBlock_load_profile_error_too_new_title=Importing Profile
402
CodingStyleConfigurationBlock_load_profile_error_too_new_message=This profile has been created with \
403
a more recent CDT build than the one you are using. Due to changes in the code formatter, \
404
some older settings might be reset to their default values and newer settings are ignored. Please note \
405
that upgrading profiles from older to newer builds is fully supported.
406
CodingStyleConfigurationBlock_preview_title=A sample source file for the code formatter preview
407
CodingStyleConfigurationBlock_save_profile_overwrite_title=Export Profile
408
CodingStyleConfigurationBlock_save_profile_overwrite_message={0} " already exists.\nDo you want to replace it?"
409
CodingStyleConfigurationBlock_edit_button_desc=&Edit...
410
CodingStyleConfigurationBlock_show_button_desc=&Show...
411
CodingStyleConfigurationBlock_rename_button_desc=Re&name...
412
CodingStyleConfigurationBlock_remove_button_desc=&Remove
413
CodingStyleConfigurationBlock_new_button_desc=Ne&w...
414
CodingStyleConfigurationBlock_load_button_desc=I&mport...
415
CodingStyleConfigurationBlock_save_button_desc=E&xport...
416
CodingStyleConfigurationBlock_preview_label_text=Prev&iew:
417
CodingStyleConfigurationBlock_error_reading_xml_message=Problems reading profiles from XML
418
CodingStyleConfigurationBlock_error_serializing_xml_message=Problems serializing the profiles to XML
419
CodingStyleConfigurationBlock_delete_confirmation_title=Confirm Remove
420
CodingStyleConfigurationBlock_delete_confirmation_question=Are you sure you want to remove profile ''{0}''?
421
422
CustomCodeFormatterBlock_formatter_name=Code &Formatter:
423
CustomCodeFormatterBlock_no_formatter=(NONE)
424
CustomCodeFormatterBlock_contributed_formatter_warning=Some formatters may not respect all code style settings.
425
426
#CommentsTabPage_group1_title=General settings
427
#CommentsTabPage_enable_comment_formatting=Enable &comment formatting
428
#CommentsTabPage_format_header=Format &header comment
429
#CommentsTabPage_format_html=Format HTML ta&gs
430
#CommentsTabPage_format_code_snippets=Format &C code snippets
431
432
#CommentsTabPage_clear_blank_lines=Clear &blank lines in comments
433
#CommentsTabPage_group3_title=Line width
434
#CommentsTabPage_line_width=Ma&ximum line width for comments:
435
436
437
#ControlStatementsTabPage_preview_header=If...else
438
#ControlStatementsTabPage_general_group_title=General
439
#ControlStatementsTabPage_general_group_insert_new_line_before_else_statements=Insert new line before '&else' in an 'if' statement
440
#ControlStatementsTabPage_general_group_insert_new_line_before_catch_statements=Insert new line before '&catch' in a 'try' statement
441
#ControlStatementsTabPage_general_group_insert_new_line_before_finally_statements=Insert new line before '&finally' in a 'try' statement
442
#ControlStatementsTabPage_general_group_insert_new_line_before_while_in_do_statements=Insert new line before 'w&hile' in a 'do' statement
443
444
#ControlStatementsTabPage_if_else_group_title='if else'
445
#ControlStatementsTabPage_if_else_group_keep_then_on_same_line=Keep 'then' statement &on same line
446
#ControlStatementsTabPage_if_else_group_keep_simple_if_on_one_line=Keep &simple 'if' on one line
447
#ControlStatementsTabPage_if_else_group_keep_else_on_same_line=Keep 'else' st&atement on same line
448
#ControlStatementsTabPage_if_else_group_keep_else_if_on_one_line=&Keep 'else if' on one line
449
#ControlStatementsTabPage_if_else_group_keep_guardian_clause_on_one_line=Keep 'return' or 'throw' cla&use on one line
450
451
CreateProfileDialog_status_message_profile_with_this_name_already_exists=A profile with this name already exists.
452
CreateProfileDialog_status_message_profile_name_is_empty=Profile name is empty
453
CreateProfileDialog_dialog_title=New Code Formatter Profile
454
CreateProfileDialog_profile_name_label_text=&Profile name:
455
CreateProfileDialog_base_profile_label_text=I&nitialize settings with the following profile:
456
CreateProfileDialog_open_edit_dialog_checkbox_text=&Open the edit dialog now
457
458
IndentationTabPage_preview_header=Indentation
459
460
IndentationTabPage_general_group_title=General settings
461
IndentationTabPage_general_group_option_tab_policy=Tab polic&y:
462
IndentationTabPage_general_group_option_tab_policy_SPACE=Spaces only
463
IndentationTabPage_general_group_option_tab_policy_TAB=Tabs only
464
IndentationTabPage_general_group_option_tab_policy_MIXED=Mixed
465
IndentationTabPage_general_group_option_tab_size=Tab &size:
466
IndentationTabPage_general_group_option_indent_size=&Indentation size:
467
468
IndentationTabPage_field_alignment_group_title=Alignment of fields in class declarations
469
IndentationTabPage_field_alignment_group_align_fields_in_columns=&Align fields in columns
470
471
IndentationTabPage_indent_group_title=Indent
472
473
IndentationTabPage_class_group_option_indent_access_specifiers_within_class_body='public', 'protected', 'private' within class &body
474
IndentationTabPage_class_group_option_indent_declarations_compare_to_access_specifiers=De&clarations relative to 'public', 'protected', 'private'
475
IndentationTabPage_class_group_option_indent_declarations_within_enum_const=Declarations within en&um constants
476
IndentationTabPage_class_group_option_indent_declarations_within_enum_decl=Declarations within enum declaration
477
IndentationTabPage_block_group_option_indent_statements_compare_to_body=Stat&ements within method/constructor body
478
IndentationTabPage_block_group_option_indent_statements_compare_to_block=Statements within bl&ocks
479
IndentationTabPage_indent_empty_lines=Empty lines
480
481
IndentationTabPage_switch_group_option_indent_statements_within_switch_body=Statements wit&hin 'switch' body
482
IndentationTabPage_switch_group_option_indent_statements_within_case_body=Statements within 'case' bo&dy
483
IndentationTabPage_switch_group_option_indent_break_statements='brea&k' statements
484
485
IndentationTabPage_use_tabs_only_for_leading_indentations=Use tabs only for leading indentations
486
487
ModifyDialog_dialog_title=Edit Profile ''{0}''
488
ModifyDialog_apply_button=Apply
489
ModifyDialog_dialog_show_title=Show Profile ''{0}''
490
ModifyDialog_dialog_show_warning_builtin=This is a built-in profile, you will be prompted to enter a new name after closing this dialog.
491
ModifyDialog_tabpage_braces_title=B&races
492
ModifyDialog_tabpage_indentation_title=In&dentation
493
ModifyDialog_tabpage_whitespace_title=&White Space
494
ModifyDialog_tabpage_blank_lines_title=Bla&nk Lines
495
ModifyDialog_tabpage_new_lines_title=New &Lines
496
ModifyDialog_tabpage_control_statements_title=Con&trol Statements
497
ModifyDialog_tabpage_line_wrapping_title=Line Wra&pping
498
ModifyDialog_tabpage_comments_title=Co&mments
499
500
ModifyDialogTabPage_preview_label_text=Pre&view:
501
ModifyDialogTabPage_error_msg_values_text_unassigned=Values and text must be assigned.
502
ModifyDialogTabPage_error_msg_values_items_text_unassigned=Values, items and text must be assigned.
503
ModifyDialogTabPage_NumberPreference_error_invalid_key=The key {0} does not yield a valid integer value.
504
ModifyDialogTabPage_NumberPreference_error_invalid_value=Invalid value: Please enter a number between {0} and {1}.
505
506
#NewLinesTabPage_preview_header=New Lines
507
#NewLinesTabPage_newlines_group_title=Insert new line
508
509
#NewLinesTabPage_newlines_group_option_empty_class_body=in empty &class body
510
#NewLinesTabPage_newlines_group_option_empty_annotation_decl_body=in empty annotation body
511
#NewLinesTabPage_newlines_group_option_empty_anonymous_class_body=in empty &anonymous class body
512
#NewLinesTabPage_newlines_group_option_empty_enum_declaration=in empty &enum declaration
513
#NewLinesTabPage_newlines_group_option_empty_enum_constant=in empty enum c&onstant body
514
#NewLinesTabPage_newlines_group_option_empty_method_body=in empt&y method body
515
#NewLinesTabPage_newlines_group_option_empty_block=in empty &block
516
#NewLinesTabPage_newlines_group_option_empty_end_of_file=at end of &file
517
#NewLinesTabPage_empty_statement_group_title=Empty statements
518
#NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line=Put empty &statement on new line
519
520
#NewLinesTabPage_arrayInitializer_group_title=Array initializers
521
#NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer=Insert new line after openin&g brace of array initializer
522
#NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer=Insert new line before closing brace of array initiali&zer
523
524
#NewLinesTabPage_annotations_group_title=Annotations
525
#NewLinesTabPage_annotations_group_option_after_annotation=&Insert new line after annotations
526
527
ProfileManager_default_profile_name=Default [built-in]
528
529
ProfileManager_unmanaged_profile=Unmanaged profile
530
ProfileManager_unmanaged_profile_with_name=Unmanaged profile "{0}"
531
532
RenameProfileDialog_status_message_profile_with_this_name_already_exists=A profile with this name already exists.
533
RenameProfileDialog_status_message_profile_name_empty=Profile name is empty
534
RenameProfileDialog_dialog_title=Rename Profile
535
RenameProfileDialog_dialog_label_enter_a_new_name=Please &enter a new name:
536
537
CPreview_formatter_exception=The formatter threw an unhandled exception while formatting the preview.
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/FormatterMessages.java (+461 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.preferences.formatter;
13
14
import org.eclipse.osgi.util.NLS;
15
16
/**
17
 * Helper class to get NLSed messages.
18
 */
19
final class FormatterMessages extends NLS {
20
21
	private static final String BUNDLE_NAME= FormatterMessages.class.getName(); 
22
23
	private FormatterMessages() {
24
		// Do not instantiate
25
	}
26
27
//	public static String WhiteSpaceTabPage_assignments;
28
//	public static String WhiteSpaceTabPage_assignments_before_assignment_operator;
29
//	public static String WhiteSpaceTabPage_assignments_after_assignment_operator;
30
//	public static String WhiteSpaceTabPage_operators;
31
//	public static String WhiteSpaceTabPage_operators_before_binary_operators;
32
//	public static String WhiteSpaceTabPage_operators_after_binary_operators;
33
//	public static String WhiteSpaceTabPage_operators_before_unary_operators;
34
//	public static String WhiteSpaceTabPage_operators_after_unary_operators;
35
//	public static String WhiteSpaceTabPage_operators_before_prefix_operators;
36
//	public static String WhiteSpaceTabPage_operators_after_prefix_operators;
37
//	public static String WhiteSpaceTabPage_operators_before_postfix_operators;
38
//	public static String WhiteSpaceTabPage_operators_after_postfix_operators;
39
//	public static String WhiteSpaceTabPage_classes;
40
//	public static String WhiteSpaceTabPage_classes_before_opening_brace_of_a_class;
41
//	public static String WhiteSpaceTabPage_classes_before_opening_brace_of_anon_class;
42
//	public static String WhiteSpaceTabPage_classes_before_comma_implements;
43
//	public static String WhiteSpaceTabPage_classes_after_comma_implements;
44
//	public static String WhiteSpaceTabPage_methods;
45
//	public static String WhiteSpaceTabPage_constructors;
46
//	public static String WhiteSpaceTabPage_fields;
47
//	public static String WhiteSpaceTabPage_fields_before_comma;
48
//	public static String WhiteSpaceTabPage_fields_after_comma;
49
//	public static String WhiteSpaceTabPage_localvars;
50
//	public static String WhiteSpaceTabPage_localvars_before_comma;
51
//	public static String WhiteSpaceTabPage_localvars_after_comma;
52
//	public static String WhiteSpaceTabPage_arrayinit;
53
//	public static String WhiteSpaceTabPage_arraydecls;
54
//	public static String WhiteSpaceTabPage_arrayelem;
55
//	public static String WhiteSpaceTabPage_arrayalloc;
56
//	public static String WhiteSpaceTabPage_calls;
57
//	public static String WhiteSpaceTabPage_calls_before_comma_in_method_args;
58
//	public static String WhiteSpaceTabPage_calls_after_comma_in_method_args;
59
//	public static String WhiteSpaceTabPage_calls_before_comma_in_alloc;
60
//	public static String WhiteSpaceTabPage_calls_after_comma_in_alloc;
61
//	public static String WhiteSpaceTabPage_calls_before_comma_in_qalloc;
62
//	public static String WhiteSpaceTabPage_calls_after_comma_in_qalloc;
63
//	public static String WhiteSpaceTabPage_statements;
64
//	public static String WhiteSpaceTabPage_blocks;
65
//	public static String WhiteSpaceTabPage_switch;
66
//	public static String WhiteSpaceTabPage_switch_before_case_colon;
67
//	public static String WhiteSpaceTabPage_switch_before_default_colon;
68
//	public static String WhiteSpaceTabPage_do;
69
//	public static String WhiteSpaceTabPage_synchronized;
70
//	public static String WhiteSpaceTabPage_try;
71
//	public static String WhiteSpaceTabPage_if;
72
//	public static String WhiteSpaceTabPage_assert;
73
//	public static String WhiteSpaceTabPage_for;
74
//	public static String WhiteSpaceTabPage_for_before_comma_init;
75
//	public static String WhiteSpaceTabPage_for_after_comma_init;
76
//	public static String WhiteSpaceTabPage_for_before_comma_inc;
77
//	public static String WhiteSpaceTabPage_for_after_comma_inc;
78
//	public static String WhiteSpaceTabPage_labels;
79
//	public static String WhiteSpaceTabPage_annotations;
80
//	public static String WhiteSpaceTabPage_annotation_types;
81
//	public static String WhiteSpaceTabPage_enums;
82
//	public static String WhiteSpaceTabPage_wildcardtype;
83
//	public static String WhiteSpaceTabPage_param_type_ref;
84
//	public static String WhiteSpaceTabPage_type_arguments;
85
//	public static String WhiteSpaceTabPage_type_parameters;
86
//	public static String WhiteSpaceTabPage_conditionals;
87
//	public static String WhiteSpaceTabPage_typecasts;
88
//	public static String WhiteSpaceTabPage_parenexpr;
89
//	public static String WhiteSpaceTabPage_declarations;
90
//	public static String WhiteSpaceTabPage_expressions;
91
//	public static String WhiteSpaceTabPage_arrays;
92
//	public static String WhiteSpaceTabPage_parameterized_types;
93
//	public static String WhiteSpaceTabPage_after_opening_brace;
94
//	public static String WhiteSpaceTabPage_after_closing_brace;
95
//	public static String WhiteSpaceTabPage_before_opening_brace;
96
//	public static String WhiteSpaceTabPage_before_closing_brace;
97
//	public static String WhiteSpaceTabPage_between_empty_braces;
98
//	public static String WhiteSpaceTabPage_after_opening_paren;
99
//	public static String WhiteSpaceTabPage_after_closing_paren;
100
//	public static String WhiteSpaceTabPage_before_opening_paren;
101
//	public static String WhiteSpaceTabPage_before_closing_paren;
102
//	public static String WhiteSpaceTabPage_between_empty_parens;
103
//	public static String WhiteSpaceTabPage_after_opening_bracket;
104
//	public static String WhiteSpaceTabPage_before_opening_bracket;
105
//	public static String WhiteSpaceTabPage_before_closing_bracket;
106
//	public static String WhiteSpaceTabPage_between_empty_brackets;
107
//	public static String WhiteSpaceTabPage_before_comma_in_params;
108
//	public static String WhiteSpaceTabPage_after_comma_in_params;
109
//	public static String WhiteSpaceTabPage_before_comma_in_throws;
110
//	public static String WhiteSpaceTabPage_after_comma_in_throws;
111
//	public static String WhiteSpaceTabPage_before_ellipsis;
112
//	public static String WhiteSpaceTabPage_after_ellipsis;
113
//	public static String WhiteSpaceTabPage_before_comma;
114
//	public static String WhiteSpaceTabPage_after_comma;
115
//	public static String WhiteSpaceTabPage_after_semicolon;
116
//	public static String WhiteSpaceTabPage_before_semicolon;
117
//	public static String WhiteSpaceTabPage_before_colon;
118
//	public static String WhiteSpaceTabPage_after_colon;
119
//	public static String WhiteSpaceTabPage_before_question;
120
//	public static String WhiteSpaceTabPage_after_question;
121
//	public static String WhiteSpaceTabPage_before_at;
122
//	public static String WhiteSpaceTabPage_after_at;
123
//	public static String WhiteSpaceTabPage_after_opening_angle_bracket;
124
//	public static String WhiteSpaceTabPage_after_closing_angle_bracket;
125
//	public static String WhiteSpaceTabPage_before_opening_angle_bracket;
126
//	public static String WhiteSpaceTabPage_before_closing_angle_bracket;
127
//	public static String WhiteSpaceTabPage_before_and_list;
128
//	public static String WhiteSpaceTabPage_after_and_list;
129
//	public static String WhiteSpaceTabPage_enum_decl_before_opening_brace;
130
//	public static String WhiteSpaceTabPage_enum_decl_before_comma;
131
//	public static String WhiteSpaceTabPage_enum_decl_after_comma;
132
//	public static String WhiteSpaceTabPage_enum_const_arg_before_opening_paren;
133
//	public static String WhiteSpaceTabPage_enum_const_arg_after_opening_paren;
134
//	public static String WhiteSpaceTabPage_enum_const_arg_between_empty_parens;
135
//	public static String WhiteSpaceTabPage_enum_const_arg_before_comma;
136
//	public static String WhiteSpaceTabPage_enum_const_arg_after_comma;
137
//	public static String WhiteSpaceTabPage_enum_const_arg_before_closing_paren;
138
//	public static String WhiteSpaceTabPage_enum_const_before_opening_brace;
139
//	public static String WhiteSpaceTabPage_annot_type_method_before_opening_paren;
140
//	public static String WhiteSpaceTabPage_annot_type_method_between_empty_parens;
141
//	public static String WhiteSpaceTabPage_before_parenthesized_expressions;
142
//	public static String WhiteSpaceTabPage_insert_space;
143
//	public static String WhiteSpaceTabPage_sort_by_c_element;
144
//	public static String WhiteSpaceTabPage_sort_by_syntax_element;
145
//	public static String WhiteSpaceOptions_return;
146
//	public static String WhiteSpaceOptions_before;
147
//	public static String WhiteSpaceOptions_after;
148
//	public static String WhiteSpaceOptions_operator;
149
//	public static String WhiteSpaceOptions_assignment_operator;
150
//	public static String WhiteSpaceOptions_binary_operator;
151
//	public static String WhiteSpaceOptions_unary_operator;
152
//	public static String WhiteSpaceOptions_prefix_operator;
153
//	public static String WhiteSpaceOptions_postfix_operator;
154
//	public static String WhiteSpaceOptions_opening_paren;
155
//	public static String WhiteSpaceOptions_catch;
156
//	public static String WhiteSpaceOptions_for;
157
//	public static String WhiteSpaceOptions_if;
158
//	public static String WhiteSpaceOptions_switch;
159
//	public static String WhiteSpaceOptions_synchronized;
160
//	public static String WhiteSpaceOptions_while;
161
//	public static String WhiteSpaceOptions_assert;
162
//	public static String WhiteSpaceOptions_member_function_declaration;
163
//	public static String WhiteSpaceOptions_constructor;
164
//	public static String WhiteSpaceOptions_method;
165
//	public static String WhiteSpaceOptions_method_call;
166
//	public static String WhiteSpaceOptions_paren_expr;
167
//	public static String WhiteSpaceOptions_enum_constant_body;
168
//	public static String WhiteSpaceOptions_enum_constant_arguments;
169
//	public static String WhiteSpaceOptions_enum_declaration;
170
//	public static String WhiteSpaceOptions_annotation_modifier;
171
//	public static String WhiteSpaceOptions_annotation_modifier_args;
172
//	public static String WhiteSpaceOptions_annotation_type_member;
173
//	public static String WhiteSpaceOptions_annotation_type;
174
//	public static String WhiteSpaceOptions_type_cast;
175
//	public static String WhiteSpaceOptions_parameterized_type;
176
//	public static String WhiteSpaceOptions_type_arguments;
177
//	public static String WhiteSpaceOptions_type_parameters;
178
//	public static String WhiteSpaceOptions_vararg_parameter;
179
//	public static String WhiteSpaceOptions_closing_paren;
180
//	public static String WhiteSpaceOptions_opening_brace;
181
//	public static String WhiteSpaceOptions_closing_brace;
182
//	public static String WhiteSpaceOptions_opening_bracket;
183
//	public static String WhiteSpaceOptions_closing_bracket;
184
//	public static String WhiteSpaceOptions_class_decl;
185
//	public static String WhiteSpaceOptions_anon_class_decl;
186
//	public static String WhiteSpaceOptions_initializer;
187
//	public static String WhiteSpaceOptions_block;
188
//	public static String WhiteSpaceOptions_array_decl;
189
//	public static String WhiteSpaceOptions_array_element_access;
190
//	public static String WhiteSpaceOptions_array_alloc;
191
//	public static String WhiteSpaceOptions_array_init;
192
//	public static String WhiteSpaceOptions_arguments;
193
//	public static String WhiteSpaceOptions_initialization;
194
//	public static String WhiteSpaceOptions_incrementation;
195
//	public static String WhiteSpaceOptions_parameters;
196
//	public static String WhiteSpaceOptions_explicit_constructor_call;
197
//	public static String WhiteSpaceOptions_alloc_expr;
198
//	public static String WhiteSpaceOptions_throws;
199
//	public static String WhiteSpaceOptions_mult_decls;
200
//	public static String WhiteSpaceOptions_local_vars;
201
//	public static String WhiteSpaceOptions_fields;
202
//	public static String WhiteSpaceOptions_implements_clause;
203
//	public static String WhiteSpaceOptions_colon;
204
//	public static String WhiteSpaceOptions_conditional;
205
//	public static String WhiteSpaceOptions_wildcard;
206
//	public static String WhiteSpaceOptions_label;
207
//	public static String WhiteSpaceOptions_comma;
208
//	public static String WhiteSpaceOptions_semicolon;
209
//	public static String WhiteSpaceOptions_question_mark;
210
//	public static String WhiteSpaceOptions_between_empty_parens;
211
//	public static String WhiteSpaceOptions_between_empty_braces;
212
//	public static String WhiteSpaceOptions_between_empty_brackets;
213
//	public static String WhiteSpaceOptions_constructor_decl;
214
//	public static String WhiteSpaceOptions_method_decl;
215
//	public static String WhiteSpaceOptions_case;
216
//	public static String WhiteSpaceOptions_default;
217
//	public static String WhiteSpaceOptions_statements;
218
//	public static String WhiteSpaceOptions_before_opening_paren;
219
//	public static String WhiteSpaceOptions_after_opening_paren;
220
//	public static String WhiteSpaceOptions_before_closing_paren;
221
//	public static String WhiteSpaceOptions_after_closing_paren;
222
//	public static String WhiteSpaceOptions_before_opening_brace;
223
//	public static String WhiteSpaceOptions_after_opening_brace;
224
//	public static String WhiteSpaceOptions_after_closing_brace;
225
//	public static String WhiteSpaceOptions_before_closing_brace;
226
//	public static String WhiteSpaceOptions_before_opening_bracket;
227
//	public static String WhiteSpaceOptions_after_opening_bracket;
228
//	public static String WhiteSpaceOptions_before_closing_bracket;
229
//	public static String WhiteSpaceOptions_before_opening_angle_bracket;
230
//	public static String WhiteSpaceOptions_after_opening_angle_bracket;
231
//	public static String WhiteSpaceOptions_before_closing_angle_bracket;
232
//	public static String WhiteSpaceOptions_after_closing_angle_bracket;
233
//	public static String WhiteSpaceOptions_before_operator;
234
//	public static String WhiteSpaceOptions_after_operator;
235
//	public static String WhiteSpaceOptions_before_comma;
236
//	public static String WhiteSpaceOptions_after_comma;
237
//	public static String WhiteSpaceOptions_after_colon;
238
//	public static String WhiteSpaceOptions_before_colon;
239
//	public static String WhiteSpaceOptions_before_semicolon;
240
//	public static String WhiteSpaceOptions_after_semicolon;
241
//	public static String WhiteSpaceOptions_before_question_mark;
242
//	public static String WhiteSpaceOptions_after_question_mark;
243
//	public static String WhiteSpaceOptions_before_at;
244
//	public static String WhiteSpaceOptions_after_at;
245
//	public static String WhiteSpaceOptions_before_and;
246
//	public static String WhiteSpaceOptions_after_and;
247
//	public static String WhiteSpaceOptions_before_ellipsis;
248
//	public static String WhiteSpaceOptions_after_ellipsis;
249
//	public static String WhiteSpaceOptions_return_with_parenthesized_expression;
250
//	public static String LineWrappingTabPage_compact_if_else;
251
//	public static String LineWrappingTabPage_extends_clause;
252
//	public static String LineWrappingTabPage_enum_constant_arguments;
253
//	public static String LineWrappingTabPage_enum_constants;
254
//	public static String LineWrappingTabPage_implements_clause;
255
//	public static String LineWrappingTabPage_parameters;
256
//	public static String LineWrappingTabPage_arguments;
257
//	public static String LineWrappingTabPage_qualified_invocations;
258
//	public static String LineWrappingTabPage_throws_clause;
259
//	public static String LineWrappingTabPage_object_allocation;
260
//	public static String LineWrappingTabPage_qualified_object_allocation;
261
//	public static String LineWrappingTabPage_array_init;
262
//	public static String LineWrappingTabPage_explicit_constructor_invocations;
263
//	public static String LineWrappingTabPage_conditionals;
264
//	public static String LineWrappingTabPage_binary_exprs;
265
//	public static String LineWrappingTabPage_indentation_default;
266
//	public static String LineWrappingTabPage_indentation_on_column;
267
//	public static String LineWrappingTabPage_indentation_by_one;
268
//	public static String LineWrappingTabPage_class_decls;
269
//	public static String LineWrappingTabPage_method_decls;
270
//	public static String LineWrappingTabPage_constructor_decls;
271
//	public static String LineWrappingTabPage_function_calls;
272
//	public static String LineWrappingTabPage_expressions;
273
//	public static String LineWrappingTabPage_statements;
274
//	public static String LineWrappingTabPage_enum_decls;
275
//	public static String LineWrappingTabPage_wrapping_policy_label_text;
276
//	public static String LineWrappingTabPage_indentation_policy_label_text;
277
//	public static String LineWrappingTabPage_force_split_checkbox_text;
278
//	public static String LineWrappingTabPage_force_split_checkbox_multi_text;
279
//	public static String LineWrappingTabPage_line_width_for_preview_label_text;
280
//	public static String LineWrappingTabPage_group;
281
//	public static String LineWrappingTabPage_multi_group;
282
//	public static String LineWrappingTabPage_multiple_selections;
283
//	public static String LineWrappingTabPage_occurences;
284
//	public static String LineWrappingTabPage_splitting_do_not_split;
285
//	public static String LineWrappingTabPage_splitting_wrap_when_necessary;
286
//	public static String LineWrappingTabPage_splitting_always_wrap_first_others_when_necessary;
287
//	public static String LineWrappingTabPage_splitting_wrap_always;
288
//	public static String LineWrappingTabPage_splitting_wrap_always_indent_all_but_first;
289
//	public static String LineWrappingTabPage_splitting_wrap_always_except_first_only_if_necessary;
290
//	public static String LineWrappingTabPage_width_indent;
291
//	public static String LineWrappingTabPage_width_indent_option_max_line_width;
292
//	public static String LineWrappingTabPage_width_indent_option_default_indent_wrapped;
293
//	public static String LineWrappingTabPage_width_indent_option_default_indent_array;
294
//	public static String LineWrappingTabPage_error_invalid_value;
295
//	public static String LineWrappingTabPage_enum_superinterfaces;
296
//	public static String LineWrappingTabPage_assignment_alignment;
297
	public static String AlreadyExistsDialog_message_profile_already_exists;
298
	public static String AlreadyExistsDialog_message_profile_name_empty;
299
	public static String AlreadyExistsDialog_dialog_title;
300
	public static String AlreadyExistsDialog_dialog_label;
301
	public static String AlreadyExistsDialog_rename_radio_button_desc;
302
	public static String AlreadyExistsDialog_overwrite_radio_button_desc;
303
//	public static String BlankLinesTabPage_preview_header;
304
//	public static String BlankLinesTabPage_compilation_unit_group_title;
305
//	public static String BlankLinesTabPage_compilation_unit_option_before_package;
306
//	public static String BlankLinesTabPage_compilation_unit_option_after_package;
307
//	public static String BlankLinesTabPage_compilation_unit_option_before_import;
308
//	public static String BlankLinesTabPage_compilation_unit_option_after_import;
309
//	public static String BlankLinesTabPage_compilation_unit_option_between_type_declarations;
310
//	public static String BlankLinesTabPage_class_group_title;
311
//	public static String BlankLinesTabPage_class_option_before_first_decl;
312
//	public static String BlankLinesTabPage_class_option_before_decls_of_same_kind;
313
//	public static String BlankLinesTabPage_class_option_before_member_class_decls;
314
//	public static String BlankLinesTabPage_class_option_before_field_decls;
315
//	public static String BlankLinesTabPage_class_option_before_method_decls;
316
//	public static String BlankLinesTabPage_class_option_at_beginning_of_method_body;
317
//	public static String BlankLinesTabPage_blank_lines_group_title;
318
//	public static String BlankLinesTabPage_blank_lines_option_empty_lines_to_preserve;
319
//	public static String BracesTabPage_preview_header;
320
//	public static String BracesTabPage_position_same_line;
321
//	public static String BracesTabPage_position_next_line;
322
//	public static String BracesTabPage_position_next_line_indented;
323
//	public static String BracesTabPage_position_next_line_on_wrap;
324
//	public static String BracesTabPage_group_brace_positions_title;
325
//	public static String BracesTabPage_option_class_declaration;
326
//	public static String BracesTabPage_option_anonymous_class_declaration;
327
//	public static String BracesTabPage_option_method_declaration;
328
//	public static String BracesTabPage_option_constructor_declaration;
329
//	public static String BracesTabPage_option_blocks;
330
//	public static String BracesTabPage_option_blocks_in_case;
331
//	public static String BracesTabPage_option_switch_case;
332
//	public static String BracesTabPage_option_array_initializer;
333
//	public static String BracesTabPage_option_keep_empty_array_initializer_on_one_line;
334
//	public static String BracesTabPage_option_enum_declaration;
335
//	public static String BracesTabPage_option_enumconst_declaration;
336
//	public static String BracesTabPage_option_annotation_type_declaration;
337
	public static String CodingStyleConfigurationBlock_save_profile_dialog_title;
338
	public static String CodingStyleConfigurationBlock_save_profile_error_title;
339
	public static String CodingStyleConfigurationBlock_save_profile_error_message;
340
	public static String CodingStyleConfigurationBlock_load_profile_dialog_title;
341
	public static String CodingStyleConfigurationBlock_load_profile_error_title;
342
	public static String CodingStyleConfigurationBlock_load_profile_error_message;
343
	public static String CodingStyleConfigurationBlock_load_profile_error_too_new_title;
344
	public static String CodingStyleConfigurationBlock_load_profile_error_too_new_message;
345
	public static String CodingStyleConfigurationBlock_preview_title;
346
	public static String CodingStyleConfigurationBlock_save_profile_overwrite_title;
347
	public static String CodingStyleConfigurationBlock_save_profile_overwrite_message;
348
	public static String CodingStyleConfigurationBlock_edit_button_desc;
349
	public static String CodingStyleConfigurationBlock_show_button_desc;
350
	public static String CodingStyleConfigurationBlock_rename_button_desc;
351
	public static String CodingStyleConfigurationBlock_remove_button_desc;
352
	public static String CodingStyleConfigurationBlock_new_button_desc;
353
	public static String CodingStyleConfigurationBlock_load_button_desc;
354
	public static String CodingStyleConfigurationBlock_save_button_desc;
355
	public static String CodingStyleConfigurationBlock_preview_label_text;
356
	public static String CodingStyleConfigurationBlock_error_reading_xml_message;
357
	public static String CodingStyleConfigurationBlock_error_serializing_xml_message;
358
	public static String CodingStyleConfigurationBlock_delete_confirmation_title;
359
	public static String CodingStyleConfigurationBlock_delete_confirmation_question;
360
	public static String CustomCodeFormatterBlock_formatter_name;
361
	public static String CustomCodeFormatterBlock_no_formatter;
362
	public static String CustomCodeFormatterBlock_contributed_formatter_warning;
363
//	public static String CommentsTabPage_group1_title;
364
//	public static String CommentsTabPage_enable_comment_formatting;
365
//	public static String CommentsTabPage_format_header;
366
//	public static String CommentsTabPage_format_html;
367
//	public static String CommentsTabPage_format_code_snippets;
368
//	public static String CommentsTabPage_group2_title;
369
//	public static String CommentsTabPage_clear_blank_lines;
370
//	public static String CommentsTabPage_indent_description_after_param;
371
//	public static String CommentsTabPage_new_line_after_param_tags;
372
//	public static String CommentsTabPage_group3_title;
373
//	public static String CommentsTabPage_line_width;
374
//	public static String ControlStatementsTabPage_preview_header;
375
//	public static String ControlStatementsTabPage_general_group_title;
376
//	public static String ControlStatementsTabPage_general_group_insert_new_line_before_else_statements;
377
//	public static String ControlStatementsTabPage_general_group_insert_new_line_before_catch_statements;
378
//	public static String ControlStatementsTabPage_general_group_insert_new_line_before_finally_statements;
379
//	public static String ControlStatementsTabPage_general_group_insert_new_line_before_while_in_do_statements;
380
//	public static String ControlStatementsTabPage_if_else_group_title;
381
//	public static String ControlStatementsTabPage_if_else_group_keep_then_on_same_line;
382
//	public static String ControlStatementsTabPage_if_else_group_keep_simple_if_on_one_line;
383
//	public static String ControlStatementsTabPage_if_else_group_keep_else_on_same_line;
384
//	public static String ControlStatementsTabPage_if_else_group_keep_else_if_on_one_line;
385
//	public static String ControlStatementsTabPage_if_else_group_keep_guardian_clause_on_one_line;
386
	public static String CreateProfileDialog_status_message_profile_with_this_name_already_exists;
387
	public static String CreateProfileDialog_status_message_profile_name_is_empty;
388
	public static String CreateProfileDialog_dialog_title;
389
	public static String CreateProfileDialog_profile_name_label_text;
390
	public static String CreateProfileDialog_base_profile_label_text;
391
	public static String CreateProfileDialog_open_edit_dialog_checkbox_text;
392
	public static String IndentationTabPage_preview_header;
393
	public static String IndentationTabPage_general_group_title;
394
	public static String IndentationTabPage_general_group_option_tab_policy;
395
	public static String IndentationTabPage_general_group_option_tab_policy_SPACE;
396
	public static String IndentationTabPage_general_group_option_tab_policy_TAB;
397
	public static String IndentationTabPage_general_group_option_tab_policy_MIXED;
398
	public static String IndentationTabPage_general_group_option_tab_size;
399
	public static String IndentationTabPage_general_group_option_indent_size;
400
	public static String IndentationTabPage_field_alignment_group_title;
401
	public static String IndentationTabPage_field_alignment_group_align_fields_in_columns;
402
	public static String IndentationTabPage_indent_group_title;
403
	public static String IndentationTabPage_class_group_option_indent_access_specifiers_within_class_body;
404
	public static String IndentationTabPage_class_group_option_indent_declarations_compare_to_access_specifiers;
405
	public static String IndentationTabPage_class_group_option_indent_declarations_within_enum_const;
406
	public static String IndentationTabPage_class_group_option_indent_declarations_within_enum_decl;
407
	public static String IndentationTabPage_block_group_option_indent_statements_compare_to_body;
408
	public static String IndentationTabPage_block_group_option_indent_statements_compare_to_block;
409
	public static String IndentationTabPage_switch_group_option_indent_statements_within_switch_body;
410
	public static String IndentationTabPage_switch_group_option_indent_statements_within_case_body;
411
	public static String IndentationTabPage_switch_group_option_indent_break_statements;
412
    public static String IndentationTabPage_indent_empty_lines;
413
	public static String IndentationTabPage_use_tabs_only_for_leading_indentations;
414
	public static String ModifyDialog_dialog_title;
415
	public static String ModifyDialog_apply_button;
416
	public static String ModifyDialog_dialog_show_title;
417
	public static String ModifyDialog_dialog_show_warning_builtin;
418
	public static String ModifyDialog_tabpage_braces_title;
419
	public static String ModifyDialog_tabpage_indentation_title;
420
	public static String ModifyDialog_tabpage_whitespace_title;
421
	public static String ModifyDialog_tabpage_blank_lines_title;
422
	public static String ModifyDialog_tabpage_new_lines_title;
423
	public static String ModifyDialog_tabpage_control_statements_title;
424
	public static String ModifyDialog_tabpage_line_wrapping_title;
425
	public static String ModifyDialog_tabpage_comments_title;
426
	public static String ModifyDialogTabPage_preview_label_text;
427
	public static String ModifyDialogTabPage_error_msg_values_text_unassigned;
428
	public static String ModifyDialogTabPage_error_msg_values_items_text_unassigned;
429
	public static String ModifyDialogTabPage_NumberPreference_error_invalid_key;
430
	public static String ModifyDialogTabPage_NumberPreference_error_invalid_value;
431
//	public static String NewLinesTabPage_preview_header;
432
//	public static String NewLinesTabPage_newlines_group_title;
433
//	public static String NewLinesTabPage_newlines_group_option_empty_class_body;
434
//	public static String NewLinesTabPage_newlines_group_option_empty_annotation_decl_body;
435
//	public static String NewLinesTabPage_newlines_group_option_empty_anonymous_class_body;
436
//	public static String NewLinesTabPage_newlines_group_option_empty_enum_declaration;
437
//	public static String NewLinesTabPage_newlines_group_option_empty_enum_constant;
438
//	public static String NewLinesTabPage_newlines_group_option_empty_method_body;
439
//	public static String NewLinesTabPage_newlines_group_option_empty_block;
440
//	public static String NewLinesTabPage_newlines_group_option_empty_end_of_file;
441
//	public static String NewLinesTabPage_empty_statement_group_title;
442
//	public static String NewLinesTabPage_emtpy_statement_group_option_empty_statement_on_new_line;
443
//	public static String NewLinesTabPage_arrayInitializer_group_title;
444
//	public static String NewLinesTabPage_array_group_option_after_opening_brace_of_array_initializer;
445
//	public static String NewLinesTabPage_array_group_option_before_closing_brace_of_array_initializer;
446
//	public static String NewLinesTabPage_annotations_group_title;
447
//	public static String NewLinesTabPage_annotations_group_option_after_annotation;
448
	public static String ProfileManager_default_profile_name;
449
	public static String ProfileManager_unmanaged_profile;
450
	public static String ProfileManager_unmanaged_profile_with_name;
451
	public static String RenameProfileDialog_status_message_profile_with_this_name_already_exists;
452
	public static String RenameProfileDialog_status_message_profile_name_empty;
453
	public static String RenameProfileDialog_dialog_title;
454
	public static String RenameProfileDialog_dialog_label_enter_a_new_name;
455
456
	public static String CPreview_formatter_exception;
457
458
	static {
459
		NLS.initializeMessages(BUNDLE_NAME, FormatterMessages.class);
460
	}
461
}
(-)src/org/eclipse/cdt/internal/ui/text/comment/CommentFormattingContext.java (+52 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.text.comment;
14
15
import org.eclipse.jface.text.formatter.FormattingContext;
16
17
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
18
19
/**
20
 * Formatting context for the comment formatter.
21
 *
22
 * @since 4.0
23
 */
24
public class CommentFormattingContext extends FormattingContext {
25
26
	/*
27
	 * @see org.eclipse.jface.text.formatter.IFormattingContext#getPreferenceKeys()
28
	 */
29
	public String[] getPreferenceKeys() {
30
		return new String[] {
31
			    DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT,
32
			    DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER,
33
			    DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE,
34
			    DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH,
35
			    DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES};
36
	}
37
38
39
	/*
40
	 * @see org.eclipse.jface.text.formatter.IFormattingContext#isBooleanPreference(java.lang.String)
41
	 */
42
	public boolean isBooleanPreference(String key) {
43
		return !key.equals(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH);
44
	}
45
46
	/*
47
	 * @see org.eclipse.jface.text.formatter.IFormattingContext#isIntegerPreference(java.lang.String)
48
	 */
49
	public boolean isIntegerPreference(String key) {
50
		return key.equals(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH);
51
	}
52
}
(-)src/org/eclipse/cdt/internal/ui/preferences/SmartTypingPreferencePage.java (+59 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporatio - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.preferences;
14
15
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.swt.widgets.Label;
17
18
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
19
import org.eclipse.cdt.ui.CUIPlugin;
20
21
/**
22
 * The page for setting the editor options.
23
 */
24
public final class SmartTypingPreferencePage extends AbstractConfigurationBlockPreferencePage {
25
	
26
	/*
27
	 * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
28
	 */
29
	protected String getHelpId() {
30
		return ICHelpContextIds.C_EDITOR_TYPING_PAGE;
31
	}
32
33
	/*
34
	 * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
35
	 */
36
	protected void setDescription() {
37
		String description= PreferencesMessages.CEditorPreferencePage_typing_tabTitle; 
38
		setDescription(description);
39
	}
40
	
41
	/*
42
	 * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
43
	 */
44
	protected void setPreferenceStore() {
45
		setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
46
	}
47
	
48
	
49
	protected Label createDescriptionLabel(Composite parent) {
50
		return null; // no description for new look.
51
	}
52
	
53
	/*
54
	 * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
55
	 */
56
	protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
57
		return new SmartTypingConfigurationBlock(overlayPreferenceStore);
58
	}
59
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileVersioner.java (+63 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.preferences.formatter;
14
15
import java.util.Iterator;
16
import java.util.Map;
17
18
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
19
20
21
public class ProfileVersioner {
22
	
23
	public static final int VERSION_1= 1; // < 20040113 (includes M6)
24
	
25
	public static final int CURRENT_VERSION= VERSION_1;
26
	
27
	public static int getVersionStatus(CustomProfile profile) {
28
		final int version= profile.getVersion();
29
		if (version < CURRENT_VERSION) 
30
			return -1;
31
		else if (version > CURRENT_VERSION)
32
			return 1;
33
		else 
34
			return 0;
35
	}
36
	
37
	public static void updateAndComplete(CustomProfile profile) {
38
		final Map oldSettings= profile.getSettings();
39
		Map newSettings= updateAndComplete(oldSettings, profile.getVersion());
40
		profile.setVersion(CURRENT_VERSION);
41
		profile.setSettings(newSettings);
42
	}
43
	
44
	public static Map updateAndComplete(Map oldSettings, int version) {
45
		final Map newSettings= ProfileManager.getDefaultSettings();
46
		
47
		switch (version) {
48
		    
49
		default:
50
		    for (final Iterator iter= oldSettings.keySet().iterator(); iter.hasNext(); ) {
51
		        final String key= (String)iter.next();
52
		        if (!newSettings.containsKey(key)) 
53
		            continue;
54
		        
55
		        final String value= (String)oldSettings.get(key);
56
		        if (value != null) {
57
		            newSettings.put(key, value);
58
		        }
59
		    }
60
		}
61
		return newSettings;
62
	}
63
 }
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialog.java (+267 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.preferences.formatter;
13
14
import java.util.ArrayList;
15
import java.util.HashMap;
16
import java.util.List;
17
import java.util.Map;
18
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.core.runtime.Status;
21
22
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.graphics.Point;
24
import org.eclipse.swt.graphics.Rectangle;
25
import org.eclipse.swt.layout.GridData;
26
import org.eclipse.swt.layout.GridLayout;
27
import org.eclipse.swt.widgets.Composite;
28
import org.eclipse.swt.widgets.Control;
29
import org.eclipse.swt.widgets.Label;
30
import org.eclipse.swt.widgets.Shell;
31
32
import org.eclipse.jface.dialogs.IDialogConstants;
33
import org.eclipse.jface.dialogs.IDialogSettings;
34
import org.eclipse.jface.dialogs.StatusDialog;
35
import org.eclipse.jface.window.Window;
36
37
import org.eclipse.cdt.internal.ui.util.Messages;
38
39
import org.eclipse.cdt.ui.CUIPlugin;
40
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
41
42
public class ModifyDialog extends StatusDialog {
43
    
44
    /**
45
     * The keys to retrieve the preferred area from the dialog settings.
46
     */
47
    private static final String DS_KEY_PREFERRED_WIDTH= CUIPlugin.PLUGIN_ID + "formatter_page.modify_dialog.preferred_width"; //$NON-NLS-1$
48
    private static final String DS_KEY_PREFERRED_HEIGHT= CUIPlugin.PLUGIN_ID + "formatter_page.modify_dialog.preferred_height"; //$NON-NLS-1$
49
    private static final String DS_KEY_PREFERRED_X= CUIPlugin.PLUGIN_ID + "formatter_page.modify_dialog.preferred_x"; //$NON-NLS-1$
50
    private static final String DS_KEY_PREFERRED_Y= CUIPlugin.PLUGIN_ID + "formatter_page.modify_dialog.preferred_y"; //$NON-NLS-1$
51
    
52
    /**
53
     * The key to store the number (beginning at 0) of the tab page which had the 
54
     * focus last time.
55
     */
56
    private static final String DS_KEY_LAST_FOCUS= CUIPlugin.PLUGIN_ID + "formatter_page.modify_dialog.last_focus"; //$NON-NLS-1$ 
57
58
	private final String fTitle;
59
	
60
	private final boolean fNewProfile;
61
62
	private Profile fProfile;
63
	private final Map fWorkingValues;
64
	
65
	private IStatus fStandardStatus;
66
	
67
	protected final List fTabPages;
68
	
69
	final IDialogSettings fDialogSettings;
70
//	private TabFolder fTabFolder;
71
	private ProfileManager fProfileManager;
72
//	private Button fApplyButton;
73
		
74
	protected ModifyDialog(Shell parentShell, Profile profile, ProfileManager profileManager, boolean newProfile) {
75
		super(parentShell);
76
		fProfileManager= profileManager;
77
		fNewProfile= newProfile;
78
		setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX );
79
				
80
		fProfile= profile;
81
		if (fProfile.isBuiltInProfile()) {
82
		    fStandardStatus= new Status(IStatus.INFO, CUIPlugin.getPluginId(), IStatus.OK, FormatterMessages.ModifyDialog_dialog_show_warning_builtin, null); 
83
		    fTitle= Messages.format(FormatterMessages.ModifyDialog_dialog_show_title, profile.getName()); 
84
		} else {
85
		    fStandardStatus= new Status(IStatus.OK, CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
86
		    fTitle= Messages.format(FormatterMessages.ModifyDialog_dialog_title, profile.getName()); 
87
		}
88
		fWorkingValues= new HashMap(fProfile.getSettings());
89
		updateStatus(fStandardStatus);
90
		setStatusLineAboveButtons(false);
91
		fTabPages= new ArrayList();
92
		fDialogSettings= CUIPlugin.getDefault().getDialogSettings();	
93
	}
94
	
95
	public void create() {
96
		super.create();
97
		int lastFocusNr= 0;
98
		try {
99
			lastFocusNr= fDialogSettings.getInt(DS_KEY_LAST_FOCUS);
100
			if (lastFocusNr < 0) lastFocusNr= 0;
101
			if (lastFocusNr > fTabPages.size() - 1) lastFocusNr= fTabPages.size() - 1;
102
		} catch (NumberFormatException x) {
103
			lastFocusNr= 0;
104
		}
105
		
106
		if (!fNewProfile) {
107
//			fTabFolder.setSelection(lastFocusNr);
108
//			((ModifyDialogTabPage)fTabFolder.getSelection()[0].getData()).setInitialFocus();
109
		}
110
	}
111
	
112
	protected void configureShell(Shell shell) {
113
		super.configureShell(shell);
114
		shell.setText(fTitle);
115
	}
116
117
	protected Control createDialogArea(Composite parent) {
118
		
119
		final Composite composite= (Composite)super.createDialogArea(parent);
120
121
		ModifyDialogTabPage tabPage = new IndentationTabPage(this, fWorkingValues);
122
		tabPage.createContents(composite);
123
//		fTabFolder = new TabFolder(composite, SWT.NONE);
124
//		fTabFolder.setFont(composite.getFont());
125
//		fTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
126
//
127
//		addTabPage(fTabFolder, FormatterMessages.ModifyDialog_tabpage_indentation_title, new IndentationTabPage(this, fWorkingValues)); 
128
//		addTabPage(fTabFolder, FormatterMessages.ModifyDialog_tabpage_braces_title, new BracesTabPage(this, fWorkingValues)); 
129
//		addTabPage(fTabFolder, FormatterMessages.ModifyDialog_tabpage_whitespace_title, new WhiteSpaceTabPage(this, fWorkingValues)); 
130
//		addTabPage(fTabFolder, FormatterMessages.ModifyDialog_tabpage_blank_lines_title, new BlankLinesTabPage(this, fWorkingValues)); 
131
//		addTabPage(fTabFolder, FormatterMessages.ModifyDialog_tabpage_new_lines_title, new NewLinesTabPage(this, fWorkingValues)); 
132
//		addTabPage(fTabFolder, FormatterMessages.ModifyDialog_tabpage_control_statements_title, new ControlStatementsTabPage(this, fWorkingValues)); 
133
//		addTabPage(fTabFolder, FormatterMessages.ModifyDialog_tabpage_line_wrapping_title, new LineWrappingTabPage(this, fWorkingValues)); 
134
//		addTabPage(fTabFolder, FormatterMessages.ModifyDialog_tabpage_comments_title, new CommentsTabPage(this, fWorkingValues)); 
135
		
136
		applyDialogFont(composite);
137
		
138
//		fTabFolder.addSelectionListener(new SelectionListener() {
139
//			public void widgetDefaultSelected(SelectionEvent e) {}
140
//			public void widgetSelected(SelectionEvent e) {
141
//				final TabItem tabItem= (TabItem)e.item;
142
//				final ModifyDialogTabPage page= (ModifyDialogTabPage)tabItem.getData();
143
////				page.fSashForm.setWeights();
144
//				fDialogSettings.put(DS_KEY_LAST_FOCUS, fTabPages.indexOf(page));
145
//				page.makeVisible();
146
//			}
147
//		});
148
		return composite;
149
	}
150
	
151
	public void updateStatus(IStatus status) {
152
	    super.updateStatus(status != null ? status : fStandardStatus);    
153
	}
154
155
	/* (non-Javadoc)
156
	 * @see org.eclipse.jface.window.Window#getInitialSize()
157
	 */
158
	protected Point getInitialSize() {
159
    	Point initialSize= super.getInitialSize();
160
        try {
161
        	int lastWidth= fDialogSettings.getInt(DS_KEY_PREFERRED_WIDTH);
162
        	if (initialSize.x > lastWidth)
163
        		lastWidth= initialSize.x;
164
        	int lastHeight= fDialogSettings.getInt(DS_KEY_PREFERRED_HEIGHT);
165
        	if (initialSize.y > lastHeight)
166
        		lastHeight= initialSize.x;
167
       		return new Point(lastWidth, lastHeight);
168
        } catch (NumberFormatException ex) {
169
        }
170
        return initialSize;
171
	}
172
	
173
	/* (non-Javadoc)
174
	 * @see org.eclipse.jface.window.Window#getInitialLocation(org.eclipse.swt.graphics.Point)
175
	 */
176
	protected Point getInitialLocation(Point initialSize) {
177
        try {
178
        	return new Point(fDialogSettings.getInt(DS_KEY_PREFERRED_X), fDialogSettings.getInt(DS_KEY_PREFERRED_Y));
179
        } catch (NumberFormatException ex) {
180
        	return super.getInitialLocation(initialSize);
181
        }
182
	}
183
	    
184
	public boolean close() {
185
		final Rectangle shell= getShell().getBounds();
186
		
187
		fDialogSettings.put(DS_KEY_PREFERRED_WIDTH, shell.width);
188
		fDialogSettings.put(DS_KEY_PREFERRED_HEIGHT, shell.height);
189
		fDialogSettings.put(DS_KEY_PREFERRED_X, shell.x);
190
		fDialogSettings.put(DS_KEY_PREFERRED_Y, shell.y);
191
		
192
		return super.close();
193
	}
194
	
195
	/* (non-Javadoc)
196
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
197
	 */
198
	protected void okPressed() {
199
		applyPressed();
200
		super.okPressed();
201
	}
202
	
203
    protected void buttonPressed(int buttonId) {
204
		if (buttonId == IDialogConstants.CLIENT_ID) {
205
			applyPressed();
206
		} else {
207
			super.buttonPressed(buttonId);
208
		}
209
    }
210
	
211
	private void applyPressed() {
212
		 if (fProfile.isBuiltInProfile() || fProfile.isSharedProfile()) {
213
		 	RenameProfileDialog dialog= new RenameProfileDialog(getShell(), fProfile, fProfileManager);
214
		 	if (dialog.open() != Window.OK) {
215
		 		return;
216
		 	}
217
218
			fProfile= dialog.getRenamedProfile();
219
			
220
		    fStandardStatus= new Status(IStatus.OK, CUIPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
221
			updateStatus(fStandardStatus);
222
		 }
223
		 fProfile.setSettings(new HashMap(fWorkingValues));
224
//		 fApplyButton.setEnabled(false);
225
	}
226
    
227
    protected void createButtonsForButtonBar(Composite parent) {
228
//	    fApplyButton= createButton(parent, IDialogConstants.CLIENT_ID, FormatterMessages.ModifyDialog_apply_button, false); 
229
//		fApplyButton.setEnabled(false);
230
		
231
		GridLayout layout= (GridLayout) parent.getLayout();
232
		layout.numColumns++;
233
		layout.makeColumnsEqualWidth= false;
234
		Label label= new Label(parent, SWT.NONE);
235
		GridData data= new GridData();
236
		data.widthHint= layout.horizontalSpacing;
237
		label.setLayoutData(data);
238
		super.createButtonsForButtonBar(parent);
239
    }
240
    
241
	
242
//	private final void addTabPage(TabFolder tabFolder, String title, ModifyDialogTabPage tabPage) {
243
//		final TabItem tabItem= new TabItem(tabFolder, SWT.NONE);
244
//		applyDialogFont(tabItem.getControl());
245
//		tabItem.setText(title);
246
//		tabItem.setData(tabPage);
247
//		tabItem.setControl(tabPage.createContents(tabFolder));
248
//		fTabPages.add(tabPage);
249
//	}
250
251
	public void valuesModified() {
252
//		if (fApplyButton != null && !fApplyButton.isDisposed()) {
253
//			fApplyButton.setEnabled(hasChanges());
254
//		}
255
	}
256
257
//	private boolean hasChanges() {
258
//		Iterator iter= fProfile.getSettings().entrySet().iterator();
259
//		for (;iter.hasNext();) {
260
//			Map.Entry curr= (Map.Entry) iter.next();
261
//			if (!fWorkingValues.get(curr.getKey()).equals(curr.getValue())) {
262
//				return true;
263
//			}
264
//		}
265
//		return false;
266
//	}
267
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/IndentationTabPage.java (+181 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     istvan@benedek-home.de - 103706 [formatter] indent empty lines
11
 *     Sergey Prigogin, Google
12
 *******************************************************************************/
13
package org.eclipse.cdt.internal.ui.preferences.formatter;
14
15
import java.util.Map;
16
import java.util.Observable;
17
import java.util.Observer;
18
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Group;
21
22
import org.eclipse.jface.text.Assert;
23
24
import org.eclipse.cdt.core.CCorePlugin;
25
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
26
27
28
public class IndentationTabPage extends ModifyDialogTabPage {
29
	
30
//	private final String PREVIEW=
31
//	createPreviewHeader(FormatterMessages.IndentationTabPage_preview_header) + 
32
//	"class Example {" +	//$NON-NLS-1$
33
//	"  int [] myArray= {1,2,3,4,5,6};" + //$NON-NLS-1$
34
//	"  int theInt= 1;" + //$NON-NLS-1$
35
//	"  String someString= \"Hello\";" + //$NON-NLS-1$
36
//	"  double aDouble= 3.0;" + //$NON-NLS-1$
37
//	"  void foo(int a, int b, int c, int d, int e, int f) {" + //$NON-NLS-1$
38
//	"    switch(a) {" + //$NON-NLS-1$
39
//	"    case 0: " + //$NON-NLS-1$
40
//	"      Other.doFoo();" + //$NON-NLS-1$
41
//	"      break;" + //$NON-NLS-1$
42
//	"    default:" + //$NON-NLS-1$
43
//	"      Other.doBaz();" + //$NON-NLS-1$
44
//	"    }" + //$NON-NLS-1$
45
//	"  }" + //$NON-NLS-1$
46
//	"  void bar(List v) {" + //$NON-NLS-1$
47
//	"    for (int i= 0; i < 10; i++) {" + //$NON-NLS-1$
48
// 	"      v.add(new Integer(i));" + //$NON-NLS-1$
49
// 	"    }" + //$NON-NLS-1$
50
//	"  }" + //$NON-NLS-1$
51
//	"}" + //$NON-NLS-1$
52
//	"\n" + //$NON-NLS-1$
53
//	"enum MyEnum {" + //$NON-NLS-1$
54
//	"    UNDEFINED(0) {" + //$NON-NLS-1$
55
//	"        void foo() {}" + //$NON-NLS-1$
56
//	"    }" + //$NON-NLS-1$
57
//	"}" + //$NON-NLS-1$
58
//	"@interface MyAnnotation {" + //$NON-NLS-1$
59
//	"    int count() default 1;" + //$NON-NLS-1$
60
//	"}";//$NON-NLS-1$
61
	
62
//	private CompilationUnitPreview fPreview;
63
	private String fOldTabChar= null;
64
	
65
	public IndentationTabPage(ModifyDialog modifyDialog, Map workingValues) {
66
		super(modifyDialog, workingValues);
67
	}
68
69
	protected void doCreatePreferences(Composite composite, int numColumns) {
70
71
		final Group generalGroup= createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_general_group_title); 
72
		
73
		final String[] tabPolicyValues= new String[] {CCorePlugin.SPACE, CCorePlugin.TAB, DefaultCodeFormatterConstants.MIXED};
74
		final String[] tabPolicyLabels= new String[] {
75
				FormatterMessages.IndentationTabPage_general_group_option_tab_policy_SPACE, 
76
				FormatterMessages.IndentationTabPage_general_group_option_tab_policy_TAB, 
77
				FormatterMessages.IndentationTabPage_general_group_option_tab_policy_MIXED
78
		};
79
		final ComboPreference tabPolicy= createComboPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_tab_policy, DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, tabPolicyValues, tabPolicyLabels);
80
		final CheckboxPreference onlyForLeading= createCheckboxPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_use_tabs_only_for_leading_indentations, DefaultCodeFormatterConstants.FORMATTER_USE_TABS_ONLY_FOR_LEADING_INDENTATIONS, FALSE_TRUE);
81
		final NumberPreference indentSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_indent_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32); 
82
		final NumberPreference tabSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_tab_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32);
83
		
84
		String tabchar= (String) fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
85
		updateTabPreferences(tabchar, tabSize, indentSize, onlyForLeading);
86
		tabPolicy.addObserver(new Observer() {
87
			public void update(Observable o, Object arg) {
88
				updateTabPreferences((String) arg, tabSize, indentSize, onlyForLeading);
89
			}
90
		});
91
		tabSize.addObserver(new Observer() {
92
			public void update(Observable o, Object arg) {
93
				indentSize.updateWidget();
94
			}
95
		});
96
		
97
//		final Group typeMemberGroup= createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_field_alignment_group_title); 
98
//		createCheckboxPref(typeMemberGroup, numColumns, FormatterMessages.IndentationTabPage_field_alignment_group_align_fields_in_columns, DefaultCodeFormatterConstants.FORMATTER_ALIGN_TYPE_MEMBERS_ON_COLUMNS, FALSE_TRUE); 
99
		
100
		final Group classGroup = createGroup(numColumns, composite, FormatterMessages.IndentationTabPage_indent_group_title); 
101
		createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_class_group_option_indent_access_specifiers_within_class_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_ACCESS_SPECIFIER_COMPARE_TO_TYPE_HEADER, FALSE_TRUE); 
102
		createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_class_group_option_indent_declarations_compare_to_access_specifiers, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ACCESS_SPECIFIER, FALSE_TRUE); 
103
		createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_class_group_option_indent_declarations_within_enum_decl, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_DECLARATION_HEADER, FALSE_TRUE);
104
		createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_class_group_option_indent_declarations_within_enum_const, DefaultCodeFormatterConstants.FORMATTER_INDENT_BODY_DECLARATIONS_COMPARE_TO_ENUM_CONSTANT_HEADER, FALSE_TRUE); 
105
106
		createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_block_group_option_indent_statements_compare_to_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BODY, FALSE_TRUE); 
107
		createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_block_group_option_indent_statements_compare_to_block, DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK, FALSE_TRUE); 
108
109
		createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_switch_group_option_indent_statements_within_switch_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_SWITCH, FALSE_TRUE); 
110
		createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_switch_group_option_indent_statements_within_case_body, DefaultCodeFormatterConstants.FORMATTER_INDENT_SWITCHSTATEMENTS_COMPARE_TO_CASES, FALSE_TRUE); 
111
		createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_switch_group_option_indent_break_statements, DefaultCodeFormatterConstants.FORMATTER_INDENT_BREAKS_COMPARE_TO_CASES, FALSE_TRUE); 
112
        createCheckboxPref(classGroup, numColumns, FormatterMessages.IndentationTabPage_indent_empty_lines, DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES, FALSE_TRUE); 
113
	}
114
	
115
	public void initializePage() {
116
//	    fPreview.setPreviewText(PREVIEW);
117
	}
118
	
119
    /* (non-Javadoc)
120
     * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doCreateCPreview(org.eclipse.swt.widgets.Composite)
121
     */
122
    protected CPreview doCreateCPreview(Composite parent) {
123
//        fPreview= new CompilationUnitPreview(fWorkingValues, parent);
124
//        return fPreview;
125
    	return null;
126
    }
127
128
    /* (non-Javadoc)
129
     * @see org.eclipse.cdt.internal.ui.preferences.formatter.ModifyDialogTabPage#doUpdatePreview()
130
     */
131
    protected void doUpdatePreview() {
132
//        fPreview.update();
133
    }
134
135
	private void updateTabPreferences(String tabPolicy, NumberPreference tabPreference, NumberPreference indentPreference, CheckboxPreference onlyForLeading) {
136
		/*
137
		 * If the tab-char is SPACE (or TAB), INDENTATION_SIZE
138
		 * preference is not used by the core formatter. We piggy back the
139
		 * visual tab length setting in that preference in that case. If the
140
		 * user selects MIXED, we use the previous TAB_SIZE preference as the
141
		 * new INDENTATION_SIZE (as this is what it really is) and set the 
142
		 * visual tab size to the value piggy backed in the INDENTATION_SIZE
143
		 * preference. See also CodeFormatterUtil. 
144
		 */
145
		if (DefaultCodeFormatterConstants.MIXED.equals(tabPolicy)) {
146
			if (CCorePlugin.SPACE.equals(fOldTabChar) || CCorePlugin.TAB.equals(fOldTabChar))
147
				swapTabValues();
148
			tabPreference.setEnabled(true);
149
			tabPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
150
			indentPreference.setEnabled(true);
151
			indentPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
152
			onlyForLeading.setEnabled(true);
153
		} else if (CCorePlugin.SPACE.equals(tabPolicy)) {
154
			if (DefaultCodeFormatterConstants.MIXED.equals(fOldTabChar))
155
				swapTabValues();
156
			tabPreference.setEnabled(true);
157
			tabPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
158
			indentPreference.setEnabled(true);
159
			indentPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
160
			onlyForLeading.setEnabled(false);
161
		} else if (CCorePlugin.TAB.equals(tabPolicy)) {
162
			if (DefaultCodeFormatterConstants.MIXED.equals(fOldTabChar))
163
				swapTabValues();
164
			tabPreference.setEnabled(true);
165
			tabPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
166
			indentPreference.setEnabled(false);
167
			indentPreference.setKey(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
168
			onlyForLeading.setEnabled(true);
169
		} else {
170
			Assert.isTrue(false);
171
		}
172
		fOldTabChar= tabPolicy;
173
	}
174
175
	private void swapTabValues() {
176
		Object tabSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
177
		Object indentSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
178
		fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, indentSize);
179
		fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, tabSize);
180
	}
181
}
(-)src/org/eclipse/cdt/internal/ui/actions/IndentAction.java (+573 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.actions;
13
14
import java.util.ResourceBundle;
15
16
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.Status;
18
19
import org.eclipse.swt.custom.BusyIndicator;
20
import org.eclipse.swt.widgets.Display;
21
22
import org.eclipse.jface.viewers.ISelection;
23
import org.eclipse.jface.viewers.ISelectionProvider;
24
25
import org.eclipse.jface.text.Assert;
26
import org.eclipse.jface.text.BadLocationException;
27
import org.eclipse.jface.text.IDocument;
28
import org.eclipse.jface.text.IRegion;
29
import org.eclipse.jface.text.IRewriteTarget;
30
import org.eclipse.jface.text.ITextSelection;
31
import org.eclipse.jface.text.ITypedRegion;
32
import org.eclipse.jface.text.Position;
33
import org.eclipse.jface.text.TextSelection;
34
import org.eclipse.jface.text.TextUtilities;
35
import org.eclipse.jface.text.source.ISourceViewer;
36
37
import org.eclipse.ui.IEditorInput;
38
import org.eclipse.ui.texteditor.IDocumentProvider;
39
import org.eclipse.ui.texteditor.ITextEditor;
40
import org.eclipse.ui.texteditor.ITextEditorExtension3;
41
import org.eclipse.ui.texteditor.TextEditorAction;
42
43
import org.eclipse.cdt.core.CCorePlugin;
44
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
45
import org.eclipse.cdt.core.model.ICProject;
46
import org.eclipse.cdt.core.model.ITranslationUnit;
47
48
import org.eclipse.cdt.ui.CUIPlugin;
49
import org.eclipse.cdt.ui.text.ICPartitions;
50
51
import org.eclipse.cdt.internal.ui.editor.CEditor;
52
import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
53
import org.eclipse.cdt.internal.ui.text.CIndenter;
54
55
56
/**
57
 * Indents a line or range of lines in a C document to its correct position. No complete
58
 * AST must be present, the indentation is computed using heuristics. The algorithm used is fast for
59
 * single lines, but does not store any information and therefore not so efficient for large line
60
 * ranges.
61
 * 
62
 * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner
63
 * @see org.eclipse.cdt.internal.ui.text.CIndenter
64
 */
65
public class IndentAction extends TextEditorAction {
66
	
67
	/** The caret offset after an indent operation. */
68
	private int fCaretOffset;
69
	
70
	/** 
71
	 * Whether this is the action invoked by TAB. When <code>true</code>, indentation behaves 
72
	 * differently to accommodate normal TAB operation.
73
	 */
74
	private final boolean fIsTabAction;
75
	
76
	/**
77
	 * Creates a new instance.
78
	 * 
79
	 * @param bundle the resource bundle
80
	 * @param prefix the prefix to use for keys in <code>bundle</code>
81
	 * @param editor the text editor
82
	 * @param isTabAction whether the action should insert tabs if over the indentation
83
	 */
84
	public IndentAction(ResourceBundle bundle, String prefix, ITextEditor editor, boolean isTabAction) {
85
		super(bundle, prefix, editor);
86
		fIsTabAction= isTabAction;
87
	}
88
	
89
	/*
90
	 * @see org.eclipse.jface.action.Action#run()
91
	 */
92
	public void run() {
93
		// update has been called by the framework
94
		if (!isEnabled() || !validateEditorInputState())
95
			return;
96
		
97
		ITextSelection selection= getSelection();
98
		final IDocument document= getDocument();
99
		
100
		if (document != null) {
101
			final int offset= selection.getOffset();
102
			final int length= selection.getLength();
103
			final Position end= new Position(offset + length);
104
			final int firstLine, nLines;
105
			fCaretOffset= -1;
106
			
107
			try {
108
				document.addPosition(end);
109
				firstLine= document.getLineOfOffset(offset);
110
				// check for marginal (zero-length) lines
111
				int minusOne= length == 0 ? 0 : 1;
112
				nLines= document.getLineOfOffset(offset + length - minusOne) - firstLine + 1;
113
			} catch (BadLocationException e) {
114
				// will only happen on concurrent modification
115
				CUIPlugin.getDefault().log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "", e)); //$NON-NLS-1$
116
				return;
117
			}
118
			
119
			Runnable runnable= new Runnable() {
120
				public void run() {
121
					IRewriteTarget target= (IRewriteTarget)getTextEditor().getAdapter(IRewriteTarget.class);
122
					if (target != null)
123
						target.beginCompoundChange();
124
					
125
					try {
126
						CHeuristicScanner scanner= new CHeuristicScanner(document);
127
						CIndenter indenter= new CIndenter(document, scanner, getCProject());
128
						final boolean multiLine= nLines > 1;
129
						boolean hasChanged= false;
130
						for (int i= 0; i < nLines; i++) {
131
							hasChanged |= indentLine(document, firstLine + i, offset, indenter, scanner, multiLine);
132
						}
133
						
134
						// update caret position: move to new position when indenting just one line
135
						// keep selection when indenting multiple
136
						int newOffset, newLength;
137
						if (!fIsTabAction && multiLine) {
138
							newOffset= offset;
139
							newLength= end.getOffset() - offset;
140
						} else {
141
							newOffset= fCaretOffset;
142
							newLength= 0;
143
						}
144
						
145
						// always reset the selection if anything was replaced
146
						// but not when we had a single line non-tab invocation
147
						if (newOffset != -1 && (hasChanged || newOffset != offset || newLength != length))
148
							selectAndReveal(newOffset, newLength);
149
						
150
						document.removePosition(end);
151
					} catch (BadLocationException e) {
152
						// will only happen on concurrent modification
153
						CUIPlugin.getDefault().log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "ConcurrentModification in IndentAction", e)); //$NON-NLS-1$
154
					} finally {
155
						if (target != null)
156
							target.endCompoundChange();
157
					}
158
				}
159
			};
160
			
161
			if (nLines > 50) {
162
				Display display= getTextEditor().getEditorSite().getWorkbenchWindow().getShell().getDisplay();
163
				BusyIndicator.showWhile(display, runnable);
164
			} else {
165
				runnable.run();
166
			}
167
		}
168
	}
169
	
170
	/**
171
	 * Selects the given range on the editor.
172
	 * 
173
	 * @param newOffset the selection offset
174
	 * @param newLength the selection range
175
	 */
176
	private void selectAndReveal(int newOffset, int newLength) {
177
		Assert.isTrue(newOffset >= 0); 
178
		Assert.isTrue(newLength >= 0); 
179
		ITextEditor editor= getTextEditor();
180
		if (editor instanceof CEditor) {
181
			ISourceViewer viewer= ((CEditor)editor).getViewer();
182
			if (viewer != null)
183
				viewer.setSelectedRange(newOffset, newLength);
184
		} else {
185
			// this is too intrusive, but will never get called anyway
186
			getTextEditor().selectAndReveal(newOffset, newLength);
187
		}
188
	}
189
190
	/**
191
	 * Indents a single line using the java heuristic scanner. Cdoc and multiline comments are 
192
	 * indented as specified by the <code>CDocAutoIndentStrategy</code>.
193
	 * 
194
	 * @param document the document
195
	 * @param line the line to be indented
196
	 * @param caret the caret position
197
	 * @param indenter the java indenter
198
	 * @param scanner the heuristic scanner
199
	 * @param multiLine <code>true</code> if more than one line is being indented 
200
	 * @return <code>true</code> if <code>document</code> was modified, <code>false</code> otherwise
201
	 * @throws BadLocationException if the document got changed concurrently 
202
	 */
203
	private boolean indentLine(IDocument document, int line, int caret, CIndenter indenter, CHeuristicScanner scanner, boolean multiLine) throws BadLocationException {
204
		IRegion currentLine= document.getLineInformation(line);
205
		int offset= currentLine.getOffset();
206
		int wsStart= offset; // where we start searching for non-WS; after the "//" in single line comments
207
		
208
		String indent= null;
209
		if (offset < document.getLength()) {
210
			ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
211
			ITypedRegion startingPartition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, false);
212
			String type= partition.getType();
213
			if (type.equals(ICPartitions.C_MULTI_LINE_COMMENT)) {
214
				indent= computeDocIndent(document, line, scanner, startingPartition);
215
			} else if (!fIsTabAction && startingPartition.getOffset() == offset && startingPartition.getType().equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
216
				// line comment starting at position 0 -> indent inside
217
				int max= document.getLength() - offset;
218
				int slashes= 2;
219
				while (slashes < max - 1 && document.get(offset + slashes, 2).equals("//")) //$NON-NLS-1$
220
					slashes+= 2;
221
				
222
				wsStart= offset + slashes;
223
				
224
				StringBuffer computed= indenter.computeIndentation(offset);
225
				if (computed == null)
226
					computed= new StringBuffer(0);
227
				int tabSize= getTabSize();
228
				while (slashes > 0 && computed.length() > 0) {
229
					char c= computed.charAt(0);
230
					if (c == '\t') {
231
						if (slashes > tabSize)
232
							slashes-= tabSize;
233
						else
234
							break;
235
					} else if (c == ' ') {
236
						slashes--;
237
					} else {
238
						break;
239
					}
240
					
241
					computed.deleteCharAt(0);
242
				}
243
				
244
				indent= document.get(offset, wsStart - offset) + computed;
245
			}
246
		} 
247
		
248
		// standard java indentation
249
		if (indent == null) {
250
			StringBuffer computed= indenter.computeIndentation(offset);
251
			if (computed != null)
252
				indent= computed.toString();
253
			else
254
				indent= ""; //$NON-NLS-1$
255
		}
256
		
257
		// change document:
258
		// get current white space
259
		int lineLength= currentLine.getLength();
260
		int end= scanner.findNonWhitespaceForwardInAnyPartition(wsStart, offset + lineLength);
261
		if (end == CHeuristicScanner.NOT_FOUND) {
262
			// an empty line
263
			end= offset + lineLength;
264
			if (multiLine && !indentEmptyLines())
265
				indent= ""; //$NON-NLS-1$
266
		}
267
		int length= end - offset;
268
		String currentIndent= document.get(offset, length);
269
		
270
		// if we are right before the text start / line end, and already after the insertion point
271
		// then just insert a tab.
272
		if (fIsTabAction && caret == end && whiteSpaceLength(currentIndent) >= whiteSpaceLength(indent)) {
273
			String tab= getTabEquivalent();
274
			document.replace(caret, 0, tab);
275
			fCaretOffset= caret + tab.length();
276
			return true;
277
		}
278
		
279
		// set the caret offset so it can be used when setting the selection
280
		if (caret >= offset && caret <= end)
281
			fCaretOffset= offset + indent.length();
282
		else
283
			fCaretOffset= -1;
284
		
285
		// only change the document if it is a real change
286
		if (!indent.equals(currentIndent)) {
287
			document.replace(offset, length, indent);
288
			return true;
289
		} else {
290
			return false;
291
		}
292
	}
293
294
	/**
295
	 * Computes and returns the indentation for a javadoc line. The line
296
	 * must be inside a javadoc comment.
297
	 * 
298
	 * @param document the document
299
	 * @param line the line in document
300
	 * @param scanner the scanner
301
	 * @param partition the javadoc partition
302
	 * @return the indent, or <code>null</code> if not computable
303
	 * @throws BadLocationException
304
	 */
305
	private String computeDocIndent(IDocument document, int line, CHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException {
306
		if (line == 0) // impossible - the first line is never inside a javadoc comment
307
			return null;
308
		
309
		// don't make any assumptions if the line does not start with \s*\* - it might be
310
		// commented out code, for which we don't want to change the indent
311
		final IRegion lineInfo= document.getLineInformation(line);
312
		final int lineStart= lineInfo.getOffset();
313
		final int lineLength= lineInfo.getLength();
314
		final int lineEnd= lineStart + lineLength;
315
		int nonWS= scanner.findNonWhitespaceForwardInAnyPartition(lineStart, lineEnd);
316
		if (nonWS == CHeuristicScanner.NOT_FOUND || document.getChar(nonWS) != '*') {
317
			if (nonWS == CHeuristicScanner.NOT_FOUND)
318
				return document.get(lineStart, lineLength);
319
			return document.get(lineStart, nonWS - lineStart);
320
		}
321
		
322
		// take the indent from the previous line and reuse
323
		IRegion previousLine= document.getLineInformation(line - 1);
324
		int previousLineStart= previousLine.getOffset();
325
		int previousLineLength= previousLine.getLength();
326
		int previousLineEnd= previousLineStart + previousLineLength;
327
		
328
		StringBuffer buf= new StringBuffer();
329
		int previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
330
		if (previousLineNonWS == CHeuristicScanner.NOT_FOUND || document.getChar(previousLineNonWS) != '*') {
331
			// align with the comment start if the previous line is not an asterisked line
332
			previousLine= document.getLineInformationOfOffset(partition.getOffset());
333
			previousLineStart= previousLine.getOffset();
334
			previousLineLength= previousLine.getLength();
335
			previousLineEnd= previousLineStart + previousLineLength;
336
			previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
337
			if (previousLineNonWS == CHeuristicScanner.NOT_FOUND)
338
				previousLineNonWS= previousLineEnd;
339
			
340
			// add the initial space 
341
			// TODO this may be controlled by a formatter preference in the future
342
			buf.append(' ');
343
		}
344
		
345
		String indentation= document.get(previousLineStart, previousLineNonWS - previousLineStart);
346
		buf.insert(0, indentation);
347
		return buf.toString();
348
	}
349
	
350
	/**
351
	 * Returns the size in characters of a string. All characters count one, tabs count the editor's
352
	 * preference for the tab display 
353
	 * 
354
	 * @param indent the string to be measured.
355
	 * @return the size in characters of a string
356
	 */
357
	private int whiteSpaceLength(String indent) {
358
		if (indent == null)
359
			return 0;
360
		else {
361
			int size= 0;
362
			int l= indent.length();
363
			int tabSize= getTabSize();
364
			
365
			for (int i= 0; i < l; i++)
366
				size += indent.charAt(i) == '\t' ? tabSize : 1;
367
			return size;
368
		}
369
	}
370
371
	/**
372
	 * Returns a tab equivalent, either as a tab character or as spaces, depending on the editor and
373
	 * formatter preferences.
374
	 * 
375
	 * @return a string representing one tab in the editor, never <code>null</code>
376
	 */
377
	private String getTabEquivalent() {
378
		String tab;
379
		if (CCorePlugin.SPACE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR))) {
380
			int size= getTabSize();
381
			StringBuffer buf= new StringBuffer();
382
			for (int i= 0; i< size; i++)
383
				buf.append(' ');
384
			tab= buf.toString();
385
		} else {
386
			tab= "\t"; //$NON-NLS-1$
387
		}
388
	
389
		return tab;
390
	}
391
	
392
	/**
393
	 * Returns the tab size used by the java editor, which is deduced from the
394
	 * formatter preferences.
395
	 * 
396
	 * @return the tab size as defined in the current formatter preferences
397
	 */
398
	private int getTabSize() {
399
		return getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 4);
400
	}
401
402
	/**
403
	 * Returns <code>true</code> if empty lines should be indented, false otherwise.
404
	 * 
405
	 * @return <code>true</code> if empty lines should be indented, false otherwise
406
	 */
407
	private boolean indentEmptyLines() {
408
		return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES));
409
	}
410
	
411
	/**
412
	 * Returns the possibly project-specific core preference defined under <code>key</code>.
413
	 * 
414
	 * @param key the key of the preference
415
	 * @return the value of the preference
416
	 */
417
	private String getCoreFormatterOption(String key) {
418
		ICProject project= getCProject();
419
		if (project == null)
420
			return CCorePlugin.getOption(key);
421
		return project.getOption(key, true);
422
	}
423
424
	/**
425
	 * Returns the possibly project-specific core preference defined under <code>key</code>, or
426
	 * <code>def</code> if the value is not a integer.
427
	 * 
428
	 * @param key the key of the preference
429
	 * @param def the default value
430
	 * @return the value of the preference
431
	 */
432
	private int getCoreFormatterOption(String key, int def) {
433
		try {
434
			return Integer.parseInt(getCoreFormatterOption(key));
435
		} catch (NumberFormatException e) {
436
			return def;
437
		}
438
	}
439
440
	/**
441
	 * Returns the <code>ICProject</code> of the current editor input, or
442
	 * <code>null</code> if it cannot be found.
443
	 * 
444
	 * @return the <code>ICProject</code> of the current editor input, or
445
	 *         <code>null</code> if it cannot be found
446
	 */
447
	private ICProject getCProject() {
448
		ITextEditor editor= getTextEditor();
449
		if (editor == null)
450
			return null;
451
		
452
		ITranslationUnit cu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput());
453
		if (cu == null)
454
			return null;
455
		return cu.getCProject();
456
	}
457
458
	/**
459
	 * Returns the editor's selection provider.
460
	 * 
461
	 * @return the editor's selection provider or <code>null</code>
462
	 */
463
	private ISelectionProvider getSelectionProvider() {
464
		ITextEditor editor= getTextEditor();
465
		if (editor != null) {
466
			return editor.getSelectionProvider();
467
		}
468
		return null;
469
	}
470
	
471
	/*
472
	 * @see org.eclipse.ui.texteditor.IUpdate#update()
473
	 */
474
	public void update() {
475
		super.update();
476
		
477
		if (isEnabled()) {
478
			if (fIsTabAction)
479
				setEnabled(canModifyEditor() && isSmartMode() && isValidSelection());
480
			else
481
				setEnabled(canModifyEditor() && !getSelection().isEmpty());
482
		}
483
	}
484
	
485
	/**
486
	 * Returns if the current selection is valid, i.e. whether it is empty and the caret in the 
487
	 * whitespace at the start of a line, or covers multiple lines.
488
	 * 
489
	 * @return <code>true</code> if the selection is valid for an indent operation
490
	 */
491
	private boolean isValidSelection() {
492
		ITextSelection selection= getSelection();
493
		if (selection.isEmpty())
494
			return false;
495
		
496
		int offset= selection.getOffset();
497
		int length= selection.getLength();
498
		
499
		IDocument document= getDocument();
500
		if (document == null)
501
			return false;
502
		
503
		try {
504
			IRegion firstLine= document.getLineInformationOfOffset(offset);
505
			int lineOffset= firstLine.getOffset();
506
			
507
			// either the selection has to be empty and the caret in the WS at the line start
508
			// or the selection has to extend over multiple lines
509
			if (length == 0) {
510
				return document.get(lineOffset, offset - lineOffset).trim().length() == 0;
511
			} else {
512
//				return lineOffset + firstLine.getLength() < offset + length;
513
				return false; // only enable for empty selections for now
514
			}
515
		} catch (BadLocationException e) {
516
		}
517
		
518
		return false;
519
	}
520
	
521
	/**
522
	 * Returns the smart preference state.
523
	 * 
524
	 * @return <code>true</code> if smart mode is on, <code>false</code> otherwise
525
	 */
526
	private boolean isSmartMode() {
527
		ITextEditor editor= getTextEditor();
528
		
529
		if (editor instanceof ITextEditorExtension3)
530
			return ((ITextEditorExtension3) editor).getInsertMode() == ITextEditorExtension3.SMART_INSERT;
531
		
532
		return false;
533
	}
534
	
535
	/**
536
	 * Returns the document currently displayed in the editor, or <code>null</code> if none can be 
537
	 * obtained.
538
	 * 
539
	 * @return the current document or <code>null</code>
540
	 */
541
	private IDocument getDocument() {
542
		
543
		ITextEditor editor= getTextEditor();
544
		if (editor != null) {
545
			
546
			IDocumentProvider provider= editor.getDocumentProvider();
547
			IEditorInput input= editor.getEditorInput();
548
			if (provider != null && input != null)
549
				return provider.getDocument(input);
550
			
551
		}
552
		return null;
553
	}
554
	
555
	/**
556
	 * Returns the selection on the editor or an invalid selection if none can be obtained. Returns
557
	 * never <code>null</code>.
558
	 * 
559
	 * @return the current selection, never <code>null</code>
560
	 */
561
	private ITextSelection getSelection() {
562
		ISelectionProvider provider= getSelectionProvider();
563
		if (provider != null) {
564
			
565
			ISelection selection= provider.getSelection();
566
			if (selection instanceof ITextSelection)
567
				return (ITextSelection) selection;
568
		}
569
		
570
		// null object
571
		return TextSelection.emptySelection();
572
	}
573
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/CodeFormatterConfigurationBlock.java (+548 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting Unnamed profile fails silently
11
 *     Sergey Prigogin, Google
12
 *******************************************************************************/
13
package org.eclipse.cdt.internal.ui.preferences.formatter;
14
15
import java.io.File;
16
import java.util.ArrayList;
17
import java.util.Collection;
18
import java.util.List;
19
import java.util.Observable;
20
import java.util.Observer;
21
22
import org.eclipse.core.runtime.CoreException;
23
import org.eclipse.core.runtime.preferences.DefaultScope;
24
import org.eclipse.core.runtime.preferences.IScopeContext;
25
26
import org.eclipse.core.resources.IProject;
27
import org.eclipse.core.resources.ProjectScope;
28
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.events.SelectionEvent;
31
import org.eclipse.swt.events.SelectionListener;
32
import org.eclipse.swt.layout.GridData;
33
import org.eclipse.swt.layout.GridLayout;
34
import org.eclipse.swt.widgets.Button;
35
import org.eclipse.swt.widgets.Combo;
36
import org.eclipse.swt.widgets.Composite;
37
import org.eclipse.swt.widgets.FileDialog;
38
import org.eclipse.swt.widgets.Label;
39
40
import org.eclipse.jface.dialogs.MessageDialog;
41
import org.eclipse.jface.window.Window;
42
43
import org.eclipse.cdt.core.CCorePlugin;
44
45
import org.eclipse.cdt.internal.ui.util.Messages;
46
47
import org.eclipse.cdt.ui.CUIPlugin;
48
49
import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
50
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
51
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
52
import org.eclipse.cdt.internal.ui.util.ExceptionHandler;
53
import org.eclipse.cdt.internal.ui.util.PixelConverter;
54
import org.eclipse.cdt.internal.ui.util.SWTUtil;
55
56
import org.osgi.service.prefs.BackingStoreException;
57
58
59
/**
60
 * The code formatter preference page. 
61
 */
62
public class CodeFormatterConfigurationBlock {
63
    
64
    private static final String DIALOGSTORE_LASTLOADPATH= CUIPlugin.PLUGIN_ID + ".codeformatter.loadpath"; //$NON-NLS-1$
65
	private static final String DIALOGSTORE_LASTSAVEPATH= CUIPlugin.PLUGIN_ID + ".codeformatter.savepath"; //$NON-NLS-1$
66
	
67
	private class StoreUpdater implements Observer {
68
		
69
		public StoreUpdater() {
70
			fProfileManager.addObserver(this);
71
		}
72
73
		public void update(Observable o, Object arg) {
74
			final int value= ((Integer)arg).intValue();
75
			switch (value) {
76
			case ProfileManager.PROFILE_DELETED_EVENT:
77
			case ProfileManager.PROFILE_RENAMED_EVENT:
78
			case ProfileManager.PROFILE_CREATED_EVENT:
79
			case ProfileManager.SETTINGS_CHANGED_EVENT:
80
				try {
81
					ProfileStore.writeProfiles(fProfileManager.getSortedProfiles(), fInstanceScope); // update profile store
82
					fProfileManager.commitChanges(fCurrContext); // update formatter settings with curently selected profile 
83
				} catch (CoreException x) {
84
					CUIPlugin.getDefault().log(x);
85
				}
86
				break;
87
			case ProfileManager.SELECTION_CHANGED_EVENT:
88
				fProfileManager.commitChanges(fCurrContext); // update formatter settings with curently selected profile
89
				break;
90
			}
91
		}
92
	}
93
94
	private class ProfileComboController implements Observer, SelectionListener {
95
		
96
		private final List fSortedProfiles;
97
		
98
		public ProfileComboController() {
99
			fSortedProfiles= fProfileManager.getSortedProfiles();
100
			fProfileCombo.addSelectionListener(this);
101
			fProfileManager.addObserver(this);
102
			updateProfiles();
103
			updateSelection();
104
		}
105
		
106
		public void widgetSelected(SelectionEvent e) {
107
			final int index= fProfileCombo.getSelectionIndex();
108
			fProfileManager.setSelected((Profile)fSortedProfiles.get(index));
109
		}
110
111
		public void widgetDefaultSelected(SelectionEvent e) {}
112
113
		public void update(Observable o, Object arg) {
114
			if (arg == null) return;
115
			final int value= ((Integer)arg).intValue();
116
			switch (value) {
117
				case ProfileManager.PROFILE_CREATED_EVENT:
118
				case ProfileManager.PROFILE_DELETED_EVENT:
119
				case ProfileManager.PROFILE_RENAMED_EVENT:
120
					updateProfiles();
121
					updateSelection();
122
					break;
123
				case ProfileManager.SELECTION_CHANGED_EVENT:
124
					updateSelection();
125
					break;
126
			}
127
		}
128
		
129
		private void updateProfiles() {
130
			fProfileCombo.setItems(fProfileManager.getSortedDisplayNames());
131
		}
132
133
		private void updateSelection() {
134
			fProfileCombo.setText(fProfileManager.getSelected().getName());
135
		}
136
	}
137
	
138
	private class ButtonController implements Observer, SelectionListener {
139
		
140
		public ButtonController() {
141
			fProfileManager.addObserver(this);
142
			fNewButton.addSelectionListener(this);
143
			fRenameButton.addSelectionListener(this);
144
			fEditButton.addSelectionListener(this);
145
			fDeleteButton.addSelectionListener(this);
146
			fSaveButton.addSelectionListener(this);
147
			fLoadButton.addSelectionListener(this);
148
			update(fProfileManager, null);
149
		}
150
151
		public void update(Observable o, Object arg) {
152
			Profile selected= ((ProfileManager)o).getSelected();
153
			final boolean notBuiltIn= !selected.isBuiltInProfile();
154
			fEditButton.setText(notBuiltIn ? FormatterMessages.CodingStyleConfigurationBlock_edit_button_desc
155
			    : FormatterMessages.CodingStyleConfigurationBlock_show_button_desc); 
156
			fDeleteButton.setEnabled(notBuiltIn);
157
			fSaveButton.setEnabled(notBuiltIn);
158
			fRenameButton.setEnabled(notBuiltIn);
159
		}
160
161
		public void widgetSelected(SelectionEvent e) {
162
			final Button button= (Button)e.widget;
163
			if (button == fSaveButton)
164
				saveButtonPressed();
165
			else if (button == fEditButton)
166
				modifyButtonPressed();
167
			else if (button == fDeleteButton) 
168
				deleteButtonPressed();
169
			else if (button == fNewButton)
170
				newButtonPressed();
171
			else if (button == fLoadButton)
172
				loadButtonPressed();
173
			else if (button == fRenameButton) 
174
				renameButtonPressed();
175
		}
176
		
177
		public void widgetDefaultSelected(SelectionEvent e) {
178
		}
179
		
180
		private void renameButtonPressed() {
181
			if (fProfileManager.getSelected().isBuiltInProfile())
182
				return;
183
			final CustomProfile profile= (CustomProfile) fProfileManager.getSelected();
184
			final RenameProfileDialog renameDialog= new RenameProfileDialog(fComposite.getShell(), profile, fProfileManager);
185
			if (renameDialog.open() == Window.OK) {
186
				fProfileManager.setSelected(renameDialog.getRenamedProfile());
187
			}
188
		}
189
		
190
		private void modifyButtonPressed() {
191
			final ModifyDialog modifyDialog= new ModifyDialog(fComposite.getShell(), fProfileManager.getSelected(), fProfileManager, false);
192
			modifyDialog.open();
193
		}
194
		
195
		private void deleteButtonPressed() {
196
			if (MessageDialog.openQuestion(
197
				fComposite.getShell(), 
198
				FormatterMessages.CodingStyleConfigurationBlock_delete_confirmation_title, 
199
				Messages.format(FormatterMessages.CodingStyleConfigurationBlock_delete_confirmation_question, fProfileManager.getSelected().getName()))) { 
200
				fProfileManager.deleteSelected();
201
			}
202
		}
203
		
204
		private void newButtonPressed() {
205
			final CreateProfileDialog p= new CreateProfileDialog(fComposite.getShell(), fProfileManager);
206
			if (p.open() != Window.OK) 
207
				return;
208
			if (!p.openEditDialog()) 
209
				return;
210
			final ModifyDialog modifyDialog= new ModifyDialog(fComposite.getShell(), p.getCreatedProfile(), fProfileManager, true);
211
			modifyDialog.open();
212
		}
213
		
214
		private void saveButtonPressed() {
215
			Profile selected= fProfileManager.getSelected();
216
			if (selected.isSharedProfile()) {
217
				final RenameProfileDialog renameDialog= new RenameProfileDialog(fComposite.getShell(), selected, fProfileManager);
218
				if (renameDialog.open() != Window.OK) {
219
					return;
220
				}
221
					
222
				selected= renameDialog.getRenamedProfile();
223
				fProfileManager.setSelected(selected);
224
			}
225
			
226
			final FileDialog dialog= new FileDialog(fComposite.getShell(), SWT.SAVE);
227
			dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_save_profile_dialog_title); 
228
			dialog.setFilterExtensions(new String [] {"*.xml"}); //$NON-NLS-1$
229
			
230
			final String lastPath= CUIPlugin.getDefault().getDialogSettings().get(DIALOGSTORE_LASTSAVEPATH);
231
			if (lastPath != null) {
232
				dialog.setFilterPath(lastPath);
233
			}
234
			final String path= dialog.open();
235
			if (path == null) 
236
				return;
237
			
238
			CUIPlugin.getDefault().getDialogSettings().put(DIALOGSTORE_LASTSAVEPATH, dialog.getFilterPath());
239
			
240
			final File file= new File(path);
241
			if (file.exists() && !MessageDialog.openQuestion(fComposite.getShell(), FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_title, Messages.format(FormatterMessages.CodingStyleConfigurationBlock_save_profile_overwrite_message, path))) { 
242
				return;
243
			}
244
			
245
			final Collection profiles= new ArrayList();
246
247
			profiles.add(selected);
248
			try {
249
				ProfileStore.writeProfilesToFile(profiles, file);
250
			} catch (CoreException e) {
251
				final String title= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_title; 
252
				final String message= FormatterMessages.CodingStyleConfigurationBlock_save_profile_error_message; 
253
				ExceptionHandler.handle(e, fComposite.getShell(), title, message);
254
			}
255
		}
256
		
257
		private void loadButtonPressed() {
258
			final FileDialog dialog= new FileDialog(fComposite.getShell(), SWT.OPEN);
259
			dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_load_profile_dialog_title); 
260
			dialog.setFilterExtensions(new String [] {"*.xml"}); //$NON-NLS-1$
261
			final String lastPath= CUIPlugin.getDefault().getDialogSettings().get(DIALOGSTORE_LASTLOADPATH);
262
			if (lastPath != null) {
263
				dialog.setFilterPath(lastPath);
264
			}
265
			final String path= dialog.open();
266
			if (path == null) 
267
				return;
268
			CUIPlugin.getDefault().getDialogSettings().put(DIALOGSTORE_LASTLOADPATH, dialog.getFilterPath());
269
			
270
			final File file= new File(path);
271
			Collection profiles= null;
272
			try {
273
				profiles= ProfileStore.readProfilesFromFile(file);
274
			} catch (CoreException e) {
275
				final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_title; 
276
				final String message= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_message; 
277
				ExceptionHandler.handle(e, fComposite.getShell(), title, message);
278
			}
279
			if (profiles == null || profiles.isEmpty())
280
				return;
281
			
282
			final CustomProfile profile= (CustomProfile)profiles.iterator().next();
283
			
284
			if (ProfileVersioner.getVersionStatus(profile) > 0) {
285
				final String title= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_title; 
286
				final String message= FormatterMessages.CodingStyleConfigurationBlock_load_profile_error_too_new_message; 
287
			    MessageDialog.openWarning(fComposite.getShell(), title, message);
288
			}
289
			
290
			if (fProfileManager.containsName(profile.getName())) {
291
				final AlreadyExistsDialog aeDialog= new AlreadyExistsDialog(fComposite.getShell(), profile, fProfileManager);
292
				if (aeDialog.open() != Window.OK) 
293
					return;
294
			}
295
			ProfileVersioner.updateAndComplete(profile);
296
			fProfileManager.addProfile(profile);
297
		}
298
	}
299
	
300
//	private class PreviewController implements Observer {
301
//
302
//		public PreviewController() {
303
//			fProfileManager.addObserver(this);
304
//			fCodeStylePreview.setWorkingValues(fProfileManager.getSelected().getSettings());
305
//			fCodeStylePreview.update();
306
//		}
307
//		
308
//		public void update(Observable o, Object arg) {
309
//			final int value= ((Integer)arg).intValue();
310
//			switch (value) {
311
//				case ProfileManager.PROFILE_CREATED_EVENT:
312
//				case ProfileManager.PROFILE_DELETED_EVENT:
313
//				case ProfileManager.SELECTION_CHANGED_EVENT:
314
//				case ProfileManager.SETTINGS_CHANGED_EVENT:
315
//					fCodeStylePreview.setWorkingValues(((ProfileManager)o).getSelected().getSettings());
316
//					fCodeStylePreview.update();
317
//			}
318
//		}
319
//	}
320
	
321
//	/**
322
//	 * Some C source code used for preview.
323
//	 */
324
//	private final static String PREVIEW=
325
//		"/*\n* " + //$NON-NLS-1$
326
//		FormatterMessages.CodingStyleConfigurationBlock_preview_title + 
327
//		"\n*/\n\n" + //$NON-NLS-1$
328
//		"#include <math.h>\n" + //$NON-NLS-1$
329
//		"class Point {" +  //$NON-NLS-1$
330
//		"public:" +  //$NON-NLS-1$
331
//		"Point(double xc, double yc) : x(xc), y(yc) {}" + //$NON-NLS-1$ 
332
//		"double distance(const Point& other) const;" + //$NON-NLS-1$
333
//		"double x;" +  //$NON-NLS-1$
334
//		"double y;" +  //$NON-NLS-1$
335
//		"};" +  //$NON-NLS-1$
336
//		"float Point::distance(const Point& other) const {" + //$NON-NLS-1$
337
//		"double dx = x - other.x;" + //$NON-NLS-1$
338
//		"double dy = y - other.y;" + //$NON-NLS-1$
339
//		"return sqrt(dx * dx + dy * dy);" + //$NON-NLS-1$
340
//		"}"; //$NON-NLS-1$
341
342
	/**
343
	 * The GUI controls
344
	 */
345
	protected Composite fComposite;
346
	protected Combo fProfileCombo;
347
	protected Button fEditButton;
348
	protected Button fRenameButton;
349
	protected Button fDeleteButton;
350
	protected Button fNewButton;
351
	protected Button fLoadButton;
352
	protected Button fSaveButton;
353
	
354
	/**
355
	 * The ProfileManager, the model of this page.
356
	 */
357
	protected final ProfileManager fProfileManager;
358
	private CustomCodeFormatterBlock fCustomCodeFormatterBlock;
359
	
360
	/**
361
	 * The CPreview.
362
	 */
363
//	protected TranslationUnitPreview fCodeStylePreview;
364
	private PixelConverter fPixConv;
365
366
	private IScopeContext fCurrContext;
367
	private IScopeContext fInstanceScope;
368
	
369
	/**
370
	 * Create a new <code>CodeFormatterConfigurationBlock</code>.
371
	 */
372
	public CodeFormatterConfigurationBlock(IProject project, PreferencesAccess access) {
373
		fInstanceScope= access.getInstanceScope();
374
		List profiles= null;
375
		try {
376
		    profiles= ProfileStore.readProfiles(fInstanceScope);
377
		} catch (CoreException e) {
378
			CUIPlugin.getDefault().log(e);
379
		}
380
		if (profiles == null) {
381
			try {
382
				// bug 129427
383
			    profiles= ProfileStore.readProfilesFromPreferences(new DefaultScope());
384
			} catch (CoreException e) {
385
				CUIPlugin.getDefault().log(e);
386
			}
387
		}
388
		
389
		if (profiles == null) 
390
		    profiles= new ArrayList();
391
		
392
		if (project != null) {
393
			fCurrContext= access.getProjectScope(project);
394
		} else {
395
			fCurrContext= fInstanceScope;
396
		}
397
		
398
		fProfileManager= new ProfileManager(profiles, fCurrContext, access);
399
		fCustomCodeFormatterBlock= new CustomCodeFormatterBlock(CUIPlugin.getDefault().getPluginPreferences());
400
401
		new StoreUpdater();
402
	}
403
404
	/**
405
	 * Create the contents
406
	 * @param parent Parent composite
407
	 * @return Created control
408
	 */
409
	public Composite createContents(Composite parent) {
410
411
		final int numColumns = 5;
412
		
413
		fPixConv = new PixelConverter(parent);
414
		fComposite = createComposite(parent, numColumns);
415
416
		fProfileCombo= createProfileCombo(fComposite, numColumns - 3, fPixConv.convertWidthInCharsToPixels(20));
417
		fEditButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_edit_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING); 
418
		fRenameButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_rename_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING); 
419
		fDeleteButton= createButton(fComposite, FormatterMessages.CodingStyleConfigurationBlock_remove_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING); 
420
421
		final Composite group= createComposite(fComposite, 4);
422
		final GridData groupData= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
423
		groupData.horizontalSpan= numColumns;
424
		group.setLayoutData(groupData);
425
426
		fNewButton= createButton(group, FormatterMessages.CodingStyleConfigurationBlock_new_button_desc, GridData.HORIZONTAL_ALIGN_BEGINNING); 
427
		((GridData)createLabel(group, "", 1).getLayoutData()).grabExcessHorizontalSpace= true; //$NON-NLS-1$
428
		fLoadButton= createButton(group, FormatterMessages.CodingStyleConfigurationBlock_load_button_desc, GridData.HORIZONTAL_ALIGN_END); 
429
		fSaveButton= createButton(group, FormatterMessages.CodingStyleConfigurationBlock_save_button_desc, GridData.HORIZONTAL_ALIGN_END); 
430
431
		fCustomCodeFormatterBlock.createContents(fComposite);
432
		
433
//		createLabel(fComposite, FormatterMessages.CodingStyleConfigurationBlock_preview_label_text, numColumns); 
434
//		configurePreview(fComposite, numColumns);
435
		
436
		new ButtonController();
437
		new ProfileComboController();
438
//		new PreviewController();
439
		
440
		return fComposite;
441
	}
442
443
	
444
	private static Button createButton(Composite composite, String text, final int style) {
445
		final Button button= new Button(composite, SWT.PUSH);
446
		button.setFont(composite.getFont());
447
		button.setText(text);
448
449
		final GridData gd= new GridData(style);
450
		gd.widthHint= SWTUtil.getButtonWidthHint(button);
451
		button.setLayoutData(gd);
452
		return button;
453
	}
454
	
455
	private static Combo createProfileCombo(Composite composite, int span, int widthHint) {
456
		final GridData gd = new GridData(GridData.FILL_HORIZONTAL);
457
		gd.horizontalSpan = span;
458
		gd.widthHint= widthHint;
459
460
		final Combo combo= new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
461
		combo.setFont(composite.getFont());
462
		combo.setLayoutData(gd);
463
		return combo;
464
	}
465
	
466
	private Label createLabel(Composite composite, String text, int numColumns) {
467
		final GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
468
		gd.horizontalSpan = numColumns;
469
		gd.widthHint= 0;
470
471
		final Label label = new Label(composite, SWT.WRAP);
472
		label.setFont(composite.getFont());
473
		label.setText(text);
474
		label.setLayoutData(gd);
475
		return label;		
476
	}
477
	
478
	private Composite createComposite(Composite parent, int numColumns) {
479
		final Composite composite = new Composite(parent, SWT.NONE);
480
		composite.setFont(parent.getFont());
481
		
482
		final GridLayout layout = new GridLayout(numColumns, false);
483
		layout.marginHeight = 0;
484
		layout.marginWidth = 0;
485
		composite.setLayout(layout);
486
		return composite;
487
	}
488
	
489
//	private void configurePreview(Composite composite, int numColumns) {
490
//		fCodeStylePreview= new TranslationUnitPreview(fProfileManager.getSelected().getSettings(), composite);
491
//		fCodeStylePreview.setPreviewText(PREVIEW);
492
//	    
493
//		final GridData gd = new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL);
494
//		gd.horizontalSpan = numColumns;
495
//		gd.verticalSpan= 7;
496
//		gd.widthHint = 0;
497
//		gd.heightHint = 0;
498
//		fCodeStylePreview.getControl().setLayoutData(gd);
499
//	}
500
501
	public final boolean hasProjectSpecificOptions(IProject project) {
502
		if (project != null) {
503
			return ProfileManager.hasProjectSpecificSettings(new ProjectScope(project));
504
		}
505
		return false;
506
	}
507
	
508
	public boolean performOk() {
509
		fCustomCodeFormatterBlock.performOk();
510
		return true;
511
	}
512
	
513
	public void performApply() {
514
		try {
515
			fCurrContext.getNode(CUIPlugin.PLUGIN_ID).flush();
516
			fCurrContext.getNode(CCorePlugin.PLUGIN_ID).flush();
517
			if (fCurrContext != fInstanceScope) {
518
				fInstanceScope.getNode(CUIPlugin.PLUGIN_ID).flush();
519
				fInstanceScope.getNode(CCorePlugin.PLUGIN_ID).flush();
520
			}
521
			fCustomCodeFormatterBlock.performOk();
522
		} catch (BackingStoreException e) {
523
			CUIPlugin.getDefault().log(e);
524
		}
525
	}
526
	
527
	public void performDefaults() {
528
		Profile profile= fProfileManager.getProfile(ProfileManager.DEFAULT_PROFILE);
529
		if (profile != null) {
530
			int defaultIndex= fProfileManager.getSortedProfiles().indexOf(profile);
531
			if (defaultIndex != -1) {
532
				fProfileManager.setSelected(profile);
533
			}
534
		}
535
		fCustomCodeFormatterBlock.performDefaults();
536
	}
537
	
538
	public void dispose() {
539
	}
540
541
	public void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
542
		if (useProjectSpecificSettings) {
543
			fProfileManager.commitChanges(fCurrContext);
544
		} else {
545
			fProfileManager.clearAllSettings(fCurrContext);
546
		}
547
	}
548
}
(-)src/org/eclipse/cdt/internal/ui/preferences/PreferencesAccess.java (+124 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.preferences;
14
15
import org.eclipse.core.runtime.IPath;
16
import org.eclipse.core.runtime.preferences.DefaultScope;
17
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
18
import org.eclipse.core.runtime.preferences.IScopeContext;
19
import org.eclipse.core.runtime.preferences.InstanceScope;
20
21
import org.eclipse.core.resources.IProject;
22
import org.eclipse.core.resources.ProjectScope;
23
24
import org.eclipse.ui.preferences.IWorkingCopyManager;
25
26
import org.osgi.service.prefs.BackingStoreException;
27
28
/**
29
 * 
30
 */
31
public class PreferencesAccess {
32
	
33
	public static PreferencesAccess getOriginalPreferences() {
34
		return new PreferencesAccess();
35
	}
36
	
37
	public static PreferencesAccess getWorkingCopyPreferences(IWorkingCopyManager workingCopyManager) {
38
		return new WorkingCopyPreferencesAccess(workingCopyManager);
39
	}
40
		
41
	private PreferencesAccess() {
42
		// can only extends in this file
43
	}
44
	
45
	public IScopeContext getDefaultScope() {
46
		return new DefaultScope();
47
	}
48
	
49
	public IScopeContext getInstanceScope() {
50
		return new InstanceScope();
51
	}
52
	
53
	public IScopeContext getProjectScope(IProject project) {
54
		return new ProjectScope(project);
55
	}
56
	
57
	public void applyChanges() throws BackingStoreException {
58
	}
59
	
60
	
61
	private static class WorkingCopyPreferencesAccess extends PreferencesAccess {
62
		
63
		private final IWorkingCopyManager fWorkingCopyManager;
64
65
		private WorkingCopyPreferencesAccess(IWorkingCopyManager workingCopyManager) {
66
			fWorkingCopyManager= workingCopyManager;
67
		}
68
		
69
		private final IScopeContext getWorkingCopyScopeContext(IScopeContext original) {
70
			return new WorkingCopyScopeContext(fWorkingCopyManager, original);
71
		}
72
		
73
		public IScopeContext getDefaultScope() {
74
			return getWorkingCopyScopeContext(super.getDefaultScope());
75
		}
76
		
77
		public IScopeContext getInstanceScope() {
78
			return getWorkingCopyScopeContext(super.getInstanceScope());
79
		}
80
		
81
		public IScopeContext getProjectScope(IProject project) {
82
			return getWorkingCopyScopeContext(super.getProjectScope(project));
83
		}
84
		
85
		/* (non-Javadoc)
86
		 * @see org.eclipse.cdt.internal.ui.preferences.PreferencesAccess#applyChanges()
87
		 */
88
		public void applyChanges() throws BackingStoreException {
89
			fWorkingCopyManager.applyChanges();
90
		}
91
	}
92
	
93
	private static class WorkingCopyScopeContext implements IScopeContext {
94
		
95
		private final IWorkingCopyManager fWorkingCopyManager;
96
		private final IScopeContext fOriginal;
97
98
		public WorkingCopyScopeContext(IWorkingCopyManager workingCopyManager, IScopeContext original) {
99
			fWorkingCopyManager= workingCopyManager;
100
			fOriginal= original;	
101
		}
102
103
		/* (non-Javadoc)
104
		 * @see org.eclipse.core.runtime.preferences.IScopeContext#getName()
105
		 */
106
		public String getName() {
107
			return fOriginal.getName();
108
		}
109
110
		/* (non-Javadoc)
111
		 * @see org.eclipse.core.runtime.preferences.IScopeContext#getNode(java.lang.String)
112
		 */
113
		public IEclipsePreferences getNode(String qualifier) {
114
			return fWorkingCopyManager.getWorkingCopy(fOriginal.getNode(qualifier));
115
		}
116
117
		/* (non-Javadoc)
118
		 * @see org.eclipse.core.runtime.preferences.IScopeContext#getLocation()
119
		 */
120
		public IPath getLocation() {
121
			return fOriginal.getLocation();
122
		}
123
	}
124
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/CustomCodeFormatterBlock.java (+177 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 QNX Software Systems and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     QNX Software Systems - Initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.preferences.formatter;
14
15
import java.util.HashMap;
16
import java.util.Iterator;
17
import java.util.Map;
18
19
import org.eclipse.core.runtime.IConfigurationElement;
20
import org.eclipse.core.runtime.IExtension;
21
import org.eclipse.core.runtime.IExtensionPoint;
22
import org.eclipse.core.runtime.Platform;
23
import org.eclipse.core.runtime.Preferences;
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.SelectionAdapter;
26
import org.eclipse.swt.events.SelectionEvent;
27
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.Combo;
30
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Control;
32
import org.eclipse.swt.widgets.Label;
33
import org.eclipse.ui.PlatformUI;
34
35
import org.eclipse.cdt.core.CCorePlugin;
36
import org.eclipse.cdt.core.CCorePreferenceConstants;
37
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
38
39
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
40
41
/**
42
 * 
43
 */
44
public class CustomCodeFormatterBlock {
45
46
	private HashMap idMap = new HashMap();
47
	Preferences fPrefs;
48
	protected Combo fFormatterCombo;
49
	private static final String ATTR_NAME = "name"; //$NON-NLS-1$
50
	private static final String ATTR_ID = "id"; //$NON-NLS-1$
51
	// This is a hack until we have a default Formatter.
52
	// For now it is comment out in the plugin.xml
53
	private static final String NONE = FormatterMessages.CustomCodeFormatterBlock_no_formatter;
54
55
56
	public CustomCodeFormatterBlock(Preferences prefs) {
57
		fPrefs = prefs;
58
		initializeFormatters();
59
	}
60
61
	public void performOk() {
62
		String text = fFormatterCombo.getText();
63
		String selection = (String)idMap.get(text);
64
		if (selection != null && selection.length() > 0) {
65
			HashMap options = CCorePlugin.getOptions();
66
			String formatterID = (String)options.get(CCorePreferenceConstants.CODE_FORMATTER);
67
			if (formatterID == null || !formatterID.equals(selection)) {
68
				options.put(CCorePreferenceConstants.CODE_FORMATTER, selection);
69
				CCorePlugin.setOptions(options);
70
			}
71
		} else {
72
			// simply reset to the default one.
73
			performDefaults();
74
		}
75
	}
76
77
	public void performDefaults() {
78
		HashMap optionsDefault = CCorePlugin.getDefaultOptions();
79
		HashMap options = CCorePlugin.getOptions();
80
		String formatterID = (String)optionsDefault.get(CCorePreferenceConstants.CODE_FORMATTER);
81
		options.put(CCorePreferenceConstants.CODE_FORMATTER, formatterID);
82
		CCorePlugin.setOptions(options);
83
84
		fFormatterCombo.clearSelection();
85
		fFormatterCombo.setText(NONE);
86
		Iterator iterator = idMap.entrySet().iterator();
87
		while (iterator.hasNext()) {
88
			Map.Entry entry = (Map.Entry)iterator.next();
89
			String val = (String)entry.getValue();
90
			if (val != null && val.equals(formatterID)) {
91
				fFormatterCombo.setText((String)entry.getKey());
92
			}
93
		}
94
	}
95
96
	/* (non-Javadoc)
97
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
98
	 */
99
	public Control createContents(Composite parent) {
100
		Composite composite = ControlFactory.createComposite(parent, 1);
101
		((GridLayout)composite.getLayout()).marginWidth = 0;
102
		((GridData)composite.getLayoutData()).horizontalSpan = 2;
103
104
		PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, ICHelpContextIds.CODEFORMATTER_PREFERENCE_PAGE);
105
106
		ControlFactory.createEmptySpace(composite, 1);
107
108
		Label label = ControlFactory.createLabel(composite, FormatterMessages.CustomCodeFormatterBlock_formatter_name);
109
		fFormatterCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
110
		fFormatterCombo.setFont(parent.getFont());
111
		fFormatterCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
112
		fFormatterCombo.addSelectionListener(new SelectionAdapter() {
113
			public void widgetSelected(SelectionEvent e) {
114
				handleFormatterChanged();
115
			}
116
		});
117
		Iterator items = idMap.keySet().iterator();
118
		while (items.hasNext()) {
119
			fFormatterCombo.add((String) items.next());
120
		}
121
122
		label = ControlFactory.createLabel(parent, FormatterMessages.CustomCodeFormatterBlock_contributed_formatter_warning);
123
		((GridData)label.getLayoutData()).horizontalSpan = 5;
124
		
125
		initDefault();
126
		handleFormatterChanged();
127
		
128
		if (getNumberOfAvailableFormatters() == 0) {
129
			composite.setVisible(false);
130
			label.setVisible(false);
131
		}
132
		return composite;
133
	}
134
135
	private void handleFormatterChanged() {	
136
		// TODO: UI part.
137
	}
138
139
	private void initDefault() {
140
		boolean init = false;
141
		String selection = CCorePlugin.getOption(CCorePreferenceConstants.CODE_FORMATTER);
142
		if (selection != null) {
143
			Iterator iterator = idMap.entrySet().iterator();
144
			while (iterator.hasNext()) {
145
				Map.Entry entry = (Map.Entry)iterator.next();
146
				String val = (String)entry.getValue();
147
				if (val != null && val.equals(selection)) {
148
					fFormatterCombo.setText((String)entry.getKey());
149
					init = true;
150
				}
151
			}
152
		}
153
		if (!init) {
154
			fFormatterCombo.setText(NONE);
155
		}
156
	}
157
158
	private void initializeFormatters() {
159
		idMap = new HashMap();
160
		idMap.put(NONE, null);
161
		IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.FORMATTER_EXTPOINT_ID);
162
		if (point != null) {
163
			IExtension[] exts = point.getExtensions();
164
			for (int i = 0; i < exts.length; i++) {
165
		 		IConfigurationElement[] elements = exts[i].getConfigurationElements();
166
		 		for (int j = 0; j < elements.length; ++j) {
167
		 			String name = elements[j].getAttribute(ATTR_NAME);
168
		 			idMap.put(name, elements[j].getAttribute(ATTR_ID));
169
		 		}
170
			}
171
		}
172
	}
173
	
174
	private final int getNumberOfAvailableFormatters() {
175
		return idMap.size() - 1;
176
	}
177
}
(-)src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java (+141 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.text;
13
14
import org.eclipse.jface.preference.IPreferenceStore;
15
16
import org.eclipse.jface.text.IAutoEditStrategy;
17
import org.eclipse.jface.text.IInformationControlCreator;
18
import org.eclipse.jface.text.ITextHover;
19
import org.eclipse.jface.text.formatter.IContentFormatter;
20
import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
21
import org.eclipse.jface.text.information.IInformationPresenter;
22
import org.eclipse.jface.text.source.IAnnotationHover;
23
import org.eclipse.jface.text.source.ISourceViewer;
24
25
import org.eclipse.ui.texteditor.ITextEditor;
26
27
28
/**
29
 * A simple {@linkplain org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration C source viewer configuration}.
30
 * <p>
31
 * This simple source viewer configuration basically provides syntax coloring
32
 * and disables all other features like code assist, quick outlines, hyperlinking, etc.
33
 * </p>
34
 */
35
public class SimpleCSourceViewerConfiguration extends CSourceViewerConfiguration {
36
37
38
	private boolean fConfigureFormatter;
39
40
	/**
41
	 * Creates a new C source viewer configuration for viewers in the given editor
42
	 * using the given preference store, the color manager and the specified document partitioning.
43
	 *
44
	 * @param colorManager the color manager
45
	 * @param preferenceStore the preference store, can be read-only
46
	 * @param editor the editor in which the configured viewer(s) will reside, or <code>null</code> if none
47
	 * @param partitioning the document partitioning for this configuration, or <code>null</code> for the default partitioning
48
	 * @param configureFormatter <code>true</code> if a content formatter should be configured
49
	 */
50
	public SimpleCSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor, String partitioning, boolean configureFormatter) {
51
		super(colorManager, preferenceStore, editor, partitioning);
52
		fConfigureFormatter= configureFormatter;
53
	}
54
	
55
	/*
56
	 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAutoEditStrategies(org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
57
	 */
58
	public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
59
		return null;
60
	}
61
62
	/*
63
	 * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
64
	 */
65
	public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
66
		return null;
67
	}
68
69
	/*
70
	 * @see SourceViewerConfiguration#getOverviewRulerAnnotationHover(ISourceViewer)
71
	 */
72
	public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) {
73
		return null;
74
	}
75
76
	/*
77
	 * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer, String)
78
	 */
79
	public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) {
80
		return null;
81
	}
82
83
	/*
84
	 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
85
	 */
86
	public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
87
		return null;
88
	}
89
90
	/*
91
	 * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
92
	 */
93
	public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
94
		return null;
95
	}
96
97
	/*
98
	 * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
99
	 */
100
	public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
101
		if (fConfigureFormatter)
102
			return super.getContentFormatter(sourceViewer);
103
		else
104
			return null;
105
	}
106
107
	/*
108
	 * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
109
	 */
110
	public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
111
		return null;
112
	}
113
114
	/*
115
	 * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
116
	 */
117
	public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
118
		return null;
119
	}
120
121
	/*
122
	 * @see org.eclipse.cdt.ui.text.CSourceViewerConfiguration#getOutlinePresenter(org.eclipse.jface.text.source.ISourceViewer, boolean)
123
	 */
124
	public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer, boolean doCodeResolve) {
125
		return null;
126
	}
127
128
	/*
129
	 * @see org.eclipse.cdt.ui.text.CSourceViewerConfiguration#getHierarchyPresenter(org.eclipse.jface.text.source.ISourceViewer, boolean)
130
	 */
131
	public IInformationPresenter getHierarchyPresenter(ISourceViewer sourceViewer, boolean doCodeResolve) {
132
		return null;
133
	}
134
135
	/*
136
	 * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectors(org.eclipse.jface.text.source.ISourceViewer)
137
	 */
138
	public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
139
		return null;
140
	}
141
}
(-)src/org/eclipse/cdt/internal/ui/preferences/ScrolledPageContent.java (+65 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.preferences;
13
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.swt.widgets.Control;
17
18
import org.eclipse.ui.forms.FormColors;
19
import org.eclipse.ui.forms.widgets.FormToolkit;
20
import org.eclipse.ui.forms.widgets.SharedScrolledComposite;
21
22
23
public class ScrolledPageContent extends SharedScrolledComposite {
24
25
	private FormToolkit fToolkit;
26
	
27
	public ScrolledPageContent(Composite parent) {
28
		this(parent, SWT.V_SCROLL | SWT.H_SCROLL);
29
	}
30
	
31
	public ScrolledPageContent(Composite parent, int style) {
32
		super(parent, style);
33
		
34
		setFont(parent.getFont());
35
		
36
		FormColors colors= new FormColors(parent.getDisplay());
37
		colors.setBackground(null);
38
		colors.setForeground(null);
39
		
40
		fToolkit= new FormToolkit(colors);
41
		
42
		setExpandHorizontal(true);
43
		setExpandVertical(true);
44
		
45
		Composite body= new Composite(this, SWT.NONE);
46
		body.setFont(parent.getFont());
47
		setContent(body);
48
	}
49
	
50
	/* (non-Javadoc)
51
	 * @see org.eclipse.swt.widgets.Widget#dispose()
52
	 */
53
	public void dispose() {
54
		fToolkit.dispose();
55
		super.dispose();
56
	}
57
	
58
	public void adaptChild(Control childControl) {
59
		fToolkit.adapt(childControl, true, true);
60
	}
61
	
62
	public Composite getBody() {
63
		return (Composite) getContent();
64
	}
65
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/ProfileManager.java (+793 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.preferences.formatter;
13
14
import java.util.ArrayList;
15
import java.util.Collections;
16
import java.util.HashMap;
17
import java.util.Iterator;
18
import java.util.List;
19
import java.util.Map;
20
import java.util.Observable;
21
22
import org.eclipse.core.runtime.preferences.DefaultScope;
23
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
24
import org.eclipse.core.runtime.preferences.IScopeContext;
25
import org.eclipse.core.runtime.preferences.InstanceScope;
26
27
import org.eclipse.core.resources.IProject;
28
import org.eclipse.core.resources.ProjectScope;
29
import org.eclipse.core.resources.ResourcesPlugin;
30
31
import org.eclipse.cdt.core.CCorePlugin;
32
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
33
34
import org.eclipse.cdt.internal.ui.util.Messages;
35
36
import org.eclipse.cdt.ui.CUIPlugin;
37
import org.eclipse.cdt.ui.PreferenceConstants;
38
39
import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
40
41
import org.osgi.service.prefs.BackingStoreException;
42
43
44
/**
45
 * The model for the set of profiles which are available in the workbench.
46
 */
47
public class ProfileManager extends Observable {
48
	
49
    /**
50
     * A prefix which is prepended to every ID of a user-defined profile, in order
51
     * to differentiate it from a built-in profile.
52
     */
53
	private final static String ID_PREFIX= "_"; //$NON-NLS-1$
54
	
55
	/**
56
	 * Represents a profile with a unique ID, a name and a map 
57
	 * containing the code formatter settings.
58
	 */
59
	public static abstract class Profile implements Comparable {
60
		
61
		public abstract String getName();
62
		public abstract Profile rename(String name, ProfileManager manager);
63
		
64
		public abstract Map getSettings();
65
		public abstract void setSettings(Map settings);
66
		
67
		public int getVersion() {
68
			return ProfileVersioner.CURRENT_VERSION;
69
		}
70
		
71
		public boolean hasEqualSettings(Map otherMap, List allKeys) {
72
			Map settings= getSettings();
73
			for (Iterator iter= allKeys.iterator(); iter.hasNext(); ){
74
				String key= (String) iter.next();
75
				Object other= otherMap.get(key);
76
				Object curr= settings.get(key);
77
				if (other == null) {
78
					if (curr != null) {
79
						return false;
80
					}
81
				} else if (!other.equals(curr)) {
82
					return false;
83
				}
84
			}
85
			return true;
86
		}
87
		
88
		public abstract boolean isProfileToSave();
89
		
90
		public abstract String getID();
91
		
92
		public boolean isSharedProfile() {
93
			return false;
94
		}
95
		
96
		public boolean isBuiltInProfile() {
97
			return false;
98
		}
99
	}
100
	
101
	/**
102
	 * Represents a built-in profile. The state of a built-in profile 
103
	 * cannot be changed after instantiation.
104
	 */
105
	public final static class BuiltInProfile extends Profile {
106
		private final String fName;
107
		private final String fID;
108
		private final Map fSettings;
109
		private final int fOrder;
110
		
111
		protected BuiltInProfile(String ID, String name, Map settings, int order) {
112
			fName= name;
113
			fID= ID;
114
			fSettings= settings;
115
			fOrder= order;
116
		}
117
		
118
		public String getName() { 
119
			return fName;	
120
		}
121
		
122
		public Profile rename(String name, ProfileManager manager) {
123
			final String trimmed= name.trim();
124
		 	CustomProfile newProfile= new CustomProfile(trimmed, fSettings, ProfileVersioner.CURRENT_VERSION);
125
		 	manager.addProfile(newProfile);
126
			return newProfile;
127
		}
128
		
129
		public Map getSettings() {
130
			return fSettings;
131
		}
132
	
133
		public void setSettings(Map settings) {
134
		}
135
	
136
		public String getID() { 
137
			return fID; 
138
		}
139
		
140
		public final int compareTo(Object o) {
141
			if (o instanceof BuiltInProfile) {
142
				return fOrder - ((BuiltInProfile)o).fOrder;
143
			}
144
			return -1;
145
		}
146
147
		public boolean isProfileToSave() {
148
			return false;
149
		}
150
		
151
		public boolean isBuiltInProfile() {
152
			return true;
153
		}
154
	
155
	}
156
157
	/**
158
	 * Represents a user-defined profile. A custom profile can be modified after instantiation.
159
	 */
160
	public static class CustomProfile extends Profile {
161
		private String fName;
162
		private Map fSettings;
163
		protected ProfileManager fManager;
164
		private int fVersion;
165
166
		public CustomProfile(String name, Map settings, int version) {
167
			fName= name;
168
			fSettings= settings;
169
			fVersion= version;
170
		}
171
		
172
		public String getName() {
173
			return fName;
174
		}
175
		
176
		public Profile rename(String name, ProfileManager manager) {
177
			final String trimmed= name.trim();
178
			if (trimmed.equals(getName())) 
179
				return this;
180
			
181
			String oldID= getID(); // remember old id before changing name
182
			fName= trimmed;
183
			
184
			manager.profileRenamed(this, oldID);
185
			return this;
186
		}
187
188
		public Map getSettings() { 
189
			return fSettings;
190
		}
191
		
192
		public void setSettings(Map settings) {
193
			if (settings == null)
194
				throw new IllegalArgumentException();
195
			fSettings= settings;
196
			if (fManager != null) {
197
				fManager.profileChanged(this);
198
			}
199
		}
200
		
201
		public String getID() { 
202
			return ID_PREFIX + fName;
203
		}
204
		
205
		public void setManager(ProfileManager profileManager) {
206
			fManager= profileManager;
207
		}
208
		
209
		public ProfileManager getManager() {
210
			return fManager;
211
		}
212
213
		public int getVersion() {
214
			return fVersion;
215
		}
216
		
217
		public void setVersion(int version)	{
218
			fVersion= version;
219
		}
220
		
221
		public int compareTo(Object o) {
222
			if (o instanceof SharedProfile) {
223
				return -1;
224
			}
225
			if (o instanceof CustomProfile) {
226
				return getName().compareToIgnoreCase(((Profile)o).getName());
227
			}
228
			return 1;
229
		}
230
		
231
		public boolean isProfileToSave() {
232
			return true;
233
		}
234
235
	}
236
	
237
	public final static class SharedProfile extends CustomProfile {
238
		
239
		public SharedProfile(String oldName, Map options) {
240
			super(oldName, options, ProfileVersioner.CURRENT_VERSION);
241
		}
242
		
243
		public Profile rename(String name, ProfileManager manager) {
244
			CustomProfile profile= new CustomProfile(name.trim(), getSettings(), getVersion());
245
246
			manager.profileReplaced(this, profile);
247
			return profile;
248
		}
249
				
250
		public String getID() { 
251
			return SHARED_PROFILE;
252
		}
253
		
254
		public final int compareTo(Object o) {
255
			return 1;
256
		}
257
		
258
		public boolean isProfileToSave() {
259
			return false;
260
		}
261
		
262
		public boolean isSharedProfile() {
263
			return true;
264
		}
265
	}
266
	
267
268
	/**
269
	 * The possible events for observers listening to this class.
270
	 */
271
	public final static int SELECTION_CHANGED_EVENT= 1;
272
	public final static int PROFILE_DELETED_EVENT= 2;
273
	public final static int PROFILE_RENAMED_EVENT= 3;
274
	public final static int PROFILE_CREATED_EVENT= 4;
275
	public final static int SETTINGS_CHANGED_EVENT= 5;
276
	
277
	/**
278
	 * The key of the preference where the selected profile is stored.
279
	 */
280
	private final static String PROFILE_KEY= PreferenceConstants.FORMATTER_PROFILE;
281
	
282
	/**
283
	 * The key of the preference where the version of the current settings is stored
284
	 */
285
	private final static String FORMATTER_SETTINGS_VERSION= "formatter_settings_version";  //$NON-NLS-1$
286
287
	/**
288
	 * The keys of the built-in profiles
289
	 */
290
	public final static String ECLIPSE_PROFILE= "org.eclipse.cdt.ui.default.eclipse_profile"; //$NON-NLS-1$
291
	public final static String SHARED_PROFILE= "org.eclipse.cdt.ui.default.shared"; //$NON-NLS-1$
292
	
293
	public final static String DEFAULT_PROFILE= ECLIPSE_PROFILE;
294
	
295
	/**
296
	 * A map containing the available profiles, using the IDs as keys.
297
	 */
298
	private final Map fProfiles;
299
	
300
	/**
301
	 * The available profiles, sorted by name.
302
	 */
303
	private final List fProfilesByName;
304
	
305
306
	/**
307
	 * The currently selected profile. 
308
	 */
309
	private Profile fSelected;
310
	
311
	/**
312
	 * The keys of the options to be saved with each profile
313
	 */
314
	private final static List fUIKeys= Collections.EMPTY_LIST; 
315
	private final static List fCoreKeys= new ArrayList(DefaultCodeFormatterConstants.getEclipseDefaultSettings().keySet());
316
317
	/**
318
	 * All keys appearing in a profile, sorted alphabetically
319
	 */
320
	private final static List fKeys;
321
	private final PreferencesAccess fPreferencesAccess;
322
	
323
	static {
324
	    fKeys= new ArrayList();
325
	    fKeys.addAll(fUIKeys);
326
	    fKeys.addAll(fCoreKeys);
327
	    Collections.sort(fKeys);
328
	}
329
	
330
331
	/**
332
	 * Create and initialize a new profile manager.
333
	 * @param profiles Initial custom profiles (List of type <code>CustomProfile</code>)
334
	 */
335
	public ProfileManager(List profiles, IScopeContext context, PreferencesAccess preferencesAccess) {
336
		fPreferencesAccess= preferencesAccess;
337
		
338
		fProfiles= new HashMap();
339
		fProfilesByName= new ArrayList();
340
	
341
		addBuiltinProfiles(fProfiles, fProfilesByName);
342
		
343
		for (final Iterator iter = profiles.iterator(); iter.hasNext();) {
344
			final CustomProfile profile= (CustomProfile) iter.next();
345
			profile.setManager(this);
346
			fProfiles.put(profile.getID(), profile);
347
			fProfilesByName.add(profile);
348
		}
349
		
350
		Collections.sort(fProfilesByName);
351
		
352
		IScopeContext instanceScope= fPreferencesAccess.getInstanceScope(); 
353
		String profileId= instanceScope.getNode(CUIPlugin.PLUGIN_ID).get(PROFILE_KEY, null);
354
		if (profileId == null) {
355
			profileId= new DefaultScope().getNode(CUIPlugin.PLUGIN_ID).get(PROFILE_KEY, null);
356
		}
357
		
358
		Profile profile= (Profile) fProfiles.get(profileId);
359
		if (profile == null) {
360
			profile= (Profile) fProfiles.get(DEFAULT_PROFILE);
361
		}
362
		fSelected= profile;
363
		
364
		if (context.getName() == ProjectScope.SCOPE && hasProjectSpecificSettings(context)) {
365
			Map map= readFromPreferenceStore(context, profile);
366
			if (map != null) {
367
				Profile matching= null;
368
			
369
				String projProfileId= context.getNode(CUIPlugin.PLUGIN_ID).get(PROFILE_KEY, null);
370
				if (projProfileId != null) {
371
					Profile curr= (Profile) fProfiles.get(projProfileId);
372
					if (curr != null && (curr.isBuiltInProfile() || curr.hasEqualSettings(map, getKeys()))) {
373
						matching= curr;
374
					}
375
				} else {
376
					// old version: look for similar
377
					for (final Iterator iter = fProfilesByName.iterator(); iter.hasNext();) {
378
						Profile curr= (Profile) iter.next();
379
						if (curr.hasEqualSettings(map, getKeys())) {
380
							matching= curr;
381
							break;
382
						}
383
					}
384
				}
385
				if (matching == null) {
386
					String name;
387
					if (projProfileId != null && !fProfiles.containsKey(projProfileId)) {
388
						name= Messages.format(FormatterMessages.ProfileManager_unmanaged_profile_with_name, projProfileId.substring(ID_PREFIX.length()));
389
					} else {
390
						name= FormatterMessages.ProfileManager_unmanaged_profile;
391
					}
392
					// current settings do not correspond to any profile -> create a 'team' profile
393
					SharedProfile shared= new SharedProfile(name, map);
394
					shared.setManager(this);
395
					fProfiles.put(shared.getID(), shared);
396
					fProfilesByName.add(shared); // add last
397
					matching= shared;
398
				}
399
				fSelected= matching;
400
			}
401
		}
402
	}
403
	
404
405
406
407
408
	/**
409
	 * Notify observers with a message. The message must be one of the following:
410
	 * @param message Message to send out
411
	 * 
412
	 * @see #SELECTION_CHANGED_EVENT
413
	 * @see #PROFILE_DELETED_EVENT
414
	 * @see #PROFILE_RENAMED_EVENT
415
	 * @see #PROFILE_CREATED_EVENT
416
	 * @see #SETTINGS_CHANGED_EVENT
417
	 */
418
	protected void notifyObservers(int message) {
419
		setChanged();
420
		notifyObservers(new Integer(message));
421
	}
422
	
423
	public static boolean hasProjectSpecificSettings(IScopeContext context) {
424
		IEclipsePreferences corePrefs= context.getNode(CCorePlugin.PLUGIN_ID);
425
		for (final Iterator keyIter = fCoreKeys.iterator(); keyIter.hasNext(); ) {
426
			final String key= (String) keyIter.next();
427
			Object val= corePrefs.get(key, null);
428
			if (val != null) {
429
				return true;
430
			}
431
		}
432
		
433
		IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
434
		for (final Iterator keyIter = fUIKeys.iterator(); keyIter.hasNext(); ) {
435
			final String key= (String) keyIter.next();
436
			Object val= uiPrefs.get(key, null);
437
			if (val != null) {
438
				return true;
439
			}
440
		}
441
		return false;
442
	}
443
444
	
445
	/**
446
	 * Only to read project specific settings to find out to what profile it matches.
447
	 * @param context The project context
448
	 */
449
	public Map readFromPreferenceStore(IScopeContext context, Profile workspaceProfile) {
450
		final Map profileOptions= new HashMap();
451
		IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
452
		IEclipsePreferences corePrefs= context.getNode(CCorePlugin.PLUGIN_ID);
453
				
454
		int version= uiPrefs.getInt(FORMATTER_SETTINGS_VERSION, ProfileVersioner.VERSION_1);
455
		if (version != ProfileVersioner.CURRENT_VERSION) {
456
			Map allOptions= new HashMap();
457
			addAll(uiPrefs, allOptions);
458
			addAll(corePrefs, allOptions);
459
			return ProfileVersioner.updateAndComplete(allOptions, version);
460
		}
461
		
462
		boolean hasValues= false;
463
		for (final Iterator keyIter = fCoreKeys.iterator(); keyIter.hasNext(); ) {
464
			final String key= (String) keyIter.next();
465
			Object val= corePrefs.get(key, null);
466
			if (val != null) {
467
				hasValues= true;
468
			} else {
469
				val= workspaceProfile.getSettings().get(key);
470
			}
471
			profileOptions.put(key, val);
472
		}
473
		
474
		for (final Iterator keyIter = fUIKeys.iterator(); keyIter.hasNext(); ) {
475
			final String key= (String) keyIter.next();
476
			Object val= uiPrefs.get(key, null);
477
			if (val != null) {
478
				hasValues= true;
479
			} else {
480
				val= workspaceProfile.getSettings().get(key);
481
			}
482
			profileOptions.put(key, val);
483
		}
484
		
485
		if (!hasValues) {
486
			return null;
487
		}
488
489
		return profileOptions;
490
	}
491
	
492
	/**
493
	 * @param uiPrefs
494
	 * @param allOptions
495
	 */
496
	private void addAll(IEclipsePreferences uiPrefs, Map allOptions) {
497
		try {
498
			String[] keys= uiPrefs.keys();
499
			for (int i= 0; i < keys.length; i++) {
500
				String key= keys[i];
501
				String val= uiPrefs.get(key, null);
502
				if (val != null) {
503
					allOptions.put(key, val);
504
				}
505
			}
506
		} catch (BackingStoreException e) {
507
			// ignore
508
		}
509
		
510
	}
511
512
	private boolean updatePreferences(IEclipsePreferences prefs, List keys, Map profileOptions) {
513
		boolean hasChanges= false;
514
		for (final Iterator keyIter = keys.iterator(); keyIter.hasNext(); ) {
515
			final String key= (String) keyIter.next();
516
			final String oldVal= prefs.get(key, null);
517
			final String val= (String) profileOptions.get(key);
518
			if (val == null) {
519
				if (oldVal != null) {
520
					prefs.remove(key);
521
					hasChanges= true;
522
				}
523
			} else if (!val.equals(oldVal)) {
524
				prefs.put(key, val);
525
				hasChanges= true;
526
			}
527
		}
528
		return hasChanges;
529
	}
530
	
531
	
532
	/**
533
	 * Update all formatter settings with the settings of the specified profile. 
534
	 * @param profile The profile to write to the preference store
535
	 */
536
	private void writeToPreferenceStore(Profile profile, IScopeContext context) {
537
		final Map profileOptions= profile.getSettings();
538
		
539
		final IEclipsePreferences corePrefs= context.getNode(CCorePlugin.PLUGIN_ID);
540
		updatePreferences(corePrefs, fCoreKeys, profileOptions);
541
		
542
		final IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
543
		updatePreferences(uiPrefs, fUIKeys, profileOptions);
544
		
545
		if (uiPrefs.getInt(FORMATTER_SETTINGS_VERSION, 0) != ProfileVersioner.CURRENT_VERSION) {
546
			uiPrefs.putInt(FORMATTER_SETTINGS_VERSION, ProfileVersioner.CURRENT_VERSION);
547
		}
548
		
549
		if (context.getName() == InstanceScope.SCOPE) {
550
			uiPrefs.put(PROFILE_KEY, profile.getID());
551
		} else if (context.getName() == ProjectScope.SCOPE && !profile.isSharedProfile()) {
552
			uiPrefs.put(PROFILE_KEY, profile.getID());
553
		}
554
	}
555
	
556
	/**
557
	 * Add all the built-in profiles to the map and to the list.
558
	 * @param profiles The map to add the profiles to
559
	 * @param profilesByName List of profiles by
560
	 */
561
	private void addBuiltinProfiles(Map profiles, List profilesByName) {
562
		final Profile eclipseProfile= new BuiltInProfile(ECLIPSE_PROFILE, FormatterMessages.ProfileManager_default_profile_name, getEclipseSettings(), 2); 
563
		profiles.put(eclipseProfile.getID(), eclipseProfile);
564
		profilesByName.add(eclipseProfile);
565
	}
566
	
567
	/**
568
	 * @return Returns the settings for the new eclipse profile.
569
	 */	
570
	public static Map getEclipseSettings() {
571
		return DefaultCodeFormatterConstants.getEclipseDefaultSettings();
572
	}
573
574
	/** 
575
	 * @return Returns the default settings.
576
	 */
577
	public static Map getDefaultSettings() {
578
		return getEclipseSettings();
579
	}
580
	
581
	/**
582
	 * @return All keys appearing in a profile, sorted alphabetically.
583
	 */
584
	public static List getKeys() {
585
	    return fKeys;
586
	}
587
	
588
	/** 
589
	 * Get an immutable list as view on all profiles, sorted alphabetically. Unless the set 
590
	 * of profiles has been modified between the two calls, the sequence is guaranteed to 
591
	 * correspond to the one returned by <code>getSortedNames</code>.
592
	 * @return a list of elements of type <code>Profile</code>
593
	 * 
594
	 * @see #getSortedDisplayNames()
595
	 */
596
	public List getSortedProfiles() {
597
		return Collections.unmodifiableList(fProfilesByName);
598
	}
599
600
	/**
601
	 * Get the names of all profiles stored in this profile manager, sorted alphabetically. Unless the set of 
602
	 * profiles has been modified between the two calls, the sequence is guaranteed to correspond to the one 
603
	 * returned by <code>getSortedProfiles</code>.
604
	 * @return All names, sorted alphabetically
605
	 * @see #getSortedProfiles()  
606
	 */	
607
	public String[] getSortedDisplayNames() {
608
		final String[] sortedNames= new String[fProfilesByName.size()];
609
		int i= 0;
610
		for (final Iterator iter = fProfilesByName.iterator(); iter.hasNext();) {
611
			Profile curr= (Profile) iter.next();
612
			sortedNames[i++]= curr.getName();
613
		}
614
		return sortedNames;
615
	}
616
	
617
	/**
618
	 * Get the profile for this profile id.
619
	 * @param ID The profile ID
620
	 * @return The profile with the given ID or <code>null</code> 
621
	 */
622
	public Profile getProfile(String ID) {
623
		return (Profile)fProfiles.get(ID);
624
	}
625
	
626
	/**
627
	 * Activate the selected profile, update all necessary options in
628
	 * preferences and save profiles to disk.
629
	 */
630
	public void commitChanges(IScopeContext scopeContext) {
631
		if (fSelected != null) {
632
			writeToPreferenceStore(fSelected, scopeContext);
633
		}
634
	}
635
	
636
	public void clearAllSettings(IScopeContext context) {
637
		final IEclipsePreferences corePrefs= context.getNode(CCorePlugin.PLUGIN_ID);
638
		updatePreferences(corePrefs, fCoreKeys, Collections.EMPTY_MAP);
639
		
640
		final IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
641
		updatePreferences(uiPrefs, fUIKeys, Collections.EMPTY_MAP);
642
		
643
		uiPrefs.remove(PROFILE_KEY);
644
	}
645
	
646
	/**
647
	 * Get the currently selected profile.
648
	 * @return The currently selected profile.
649
	 */
650
	public Profile getSelected() {
651
		return fSelected;
652
	}
653
654
	/**
655
	 * Set the selected profile. The profile must already be contained in this profile manager.
656
	 * @param profile The profile to select
657
	 */
658
	public void setSelected(Profile profile) {
659
		final Profile newSelected= (Profile)fProfiles.get(profile.getID());
660
		if (newSelected != null && !newSelected.equals(fSelected)) {
661
			fSelected= newSelected;
662
			notifyObservers(SELECTION_CHANGED_EVENT);
663
		}
664
	}
665
666
	/**
667
	 * Check whether a user-defined profile in this profile manager
668
	 * already has this name.
669
	 * @param name The name to test for
670
	 * @return Returns <code>true</code> if a profile with the given name exists
671
	 */
672
	public boolean containsName(String name) {
673
		for (final Iterator iter = fProfilesByName.iterator(); iter.hasNext();) {
674
			Profile curr= (Profile) iter.next();
675
			if (name.equals(curr.getName())) {
676
				return true;
677
			}
678
		}
679
		return false;
680
	}
681
	
682
	/**
683
	 * Add a new custom profile to this profile manager.
684
	 * @param profile The profile to add
685
	 */	
686
	public void addProfile(CustomProfile profile) {
687
		profile.setManager(this);
688
		final CustomProfile oldProfile= (CustomProfile)fProfiles.get(profile.getID());
689
		if (oldProfile != null) {
690
			fProfiles.remove(oldProfile.getID());
691
			fProfilesByName.remove(oldProfile);
692
			oldProfile.setManager(null);
693
		}
694
		fProfiles.put(profile.getID(), profile);
695
		fProfilesByName.add(profile);
696
		Collections.sort(fProfilesByName);
697
		fSelected= profile;
698
		notifyObservers(PROFILE_CREATED_EVENT);
699
	}
700
	
701
	/**
702
	 * Delete the currently selected profile from this profile manager. The next profile
703
	 * in the list is selected.
704
	 * @return true if the profile has been successfully removed, false otherwise.
705
	 */
706
	public boolean deleteSelected() {
707
		if (!(fSelected instanceof CustomProfile)) 
708
			return false;
709
		
710
		Profile removedProfile= fSelected;
711
		
712
		int index= fProfilesByName.indexOf(removedProfile);
713
		
714
		fProfiles.remove(removedProfile.getID());
715
		fProfilesByName.remove(removedProfile);
716
		
717
		((CustomProfile)removedProfile).setManager(null);
718
		
719
		if (index >= fProfilesByName.size())
720
			index--;
721
		fSelected= (Profile) fProfilesByName.get(index);
722
723
		if (!removedProfile.isSharedProfile()) {
724
			updateProfilesWithName(removedProfile.getID(), null, false);
725
		}
726
		
727
		notifyObservers(PROFILE_DELETED_EVENT);
728
		return true;
729
	}
730
	
731
	public void profileRenamed(CustomProfile profile, String oldID) {
732
		fProfiles.remove(oldID);
733
		fProfiles.put(profile.getID(), profile);
734
735
		if (!profile.isSharedProfile()) {
736
			updateProfilesWithName(oldID, profile, false);
737
		}
738
		
739
		Collections.sort(fProfilesByName);
740
		notifyObservers(PROFILE_RENAMED_EVENT);
741
	}
742
	
743
	public void profileReplaced(CustomProfile oldProfile, CustomProfile newProfile) {
744
		fProfiles.remove(oldProfile.getID());
745
		fProfiles.put(newProfile.getID(), newProfile);
746
		fProfilesByName.remove(oldProfile);
747
		fProfilesByName.add(newProfile);
748
		Collections.sort(fProfilesByName);
749
		
750
		if (!oldProfile.isSharedProfile()) {
751
			updateProfilesWithName(oldProfile.getID(), null, false);
752
		}
753
		
754
		setSelected(newProfile);
755
		notifyObservers(PROFILE_CREATED_EVENT);
756
		notifyObservers(SELECTION_CHANGED_EVENT);
757
	}
758
	
759
	public void profileChanged(CustomProfile profile) {
760
		if (!profile.isSharedProfile()) {
761
			updateProfilesWithName(profile.getID(), profile, true);
762
		}
763
		
764
		notifyObservers(SETTINGS_CHANGED_EVENT);
765
	}
766
	
767
	
768
	private void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) {
769
		IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
770
		for (int i= 0; i < projects.length; i++) {
771
			IScopeContext projectScope= fPreferencesAccess.getProjectScope(projects[i]);
772
			IEclipsePreferences node= projectScope.getNode(CUIPlugin.PLUGIN_ID);
773
			String profileId= node.get(PROFILE_KEY, null);
774
			if (oldName.equals(profileId)) {
775
				if (newProfile == null) {
776
					node.remove(PROFILE_KEY);
777
				} else {
778
					if (applySettings) {
779
						writeToPreferenceStore(newProfile, projectScope);
780
					} else {
781
						node.put(PROFILE_KEY, newProfile.getID());
782
					}
783
				}
784
			}
785
		}
786
		
787
		IScopeContext instanceScope= fPreferencesAccess.getInstanceScope();
788
		final IEclipsePreferences uiPrefs= instanceScope.getNode(CUIPlugin.PLUGIN_ID);
789
		if (newProfile != null && oldName.equals(uiPrefs.get(PROFILE_KEY, null))) {
790
			writeToPreferenceStore(newProfile, instanceScope);
791
		}
792
	}
793
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/TranslationUnitPreview.java (+79 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.preferences.formatter;
14
15
import java.util.Map;
16
17
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.Status;
19
20
import org.eclipse.swt.widgets.Composite;
21
22
import org.eclipse.jface.text.Region;
23
import org.eclipse.jface.text.formatter.FormattingContextProperties;
24
import org.eclipse.jface.text.formatter.IContentFormatter;
25
import org.eclipse.jface.text.formatter.IContentFormatterExtension;
26
import org.eclipse.jface.text.formatter.IFormattingContext;
27
28
import org.eclipse.cdt.internal.ui.ICStatusConstants;
29
import org.eclipse.cdt.internal.ui.text.comment.CommentFormattingContext;
30
31
import org.eclipse.cdt.ui.CUIPlugin;
32
33
34
public class TranslationUnitPreview extends CPreview {
35
36
    private String fPreviewText;
37
38
    /**
39
     * @param workingValues
40
     * @param parent
41
     */
42
    public TranslationUnitPreview(Map workingValues, Composite parent) {
43
        super(workingValues, parent);
44
    }
45
46
    protected void doFormatPreview() {
47
        if (fPreviewText == null) {
48
            fPreviewDocument.set(""); //$NON-NLS-1$
49
            return;
50
        }
51
        fPreviewDocument.set(fPreviewText);
52
		
53
		fSourceViewer.setRedraw(false);
54
		final IFormattingContext context = new CommentFormattingContext();
55
		try {
56
			final IContentFormatter formatter =	fViewerConfiguration.getContentFormatter(fSourceViewer);
57
			if (formatter instanceof IContentFormatterExtension) {
58
				final IContentFormatterExtension extension = (IContentFormatterExtension) formatter;
59
				context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, fWorkingValues);
60
				context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true));
61
				extension.format(fPreviewDocument, context);
62
			} else
63
				formatter.format(fPreviewDocument, new Region(0, fPreviewDocument.getLength()));
64
		} catch (Exception e) {
65
			final IStatus status= new Status(IStatus.ERROR, CUIPlugin.getPluginId(), ICStatusConstants.INTERNAL_ERROR, 
66
				FormatterMessages.CPreview_formatter_exception, e); 
67
			CUIPlugin.getDefault().log(status);
68
		} finally {
69
		    context.dispose();
70
		    fSourceViewer.setRedraw(true);
71
		}
72
    }
73
    
74
    public void setPreviewText(String previewText) {
75
//        if (previewText == null) throw new IllegalArgumentException();
76
        fPreviewText= previewText;
77
        update();
78
    }
79
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/ModifyDialogTabPage.java (+802 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.preferences.formatter;
13
14
import java.util.ArrayList;
15
import java.util.HashMap;
16
import java.util.List;
17
import java.util.Map;
18
import java.util.Observable;
19
import java.util.Observer;
20
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.Status;
23
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.FocusAdapter;
26
import org.eclipse.swt.events.FocusEvent;
27
import org.eclipse.swt.events.FocusListener;
28
import org.eclipse.swt.events.ModifyEvent;
29
import org.eclipse.swt.events.ModifyListener;
30
import org.eclipse.swt.events.SelectionAdapter;
31
import org.eclipse.swt.events.SelectionEvent;
32
import org.eclipse.swt.layout.GridData;
33
import org.eclipse.swt.layout.GridLayout;
34
import org.eclipse.swt.widgets.Button;
35
import org.eclipse.swt.widgets.Combo;
36
import org.eclipse.swt.widgets.Composite;
37
import org.eclipse.swt.widgets.Control;
38
import org.eclipse.swt.widgets.Group;
39
import org.eclipse.swt.widgets.Label;
40
import org.eclipse.swt.widgets.Text;
41
42
import org.eclipse.jface.dialogs.IDialogConstants;
43
import org.eclipse.jface.dialogs.IDialogSettings;
44
45
import org.eclipse.cdt.core.CCorePlugin;
46
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
47
48
import org.eclipse.cdt.ui.CUIPlugin;
49
50
import org.eclipse.cdt.internal.ui.util.Messages;
51
import org.eclipse.cdt.internal.ui.util.PixelConverter;
52
53
54
public abstract class ModifyDialogTabPage {
55
	
56
	/**
57
	 * This is the default listener for any of the Preference
58
	 * classes. It is added by the respective factory methods and
59
	 * updates the page's preview on each change. 
60
	 */
61
	protected final Observer fUpdater= new Observer() {
62
		public void update(Observable o, Object arg) {
63
			doUpdatePreview();
64
			notifyValuesModified();
65
		}
66
	};
67
	
68
	/**
69
	 * The base class of all Preference classes. A preference class provides a wrapper
70
	 * around one or more SWT widgets and handles the input of values for some key.
71
	 * On each change, the new value is written to the map and the listeners are notified.
72
	 */
73
	protected abstract class Preference extends Observable {
74
	    private final Map fPreferences;
75
	    private boolean fEnabled;
76
	    private String fKey;
77
	    
78
	    /**
79
	     * Create a new Preference.
80
	     * @param preferences The map where the value is written.
81
	     * @param key The key for which a value is managed.
82
	     */
83
	    public Preference(Map preferences, String key) {
84
	        fPreferences= preferences;
85
	        fEnabled= true;
86
	        fKey= key;
87
	    }
88
	    /**
89
	     * @return Gets the map of this Preference.
90
	     */
91
	    protected final Map getPreferences() {
92
	        return fPreferences;
93
	    }
94
95
	    /**
96
	     * Set the enabled state of all SWT widgets of this preference. 
97
	     * @param enabled new value
98
	     */
99
	    public final void setEnabled(boolean enabled) {
100
	        fEnabled= enabled;
101
	        updateWidget();
102
	    }
103
	    
104
	    /**
105
	     * @return Gets the enabled state of all SWT widgets of this Preference.
106
	     */
107
	    public final boolean getEnabled() {
108
	        return fEnabled;
109
	    }
110
	    
111
	    /**
112
	     * Set the key which is used to store the value.
113
	     * @param key New value
114
	     */
115
	    public final void setKey(String key) {
116
	        if (key == null || !fKey.equals(key)) {
117
	            fKey= key;
118
	            updateWidget();
119
	        }
120
	    }
121
	    /**
122
	     * @return Gets the currently used key which is used to store the value.
123
	     */	    
124
	    public final String getKey() {
125
	        return fKey;
126
	    }
127
	    
128
	    /**
129
	     * Returns the main control of a preference, which is mainly used to 
130
	     * manage the focus. This may be <code>null</code> if the preference doesn't
131
	     * have a control which is able to have the focus. 
132
	     * @return The main control
133
	     */
134
	    public abstract Control getControl();
135
	    
136
	    /**
137
	     * To be implemented in subclasses. Update the SWT widgets when the state 
138
	     * of this object has changed (enabled, key, ...).
139
	     */
140
	    protected abstract void updateWidget();
141
	}
142
	
143
	/**
144
	 * Wrapper around a checkbox and a label. 
145
	 */	
146
	protected final class CheckboxPreference extends Preference {
147
		private final String[] fValues;
148
		private final Button fCheckbox;
149
		
150
		/**
151
		 * Create a new CheckboxPreference.
152
		 * @param composite The composite on which the SWT widgets are added.
153
		 * @param numColumns The number of columns in the composite's GridLayout.
154
		 * @param preferences The map to store the values.
155
		 * @param key The key to store the values.
156
		 * @param values An array of two elements indicating the values to store on unchecked/checked.
157
		 * @param text The label text for this Preference.
158
		 */
159
		public CheckboxPreference(Composite composite, int numColumns,
160
								  Map preferences, String key, 
161
								  String [] values, String text) {
162
		    super(preferences, key);
163
		    if (values == null || text == null) 
164
		        throw new IllegalArgumentException(FormatterMessages.ModifyDialogTabPage_error_msg_values_text_unassigned); 
165
			fValues= values;
166
167
			fCheckbox= new Button(composite, SWT.CHECK);
168
			fCheckbox.setText(text);
169
			fCheckbox.setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL, SWT.DEFAULT));
170
			fCheckbox.setFont(composite.getFont());
171
			
172
			updateWidget();
173
174
			fCheckbox.addSelectionListener(new SelectionAdapter() {
175
				public void widgetSelected(SelectionEvent e) {
176
					checkboxChecked(((Button)e.widget).getSelection());
177
				}
178
			});
179
		}
180
		
181
		protected void checkboxChecked(boolean state) {
182
			getPreferences().put(getKey(), state ? fValues[1] : fValues[0]);
183
			setChanged();
184
			notifyObservers();
185
		}
186
		
187
		protected void updateWidget() {
188
			if (getKey() != null) {
189
				fCheckbox.setEnabled(getEnabled());
190
				fCheckbox.setSelection(getChecked());
191
			} else {
192
				fCheckbox.setSelection(false);
193
				fCheckbox.setEnabled(false);
194
			}
195
		}
196
		
197
		public boolean getChecked() {
198
			return fValues[1].equals(getPreferences().get(getKey()));
199
		}
200
		
201
		public Control getControl() {
202
			return fCheckbox;
203
		}
204
	}
205
	
206
	
207
	/**
208
	 * Wrapper around a Combo box.
209
	 */
210
	protected final class ComboPreference extends Preference {
211
		private final String [] fItems;
212
		private final String[] fValues;
213
		private final Combo fCombo;
214
		
215
		/**
216
		 * Create a new ComboPreference.
217
		 * @param composite The composite on which the SWT widgets are added.
218
		 * @param numColumns The number of columns in the composite's GridLayout.
219
		 * @param preferences The map to store the values.
220
		 * @param key The key to store the values.
221
		 * @param values An array of n elements indicating the values to store for each selection.
222
		 * @param text The label text for this Preference.
223
		 * @param items An array of n elements indicating the text to be written in the combo box.
224
		 */
225
		public ComboPreference(Composite composite, int numColumns,
226
								  Map preferences, String key, 
227
								  String [] values, String text, String [] items) {
228
		    super(preferences, key);
229
		    if (values == null || items == null || text == null) 
230
		        throw new IllegalArgumentException(FormatterMessages.ModifyDialogTabPage_error_msg_values_items_text_unassigned); 
231
			fValues= values;
232
			fItems= items;
233
			createLabel(numColumns - 1, composite, text);
234
			fCombo= new Combo(composite, SWT.SINGLE | SWT.READ_ONLY);
235
			fCombo.setFont(composite.getFont());
236
			fCombo.setItems(items);
237
			
238
			int max= 0;
239
			for (int i= 0; i < items.length; i++)
240
			    if (items[i].length() > max) max= items[i].length();
241
			
242
			fCombo.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_FILL, fCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x));			
243
244
			updateWidget();
245
246
			fCombo.addSelectionListener(new SelectionAdapter() {
247
				public void widgetSelected(SelectionEvent e) {
248
					comboSelected(((Combo)e.widget).getSelectionIndex());
249
				}
250
			});
251
		}
252
		
253
		protected void comboSelected(int index) {
254
			getPreferences().put(getKey(), fValues[index]);
255
			setChanged();
256
			notifyObservers(fValues[index]);
257
		}
258
		
259
		protected void updateWidget() {
260
			if (getKey() != null) {
261
				fCombo.setEnabled(getEnabled());
262
				fCombo.setText(getSelectedItem());
263
			} else {
264
				fCombo.setText(""); //$NON-NLS-1$
265
				fCombo.setEnabled(false);
266
			}
267
		}
268
		
269
		public String getSelectedItem() {
270
			final String selected= (String)getPreferences().get(getKey());
271
			for (int i= 0; i < fValues.length; i++) {
272
				if (fValues[i].equals(selected)) {
273
					return fItems[i];
274
				}
275
			}
276
			return ""; //$NON-NLS-1$
277
		}
278
		
279
		public boolean hasValue(String value) {
280
			return value.equals(getPreferences().get(getKey()));
281
		}
282
		
283
		public Control getControl() {
284
			return fCombo;
285
		}
286
	}
287
	
288
	/**
289
	 * Wrapper around a textfied which requests an integer input of a given range.
290
	 */
291
	protected final class NumberPreference extends Preference {
292
		
293
		private final int fMinValue, fMaxValue;
294
		private final Label fNumberLabel;
295
		private final Text fNumberText;
296
297
		protected int fSelected;
298
        protected int fOldSelected;
299
        
300
        
301
		/**
302
		 * Create a new NumberPreference.
303
		 * @param composite The composite on which the SWT widgets are added.
304
		 * @param numColumns The number of columns in the composite's GridLayout.
305
		 * @param preferences The map to store the values.
306
		 * @param key The key to store the values.
307
		 * @param minValue The minimum value which is valid input.
308
		 * @param maxValue The maximum value which is valid input.
309
		 * @param text The label text for this Preference.
310
		 */
311
		public NumberPreference(Composite composite, int numColumns,
312
							   Map preferences, String key, 
313
							   int minValue, int maxValue, String text) {
314
		    super(preferences, key);
315
		    
316
			fNumberLabel= createLabel(numColumns - 1, composite, text, GridData.FILL_HORIZONTAL);
317
			fNumberText= new Text(composite, SWT.SINGLE | SWT.BORDER | SWT.RIGHT);
318
			fNumberText.setFont(composite.getFont());
319
320
			final int length= Integer.toString(maxValue).length() + 3; 
321
			fNumberText.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_END, fPixelConverter.convertWidthInCharsToPixels(length)));
322
			
323
			fMinValue= minValue;
324
			fMaxValue= maxValue;
325
			
326
			updateWidget();
327
			
328
			fNumberText.addFocusListener(new FocusListener() {
329
				public void focusGained(FocusEvent e) {
330
				    NumberPreference.this.focusGained();
331
				}
332
                public void focusLost(FocusEvent e) {
333
				    NumberPreference.this.focusLost();
334
				}
335
			});
336
			
337
			fNumberText.addModifyListener(new ModifyListener() {
338
				public void modifyText(ModifyEvent e) {
339
					fieldModified();
340
				}
341
			});
342
		}
343
		
344
		private IStatus createErrorStatus() {
345
		    return new Status(IStatus.ERROR, CUIPlugin.getPluginId(), 0, Messages.format(FormatterMessages.ModifyDialogTabPage_NumberPreference_error_invalid_value, new String [] {Integer.toString(fMinValue), Integer.toString(fMaxValue)}), null); 
346
		}
347
348
		protected void focusGained() {
349
		    fOldSelected= fSelected;
350
		    fNumberText.setSelection(0, fNumberText.getCharCount());
351
		}
352
		
353
		protected void focusLost() {
354
		    updateStatus(null);
355
		    final String input= fNumberText.getText();
356
		    if (!validInput(input))
357
		        fSelected= fOldSelected;
358
		    else
359
		        fSelected= Integer.parseInt(input);
360
		    if (fSelected != fOldSelected) {
361
		    	saveSelected();
362
		    	fNumberText.setText(Integer.toString(fSelected));
363
		    }
364
		}
365
		
366
		
367
		protected void fieldModified() {
368
		    final String trimInput= fNumberText.getText().trim();
369
		    final boolean valid= validInput(trimInput);
370
		    
371
		    updateStatus(valid ? null : createErrorStatus());
372
373
		    if (valid) {
374
		        final int number= Integer.parseInt(trimInput);
375
		        if (fSelected != number) {
376
		            fSelected= number;
377
		            saveSelected();
378
		        }
379
		    }
380
		}
381
		
382
		private boolean validInput(String trimInput) {
383
		    int number;
384
		    
385
		    try {
386
		        number= Integer.parseInt(trimInput);
387
		    } catch (NumberFormatException x) {
388
		        return false;
389
		    }
390
		    
391
		    if (number < fMinValue) return false;
392
		    if (number > fMaxValue) return false;
393
		    return true;
394
		}
395
		
396
		private void saveSelected() {
397
			getPreferences().put(getKey(), Integer.toString(fSelected));
398
			setChanged();
399
			notifyObservers();
400
		}
401
		
402
		protected void updateWidget() {
403
		    final boolean hasKey= getKey() != null;
404
405
		    fNumberLabel.setEnabled(hasKey && getEnabled());
406
			fNumberText.setEnabled(hasKey && getEnabled());
407
408
			if (hasKey) {
409
			    String s= (String)getPreferences().get(getKey());
410
			    try {
411
			        fSelected= Integer.parseInt(s);
412
			    } catch (NumberFormatException e) {
413
			        final String message= Messages.format(FormatterMessages.ModifyDialogTabPage_NumberPreference_error_invalid_key, getKey()); 
414
			        CUIPlugin.getDefault().log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, message, e));
415
			        s= ""; //$NON-NLS-1$
416
			    }
417
			    fNumberText.setText(s);
418
			} else {
419
			    fNumberText.setText(""); //$NON-NLS-1$
420
			}
421
		}
422
		
423
		public Control getControl() {
424
			return fNumberText;
425
		}
426
	}
427
428
	
429
	/**
430
	 * This class provides the default way to preserve and re-establish the focus
431
	 * over multiple modify sessions. Each ModifyDialogTabPage has its own instance,
432
	 * and it should add all relevant controls upon creation, always in the same sequence.
433
	 * This established a mapping of controls to indexes, which allows to restore the focus
434
	 * in a later session. 
435
	 * The index is saved in the dialog settings, and there is only one common preference for 
436
	 * all tab pages. It is always the currently active tab page which stores its focus
437
	 * index. 
438
	 */
439
	protected final static class DefaultFocusManager extends FocusAdapter {
440
		
441
		private final static String PREF_LAST_FOCUS_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.modify_dialog_tab_page.last_focus_index"; //$NON-NLS-1$ 
442
		
443
		private final IDialogSettings fDialogSettings;
444
		
445
		private final Map fItemMap;
446
		private final List fItemList;
447
		
448
		private int fIndex;
449
		
450
		public DefaultFocusManager() {
451
			fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
452
			fItemMap= new HashMap();
453
			fItemList= new ArrayList();
454
			fIndex= 0;
455
		}
456
457
		public void focusGained(FocusEvent e) {
458
			fDialogSettings.put(PREF_LAST_FOCUS_INDEX, ((Integer)fItemMap.get(e.widget)).intValue());
459
		}
460
		
461
		public void add(Control control) {
462
			control.addFocusListener(this);
463
			fItemList.add(fIndex, control);
464
			fItemMap.put(control, new Integer(fIndex++));
465
		}
466
		
467
		public void add(Preference preference) {
468
			final Control control= preference.getControl();
469
			if (control != null) 
470
				add(control);
471
		}
472
		
473
		public boolean isUsed() {
474
			return fIndex != 0;
475
		}
476
		
477
		public void restoreFocus() {
478
			int index= 0;
479
			try {
480
				index= fDialogSettings.getInt(PREF_LAST_FOCUS_INDEX);
481
				// make sure the value is within the range
482
				if ((index >= 0) && (index <= fItemList.size() - 1)) {
483
					((Control)fItemList.get(index)).setFocus();
484
				}
485
			} catch (NumberFormatException ex) {
486
				// this is the first time
487
			}
488
		}
489
		
490
		public void resetFocus() {
491
			fDialogSettings.put(PREF_LAST_FOCUS_INDEX, -1);
492
		}
493
	}
494
495
	/**
496
	 * The default focus manager. This widget knows all widgets which can have the focus
497
	 * and listens for focusGained events, on which it stores the index of the current
498
	 * focus holder. When the dialog is restarted, <code>restoreFocus()</code> sets the 
499
	 * focus to the last control which had it.
500
	 * 
501
	 * The standard Preference object are managed by this focus manager if they are created
502
	 * using the respective factory methods. Other SWT widgets can be added in subclasses 
503
	 * when they are created.
504
	 */
505
	protected final DefaultFocusManager fDefaultFocusManager;
506
	
507
	
508
	
509
	/**
510
	 * Constant array for boolean selection 
511
	 */
512
	protected static String[] FALSE_TRUE = {
513
		DefaultCodeFormatterConstants.FALSE,
514
		DefaultCodeFormatterConstants.TRUE
515
	};	
516
	
517
    /**
518
     * Constant array for insert / not_insert. 
519
     */
520
    protected static String[] DO_NOT_INSERT_INSERT = {
521
        CCorePlugin.DO_NOT_INSERT,
522
        CCorePlugin.INSERT
523
    };
524
525
	/**
526
	 * A pixel converter for layout calculations
527
	 */
528
	protected PixelConverter fPixelConverter;
529
	
530
	
531
	/**
532
	 * The map where the current settings are stored.
533
	 */
534
	protected final Map fWorkingValues;
535
	
536
	/**
537
	 * The modify dialog where we can display status messages.
538
	 */
539
	private final ModifyDialog fModifyDialog;
540
541
542
	/*
543
	 * Create a new <code>ModifyDialogTabPage</code>
544
	 */
545
	public ModifyDialogTabPage(ModifyDialog modifyDialog, Map workingValues) {
546
		fWorkingValues= workingValues;
547
		fModifyDialog= modifyDialog;
548
		fDefaultFocusManager= new DefaultFocusManager();
549
	}
550
	
551
	/**
552
	 * Create the contents of this tab page. Subclasses cannot override this, 
553
	 * instead they must implement <code>doCreatePreferences</code>. <code>doCreatePreview</code> may also
554
	 * be overridden as necessary.
555
	 * @param parent The parent composite
556
	 * @return Created content control
557
	 */
558
	public final Composite createContents(Composite parent) {
559
		final int numColumns= 4;
560
		
561
		if (fPixelConverter == null) {
562
		    fPixelConverter= new PixelConverter(parent);
563
		}
564
		
565
//		final SashForm fSashForm = new SashForm(parent, SWT.HORIZONTAL);
566
//		fSashForm.setFont(parent.getFont());
567
		
568
//		final Composite settingsPane= new Composite(fSashForm, SWT.NONE);
569
//		settingsPane.setFont(fSashForm.getFont());
570
		
571
		final Composite settingsPane= new Composite(parent, SWT.NONE);
572
		settingsPane.setFont(parent.getFont());
573
		settingsPane.setLayoutData(new GridData(GridData.FILL_BOTH));
574
		
575
		final GridLayout layout= new GridLayout(numColumns, false);
576
		layout.verticalSpacing= (int)(1.5 * fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING));
577
		layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
578
		layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
579
		layout.marginWidth= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
580
		settingsPane.setLayout(layout);
581
		doCreatePreferences(settingsPane, numColumns);
582
583
		return settingsPane;
584
//		final Composite previewPane= new Composite(fSashForm, SWT.NONE);
585
//		previewPane.setLayout(createGridLayout(numColumns, true));
586
//		previewPane.setFont(fSashForm.getFont());
587
//		doCreatePreviewPane(previewPane, numColumns);
588
//
589
//		initializePage();
590
//	
591
//		fSashForm.setWeights(new int [] {3, 3});
592
//		return fSashForm;
593
	}
594
	
595
	/**
596
	 * This method is called after all controls have been alloated, including the preview. 
597
	 * It can be used to set the preview text and to create listeners.
598
	 *
599
	 */
600
	protected abstract void initializePage();
601
	
602
603
	/**
604
	 * Create the left side of the modify dialog. This is meant to be implemented by subclasses. 
605
	 * @param composite Composite to create in
606
	 * @param numColumns Number of columns to use
607
	 */
608
	protected abstract void doCreatePreferences(Composite composite, int numColumns);
609
	
610
611
	/**
612
	 * Create the right side of the modify dialog. By default, the preview is displayed there.
613
	 * Subclasses can override this method in order to customize the right-hand side of the 
614
	 * dialog.
615
	 * @param composite Composite to create in
616
	 * @param numColumns Number of columns to use
617
	 * @return Created composite
618
	 */
619
	protected Composite doCreatePreviewPane(Composite composite, int numColumns) {
620
		createLabel(numColumns, composite, FormatterMessages.ModifyDialogTabPage_preview_label_text);  
621
		
622
		final CPreview preview= doCreateCPreview(composite);
623
		fDefaultFocusManager.add(preview.getControl());
624
		
625
		final GridData gd= createGridData(numColumns, GridData.FILL_BOTH, 0);
626
		gd.widthHint= 0;
627
		gd.heightHint=0;
628
		preview.getControl().setLayoutData(gd);
629
		
630
		return composite;
631
	}
632
633
	/**
634
	 * To be implemented by subclasses. This method should return an instance of CPreview.
635
	 * Currently, the choice is between CompilationUnitPreview which contains a valid compilation
636
	 * unit, or a SnippetPreview which formats several independent code snippets and displays them 
637
	 * in the same window.
638
	 * @param parent Parent composite
639
	 * @return Created preview
640
	 */
641
	protected abstract CPreview doCreateCPreview(Composite parent);
642
	
643
	/**
644
	 * This is called when the page becomes visible. 
645
	 * Common tasks to do include:
646
	 * <ul><li>Updating the preview.</li>
647
	 * <li>Setting the focus</li>
648
	 * </ul>
649
	 */
650
	final public void makeVisible() {
651
		fDefaultFocusManager.resetFocus();
652
		doUpdatePreview();
653
	}
654
	
655
	/**
656
	 * Update the preview. To be implemented by subclasses.
657
	 */
658
	protected abstract void doUpdatePreview();
659
	
660
	protected void notifyValuesModified() {
661
		fModifyDialog.valuesModified();
662
	}
663
    /**
664
     * Each tab page should remember where its last focus was, and reset it
665
     * correctly within this method. This method is only called after
666
     * initialization on the first tab page to be displayed in order to restore
667
     * the focus of the last session.
668
     */
669
    public void setInitialFocus() {
670
		if (fDefaultFocusManager.isUsed()) {
671
			fDefaultFocusManager.restoreFocus();
672
		}
673
	}
674
	
675
676
    /**
677
     * Set the status field on the dialog. This can be used by tab pages to report 
678
     * inconsistent input. The OK button is disabled if the kind is IStatus.ERROR. 
679
     * @param status Status describing the current page error state
680
     */
681
	protected void updateStatus(IStatus status) {
682
	    fModifyDialog.updateStatus(status);
683
	}
684
	
685
	/*
686
	 * Factory methods to make GUI construction easier
687
	 */
688
	
689
	/*
690
	 * Create a GridLayout with the default margin and spacing settings, as
691
	 * well as the specified number of columns.
692
	 */
693
	protected GridLayout createGridLayout(int numColumns, boolean margins) {
694
		final GridLayout layout= new GridLayout(numColumns, false);
695
		layout.verticalSpacing= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
696
		layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
697
		if (margins) {
698
			layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
699
			layout.marginWidth= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
700
		} else {
701
			layout.marginHeight= 0;
702
			layout.marginWidth= 0;
703
		}
704
		return layout;
705
	}
706
707
	/*
708
	 * Convenience method to create a GridData.
709
	 */
710
	protected static GridData createGridData(int numColumns, int style, int widthHint) {
711
		final GridData gd= new GridData(style);
712
		gd.horizontalSpan= numColumns;
713
		gd.widthHint= widthHint;
714
		return gd;		
715
	}
716
717
718
	/* 
719
	 * Convenience method to create a label.  
720
	 */
721
	protected static Label createLabel(int numColumns, Composite parent, String text) {
722
		return createLabel(numColumns, parent, text, GridData.FILL_HORIZONTAL);
723
	}
724
	
725
	/*
726
	 * Convenience method to create a label
727
	 */
728
	protected static Label createLabel(int numColumns, Composite parent, String text, int gridDataStyle) {
729
		final Label label= new Label(parent, SWT.WRAP);
730
		label.setFont(parent.getFont());
731
		label.setText(text);
732
		label.setLayoutData(createGridData(numColumns, gridDataStyle, SWT.DEFAULT));
733
		return label;
734
	}
735
736
	/*
737
	 * Convenience method to create a group
738
	 */
739
	protected Group createGroup(int numColumns, Composite parent, String text ) {
740
		final Group group= new Group(parent, SWT.NONE);
741
		group.setFont(parent.getFont());
742
		group.setLayoutData(createGridData(numColumns, GridData.FILL_HORIZONTAL, SWT.DEFAULT));
743
		
744
		final GridLayout layout= new GridLayout(numColumns, false);
745
		layout.verticalSpacing=  fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
746
		layout.horizontalSpacing= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
747
		layout.marginHeight=  fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
748
749
		//layout.marginHeight= fPixelConverter.convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
750
		//layout.marginWidth= fPixelConverter.convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
751
		
752
		group.setLayout(layout);//createGridLayout(numColumns, true));
753
		group.setText(text);
754
		return group;
755
	}
756
	
757
	/*
758
	 * Convenience method to create a NumberPreference. The widget is registered as 
759
	 * a potential focus holder, and the default updater is added.
760
	 */
761
	protected NumberPreference createNumberPref(Composite composite, int numColumns, String name, String key,
762
												int minValue, int maxValue) {
763
		final NumberPreference pref= new NumberPreference(composite, numColumns, fWorkingValues, 
764
			key, minValue, maxValue, name);
765
		fDefaultFocusManager.add(pref);
766
		pref.addObserver(fUpdater);
767
		return pref;
768
	}
769
	
770
	/*
771
	 * Convenience method to create a ComboPreference. The widget is registered as 
772
	 * a potential focus holder, and the default updater is added.
773
	 */
774
	protected ComboPreference createComboPref(Composite composite, int numColumns, String name, 
775
											  String key, String [] values, String [] items) {
776
		final ComboPreference pref= new ComboPreference(composite, numColumns, 
777
			fWorkingValues, key, values, name, items);
778
		fDefaultFocusManager.add(pref);
779
		pref.addObserver(fUpdater);
780
		return pref;
781
	}
782
783
	/*
784
	 * Convenience method to create a CheckboxPreference. The widget is registered as 
785
	 * a potential focus holder, and the default updater is added.
786
	 */
787
	protected CheckboxPreference createCheckboxPref(Composite composite, int numColumns, String name, String key,
788
													String [] values) {
789
		final CheckboxPreference pref= new CheckboxPreference(composite, numColumns, 
790
			fWorkingValues, key, values, name);
791
		fDefaultFocusManager.add(pref);
792
		pref.addObserver(fUpdater);
793
		return pref;
794
	}
795
	
796
	/*
797
	 * Create a nice javadoc comment for some string.
798
	 */
799
	protected static String createPreviewHeader(String title) {
800
		return "/**\n* " + title + "\n*/\n"; //$NON-NLS-1$ //$NON-NLS-2$
801
	}
802
}
(-)src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java (+475 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.preferences;
14
15
import java.util.ArrayList;
16
import java.util.HashMap;
17
import java.util.HashSet;
18
import java.util.Iterator;
19
import java.util.Map;
20
import java.util.Set;
21
22
import org.eclipse.core.runtime.IStatus;
23
24
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.events.ModifyEvent;
26
import org.eclipse.swt.events.ModifyListener;
27
import org.eclipse.swt.events.SelectionEvent;
28
import org.eclipse.swt.events.SelectionListener;
29
import org.eclipse.swt.layout.GridData;
30
import org.eclipse.swt.layout.GridLayout;
31
import org.eclipse.swt.widgets.Button;
32
import org.eclipse.swt.widgets.Composite;
33
import org.eclipse.swt.widgets.Control;
34
import org.eclipse.swt.widgets.Group;
35
import org.eclipse.swt.widgets.Label;
36
import org.eclipse.swt.widgets.Text;
37
38
import org.eclipse.jface.preference.IPreferenceStore;
39
import org.eclipse.jface.preference.PreferencePage;
40
import org.eclipse.jface.resource.JFaceResources;
41
42
import org.eclipse.jface.text.Assert;
43
44
import org.eclipse.ui.forms.events.ExpansionAdapter;
45
import org.eclipse.ui.forms.events.ExpansionEvent;
46
import org.eclipse.ui.forms.widgets.ExpandableComposite;
47
48
import org.eclipse.cdt.internal.ui.util.Messages;
49
50
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
51
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
52
import org.eclipse.cdt.internal.ui.util.PixelConverter;
53
54
/**
55
 * Abstract implementation of a generic {@link IPreferenceConfigurationBlock}.
56
 * 
57
 * @since 4.0
58
 */
59
abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlock {
60
61
	/**
62
	 * Use as follows:
63
	 * 
64
	 * <pre>
65
	 * SectionManager manager= new SectionManager();
66
	 * Composite composite= manager.createSectionComposite(parent);
67
	 * 
68
	 * Composite xSection= manager.createSection("section X"));
69
	 * xSection.setLayout(new FillLayout());
70
	 * new Button(xSection, SWT.PUSH); // add controls to section..
71
	 * 
72
	 * [...]
73
	 * 
74
	 * return composite; // return main composite
75
	 * </pre>
76
	 */
77
	protected final class SectionManager {
78
		/** The preference setting for keeping no section open. */
79
		private static final String __NONE= "__none"; //$NON-NLS-1$
80
		private Set fSections= new HashSet();
81
		private boolean fIsBeingManaged= false;
82
		private ExpansionAdapter fListener= new ExpansionAdapter() {
83
			public void expansionStateChanged(ExpansionEvent e) {
84
				ExpandableComposite source= (ExpandableComposite) e.getSource();
85
				updateSectionStyle(source);
86
				if (fIsBeingManaged)
87
					return;
88
				if (e.getState()) {
89
					try {
90
						fIsBeingManaged= true;
91
						for (Iterator iter= fSections.iterator(); iter.hasNext();) {
92
							ExpandableComposite composite= (ExpandableComposite) iter.next();
93
							if (composite != source)
94
								composite.setExpanded(false);
95
						}
96
					} finally {
97
						fIsBeingManaged= false;
98
					}
99
					if (fLastOpenKey != null && fDialogSettingsStore != null)
100
						fDialogSettingsStore.setValue(fLastOpenKey, source.getText());
101
				} else {
102
					if (!fIsBeingManaged && fLastOpenKey != null && fDialogSettingsStore != null)
103
						fDialogSettingsStore.setValue(fLastOpenKey, __NONE);
104
				}
105
				ExpandableComposite exComp= getParentExpandableComposite(source);
106
				if (exComp != null)
107
					exComp.layout(true, true);
108
				ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(source);
109
				if (parentScrolledComposite != null) {
110
					parentScrolledComposite.reflow(true);
111
				}
112
			}
113
		};
114
		private Composite fBody;
115
		private final String fLastOpenKey;
116
		private final IPreferenceStore fDialogSettingsStore;
117
		private ExpandableComposite fFirstChild= null;
118
		/**
119
		 * Creates a new section manager.
120
		 */
121
		public SectionManager() {
122
			this(null, null);
123
		}
124
		/**
125
		 * Creates a new section manager.
126
		 */
127
		public SectionManager(IPreferenceStore dialogSettingsStore, String lastOpenKey) {
128
			fDialogSettingsStore= dialogSettingsStore;
129
			fLastOpenKey= lastOpenKey;
130
		}
131
		private void manage(ExpandableComposite section) {
132
			if (section == null)
133
				throw new NullPointerException();
134
			if (fSections.add(section))
135
				section.addExpansionListener(fListener);
136
			makeScrollableCompositeAware(section);
137
		}
138
		
139
		/**
140
		 * Creates a new composite that can contain a set of expandable
141
		 * sections. A <code>ScrolledPageComposite</code> is created and a new
142
		 * composite within that, to ensure that expanding the sections will
143
		 * always have enough space, unless there already is a
144
		 * <code>ScrolledComposite</code> along the parent chain of
145
		 * <code>parent</code>, in which case a normal <code>Composite</code>
146
		 * is created.
147
		 * <p>
148
		 * The receiver keeps a reference to the inner body composite, so that
149
		 * new sections can be added via <code>createSection</code>.
150
		 * </p>
151
		 * 
152
		 * @param parent the parent composite
153
		 * @return the newly created composite
154
		 */
155
		public Composite createSectionComposite(Composite parent) {
156
			Assert.isTrue(fBody == null);
157
			boolean isNested= isNestedInScrolledComposite(parent);
158
			Composite composite;
159
			if (isNested) {
160
				composite= new Composite(parent, SWT.NONE);
161
				fBody= composite;
162
			} else {
163
				composite= new ScrolledPageContent(parent);
164
				fBody= ((ScrolledPageContent) composite).getBody();
165
			}
166
			
167
			fBody.setLayout(new GridLayout());
168
			
169
			return composite;
170
		}
171
		
172
		/**
173
		 * Creates an expandable section within the parent created previously by
174
		 * calling <code>createSectionComposite</code>. Controls can be added 
175
		 * directly to the returned composite, which has no layout initially.
176
		 * 
177
		 * @param label the display name of the section
178
		 * @return a composite within the expandable section
179
		 */
180
		public Composite createSection(String label) {
181
			Assert.isNotNull(fBody);
182
			final ExpandableComposite excomposite= new ExpandableComposite(fBody, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
183
			if (fFirstChild == null)
184
				fFirstChild= excomposite;
185
			excomposite.setText(label);
186
			String last= null;
187
			if (fLastOpenKey != null && fDialogSettingsStore != null)
188
				last= fDialogSettingsStore.getString(fLastOpenKey);
189
			
190
			if (fFirstChild == excomposite && !__NONE.equals(last) || label.equals(last)) {
191
				excomposite.setExpanded(true);
192
				if (fFirstChild != excomposite)
193
					fFirstChild.setExpanded(false);
194
			} else {
195
				excomposite.setExpanded(false);
196
			}
197
			excomposite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));
198
			
199
			updateSectionStyle(excomposite);
200
			manage(excomposite);
201
			
202
			Composite contents= new Composite(excomposite, SWT.NONE);
203
			excomposite.setClient(contents);
204
			
205
			return contents;
206
		}
207
	}
208
209
	protected static final int INDENT= 20;
210
	private OverlayPreferenceStore fStore;
211
	
212
	private Map fCheckBoxes= new HashMap();
213
	private SelectionListener fCheckBoxListener= new SelectionListener() {
214
		public void widgetDefaultSelected(SelectionEvent e) {
215
		}
216
		public void widgetSelected(SelectionEvent e) {
217
			Button button= (Button) e.widget;
218
			fStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
219
		}
220
	};
221
	
222
	
223
	private Map fTextFields= new HashMap();
224
	private ModifyListener fTextFieldListener= new ModifyListener() {
225
		public void modifyText(ModifyEvent e) {
226
			Text text= (Text) e.widget;
227
			fStore.setValue((String) fTextFields.get(text), text.getText());
228
		}
229
	};
230
231
	private ArrayList fNumberFields= new ArrayList();
232
	private ModifyListener fNumberFieldListener= new ModifyListener() {
233
		public void modifyText(ModifyEvent e) {
234
			numberFieldChanged((Text) e.widget);
235
		}
236
	};
237
	
238
	/**
239
	 * List of master/slave listeners when there's a dependency.
240
	 * 
241
	 * @see #createDependency(Button, Control)
242
	 * @since 3.0
243
	 */
244
	private ArrayList fMasterSlaveListeners= new ArrayList();
245
	
246
	private StatusInfo fStatus;
247
	private final PreferencePage fMainPage;
248
249
	public AbstractConfigurationBlock(OverlayPreferenceStore store) {
250
		Assert.isNotNull(store);
251
		fStore= store;
252
		fMainPage= null;
253
	}
254
	
255
	public AbstractConfigurationBlock(OverlayPreferenceStore store, PreferencePage mainPreferencePage) {
256
		Assert.isNotNull(store);
257
		Assert.isNotNull(mainPreferencePage);
258
		fStore= store;
259
		fMainPage= mainPreferencePage;
260
	}
261
262
	protected final ScrolledPageContent getParentScrolledComposite(Control control) {
263
		Control parent= control.getParent();
264
		while (!(parent instanceof ScrolledPageContent) && parent != null) {
265
			parent= parent.getParent();
266
		}
267
		if (parent instanceof ScrolledPageContent) {
268
			return (ScrolledPageContent) parent;
269
		}
270
		return null;
271
	}
272
273
	private final ExpandableComposite getParentExpandableComposite(Control control) {
274
		Control parent= control.getParent();
275
		while (!(parent instanceof ExpandableComposite) && parent != null) {
276
			parent= parent.getParent();
277
		}
278
		if (parent instanceof ExpandableComposite) {
279
			return (ExpandableComposite) parent;
280
		}
281
		return null;
282
	}
283
284
	protected void updateSectionStyle(ExpandableComposite excomposite) {
285
		excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
286
	}
287
	
288
	private void makeScrollableCompositeAware(Control control) {
289
		ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(control);
290
		if (parentScrolledComposite != null) {
291
			parentScrolledComposite.adaptChild(control);
292
		}
293
	}
294
	
295
	private boolean isNestedInScrolledComposite(Composite parent) {
296
		return getParentScrolledComposite(parent) != null;
297
	}
298
	
299
	protected Button addCheckBox(Composite parent, String label, String key, int indentation) {		
300
		Button checkBox= new Button(parent, SWT.CHECK);
301
		checkBox.setText(label);
302
		
303
		GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
304
		gd.horizontalIndent= indentation;
305
		gd.horizontalSpan= 2;
306
		checkBox.setLayoutData(gd);
307
		checkBox.addSelectionListener(fCheckBoxListener);
308
		makeScrollableCompositeAware(checkBox);
309
310
		fCheckBoxes.put(checkBox, key);
311
		
312
		return checkBox;
313
	}
314
315
	/**
316
	 * Returns an array of size 2:
317
	 *  - first element is of type <code>Label</code>
318
	 *  - second element is of type <code>Text</code>
319
	 * Use <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
320
	 * 
321
	 * @param composite 	the parent composite
322
	 * @param label			the text field's label
323
	 * @param key			the preference key
324
	 * @param textLimit		the text limit
325
	 * @param indentation	the field's indentation
326
	 * @param isNumber		<code>true</code> iff this text field is used to e4dit a number
327
	 * @return the controls added
328
	 */
329
	protected Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
330
		
331
		PixelConverter pixelConverter= new PixelConverter(composite);
332
		
333
		Label labelControl= new Label(composite, SWT.NONE);
334
		labelControl.setText(label);
335
		GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
336
		gd.horizontalIndent= indentation;
337
		labelControl.setLayoutData(gd);
338
		
339
		Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE);		
340
		gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
341
		gd.widthHint= pixelConverter.convertWidthInCharsToPixels(textLimit + 1);
342
		textControl.setLayoutData(gd);
343
		textControl.setTextLimit(textLimit);
344
		fTextFields.put(textControl, key);
345
		if (isNumber) {
346
			fNumberFields.add(textControl);
347
			textControl.addModifyListener(fNumberFieldListener);
348
		} else {
349
			textControl.addModifyListener(fTextFieldListener);
350
		}
351
			
352
		return new Control[]{labelControl, textControl};
353
	}
354
355
	protected void createDependency(final Button master, final Control slave) {
356
		createDependency(master, new Control[] {slave});
357
	}
358
	
359
	protected void createDependency(final Button master, final Control[] slaves) {
360
		Assert.isTrue(slaves.length > 0);
361
		indent(slaves[0]);
362
		SelectionListener listener= new SelectionListener() {
363
			public void widgetSelected(SelectionEvent e) {
364
				boolean state= master.getSelection();
365
				for (int i= 0; i < slaves.length; i++) {
366
					slaves[i].setEnabled(state);
367
				}
368
			}
369
370
			public void widgetDefaultSelected(SelectionEvent e) {}
371
		};
372
		master.addSelectionListener(listener);
373
		fMasterSlaveListeners.add(listener);
374
	}
375
376
	protected static void indent(Control control) {
377
		((GridData) control.getLayoutData()).horizontalIndent+= INDENT;
378
	}
379
380
	public void initialize() {
381
		initializeFields();
382
	}
383
384
	private void initializeFields() {
385
		
386
		Iterator iter= fCheckBoxes.keySet().iterator();
387
		while (iter.hasNext()) {
388
			Button b= (Button) iter.next();
389
			String key= (String) fCheckBoxes.get(b);
390
			b.setSelection(fStore.getBoolean(key));
391
		}
392
		
393
		iter= fTextFields.keySet().iterator();
394
		while (iter.hasNext()) {
395
			Text t= (Text) iter.next();
396
			String key= (String) fTextFields.get(t);
397
			t.setText(fStore.getString(key));
398
		}
399
		
400
        // Update slaves
401
        iter= fMasterSlaveListeners.iterator();
402
        while (iter.hasNext()) {
403
            SelectionListener listener= (SelectionListener)iter.next();
404
            listener.widgetSelected(null);
405
        }
406
     
407
        updateStatus(new StatusInfo());
408
	}
409
410
	public void performOk() {
411
	}
412
413
	public void performDefaults() {
414
		initializeFields();
415
	}
416
417
	IStatus getStatus() {
418
		if (fStatus == null)
419
			fStatus= new StatusInfo();
420
		return fStatus;
421
	}
422
423
	/*
424
	 * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose()
425
	 */
426
	public void dispose() {
427
	}
428
	
429
	private void numberFieldChanged(Text textControl) {
430
		String number= textControl.getText();
431
		IStatus status= validatePositiveNumber(number);
432
		if (!status.matches(IStatus.ERROR))
433
			fStore.setValue((String) fTextFields.get(textControl), number);
434
		updateStatus(status);
435
	}
436
	
437
	private IStatus validatePositiveNumber(String number) {
438
		StatusInfo status= new StatusInfo();
439
		if (number.length() == 0) {
440
			status.setError(PreferencesMessages.CEditorPreferencePage_empty_input); 
441
		} else {
442
			try {
443
				int value= Integer.parseInt(number);
444
				if (value < 0)
445
					status.setError(Messages.format(PreferencesMessages.CEditorPreferencePage_invalid_input, number)); 
446
			} catch (NumberFormatException e) {
447
				status.setError(Messages.format(PreferencesMessages.CEditorPreferencePage_invalid_input, number)); 
448
			}
449
		}
450
		return status;
451
	}
452
453
	protected void updateStatus(IStatus status) {
454
		if (fMainPage == null)
455
			return;
456
		fMainPage.setValid(status.isOK());
457
		StatusUtil.applyToStatusLine(fMainPage, status);
458
	}
459
	
460
	protected final OverlayPreferenceStore getPreferenceStore() {
461
		return fStore;
462
	}
463
464
	protected Composite createSubsection(Composite parent, SectionManager manager, String label) {
465
		if (manager != null) {
466
			return manager.createSection(label);
467
		} else {
468
			Group group= new Group(parent, SWT.SHADOW_NONE);
469
			group.setText(label);
470
			GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false);
471
			group.setLayoutData(data);
472
			return group;
473
		}
474
	}
475
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/RenameProfileDialog.java (+142 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Aaron Luchko, aluchko@redhat.com - 105926 [Formatter] Exporting Unnamed profile fails silently
11
 *     Sergey Prigogin, Google
12
 *******************************************************************************/
13
package org.eclipse.cdt.internal.ui.preferences.formatter;
14
15
import org.eclipse.core.runtime.IStatus;
16
17
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.events.ModifyEvent;
19
import org.eclipse.swt.events.ModifyListener;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridLayout;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Control;
24
import org.eclipse.swt.widgets.Label;
25
import org.eclipse.swt.widgets.Shell;
26
import org.eclipse.swt.widgets.Text;
27
28
import org.eclipse.jface.dialogs.IDialogConstants;
29
import org.eclipse.jface.dialogs.StatusDialog;
30
31
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
32
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
33
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.SharedProfile;
34
35
/**
36
 * The dialog to rename a new profile. 
37
 */
38
public class RenameProfileDialog extends StatusDialog {
39
	
40
	private Label fNameLabel;
41
	private Text fNameText;
42
	
43
	private final StatusInfo fOk;
44
	private final StatusInfo fEmpty;
45
	private final StatusInfo fDuplicate;
46
	private final StatusInfo fNoMessage;
47
48
	private final Profile fProfile;
49
	private final ProfileManager fManager;
50
	private Profile fRenamedProfile;
51
	
52
	public RenameProfileDialog(Shell parentShell, Profile profile, ProfileManager manager) {
53
		super(parentShell);
54
		fManager= manager;
55
		setTitle(FormatterMessages.RenameProfileDialog_dialog_title); 
56
		fProfile= profile;
57
		fOk= new StatusInfo();
58
		fDuplicate= new StatusInfo(IStatus.ERROR, FormatterMessages.RenameProfileDialog_status_message_profile_with_this_name_already_exists); 
59
		fEmpty= new StatusInfo(IStatus.ERROR, FormatterMessages.RenameProfileDialog_status_message_profile_name_empty);
60
		fNoMessage= new StatusInfo(IStatus.ERROR, new String());
61
	}
62
	
63
	public Control createDialogArea(Composite parent) {
64
				
65
		final int numColumns= 2;
66
		
67
		GridLayout layout= new GridLayout();
68
		layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
69
		layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
70
		layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
71
		layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
72
		layout.numColumns= numColumns;
73
		
74
		final Composite composite= new Composite(parent, SWT.NULL);
75
		composite.setLayout(layout);
76
		
77
		// Create "Please enter a new name:" label
78
		GridData gd = new GridData();
79
		gd.horizontalSpan = numColumns;
80
		gd.widthHint= convertWidthInCharsToPixels(60);
81
		fNameLabel = new Label(composite, SWT.NONE);
82
		fNameLabel.setText(FormatterMessages.RenameProfileDialog_dialog_label_enter_a_new_name); 
83
		fNameLabel.setLayoutData(gd);
84
		
85
		// Create text field to enter name
86
		gd = new GridData( GridData.FILL_HORIZONTAL);
87
		gd.horizontalSpan= numColumns;
88
		fNameText= new Text(composite, SWT.SINGLE | SWT.BORDER);
89
		if (fProfile instanceof SharedProfile) {
90
			fNameText.setText(fProfile.getName());
91
		}
92
		fNameText.setSelection(0, fProfile.getName().length());
93
		fNameText.setLayoutData(gd);
94
		fNameText.addModifyListener( new ModifyListener() {
95
			public void modifyText(ModifyEvent e) {
96
				doValidation();
97
			}
98
		});
99
		fNameText.setText(fProfile.getName());
100
		fNameText.selectAll();
101
		
102
		applyDialogFont(composite);
103
		
104
		return composite;
105
	}
106
107
108
	/**
109
	 * Validate the current settings.
110
	 */
111
	protected void doValidation() {
112
		final String name= fNameText.getText().trim();
113
		
114
		if (name.length() == 0) {
115
			updateStatus(fEmpty);
116
			return;
117
		}
118
		
119
		if (name.equals(fProfile.getName())) {
120
			updateStatus(fNoMessage);
121
			return;
122
		}
123
		
124
		if (fManager.containsName(name)) {
125
			updateStatus(fDuplicate);
126
			return;
127
		}
128
		
129
		updateStatus(fOk);
130
	}
131
	
132
	public Profile getRenamedProfile() {
133
		return fRenamedProfile;
134
	}
135
	
136
	protected void okPressed() {
137
		if (!getStatus().isOK()) 
138
			return;
139
		fRenamedProfile= fProfile.rename(fNameText.getText(), fManager);
140
		super.okPressed();
141
	}
142
}
(-)src/org/eclipse/cdt/internal/ui/editor/IndentUtil.java (+477 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.editor;
13
14
import org.eclipse.jface.text.BadLocationException;
15
import org.eclipse.jface.text.IDocument;
16
import org.eclipse.jface.text.IRegion;
17
import org.eclipse.jface.text.ITypedRegion;
18
import org.eclipse.jface.text.TextUtilities;
19
import org.eclipse.jface.text.source.ILineRange;
20
21
import org.eclipse.cdt.core.model.ICProject;
22
import org.eclipse.cdt.ui.text.ICPartitions;
23
24
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
25
26
import org.eclipse.cdt.internal.ui.text.CHeuristicScanner;
27
import org.eclipse.cdt.internal.ui.text.CIndenter;
28
29
30
/**
31
 * Utility that indents a number of lines in a document.
32
 */
33
public final class IndentUtil {
34
	
35
	private static final String SLASHES= "//"; //$NON-NLS-1$
36
37
	/**
38
	 * The result of an indentation operation. The result may be passed to
39
	 * subsequent calls to
40
	 * {@link IndentUtil#indentLines(IDocument, ILineRange, ICProject, IndentResult) indentLines}
41
	 * to obtain consistent results with respect to the indentation of
42
	 * line-comments.
43
	 */
44
	public static final class IndentResult {
45
		private IndentResult(boolean[] commentLines) {
46
			commentLinesAtColumnZero= commentLines;
47
		}
48
		private boolean[] commentLinesAtColumnZero;
49
		private boolean hasChanged;
50
		private int leftmostLine= -1;
51
		/**
52
		 * Returns <code>true</code> if the indentation operation changed the
53
		 * document, <code>false</code> if not.
54
		 * @return <code>true</code> if the document was changed
55
		 */
56
		public boolean hasChanged() {
57
			return hasChanged;
58
		}
59
	}
60
	
61
	private IndentUtil() {
62
		// do not instantiate
63
	}
64
65
	/**
66
	 * Indents the line range specified by <code>lines</code> in
67
	 * <code>document</code>. The passed C project may be
68
	 * <code>null</code>, it is used solely to obtain formatter preferences.
69
	 * 
70
	 * @param document the document to be changed
71
	 * @param lines the line range to be indented
72
	 * @param project the C project to get the formatter preferences from, or
73
	 *        <code>null</code> if global preferences should be used
74
	 * @param result the result from a previous call to <code>indentLines</code>,
75
	 *        in order to maintain comment line properties, or <code>null</code>.
76
	 *        Note that the passed result may be changed by the call.
77
	 * @return an indent result that may be queried for changes and can be
78
	 *         reused in subsequent indentation operations
79
	 * @throws BadLocationException if <code>lines</code> is not a valid line
80
	 *         range on <code>document</code>
81
	 */
82
	public static IndentResult indentLines(IDocument document, ILineRange lines, ICProject project, IndentResult result) throws BadLocationException {
83
		int numberOfLines= lines.getNumberOfLines();
84
		
85
		if (numberOfLines < 1)
86
			return new IndentResult(null);
87
		
88
		result= reuseOrCreateToken(result, numberOfLines);
89
		
90
		CHeuristicScanner scanner= new CHeuristicScanner(document);
91
		CIndenter indenter= new CIndenter(document, scanner, project);
92
		boolean changed= false;
93
		int tabSize= CodeFormatterUtil.getTabWidth(project);
94
		for (int line= lines.getStartLine(), last= line + numberOfLines, i= 0; line < last; line++) {
95
			changed |= indentLine(document, line, indenter, scanner, result.commentLinesAtColumnZero, i++, tabSize);
96
		}
97
		result.hasChanged= changed;
98
		
99
		return result;
100
	}
101
	
102
	/**
103
	 * Shifts the line range specified by <code>lines</code> in
104
	 * <code>document</code>. The amount that the lines get shifted
105
	 * are determined by the first line in the range, all subsequent
106
	 * lines are adjusted accordingly. The passed C project may be
107
	 * <code>null</code>, it is used solely to obtain formatter
108
	 * preferences.
109
	 * 
110
	 * @param document the document to be changed
111
	 * @param lines the line range to be shifted
112
	 * @param project the C project to get the formatter preferences
113
	 *        from, or <code>null</code> if global preferences should
114
	 *        be used
115
	 * @param result the result from a previous call to
116
	 *        <code>shiftLines</code>, in order to maintain comment
117
	 *        line properties, or <code>null</code>. Note that the
118
	 *        passed result may be changed by the call.
119
	 * @return an indent result that may be queried for changes and can
120
	 *         be reused in subsequent indentation operations
121
	 * @throws BadLocationException if <code>lines</code> is not a
122
	 *         valid line range on <code>document</code>
123
	 */
124
	public static IndentResult shiftLines(IDocument document, ILineRange lines, ICProject project, IndentResult result) throws BadLocationException {
125
		int numberOfLines= lines.getNumberOfLines();
126
		
127
		if (numberOfLines < 1)
128
			return new IndentResult(null);
129
		
130
		result= reuseOrCreateToken(result, numberOfLines);
131
		result.hasChanged= false;
132
		
133
		CHeuristicScanner scanner= new CHeuristicScanner(document);
134
		CIndenter indenter= new CIndenter(document, scanner, project);
135
		
136
		String current= getCurrentIndent(document, lines.getStartLine());
137
		StringBuffer correct= indenter.computeIndentation(document.getLineOffset(lines.getStartLine()));
138
		if (correct == null)
139
			return result; // bail out
140
		
141
		int tabSize= CodeFormatterUtil.getTabWidth(project);
142
		StringBuffer addition= new StringBuffer();
143
		int difference= subtractIndent(correct, current, addition, tabSize);
144
		
145
		if (difference == 0)
146
			return result;
147
			
148
		if (result.leftmostLine == -1)
149
			result.leftmostLine= getLeftMostLine(document, lines, tabSize);
150
		
151
		int maxReduction= computeVisualLength(getCurrentIndent(document, result.leftmostLine + lines.getStartLine()), tabSize);
152
		
153
		if (difference > 0) {
154
			for (int line= lines.getStartLine(), last= line + numberOfLines, i= 0; line < last; line++)
155
				addIndent(document, line, addition, result.commentLinesAtColumnZero, i++);
156
		} else {
157
			int reduction= Math.min(-difference, maxReduction);
158
			for (int line= lines.getStartLine(), last= line + numberOfLines, i= 0; line < last; line++)
159
				cutIndent(document, line, reduction, tabSize, result.commentLinesAtColumnZero, i++);
160
		}
161
				
162
		result.hasChanged= true;
163
		
164
		return result;
165
		
166
	}
167
168
	/**
169
	 * Indents line <code>line</code> in <code>document</code> with <code>indent</code>.
170
	 * Leaves leading comment signs alone.
171
	 *
172
	 * @param document the document
173
	 * @param line the line
174
	 * @param indent the indentation to insert
175
	 * @param commentlines
176
	 * @throws BadLocationException on concurrent document modification
177
	 */
178
	private static void addIndent(IDocument document, int line, CharSequence indent, boolean[] commentlines, int relative) throws BadLocationException {
179
		IRegion region= document.getLineInformation(line);
180
		int insert= region.getOffset();
181
		int endOffset= region.getOffset() + region.getLength();
182
183
		// go behind line comments
184
		if (!commentlines[relative]) {
185
			while (insert < endOffset - 2 && document.get(insert, 2).equals(SLASHES))
186
				insert += 2;
187
		}
188
189
		// insert indent
190
		document.replace(insert, 0, indent.toString());
191
	}
192
193
	/**
194
	 * Cuts the visual equivalent of <code>toDelete</code> characters out of the
195
	 * indentation of line <code>line</code> in <code>document</code>. Leaves
196
	 * leading comment signs alone.
197
	 *
198
	 * @param document the document
199
	 * @param line the line
200
	 * @param toDelete the number of space equivalents to delete.
201
	 * @throws BadLocationException on concurrent document modification
202
	 */
203
	private static void cutIndent(IDocument document, int line, int toDelete, int tabSize, boolean[] commentLines, int relative) throws BadLocationException {
204
		IRegion region= document.getLineInformation(line);
205
		int from= region.getOffset();
206
		int endOffset= region.getOffset() + region.getLength();
207
208
		// go behind line comments
209
		while (from < endOffset - 2 && document.get(from, 2).equals(SLASHES))
210
			from += 2;
211
212
		int to= from;
213
		while (toDelete > 0 && to < endOffset) {
214
			char ch= document.getChar(to);
215
			if (!Character.isWhitespace(ch))
216
				break;
217
			toDelete -= computeVisualLength(ch, tabSize);
218
			if (toDelete >= 0)
219
				to++;
220
			else
221
				break;
222
		}
223
		
224
		if (endOffset > to + 1 && document.get(to, 2).equals(SLASHES))
225
			commentLines[relative]= true;
226
227
		document.replace(from, to - from, null);
228
	}
229
230
	/**
231
	 * Computes the difference of two indentations and returns the difference in
232
	 * length of current and correct. If the return value is positive, <code>addition</code>
233
	 * is initialized with a substring of that length of <code>correct</code>.
234
	 *
235
	 * @param correct the correct indentation
236
	 * @param current the current indentation (migth contain non-whitespace)
237
	 * @param difference a string buffer - if the return value is positive, it will be cleared and set to the substring of <code>current</code> of that length
238
	 * @return the difference in lenght of <code>correct</code> and <code>current</code>
239
	 */
240
	private static int subtractIndent(CharSequence correct, CharSequence current, StringBuffer difference, int tabSize) {
241
		int c1= computeVisualLength(correct, tabSize);
242
		int c2= computeVisualLength(current, tabSize);
243
		int diff= c1 - c2;
244
		if (diff <= 0)
245
			return diff;
246
247
		difference.setLength(0);
248
		int len= 0, i= 0;
249
		while (len < diff) {
250
			char c= correct.charAt(i++);
251
			difference.append(c);
252
			len += computeVisualLength(c, tabSize);
253
		}
254
255
256
		return diff;
257
	}
258
259
	private static int computeVisualLength(char ch, int tabSize) {
260
		if (ch == '\t')
261
			return tabSize;
262
		else
263
			return 1;
264
	}
265
266
	/**
267
	 * Returns the visual length of a given <code>CharSequence</code> taking into
268
	 * account the visual tabulator length.
269
	 *
270
	 * @param seq the string to measure
271
	 * @return the visual length of <code>seq</code>
272
	 */
273
	private static int computeVisualLength(CharSequence seq, int tablen) {
274
		int size= 0;
275
276
		for (int i= 0; i < seq.length(); i++) {
277
			char ch= seq.charAt(i);
278
			if (ch == '\t') {
279
				if (tablen != 0)
280
					size += tablen - size % tablen;
281
				// else: size stays the same
282
			} else {
283
				size++;
284
			}
285
		}
286
		return size;
287
	}
288
289
	/**
290
	 * Returns the indentation of the line <code>line</code> in <code>document</code>.
291
	 * The returned string may contain pairs of leading slashes that are considered
292
	 * part of the indentation. The space before the asterix in a javadoc-like
293
	 * comment is not considered part of the indentation.
294
	 *
295
	 * @param document the document
296
	 * @param line the line
297
	 * @return the indentation of <code>line</code> in <code>document</code>
298
	 * @throws BadLocationException if the document is changed concurrently
299
	 */
300
	private static String getCurrentIndent(IDocument document, int line) throws BadLocationException {
301
		IRegion region= document.getLineInformation(line);
302
		int from= region.getOffset();
303
		int endOffset= region.getOffset() + region.getLength();
304
305
		// go behind line comments
306
		int to= from;
307
		while (to < endOffset - 2 && document.get(to, 2).equals(SLASHES))
308
			to += 2;
309
310
		while (to < endOffset) {
311
			char ch= document.getChar(to);
312
			if (!Character.isWhitespace(ch))
313
				break;
314
			to++;
315
		}
316
317
		// don't count the space before javadoc like, asterix-style comment lines
318
		if (to > from && to < endOffset - 1 && document.get(to - 1, 2).equals(" *")) { //$NON-NLS-1$
319
			String type= TextUtilities.getContentType(document, ICPartitions.C_PARTITIONING, to, true);
320
			if (type.equals(ICPartitions.C_MULTI_LINE_COMMENT))
321
				to--;
322
		}
323
324
		return document.get(from, to - from);
325
	}
326
	
327
	private static int getLeftMostLine(IDocument document, ILineRange lines, int tabSize) throws BadLocationException {
328
		int numberOfLines= lines.getNumberOfLines();
329
		int first= lines.getStartLine();
330
		int minLine= -1;
331
		int minIndent= Integer.MAX_VALUE;
332
		for (int line= 0; line < numberOfLines; line++) {
333
			int length= computeVisualLength(getCurrentIndent(document, line + first), tabSize);
334
			if (length < minIndent) {
335
				minIndent= length;
336
				minLine= line;
337
			}
338
		}
339
		return minLine;
340
	}
341
342
	private static IndentResult reuseOrCreateToken(IndentResult token, int numberOfLines) {
343
		if (token == null)
344
			token= new IndentResult(new boolean[numberOfLines]);
345
		else if (token.commentLinesAtColumnZero == null)
346
			token.commentLinesAtColumnZero= new boolean[numberOfLines];
347
		else if (token.commentLinesAtColumnZero.length != numberOfLines) {
348
			boolean[] commentBooleans= new boolean[numberOfLines];
349
			System.arraycopy(token.commentLinesAtColumnZero, 0, commentBooleans, 0, Math.min(numberOfLines, token.commentLinesAtColumnZero.length));
350
			token.commentLinesAtColumnZero= commentBooleans;
351
		}
352
		return token;
353
	}
354
	
355
	/**
356
	 * Indents a single line using the java heuristic scanner. Multi line comments
357
	 * are indented as specified by the <code>CDocAutoIndentStrategy</code>.
358
	 * 
359
	 * @param document the document
360
	 * @param line the line to be indented
361
	 * @param indenter the java indenter
362
	 * @param scanner the heuristic scanner
363
	 * @param commentLines the indent token comment booleans
364
	 * @param lineIndex the zero-based line index
365
	 * @return <code>true</code> if the document was modified,
366
	 *         <code>false</code> if not
367
	 * @throws BadLocationException if the document got changed concurrently
368
	 */
369
	private static boolean indentLine(IDocument document, int line, CIndenter indenter, CHeuristicScanner scanner, boolean[] commentLines, int lineIndex, int tabSize) throws BadLocationException {
370
		IRegion currentLine= document.getLineInformation(line);
371
		final int offset= currentLine.getOffset();
372
		int wsStart= offset; // where we start searching for non-WS; after the "//" in single line comments
373
		
374
		String indent= null;
375
		if (offset < document.getLength()) {
376
			ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
377
			ITypedRegion startingPartition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, false);
378
			String type= partition.getType();
379
			if (type.equals(ICPartitions.C_MULTI_LINE_COMMENT)) {
380
				indent= computeCdocIndent(document, line, scanner, startingPartition);
381
			} else if (!commentLines[lineIndex] && startingPartition.getOffset() == offset && startingPartition.getType().equals(ICPartitions.C_SINGLE_LINE_COMMENT)) {
382
				return false;				
383
			}
384
		} 
385
		
386
		// standard java indentation
387
		if (indent == null) {
388
			StringBuffer computed= indenter.computeIndentation(offset);
389
			if (computed != null)
390
				indent= computed.toString();
391
			else
392
				indent= new String();
393
		}
394
		
395
		// change document:
396
		// get current white space
397
		int lineLength= currentLine.getLength();
398
		int end= scanner.findNonWhitespaceForwardInAnyPartition(wsStart, offset + lineLength);
399
		if (end == CHeuristicScanner.NOT_FOUND)
400
			end= offset + lineLength;
401
		int length= end - offset;
402
		String currentIndent= document.get(offset, length);
403
		
404
		// memorize the fact that a line is a single line comment (but not at column 0) and should be treated like code
405
		// as opposed to commented out code, which should keep its slashes at column 0
406
		if (length > 0) {
407
			ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, end, false);
408
			if (partition.getOffset() == end && ICPartitions.C_SINGLE_LINE_COMMENT.equals(partition.getType())) {
409
				commentLines[lineIndex]= true;
410
			}
411
		}
412
		
413
		// only change the document if it is a real change
414
		if (!indent.equals(currentIndent)) {
415
			document.replace(offset, length, indent);
416
			return true;
417
		}
418
		
419
		return false;
420
	}
421
	
422
	/**
423
	 * Computes and returns the indentation for a javadoc line. The line
424
	 * must be inside a javadoc comment.
425
	 * 
426
	 * @param document the document
427
	 * @param line the line in document
428
	 * @param scanner the scanner
429
	 * @param partition the comment partition
430
	 * @return the indent, or <code>null</code> if not computable
431
	 * @throws BadLocationException
432
	 */
433
	private static String computeCdocIndent(IDocument document, int line, CHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException {
434
		if (line == 0) // impossible - the first line is never inside a javadoc comment
435
			return null;
436
		
437
		// don't make any assumptions if the line does not start with \s*\* - it might be
438
		// commented out code, for which we don't want to change the indent
439
		final IRegion lineInfo= document.getLineInformation(line);
440
		final int lineStart= lineInfo.getOffset();
441
		final int lineLength= lineInfo.getLength();
442
		final int lineEnd= lineStart + lineLength;
443
		int nonWS= scanner.findNonWhitespaceForwardInAnyPartition(lineStart, lineEnd);
444
		if (nonWS == CHeuristicScanner.NOT_FOUND || document.getChar(nonWS) != '*') {
445
			if (nonWS == CHeuristicScanner.NOT_FOUND)
446
				return document.get(lineStart, lineLength);
447
			return document.get(lineStart, nonWS - lineStart);
448
		}
449
		
450
		// take the indent from the previous line and reuse
451
		IRegion previousLine= document.getLineInformation(line - 1);
452
		int previousLineStart= previousLine.getOffset();
453
		int previousLineLength= previousLine.getLength();
454
		int previousLineEnd= previousLineStart + previousLineLength;
455
		
456
		StringBuffer buf= new StringBuffer();
457
		int previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
458
		if (previousLineNonWS == CHeuristicScanner.NOT_FOUND || document.getChar(previousLineNonWS) != '*') {
459
			// align with the comment start if the previous line is not an asterix line
460
			previousLine= document.getLineInformationOfOffset(partition.getOffset());
461
			previousLineStart= previousLine.getOffset();
462
			previousLineLength= previousLine.getLength();
463
			previousLineEnd= previousLineStart + previousLineLength;
464
			previousLineNonWS= scanner.findNonWhitespaceForwardInAnyPartition(previousLineStart, previousLineEnd);
465
			if (previousLineNonWS == CHeuristicScanner.NOT_FOUND)
466
				previousLineNonWS= previousLineEnd;
467
			
468
			// add the initial space 
469
			// TODO this may be controlled by a formatter preference in the future
470
			buf.append(' ');
471
		}
472
		
473
		String indentation= document.get(previousLineStart, previousLineNonWS - previousLineStart);
474
		buf.insert(0, indentation);
475
		return buf.toString();
476
	}
477
}
(-)src/org/eclipse/cdt/internal/ui/preferences/SmartTypingConfigurationBlock.java (+250 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.preferences;
14
15
import org.eclipse.jface.dialogs.Dialog;
16
import org.eclipse.jface.preference.IPreferenceStore;
17
import org.eclipse.jface.text.Assert;
18
import org.eclipse.jface.util.IPropertyChangeListener;
19
import org.eclipse.jface.util.PropertyChangeEvent;
20
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.events.DisposeListener;
22
import org.eclipse.swt.events.SelectionAdapter;
23
import org.eclipse.swt.events.SelectionEvent;
24
import org.eclipse.swt.graphics.Point;
25
import org.eclipse.swt.layout.GridData;
26
import org.eclipse.swt.layout.GridLayout;
27
import org.eclipse.swt.widgets.Button;
28
import org.eclipse.swt.widgets.Composite;
29
import org.eclipse.swt.widgets.Control;
30
import org.eclipse.swt.widgets.Link;
31
import org.eclipse.ui.dialogs.PreferencesUtil;
32
33
import org.eclipse.cdt.core.CCorePlugin;
34
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
35
import org.eclipse.cdt.ui.CUIPlugin;
36
import org.eclipse.cdt.ui.PreferenceConstants;
37
38
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
39
40
import org.eclipse.cdt.internal.ui.util.Messages;
41
42
/**
43
 * Configures C Editor typing preferences.
44
 */
45
class SmartTypingConfigurationBlock extends AbstractConfigurationBlock {
46
47
	public SmartTypingConfigurationBlock(OverlayPreferenceStore store) {
48
		super(store);
49
		
50
		store.addKeys(createOverlayStoreKeys());
51
	}
52
	
53
	private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
54
		return new OverlayPreferenceStore.OverlayKey[] {
55
			new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE),
56
			
57
			new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS),
58
			new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS),
59
			new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS),
60
			new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES),
61
			new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS),
62
			new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS),
63
			
64
//			new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_SEMICOLON),
65
			new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_TAB),
66
//			new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_OPENING_BRACE),
67
		};
68
	}	
69
70
	/**
71
	 * Creates page for mark occurrences preferences.
72
	 * 
73
	 * @param parent the parent composite
74
	 * @return the control for the preference page
75
	 */
76
	public Control createControl(Composite parent) {
77
		ScrolledPageContent scrolled= new ScrolledPageContent(parent, SWT.H_SCROLL | SWT.V_SCROLL);
78
		scrolled.setExpandHorizontal(true);
79
		scrolled.setExpandVertical(true);
80
		
81
		Composite control= new Composite(scrolled, SWT.NONE);
82
		GridLayout layout= new GridLayout();
83
		control.setLayout(layout);
84
85
		Composite composite;
86
		
87
		composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_autoclose_title); 
88
		addAutoclosingSection(composite);
89
		
90
//		composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_automove_title); 
91
//		addAutopositionSection(composite);
92
		
93
		composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_tabs_title); 
94
		addTabSection(composite);
95
96
		composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_pasting_title); 
97
		addPasteSection(composite);
98
		
99
		composite= createSubsection(control, null, PreferencesMessages.SmartTypingConfigurationBlock_strings_title); 
100
		addStringsSection(composite);
101
102
		scrolled.setContent(control);
103
		final Point size= control.computeSize(SWT.DEFAULT, SWT.DEFAULT);
104
		scrolled.setMinSize(size.x, size.y);
105
		return scrolled;
106
	}
107
108
	private void addStringsSection(Composite composite) {
109
		GridLayout layout= new GridLayout();
110
		composite.setLayout(layout);
111
112
		String label;
113
		Button master, slave;
114
		label= PreferencesMessages.CEditorPreferencePage_wrapStrings; 
115
		master= addCheckBox(composite, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 0);
116
		
117
		label= PreferencesMessages.CEditorPreferencePage_escapeStrings; 
118
		slave= addCheckBox(composite, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS, 0);
119
		createDependency(master, slave);
120
	}
121
122
	private void addPasteSection(Composite composite) {
123
		GridLayout layout= new GridLayout();
124
		composite.setLayout(layout);
125
126
		String label;
127
		label= PreferencesMessages.CEditorPreferencePage_smartPaste; 
128
		addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_PASTE, 0);
129
	}
130
131
	private void addTabSection(Composite composite) {
132
		GridLayout layout= new GridLayout();
133
		composite.setLayout(layout);
134
135
		String label;
136
		label= PreferencesMessages.CEditorPreferencePage_typing_smartTab; 
137
		addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_TAB, 0);
138
		
139
		createMessage(composite);
140
	}
141
142
//	private void addAutopositionSection(Composite composite) {
143
//		GridLayout layout= new GridLayout();
144
//		composite.setLayout(layout);
145
//
146
//		String label;
147
//		
148
//		label= PreferencesMessages.CEditorPreferencePage_typing_smartSemicolon; 
149
//		addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_SEMICOLON, 0);
150
//		
151
//		label= PreferencesMessages.CEditorPreferencePage_typing_smartOpeningBrace; 
152
//		addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_OPENING_BRACE, 0);
153
//	}
154
155
	private void addAutoclosingSection(Composite composite) {
156
		
157
		GridLayout layout= new GridLayout();
158
		layout.numColumns= 1;
159
		composite.setLayout(layout);
160
161
		String label;
162
163
		label= PreferencesMessages.CEditorPreferencePage_closeStrings;
164
		addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 0);
165
166
		label= PreferencesMessages.CEditorPreferencePage_closeBrackets; 
167
		addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 0);
168
169
		label= PreferencesMessages.CEditorPreferencePage_closeAngularBrackets; 
170
		addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_ANGULAR_BRACKETS, 0);
171
172
		label= PreferencesMessages.CEditorPreferencePage_closeBraces; 
173
		addCheckBox(composite, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 0);
174
	}
175
	
176
	private void createMessage(final Composite composite) {
177
		// TODO create a link with an argument, so the formatter preference page can open the 
178
		// current profile automatically.
179
		String linkTooltip= PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tooltip; 
180
		String text;
181
		String indentMode= CUIPlugin.getDefault().getCombinedPreferenceStore().getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
182
		if (CCorePlugin.TAB.equals(indentMode))
183
			text= Messages.format(PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tab_text, new String[] {Integer.toString(getTabDisplaySize())});
184
		else
185
			text= Messages.format(PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_others_text, new String[] {Integer.toString(getTabDisplaySize()), Integer.toString(getIndentSize()), getIndentMode()}); 
186
		
187
		final Link link= new Link(composite, SWT.NONE);
188
		link.setText(text);
189
		link.setToolTipText(linkTooltip);
190
		GridData gd= new GridData(SWT.FILL, SWT.BEGINNING, true, false);
191
		gd.widthHint= 300; // don't get wider initially
192
		link.setLayoutData(gd);
193
		link.addSelectionListener(new SelectionAdapter() {
194
			public void widgetSelected(SelectionEvent e) {
195
				PreferencesUtil.createPreferenceDialogOn(link.getShell(), "org.eclipse.cdt.ui.preferences.CodeFormatterPreferencePage", null, null); //$NON-NLS-1$
196
			}
197
		});
198
		
199
		final IPreferenceStore combinedStore= CUIPlugin.getDefault().getCombinedPreferenceStore();
200
		final IPropertyChangeListener propertyChangeListener= new IPropertyChangeListener() {
201
			private boolean fHasRun= false;
202
			public void propertyChange(PropertyChangeEvent event) {
203
				if (fHasRun)
204
					return;
205
				if (composite.isDisposed())
206
					return;
207
				String property= event.getProperty();
208
				if (DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR.equals(property)
209
						|| DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE.equals(property)) {
210
					fHasRun= true;
211
					link.dispose();
212
					createMessage(composite);
213
					Dialog.applyDialogFont(composite);
214
					composite.redraw();
215
					composite.layout();
216
				}
217
			}
218
		};
219
		combinedStore.addPropertyChangeListener(propertyChangeListener);
220
		link.addDisposeListener(new DisposeListener() {
221
			public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e) {
222
				combinedStore.removePropertyChangeListener(propertyChangeListener);
223
			}
224
		});
225
	}
226
227
	private String getIndentMode() {
228
		String indentMode= CUIPlugin.getDefault().getCombinedPreferenceStore().getString(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
229
		
230
		if (CCorePlugin.SPACE.equals(indentMode))
231
			return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_spaces; 
232
		
233
		if (CCorePlugin.TAB.equals(indentMode))
234
			return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tabs;
235
		
236
		if (DefaultCodeFormatterConstants.MIXED.equals(indentMode))
237
			return PreferencesMessages.SmartTypingConfigurationBlock_tabs_message_tabsAndSpaces;
238
239
		Assert.isTrue(false, "Illegal indent mode - must not happen"); //$NON-NLS-1$
240
		return null;
241
	}
242
243
	private int getIndentSize() {
244
		return CodeFormatterUtil.getIndentWidth(null);
245
	}
246
	
247
	private int getTabDisplaySize() {
248
		return CodeFormatterUtil.getTabWidth(null);
249
	}
250
}
(-)src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlockPreferencePage.java (+128 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
13
package org.eclipse.cdt.internal.ui.preferences;
14
15
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.swt.widgets.Control;
17
18
import org.eclipse.jface.dialogs.Dialog;
19
import org.eclipse.jface.preference.PreferencePage;
20
21
import org.eclipse.ui.IWorkbench;
22
import org.eclipse.ui.IWorkbenchPreferencePage;
23
import org.eclipse.ui.PlatformUI;
24
25
import org.eclipse.cdt.ui.CUIPlugin;
26
27
/**
28
 * Abstract preference page which is used to wrap a
29
 * {@link org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock}.
30
 * 
31
 * @since 4.0
32
 */
33
public abstract class AbstractConfigurationBlockPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
34
	
35
	
36
	private IPreferenceConfigurationBlock fConfigurationBlock;
37
	private OverlayPreferenceStore fOverlayStore;
38
	
39
40
	/**
41
	 * Creates a new preference page.
42
	 */
43
	public AbstractConfigurationBlockPreferencePage() {
44
		setDescription();
45
		setPreferenceStore();
46
		fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {});
47
		fConfigurationBlock= createConfigurationBlock(fOverlayStore);
48
	}
49
		
50
	protected abstract IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore);
51
	protected abstract String getHelpId();
52
	protected abstract void setDescription();
53
	protected abstract void setPreferenceStore();
54
	
55
	/*
56
	 * @see IWorkbenchPreferencePage#init()
57
	 */	
58
	public void init(IWorkbench workbench) {
59
	}
60
61
	/*
62
	 * @see PreferencePage#createControl(Composite)
63
	 */
64
	public void createControl(Composite parent) {
65
		super.createControl(parent);
66
		PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), getHelpId());
67
	}
68
	
69
	/*
70
	 * @see PreferencePage#createContents(Composite)
71
	 */
72
	protected Control createContents(Composite parent) {
73
		
74
		fOverlayStore.load();
75
		fOverlayStore.start();
76
		
77
		Control content= fConfigurationBlock.createControl(parent);
78
		
79
		initialize();
80
		
81
		Dialog.applyDialogFont(content);
82
		return content;
83
	}
84
	
85
	private void initialize() {
86
		fConfigurationBlock.initialize();
87
	}
88
	
89
    /*
90
	 * @see PreferencePage#performOk()
91
	 */
92
	public boolean performOk() {
93
		
94
		fConfigurationBlock.performOk();
95
96
		fOverlayStore.propagate();
97
		
98
		CUIPlugin.getDefault().savePluginPreferences();
99
		
100
		return true;
101
	}
102
	
103
	/*
104
	 * @see PreferencePage#performDefaults()
105
	 */
106
	public void performDefaults() {
107
		
108
		fOverlayStore.loadDefaults();
109
		fConfigurationBlock.performDefaults();
110
111
		super.performDefaults();
112
	}
113
	
114
	/*
115
	 * @see DialogPage#dispose()
116
	 */
117
	public void dispose() {
118
		
119
		fConfigurationBlock.dispose();
120
		
121
		if (fOverlayStore != null) {
122
			fOverlayStore.stop();
123
			fOverlayStore= null;
124
		}
125
		
126
		super.dispose();
127
	}
128
}
(-)src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java (+287 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.preferences;
13
14
import java.util.Map;
15
16
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.runtime.IAdaptable;
19
import org.eclipse.core.runtime.IStatus;
20
import org.eclipse.jface.dialogs.ControlEnableState;
21
import org.eclipse.jface.dialogs.Dialog;
22
import org.eclipse.jface.preference.PreferencePage;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.layout.GridData;
25
import org.eclipse.swt.layout.GridLayout;
26
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.Link;
29
import org.eclipse.ui.IWorkbench;
30
import org.eclipse.ui.IWorkbenchPreferencePage;
31
import org.eclipse.ui.IWorkbenchPropertyPage;
32
import org.eclipse.ui.dialogs.PreferencesUtil;
33
34
import org.eclipse.cdt.internal.ui.dialogs.IStatusChangeListener;
35
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
36
import org.eclipse.cdt.internal.ui.dialogs.StatusUtil;
37
38
/**
39
 * Base for project property and preference pages
40
 */
41
public abstract class PropertyAndPreferencePage extends PreferencePage implements IWorkbenchPreferencePage, IWorkbenchPropertyPage {
42
	
43
	private Control fConfigurationBlockControl;
44
	private ControlEnableState fBlockEnableState;
45
	private Link fChangeWorkspaceSettings;
46
//	private SelectionButtonDialogField fUseProjectSettings;
47
	private IStatus fBlockStatus;
48
	private Composite fParentComposite;
49
	
50
	private IProject fProject; // project or null
51
	private Map fData; // page data
52
	
53
	public static final String DATA_NO_LINK= "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$
54
	
55
	public PropertyAndPreferencePage() {
56
		fBlockStatus= new StatusInfo();
57
		fBlockEnableState= null;
58
		fProject= null;
59
		fData= null;
60
	}
61
62
	protected abstract Control createPreferenceContent(Composite composite);
63
	protected abstract boolean hasProjectSpecificOptions(IProject project);
64
	
65
	protected abstract String getPreferencePageID();
66
	protected abstract String getPropertyPageID();
67
	
68
	protected boolean supportsProjectSpecificOptions() {
69
		return getPropertyPageID() != null;
70
	}
71
	
72
	protected boolean offerLink() {
73
		return fData == null || !Boolean.TRUE.equals(fData.get(DATA_NO_LINK));
74
	}
75
	
76
// TODO: Project specific settings are not supported yet.
77
//protected Label createDescriptionLabel(Composite parent) {
78
//		fParentComposite= parent;
79
//		if (isProjectPreferencePage()) {
80
//			Composite composite= new Composite(parent, SWT.NONE);
81
//			composite.setFont(parent.getFont());
82
//			GridLayout layout= new GridLayout();
83
//			layout.marginHeight= 0;
84
//			layout.marginWidth= 0;
85
//			layout.numColumns= 2;
86
//			composite.setLayout(layout);
87
//			composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
88
//			
89
//			IDialogFieldListener listener= new IDialogFieldListener() {
90
//				public void dialogFieldChanged(DialogField field) {
91
//					enableProjectSpecificSettings(((SelectionButtonDialogField)field).isSelected());
92
//				}
93
//			};
94
//			
95
//			fUseProjectSettings= new SelectionButtonDialogField(SWT.CHECK);
96
//			fUseProjectSettings.setDialogFieldListener(listener);
97
//			fUseProjectSettings.setLabelText(PreferencesMessages.PropertyAndPreferencePage_useprojectsettings_label); 
98
//			fUseProjectSettings.doFillIntoGrid(composite, 1);
99
//			LayoutUtil.setHorizontalGrabbing(fUseProjectSettings.getSelectionButton(null));
100
//			
101
//			if (offerLink()) {
102
//				fChangeWorkspaceSettings= createLink(composite, PreferencesMessages.PropertyAndPreferencePage_useworkspacesettings_change);
103
//				fChangeWorkspaceSettings.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
104
//			} else {
105
//				LayoutUtil.setHorizontalSpan(fUseProjectSettings.getSelectionButton(null), 2);
106
//			}
107
//			
108
//			Label horizontalLine= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
109
//			horizontalLine.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
110
//			horizontalLine.setFont(composite.getFont());
111
//		} else if (supportsProjectSpecificOptions() && offerLink()) {
112
//			fChangeWorkspaceSettings= createLink(parent, PreferencesMessages.PropertyAndPreferencePage_showprojectspecificsettings_label);
113
//			fChangeWorkspaceSettings.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
114
//		}
115
//
116
//		return super.createDescriptionLabel(parent);
117
//    }
118
	
119
	/*
120
	 * @see org.eclipse.jface.preference.IPreferencePage#createContents(Composite)
121
	 */
122
	protected Control createContents(Composite parent) {
123
		Composite composite= new Composite(parent, SWT.NONE);
124
		GridLayout layout= new GridLayout();
125
		layout.marginHeight= 0;
126
		layout.marginWidth= 0;
127
		composite.setLayout(layout);
128
		composite.setFont(parent.getFont());
129
			
130
		GridData data= new GridData(GridData.FILL, GridData.FILL, true, true);
131
		
132
		fConfigurationBlockControl= createPreferenceContent(composite);
133
		fConfigurationBlockControl.setLayoutData(data);
134
135
//      TODO: Project specific settings are not supported yet.
136
//		if (isProjectPreferencePage()) {
137
//			boolean useProjectSettings= hasProjectSpecificOptions(getProject());
138
//			enableProjectSpecificSettings(useProjectSettings);
139
//		}
140
141
		Dialog.applyDialogFont(composite);
142
		return composite;
143
	}
144
145
	protected boolean useProjectSettings() {
146
//      TODO: Project specific settings are not supported yet.
147
//		return isProjectPreferencePage() && fUseProjectSettings != null && fUseProjectSettings.isSelected();
148
		return false;
149
	}
150
	
151
	protected boolean isProjectPreferencePage() {
152
		return fProject != null;
153
	}
154
	
155
	protected IProject getProject() {
156
		return fProject;
157
	}
158
	
159
	protected final void openWorkspacePreferences(Object data) {
160
		String id= getPreferencePageID();
161
		PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { id }, data).open();
162
	}
163
	
164
	protected final void openProjectProperties(IProject project, Object data) {
165
		String id= getPropertyPageID();
166
		if (id != null) {
167
			PreferencesUtil.createPropertyDialogOn(getShell(), project, id, new String[] { id }, data).open();
168
		}
169
	}
170
	
171
//	TODO: Project specific settings are not supported yet.
172
//	protected void enableProjectSpecificSettings(boolean useProjectSpecificSettings) {
173
//		fUseProjectSettings.setSelection(useProjectSpecificSettings);
174
//		enablePreferenceContent(useProjectSpecificSettings);
175
//		updateLinkVisibility();
176
//		doStatusChanged();
177
//	}
178
//	
179
//	private void updateLinkVisibility() {
180
//		if (fChangeWorkspaceSettings == null || fChangeWorkspaceSettings.isDisposed()) {
181
//			return;
182
//		}
183
//		
184
//		if (isProjectPreferencePage()) {
185
//			fChangeWorkspaceSettings.setEnabled(!useProjectSettings());
186
//		}
187
//	}
188
	
189
	protected void setPreferenceContentStatus(IStatus status) {
190
		fBlockStatus= status;
191
		doStatusChanged();
192
	}
193
	
194
	/**
195
	 * Returns a new status change listener that calls {@link #setPreferenceContentStatus(IStatus)}
196
	 * when the status has changed
197
	 * @return The new listener
198
	 */
199
	protected IStatusChangeListener getNewStatusChangedListener() {
200
		return new IStatusChangeListener() {
201
			public void statusChanged(IStatus status) {
202
				setPreferenceContentStatus(status);
203
			}
204
		};		
205
	}
206
	
207
	protected IStatus getPreferenceContentStatus() {
208
		return fBlockStatus;
209
	}
210
211
	protected void doStatusChanged() {
212
		if (!isProjectPreferencePage() || useProjectSettings()) {
213
			updateStatus(fBlockStatus);
214
		} else {
215
			updateStatus(new StatusInfo());
216
		}
217
	}
218
		
219
	protected void enablePreferenceContent(boolean enable) {
220
		if (enable) {
221
			if (fBlockEnableState != null) {
222
				fBlockEnableState.restore();
223
				fBlockEnableState= null;
224
			}
225
		} else {
226
			if (fBlockEnableState == null) {
227
				fBlockEnableState= ControlEnableState.disable(fConfigurationBlockControl);
228
			}
229
		}	
230
	}
231
	
232
	/*
233
	 * @see org.eclipse.jface.preference.IPreferencePage#performDefaults()
234
	 */
235
	protected void performDefaults() {
236
//      TODO: Project specific settings are not supported yet.
237
//		if (useProjectSettings()) {
238
//			enableProjectSpecificSettings(false);
239
//		}
240
		super.performDefaults();
241
	}
242
243
	private void updateStatus(IStatus status) {
244
		setValid(!status.matches(IStatus.ERROR));
245
		StatusUtil.applyToStatusLine(this, status);
246
	}
247
248
	/* (non-Javadoc)
249
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
250
	 */
251
	public void init(IWorkbench workbench) {
252
	}
253
254
	/* (non-Javadoc)
255
	 * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
256
	 */
257
	public IAdaptable getElement() {
258
		return fProject;
259
	}
260
261
	/* (non-Javadoc)
262
	 * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
263
	 */
264
	public void setElement(IAdaptable element) {
265
		fProject= (IProject) element.getAdapter(IResource.class);
266
	}
267
	
268
	
269
	/* (non-Javadoc)
270
	 * @see org.eclipse.jface.preference.PreferencePage#applyData(java.lang.Object)
271
	 */
272
	public void applyData(Object data) {
273
		if (data instanceof Map) {
274
			fData= (Map) data;
275
		}
276
		if (fChangeWorkspaceSettings != null) {
277
			if (!offerLink()) {
278
				fChangeWorkspaceSettings.dispose();
279
				fParentComposite.layout(true, true);
280
			}
281
		}
282
 	}
283
	
284
	protected Map getData() {
285
		return fData;
286
	}
287
}
(-)src/org/eclipse/cdt/internal/corext/template/c/ExclusivePositionUpdater.java (+99 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.corext.template.c;
13
14
import org.eclipse.jface.text.BadPositionCategoryException;
15
import org.eclipse.jface.text.DocumentEvent;
16
import org.eclipse.jface.text.IPositionUpdater;
17
import org.eclipse.jface.text.Position;
18
19
/**
20
 * Position updater that takes any changes at the borders of a position to not belong to the position.
21
 */
22
final class ExclusivePositionUpdater implements IPositionUpdater {
23
24
	/** The position category. */
25
	private final String fCategory;
26
27
	/**
28
	 * Creates a new updater for the given <code>category</code>.
29
	 *
30
	 * @param category the new category.
31
	 */
32
	public ExclusivePositionUpdater(String category) {
33
		fCategory= category;
34
	}
35
36
	/*
37
	 * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent)
38
	 */
39
	public void update(DocumentEvent event) {
40
41
		int eventOffset= event.getOffset();
42
		int eventOldLength= event.getLength();
43
		int eventNewLength= event.getText() == null ? 0 : event.getText().length();
44
		int deltaLength= eventNewLength - eventOldLength;
45
46
		try {
47
			Position[] positions= event.getDocument().getPositions(fCategory);
48
49
			for (int i= 0; i != positions.length; i++) {
50
51
				Position position= positions[i];
52
53
				if (position.isDeleted())
54
					continue;
55
56
				int offset= position.getOffset();
57
				int length= position.getLength();
58
				int end= offset + length;
59
60
				if (offset >= eventOffset + eventOldLength)
61
					// position comes
62
					// after change - shift
63
					position.setOffset(offset + deltaLength);
64
				else if (end <= eventOffset) {
65
					// position comes way before change -
66
					// leave alone
67
				} else if (offset <= eventOffset && end >= eventOffset + eventOldLength) {
68
					// event completely internal to the position - adjust length
69
					position.setLength(length + deltaLength);
70
				} else if (offset < eventOffset) {
71
					// event extends over end of position - adjust length
72
					int newEnd= eventOffset;
73
					position.setLength(newEnd - offset);
74
				} else if (end > eventOffset + eventOldLength) {
75
					// event extends from before position into it - adjust offset
76
					// and length
77
					// offset becomes end of event, length adjusted accordingly
78
					int newOffset= eventOffset + eventNewLength;
79
					position.setOffset(newOffset);
80
					position.setLength(end - newOffset);
81
				} else {
82
					// event consumes the position - delete it
83
					position.delete();
84
				}
85
			}
86
		} catch (BadPositionCategoryException e) {
87
			// ignore and return
88
		}
89
	}
90
91
	/**
92
	 * Returns the position category.
93
	 *
94
	 * @return the position category
95
	 */
96
	public String getCategory() {
97
		return fCategory;
98
	}
99
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/AlreadyExistsDialog.java (+194 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.preferences.formatter;
13
14
import org.eclipse.core.runtime.IStatus;
15
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.ModifyEvent;
18
import org.eclipse.swt.events.ModifyListener;
19
import org.eclipse.swt.events.SelectionEvent;
20
import org.eclipse.swt.events.SelectionListener;
21
import org.eclipse.swt.layout.GridData;
22
import org.eclipse.swt.layout.GridLayout;
23
import org.eclipse.swt.widgets.Button;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Control;
26
import org.eclipse.swt.widgets.Label;
27
import org.eclipse.swt.widgets.Shell;
28
import org.eclipse.swt.widgets.Text;
29
30
import org.eclipse.jface.dialogs.IDialogConstants;
31
import org.eclipse.jface.dialogs.StatusDialog;
32
33
import org.eclipse.cdt.internal.ui.util.Messages;
34
35
import org.eclipse.cdt.internal.ui.dialogs.StatusInfo;
36
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
37
38
/**
39
 * The dialog to rename an imported profile. 
40
 */
41
public class AlreadyExistsDialog extends StatusDialog {
42
	
43
	private Composite fComposite;
44
	protected Text fNameText;
45
	private Button fRenameRadio, fOverwriteRadio;
46
	
47
	private final int NUM_COLUMNS= 2;
48
	
49
	private final StatusInfo fOk;
50
	private final StatusInfo fEmpty;
51
	private final StatusInfo fDuplicate;
52
	
53
	private final CustomProfile fProfile;
54
	private final ProfileManager fProfileManager;
55
	
56
	public AlreadyExistsDialog(Shell parentShell, CustomProfile profile, ProfileManager profileManager) {
57
		super(parentShell);
58
		fProfile= profile;
59
		fProfileManager= profileManager;
60
		fOk= new StatusInfo();
61
		fDuplicate= new StatusInfo(IStatus.ERROR, FormatterMessages.AlreadyExistsDialog_message_profile_already_exists); 
62
		fEmpty= new StatusInfo(IStatus.ERROR, FormatterMessages.AlreadyExistsDialog_message_profile_name_empty); 
63
	}
64
	
65
	
66
	public void create() {
67
		super.create();
68
		setTitle(FormatterMessages.AlreadyExistsDialog_dialog_title); 
69
	}
70
	
71
	public Control createDialogArea(Composite parent) {
72
				
73
		initializeComposite(parent);
74
		
75
		createLabel(Messages.format(FormatterMessages.AlreadyExistsDialog_dialog_label, fProfile.getName())); 
76
77
		fRenameRadio= createRadioButton(FormatterMessages.AlreadyExistsDialog_rename_radio_button_desc); 
78
		fNameText= createTextField();
79
80
		fOverwriteRadio= createRadioButton(FormatterMessages.AlreadyExistsDialog_overwrite_radio_button_desc); 
81
82
		fRenameRadio.setSelection(true);
83
		
84
		fNameText.setText(fProfile.getName());
85
		fNameText.setSelection(0, fProfile.getName().length());
86
		fNameText.setFocus();
87
		
88
		fNameText.addModifyListener( new ModifyListener() {
89
			public void modifyText(ModifyEvent e) {
90
				doValidation();
91
			}
92
		});
93
		
94
		fRenameRadio.addSelectionListener(new SelectionListener() {
95
			public void widgetSelected(SelectionEvent e) {
96
				fNameText.setEnabled(true);
97
				fNameText.setFocus();
98
				fNameText.setSelection(0, fNameText.getText().length());
99
				doValidation();
100
			}
101
			public void widgetDefaultSelected(SelectionEvent e) {
102
			}
103
		});
104
		
105
		fOverwriteRadio.addSelectionListener(new SelectionListener() {
106
			public void widgetSelected(SelectionEvent e) {
107
				fNameText.setEnabled(false);
108
				doValidation();
109
			}
110
			public void widgetDefaultSelected(SelectionEvent e) {
111
			}
112
		});
113
		
114
		updateStatus(fDuplicate);
115
		
116
		applyDialogFont(fComposite);
117
		
118
		return fComposite;
119
	}
120
	
121
	private void initializeComposite(Composite parent) {
122
		fComposite= new Composite(parent, SWT.NULL);
123
		
124
		final GridLayout layout= new GridLayout();
125
		layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
126
		layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
127
		layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
128
		layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
129
		layout.numColumns= NUM_COLUMNS;
130
		
131
		fComposite.setLayout(layout);
132
	}
133
	
134
	private Label createLabel(String text) {
135
		final GridData gd= new GridData(GridData.FILL_HORIZONTAL);
136
		gd.horizontalSpan= NUM_COLUMNS;
137
		gd.widthHint= convertWidthInCharsToPixels(60);
138
		final Label label= new Label(fComposite, SWT.WRAP);
139
		label.setText(text);
140
		label.setLayoutData(gd);
141
		return label;
142
	}
143
	
144
	private Button createRadioButton(String text) {
145
		final GridData gd = new GridData();
146
		gd.horizontalSpan = NUM_COLUMNS;
147
		gd.widthHint= convertWidthInCharsToPixels(60);
148
		final Button radio= new Button(fComposite, SWT.RADIO);
149
		radio.setLayoutData(gd);
150
		radio.setText(text);
151
		return radio;
152
	}
153
	
154
	private Text createTextField() {
155
		final GridData gd = new GridData( GridData.FILL_HORIZONTAL);
156
		gd.horizontalSpan= NUM_COLUMNS;
157
		final Text text= new Text(fComposite, SWT.SINGLE | SWT.BORDER);
158
		text.setLayoutData(gd);
159
		return text;
160
	}
161
162
	/**
163
	 * Validate the current settings
164
	 */
165
	protected void doValidation() {
166
167
		if (fOverwriteRadio.getSelection()) {
168
			updateStatus(fOk);
169
			return;
170
		}
171
172
		final String name= fNameText.getText().trim();
173
		
174
		if (name.length() == 0) {
175
			updateStatus(fEmpty);
176
			return;
177
		}
178
		
179
		if (fProfileManager.containsName(name)) {
180
			updateStatus(fDuplicate);
181
			return;
182
		}
183
		
184
		updateStatus(fOk);
185
	}
186
	
187
	protected void okPressed() {
188
		if (!getStatus().isOK()) 
189
			return;
190
		if (fRenameRadio.getSelection())
191
			fProfile.rename(fNameText.getText().trim(), fProfileManager);
192
		super.okPressed();
193
	}
194
}
(-)src/org/eclipse/cdt/internal/ui/preferences/formatter/CPreview.java (+198 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *     Sergey Prigogin, Google
11
 *******************************************************************************/
12
package org.eclipse.cdt.internal.ui.preferences.formatter;
13
14
import java.util.Map;
15
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.custom.StyledText;
18
import org.eclipse.swt.events.DisposeEvent;
19
import org.eclipse.swt.events.DisposeListener;
20
import org.eclipse.swt.graphics.Font;
21
import org.eclipse.swt.graphics.RGB;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Control;
24
25
import org.eclipse.jface.preference.IPreferenceStore;
26
import org.eclipse.jface.preference.PreferenceConverter;
27
import org.eclipse.jface.preference.PreferenceStore;
28
import org.eclipse.jface.resource.JFaceResources;
29
import org.eclipse.jface.util.IPropertyChangeListener;
30
import org.eclipse.jface.util.PropertyChangeEvent;
31
32
import org.eclipse.jface.text.Document;
33
import org.eclipse.jface.text.MarginPainter;
34
import org.eclipse.jface.text.source.SourceViewer;
35
36
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
37
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
38
39
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
40
41
import org.eclipse.cdt.ui.PreferenceConstants;
42
import org.eclipse.cdt.ui.text.ICPartitions;
43
44
import org.eclipse.cdt.ui.CUIPlugin;
45
46
import org.eclipse.cdt.internal.ui.editor.CSourceViewer;
47
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
48
import org.eclipse.cdt.internal.ui.text.CTextTools;
49
import org.eclipse.cdt.internal.ui.text.SimpleCSourceViewerConfiguration;
50
51
52
public abstract class CPreview {
53
    
54
	private final class CSourcePreviewerUpdater {
55
	    
56
	    final IPropertyChangeListener fontListener= new IPropertyChangeListener() {
57
	        public void propertyChange(PropertyChangeEvent event) {
58
	            if (event.getProperty().equals(PreferenceConstants.EDITOR_TEXT_FONT)) {
59
					final Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
60
					fSourceViewer.getTextWidget().setFont(font);
61
					if (fMarginPainter != null) {
62
						fMarginPainter.initialize();
63
					}
64
				}
65
			}
66
		};
67
		
68
	    final IPropertyChangeListener propertyListener= new IPropertyChangeListener() {
69
			public void propertyChange(PropertyChangeEvent event) {
70
				if (fViewerConfiguration.affectsTextPresentation(event)) {
71
					fViewerConfiguration.handlePropertyChangeEvent(event);
72
					fSourceViewer.invalidateTextPresentation();
73
				}
74
			}
75
		};
76
		
77
		public CSourcePreviewerUpdater() {
78
			
79
		    JFaceResources.getFontRegistry().addListener(fontListener);
80
		    fPreferenceStore.addPropertyChangeListener(propertyListener);
81
			
82
			fSourceViewer.getTextWidget().addDisposeListener(new DisposeListener() {
83
				public void widgetDisposed(DisposeEvent e) {
84
					JFaceResources.getFontRegistry().removeListener(fontListener);
85
					fPreferenceStore.removePropertyChangeListener(propertyListener);
86
				}
87
			});
88
		}
89
	}
90
	
91
	protected final CSourceViewerConfiguration fViewerConfiguration;
92
	protected final Document fPreviewDocument;
93
	protected final SourceViewer fSourceViewer;
94
	protected final IPreferenceStore fPreferenceStore;
95
	
96
	protected final MarginPainter fMarginPainter;
97
	
98
	protected Map fWorkingValues;
99
100
	private int fTabSize= 0;
101
	
102
	/**
103
	 * Create a new C preview
104
	 * @param workingValues
105
	 * @param parent
106
	 */
107
	public CPreview(Map workingValues, Composite parent) {
108
		CTextTools tools= CUIPlugin.getDefault().getTextTools();
109
		fPreviewDocument= new Document();
110
		fWorkingValues= workingValues;
111
		tools.setupCDocumentPartitioner( fPreviewDocument, ICPartitions.C_PARTITIONING);	
112
		
113
		PreferenceStore prioritizedSettings= new PreferenceStore();
114
		
115
		IPreferenceStore[] chain= { prioritizedSettings, CUIPlugin.getDefault().getCombinedPreferenceStore() };
116
		fPreferenceStore= new ChainedPreferenceStore(chain);
117
		fSourceViewer= new CSourceViewer(parent, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
118
		fViewerConfiguration= new SimpleCSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, ICPartitions.C_PARTITIONING, true);
119
		fSourceViewer.configure(fViewerConfiguration);
120
		fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));
121
		
122
		fMarginPainter= new MarginPainter(fSourceViewer);
123
		final RGB rgb= PreferenceConverter.getColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
124
		fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb));
125
		fSourceViewer.addPainter(fMarginPainter);
126
		
127
		new CSourcePreviewerUpdater();
128
		fSourceViewer.setDocument(fPreviewDocument);
129
	}
130
	
131
	public Control getControl() {
132
	    return fSourceViewer.getControl();
133
	}
134
	
135
	public void update() {
136
		if (fWorkingValues == null) {
137
		    fPreviewDocument.set(""); //$NON-NLS-1$
138
		    return;
139
		}
140
		
141
		// update the print margin
142
		final String value= (String)fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT);
143
		final int lineWidth= getPositiveIntValue(value, 0);
144
		fMarginPainter.setMarginRulerColumn(lineWidth);
145
		
146
		// update the tab size
147
		final int tabSize= getPositiveIntValue((String) fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE), 0);
148
		if (tabSize != fTabSize) fSourceViewer.getTextWidget().setTabs(tabSize);
149
		fTabSize= tabSize;
150
		
151
		final StyledText widget= (StyledText)fSourceViewer.getControl();
152
		final int height= widget.getClientArea().height;
153
		final int top0= widget.getTopPixel();
154
		
155
		final int totalPixels0= getHeightOfAllLines(widget);
156
		final int topPixelRange0= totalPixels0 > height ? totalPixels0 - height : 0;
157
		
158
		widget.setRedraw(false);
159
		doFormatPreview();
160
		fSourceViewer.setSelection(null);
161
		
162
		final int totalPixels1= getHeightOfAllLines(widget);
163
		final int topPixelRange1= totalPixels1 > height ? totalPixels1 - height : 0;
164
165
		final int top1= topPixelRange0 > 0 ? (int)(topPixelRange1 * top0 / (double)topPixelRange0) : 0;
166
		widget.setTopPixel(top1);
167
		widget.setRedraw(true);
168
	}
169
	
170
	private int getHeightOfAllLines(StyledText styledText) {
171
		int height= 0;
172
		int lineCount= styledText.getLineCount();
173
		for (int i= 0; i < lineCount; i++)
174
			height= height + styledText.getLineHeight(styledText.getOffsetAtLine(i));
175
		return height;
176
	}
177
	
178
	protected abstract void doFormatPreview();
179
180
	private static int getPositiveIntValue(String string, int defaultValue) {
181
	    try {
182
	        int i= Integer.parseInt(string);
183
	        if (i >= 0) {
184
	            return i;
185
	        }
186
	    } catch (NumberFormatException e) {
187
	    }
188
	    return defaultValue;
189
	}		
190
	
191
	public final Map getWorkingValues() {
192
		return fWorkingValues;
193
	}
194
	
195
	public final void setWorkingValues(Map workingValues) {
196
		fWorkingValues= workingValues;
197
	}
198
}

Return to bug 148582