2 * Copyright 2000-2015 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.psi.codeStyle.presentation;
18 import com.intellij.openapi.application.ApplicationBundle;
19 import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider;
20 import com.intellij.util.containers.ContainerUtil;
21 import com.intellij.util.containers.ContainerUtil.ImmutableMapBuilder;
22 import org.jetbrains.annotations.NotNull;
23 import org.jetbrains.annotations.Nullable;
24 import static com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable.*;
26 import java.util.Collections;
27 import java.util.List;
34 public class CodeStyleSettingPresentation {
36 public static class SettingsGroup {
38 public final String name;
40 public SettingsGroup(@Nullable String name) {
45 public boolean equals(Object o) {
46 if (o instanceof SettingsGroup) {
47 SettingsGroup other = (SettingsGroup) o;
48 return name != null && name.equals(other.name);
55 public int hashCode() {
56 return name == null ? 0 : name.hashCode();
59 public boolean isNull() {
65 protected String myFieldName;
68 protected String myUiName;
70 public CodeStyleSettingPresentation(@NotNull String fieldName, @NotNull String uiName) {
71 myFieldName = fieldName;
76 public String getFieldName() {
81 public String getUiName() {
85 public void setUiName(@NotNull String newName) {
90 public String getValueUiName(@NotNull Object value) {
91 return value.toString();
95 public boolean equals(Object o) {
96 return (o instanceof CodeStyleSettingPresentation) && ((CodeStyleSettingPresentation)o).getFieldName().equals(getFieldName());
100 public int hashCode() {
101 return myFieldName.hashCode();
104 protected static void putGroupTop(@NotNull Map<CodeStyleSettingPresentation.SettingsGroup, List<CodeStyleSettingPresentation>> result,
105 @NotNull String fieldName,
106 @NotNull String uiName, int[] values, String[] valueUiNames) {
107 result.put(new SettingsGroup(null), ContainerUtil.<CodeStyleSettingPresentation>immutableList(
108 new CodeStyleSelectSettingPresentation(fieldName, uiName, values, valueUiNames)
112 protected static final Map<SettingsGroup, List<CodeStyleSettingPresentation>> BLANK_LINES_STANDARD_SETTINGS;
113 protected static final Map<SettingsGroup, List<CodeStyleSettingPresentation>> SPACING_STANDARD_SETTINGS;
114 protected static final Map<SettingsGroup, List<CodeStyleSettingPresentation>> WRAPPING_AND_BRACES_STANDARD_SETTINGS;
115 protected static final Map<SettingsGroup, List<CodeStyleSettingPresentation>> INDENT_STANDARD_SETTINGS;
118 //-----------------------------------BLANK_LINES_SETTINGS-----------------------------------------------------
120 Map<SettingsGroup, List<CodeStyleSettingPresentation>> result = ContainerUtil.newLinkedHashMap();
121 result.put(new SettingsGroup(BLANK_LINES_KEEP), ContainerUtil.immutableList(
122 new CodeStyleSettingPresentation("KEEP_BLANK_LINES_IN_DECLARATIONS",
123 ApplicationBundle.message("editbox.keep.blanklines.in.declarations")),
124 new CodeStyleSettingPresentation("KEEP_BLANK_LINES_IN_CODE", ApplicationBundle.message("editbox.keep.blanklines.in.code")),
125 new CodeStyleSettingPresentation("KEEP_BLANK_LINES_BEFORE_RBRACE",
126 ApplicationBundle.message("editbox.keep.blanklines.before.rbrace"))
129 result.put(new SettingsGroup(BLANK_LINES), ContainerUtil.immutableList(
130 new CodeStyleSettingPresentation("BLANK_LINES_BEFORE_PACKAGE",
131 ApplicationBundle.message("editbox.blanklines.before.package.statement")),
132 new CodeStyleSettingPresentation("BLANK_LINES_AFTER_PACKAGE",
133 ApplicationBundle.message("editbox.blanklines.after.package.statement")),
134 new CodeStyleSettingPresentation("BLANK_LINES_BEFORE_IMPORTS", ApplicationBundle.message("editbox.blanklines.before.imports")),
135 new CodeStyleSettingPresentation("BLANK_LINES_AFTER_IMPORTS", ApplicationBundle.message("editbox.blanklines.after.imports")),
136 new CodeStyleSettingPresentation("BLANK_LINES_AROUND_CLASS", ApplicationBundle.message("editbox.blanklines.around.class")),
137 new CodeStyleSettingPresentation("BLANK_LINES_AFTER_CLASS_HEADER",
138 ApplicationBundle.message("editbox.blanklines.after.class.header")),
139 new CodeStyleSettingPresentation("BLANK_LINES_AFTER_ANONYMOUS_CLASS_HEADER",
140 ApplicationBundle.message("editbox.blanklines.after.anonymous.class.header")),
141 new CodeStyleSettingPresentation("BLANK_LINES_AROUND_FIELD_IN_INTERFACE", "Around field in interface:"),
142 //TODO why is this not loaded from bundle??
143 new CodeStyleSettingPresentation("BLANK_LINES_AROUND_FIELD", ApplicationBundle.message("editbox.blanklines.around.field")),
144 new CodeStyleSettingPresentation("BLANK_LINES_AROUND_METHOD_IN_INTERFACE", "Around method in interface:"),
145 //TODO why is this not loaded from bundle??
146 new CodeStyleSettingPresentation("BLANK_LINES_AROUND_METHOD", ApplicationBundle.message("editbox.blanklines.around.method")),
147 new CodeStyleSettingPresentation("BLANK_LINES_BEFORE_METHOD_BODY",
148 ApplicationBundle.message("editbox.blanklines.before.method.body"))
150 BLANK_LINES_STANDARD_SETTINGS = Collections.unmodifiableMap(result);
152 //-----------------------------------SPACING_SETTINGS-----------------------------------------------------
154 result = ContainerUtil.newLinkedHashMap();
155 result.put(new SettingsGroup(SPACES_BEFORE_PARENTHESES), ContainerUtil.immutableList(
156 new CodeStyleSettingPresentation("SPACE_BEFORE_METHOD_PARENTHESES",
157 ApplicationBundle.message("checkbox.spaces.method.declaration.parentheses")),
158 new CodeStyleSettingPresentation("SPACE_BEFORE_METHOD_CALL_PARENTHESES",
159 ApplicationBundle.message("checkbox.spaces.method.call.parentheses")),
160 new CodeStyleSettingPresentation("SPACE_BEFORE_IF_PARENTHESES", ApplicationBundle.message("checkbox.spaces.if.parentheses")),
161 new CodeStyleSettingPresentation("SPACE_BEFORE_FOR_PARENTHESES", ApplicationBundle.message("checkbox.spaces.for.parentheses")),
162 new CodeStyleSettingPresentation("SPACE_BEFORE_WHILE_PARENTHESES",
163 ApplicationBundle.message("checkbox.spaces.while.parentheses")),
164 new CodeStyleSettingPresentation("SPACE_BEFORE_SWITCH_PARENTHESES",
165 ApplicationBundle.message("checkbox.spaces.switch.parentheses")),
166 new CodeStyleSettingPresentation("SPACE_BEFORE_TRY_PARENTHESES", ApplicationBundle.message("checkbox.spaces.try.parentheses")),
167 new CodeStyleSettingPresentation("SPACE_BEFORE_CATCH_PARENTHESES",
168 ApplicationBundle.message("checkbox.spaces.catch.parentheses")),
169 new CodeStyleSettingPresentation("SPACE_BEFORE_SYNCHRONIZED_PARENTHESES",
170 ApplicationBundle.message("checkbox.spaces.synchronized.parentheses")),
171 new CodeStyleSettingPresentation("SPACE_BEFORE_ANOTATION_PARAMETER_LIST",
172 ApplicationBundle.message("checkbox.spaces.annotation.parameters"))
175 result.put(new SettingsGroup(SPACES_AROUND_OPERATORS), ContainerUtil.immutableList(
176 new CodeStyleSettingPresentation("SPACE_AROUND_ASSIGNMENT_OPERATORS",
177 ApplicationBundle.message("checkbox.spaces.assignment.operators")),
178 new CodeStyleSettingPresentation("SPACE_AROUND_LOGICAL_OPERATORS",
179 ApplicationBundle.message("checkbox.spaces.logical.operators")),
180 new CodeStyleSettingPresentation("SPACE_AROUND_EQUALITY_OPERATORS",
181 ApplicationBundle.message("checkbox.spaces.equality.operators")),
182 new CodeStyleSettingPresentation("SPACE_AROUND_RELATIONAL_OPERATORS",
183 ApplicationBundle.message("checkbox.spaces.relational.operators")),
184 new CodeStyleSettingPresentation("SPACE_AROUND_BITWISE_OPERATORS",
185 ApplicationBundle.message("checkbox.spaces.bitwise.operators")),
186 new CodeStyleSettingPresentation("SPACE_AROUND_ADDITIVE_OPERATORS",
187 ApplicationBundle.message("checkbox.spaces.additive.operators")),
188 new CodeStyleSettingPresentation("SPACE_AROUND_MULTIPLICATIVE_OPERATORS",
189 ApplicationBundle.message("checkbox.spaces.multiplicative.operators")),
190 new CodeStyleSettingPresentation("SPACE_AROUND_SHIFT_OPERATORS", ApplicationBundle.message("checkbox.spaces.shift.operators")),
191 new CodeStyleSettingPresentation("SPACE_AROUND_UNARY_OPERATOR",
192 ApplicationBundle.message("checkbox.spaces.around.unary.operator")),
193 new CodeStyleSettingPresentation("SPACE_AROUND_LAMBDA_ARROW", ApplicationBundle.message("checkbox.spaces.around.lambda.arrow")),
194 new CodeStyleSettingPresentation("SPACE_AROUND_METHOD_REF_DBL_COLON",
195 ApplicationBundle.message("checkbox.spaces.around.method.ref.dbl.colon.arrow"))
198 result.put(new SettingsGroup(SPACES_BEFORE_LEFT_BRACE), ContainerUtil.immutableList(
199 new CodeStyleSettingPresentation("SPACE_BEFORE_CLASS_LBRACE", ApplicationBundle.message("checkbox.spaces.class.left.brace")),
200 new CodeStyleSettingPresentation("SPACE_BEFORE_METHOD_LBRACE", ApplicationBundle.message("checkbox.spaces.method.left.brace")),
201 new CodeStyleSettingPresentation("SPACE_BEFORE_IF_LBRACE", ApplicationBundle.message("checkbox.spaces.if.left.brace")),
202 new CodeStyleSettingPresentation("SPACE_BEFORE_ELSE_LBRACE", ApplicationBundle.message("checkbox.spaces.else.left.brace")),
203 new CodeStyleSettingPresentation("SPACE_BEFORE_FOR_LBRACE", ApplicationBundle.message("checkbox.spaces.for.left.brace")),
204 new CodeStyleSettingPresentation("SPACE_BEFORE_WHILE_LBRACE", ApplicationBundle.message("checkbox.spaces.while.left.brace")),
205 new CodeStyleSettingPresentation("SPACE_BEFORE_DO_LBRACE", ApplicationBundle.message("checkbox.spaces.do.left.brace")),
206 new CodeStyleSettingPresentation("SPACE_BEFORE_SWITCH_LBRACE", ApplicationBundle.message("checkbox.spaces.switch.left.brace")),
207 new CodeStyleSettingPresentation("SPACE_BEFORE_TRY_LBRACE", ApplicationBundle.message("checkbox.spaces.try.left.brace")),
208 new CodeStyleSettingPresentation("SPACE_BEFORE_CATCH_LBRACE", ApplicationBundle.message("checkbox.spaces.catch.left.brace")),
209 new CodeStyleSettingPresentation("SPACE_BEFORE_FINALLY_LBRACE",
210 ApplicationBundle.message("checkbox.spaces.finally.left.brace")),
211 new CodeStyleSettingPresentation("SPACE_BEFORE_SYNCHRONIZED_LBRACE",
212 ApplicationBundle.message("checkbox.spaces.synchronized.left.brace")),
213 new CodeStyleSettingPresentation("SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE",
214 ApplicationBundle.message("checkbox.spaces.array.initializer.left.brace")),
215 new CodeStyleSettingPresentation("SPACE_BEFORE_ANNOTATION_ARRAY_INITIALIZER_LBRACE",
216 ApplicationBundle.message("checkbox.spaces.annotation.array.initializer.left.brace"))
219 result.put(new SettingsGroup(SPACES_BEFORE_KEYWORD), ContainerUtil.immutableList(
220 new CodeStyleSettingPresentation("SPACE_BEFORE_ELSE_KEYWORD", ApplicationBundle.message("checkbox.spaces.else.keyword")),
221 new CodeStyleSettingPresentation("SPACE_BEFORE_WHILE_KEYWORD", ApplicationBundle.message("checkbox.spaces.while.keyword")),
222 new CodeStyleSettingPresentation("SPACE_BEFORE_CATCH_KEYWORD", ApplicationBundle.message("checkbox.spaces.catch.keyword")),
223 new CodeStyleSettingPresentation("SPACE_BEFORE_FINALLY_KEYWORD", ApplicationBundle.message("checkbox.spaces.finally.keyword"))
226 result.put(new SettingsGroup(SPACES_WITHIN), ContainerUtil.immutableList(
227 new CodeStyleSettingPresentation("SPACE_WITHIN_BRACES", ApplicationBundle.message("checkbox.spaces.within.braces")),
228 new CodeStyleSettingPresentation("SPACE_WITHIN_BRACKETS", ApplicationBundle.message("checkbox.spaces.within.brackets")),
229 new CodeStyleSettingPresentation("SPACE_WITHIN_ARRAY_INITIALIZER_BRACES",
230 ApplicationBundle.message("checkbox.spaces.within.array.initializer.braces")),
231 new CodeStyleSettingPresentation("SPACE_WITHIN_EMPTY_ARRAY_INITIALIZER_BRACES",
232 ApplicationBundle.message("checkbox.spaces.within.empty.array.initializer.braces")),
233 new CodeStyleSettingPresentation("SPACE_WITHIN_PARENTHESES", ApplicationBundle.message("checkbox.spaces.within.parentheses")),
234 new CodeStyleSettingPresentation("SPACE_WITHIN_METHOD_CALL_PARENTHESES",
235 ApplicationBundle.message("checkbox.spaces.checkbox.spaces.method.call.parentheses")),
236 new CodeStyleSettingPresentation("SPACE_WITHIN_EMPTY_METHOD_CALL_PARENTHESES",
237 ApplicationBundle.message("checkbox.spaces.checkbox.spaces.empty.method.call.parentheses")),
238 new CodeStyleSettingPresentation("SPACE_WITHIN_METHOD_PARENTHESES",
239 ApplicationBundle.message("checkbox.spaces.checkbox.spaces.method.declaration.parentheses")),
240 new CodeStyleSettingPresentation("SPACE_WITHIN_EMPTY_METHOD_PARENTHESES", ApplicationBundle
241 .message("checkbox.spaces.checkbox.spaces.empty.method.declaration.parentheses")),
242 new CodeStyleSettingPresentation("SPACE_WITHIN_IF_PARENTHESES", ApplicationBundle.message("checkbox.spaces.if.parentheses")),
243 new CodeStyleSettingPresentation("SPACE_WITHIN_FOR_PARENTHESES", ApplicationBundle.message("checkbox.spaces.for.parentheses")),
244 new CodeStyleSettingPresentation("SPACE_WITHIN_WHILE_PARENTHESES",
245 ApplicationBundle.message("checkbox.spaces.while.parentheses")),
246 new CodeStyleSettingPresentation("SPACE_WITHIN_SWITCH_PARENTHESES",
247 ApplicationBundle.message("checkbox.spaces.switch.parentheses")),
248 new CodeStyleSettingPresentation("SPACE_WITHIN_TRY_PARENTHESES", ApplicationBundle.message("checkbox.spaces.try.parentheses")),
249 new CodeStyleSettingPresentation("SPACE_WITHIN_CATCH_PARENTHESES",
250 ApplicationBundle.message("checkbox.spaces.catch.parentheses")),
251 new CodeStyleSettingPresentation("SPACE_WITHIN_SYNCHRONIZED_PARENTHESES",
252 ApplicationBundle.message("checkbox.spaces.synchronized.parentheses")),
253 new CodeStyleSettingPresentation("SPACE_WITHIN_CAST_PARENTHESES",
254 ApplicationBundle.message("checkbox.spaces.type.cast.parentheses")),
255 new CodeStyleSettingPresentation("SPACE_WITHIN_ANNOTATION_PARENTHESES",
256 ApplicationBundle.message("checkbox.spaces.annotation.parentheses"))
259 result.put(new SettingsGroup(SPACES_IN_TERNARY_OPERATOR), ContainerUtil.immutableList(
260 new CodeStyleSettingPresentation("SPACE_BEFORE_QUEST", ApplicationBundle.message("checkbox.spaces.before.question")),
261 new CodeStyleSettingPresentation("SPACE_AFTER_QUEST", ApplicationBundle.message("checkbox.spaces.after.question")),
262 new CodeStyleSettingPresentation("SPACE_BEFORE_COLON", ApplicationBundle.message("checkbox.spaces.before.colon")),
263 new CodeStyleSettingPresentation("SPACE_AFTER_COLON", ApplicationBundle.message("checkbox.spaces.after.colon"))
266 result.put(new SettingsGroup(SPACES_WITHIN_TYPE_ARGUMENTS), ContainerUtil.immutableList(
267 new CodeStyleSettingPresentation("SPACE_AFTER_COMMA_IN_TYPE_ARGUMENTS",
268 ApplicationBundle.message("checkbox.spaces.after.comma"))
271 result.put(new SettingsGroup(SPACES_IN_TYPE_ARGUMENTS), ContainerUtil.<CodeStyleSettingPresentation>immutableList());
273 result.put(new SettingsGroup(SPACES_IN_TYPE_PARAMETERS), ContainerUtil.<CodeStyleSettingPresentation>immutableList());
275 result.put(new SettingsGroup(SPACES_OTHER), ContainerUtil.immutableList(
276 new CodeStyleSettingPresentation("SPACE_BEFORE_COMMA", ApplicationBundle.message("checkbox.spaces.before.comma")),
277 new CodeStyleSettingPresentation("SPACE_AFTER_COMMA", ApplicationBundle.message("checkbox.spaces.after.comma")),
278 new CodeStyleSettingPresentation("SPACE_BEFORE_SEMICOLON", ApplicationBundle.message("checkbox.spaces.before.semicolon")),
279 new CodeStyleSettingPresentation("SPACE_AFTER_SEMICOLON", ApplicationBundle.message("checkbox.spaces.after.semicolon")),
280 new CodeStyleSettingPresentation("SPACE_AFTER_TYPE_CAST", ApplicationBundle.message("checkbox.spaces.after.type.cast"))
282 SPACING_STANDARD_SETTINGS = Collections.unmodifiableMap(result);
284 //-----------------------------------WRAPPING_AND_BRACES_SETTINGS-----------------------------------------------------
286 result = ContainerUtil.newLinkedHashMap();
287 result.put(new SettingsGroup(null), ContainerUtil.<CodeStyleSettingPresentation>immutableList(
288 new CodeStyleBoundedIntegerSettingPresentation("RIGHT_MARGIN", ApplicationBundle.message("editbox.right.margin.columns"), 0, 999,
290 ApplicationBundle.message("settings.code.style.default.general"))
293 putGroupTop(result, "WRAP_ON_TYPING", ApplicationBundle.message("wrapping.wrap.on.typing"), WRAP_ON_TYPING_VALUES,
294 WRAP_ON_TYPING_OPTIONS);
296 result.put(new SettingsGroup(WRAPPING_KEEP), ContainerUtil.immutableList(
297 new CodeStyleSettingPresentation("KEEP_LINE_BREAKS", ApplicationBundle.message("wrapping.keep.line.breaks")),
298 new CodeStyleSettingPresentation("KEEP_FIRST_COLUMN_COMMENT",
299 ApplicationBundle.message("wrapping.keep.comment.at.first.column")),
300 new CodeStyleSettingPresentation("KEEP_CONTROL_STATEMENT_IN_ONE_LINE",
301 ApplicationBundle.message("checkbox.keep.when.reformatting.control.statement.in.one.line")),
302 new CodeStyleSettingPresentation("KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE",
303 ApplicationBundle.message("wrapping.keep.multiple.expressions.in.one.line")),
304 new CodeStyleSettingPresentation("KEEP_SIMPLE_BLOCKS_IN_ONE_LINE",
305 ApplicationBundle.message("wrapping.keep.simple.blocks.in.one.line")),
306 new CodeStyleSettingPresentation("KEEP_SIMPLE_METHODS_IN_ONE_LINE",
307 ApplicationBundle.message("wrapping.keep.simple.methods.in.one.line")),
308 new CodeStyleSettingPresentation("KEEP_SIMPLE_CLASSES_IN_ONE_LINE",
309 ApplicationBundle.message("wrapping.keep.simple.classes.in.one.line"))
312 result.put(new SettingsGroup(null), ContainerUtil.immutableList(
313 new CodeStyleSettingPresentation("WRAP_LONG_LINES", ApplicationBundle.message("wrapping.long.lines"))
316 result.put(new SettingsGroup(WRAPPING_COMMENTS), ContainerUtil.immutableList(
317 new CodeStyleSettingPresentation("WRAP_COMMENTS", ApplicationBundle.message("wrapping.comments.wrap.at.right.margin"))
320 result.put(new SettingsGroup(WRAPPING_BRACES), ContainerUtil.<CodeStyleSettingPresentation>immutableList(
321 new CodeStyleSelectSettingPresentation("CLASS_BRACE_STYLE",
322 ApplicationBundle.message("wrapping.brace.placement.class.declaration"),
323 BRACE_PLACEMENT_VALUES, BRACE_PLACEMENT_OPTIONS),
324 new CodeStyleSelectSettingPresentation("METHOD_BRACE_STYLE",
325 ApplicationBundle.message("wrapping.brace.placement.method.declaration"),
326 BRACE_PLACEMENT_VALUES, BRACE_PLACEMENT_OPTIONS),
327 new CodeStyleSelectSettingPresentation("BRACE_STYLE", ApplicationBundle.message("wrapping.brace.placement.other"),
328 BRACE_PLACEMENT_VALUES, BRACE_PLACEMENT_OPTIONS)
332 putGroupTop(result, "EXTENDS_LIST_WRAP", WRAPPING_EXTENDS_LIST, WRAP_VALUES, WRAP_OPTIONS);
333 result.put(new SettingsGroup(WRAPPING_EXTENDS_LIST), ContainerUtil.immutableList(
334 new CodeStyleSettingPresentation("ALIGN_MULTILINE_EXTENDS_LIST", ApplicationBundle.message("wrapping.align.when.multiline"))
337 putGroupTop(result, "EXTENDS_KEYWORD_WRAP", WRAPPING_EXTENDS_KEYWORD, WRAP_VALUES_FOR_SINGLETON, WRAP_OPTIONS_FOR_SINGLETON);
339 putGroupTop(result, "THROWS_LIST_WRAP", WRAPPING_THROWS_LIST, WRAP_VALUES, WRAP_OPTIONS);
340 result.put(new SettingsGroup(WRAPPING_THROWS_LIST), ContainerUtil.immutableList(
341 new CodeStyleSettingPresentation("ALIGN_MULTILINE_THROWS_LIST", ApplicationBundle.message("wrapping.align.when.multiline")),
342 new CodeStyleSettingPresentation("ALIGN_THROWS_KEYWORD", ApplicationBundle.message("wrapping.align.throws.keyword"))
345 putGroupTop(result, "THROWS_KEYWORD_WRAP", WRAPPING_THROWS_KEYWORD, WRAP_VALUES_FOR_SINGLETON, WRAP_OPTIONS_FOR_SINGLETON);
347 putGroupTop(result, "METHOD_PARAMETERS_WRAP", WRAPPING_METHOD_PARAMETERS, WRAP_VALUES, WRAP_OPTIONS);
348 result.put(new SettingsGroup(WRAPPING_METHOD_PARAMETERS), ContainerUtil.immutableList(
349 new CodeStyleSettingPresentation("ALIGN_MULTILINE_PARAMETERS", ApplicationBundle.message("wrapping.align.when.multiline")),
350 new CodeStyleSettingPresentation("METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE",
351 ApplicationBundle.message("wrapping.new.line.after.lpar")),
352 new CodeStyleSettingPresentation("METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE",
353 ApplicationBundle.message("wrapping.rpar.on.new.line"))
356 putGroupTop(result, "CALL_PARAMETERS_WRAP", WRAPPING_METHOD_ARGUMENTS_WRAPPING, WRAP_VALUES, WRAP_OPTIONS);
357 result.put(new SettingsGroup(WRAPPING_METHOD_ARGUMENTS_WRAPPING), ContainerUtil.immutableList(
358 new CodeStyleSettingPresentation("ALIGN_MULTILINE_PARAMETERS_IN_CALLS",
359 ApplicationBundle.message("wrapping.align.when.multiline")),
360 new CodeStyleSettingPresentation("PREFER_PARAMETERS_WRAP",
361 ApplicationBundle.message("wrapping.take.priority.over.call.chain.wrapping")),
362 new CodeStyleSettingPresentation("CALL_PARAMETERS_LPAREN_ON_NEXT_LINE",
363 ApplicationBundle.message("wrapping.new.line.after.lpar")),
364 new CodeStyleSettingPresentation("CALL_PARAMETERS_RPAREN_ON_NEXT_LINE", ApplicationBundle.message("wrapping.rpar.on.new.line"))
367 result.put(new SettingsGroup(WRAPPING_METHOD_PARENTHESES), ContainerUtil.immutableList(
368 new CodeStyleSettingPresentation("ALIGN_MULTILINE_METHOD_BRACKETS", ApplicationBundle.message("wrapping.align.when.multiline"))
371 putGroupTop(result, "METHOD_CALL_CHAIN_WRAP", WRAPPING_CALL_CHAIN, WRAP_VALUES, WRAP_OPTIONS);
372 result.put(new SettingsGroup(WRAPPING_CALL_CHAIN), ContainerUtil.immutableList(
373 new CodeStyleSettingPresentation("WRAP_FIRST_METHOD_IN_CALL_CHAIN",
374 ApplicationBundle.message("wrapping.chained.method.call.first.on.new.line")),
375 new CodeStyleSettingPresentation("ALIGN_MULTILINE_CHAINED_METHODS", ApplicationBundle.message("wrapping.align.when.multiline"))
378 result.put(new SettingsGroup(WRAPPING_IF_STATEMENT), ContainerUtil.immutableList(
379 new CodeStyleSelectSettingPresentation("IF_BRACE_FORCE", ApplicationBundle.message("wrapping.force.braces"), BRACE_VALUES,
381 new CodeStyleSettingPresentation("ELSE_ON_NEW_LINE", ApplicationBundle.message("wrapping.else.on.new.line")),
382 new CodeStyleSettingPresentation("SPECIAL_ELSE_IF_TREATMENT",
383 ApplicationBundle.message("wrapping.special.else.if.braces.treatment"))
386 putGroupTop(result, "FOR_STATEMENT_WRAP", WRAPPING_FOR_STATEMENT, WRAP_VALUES, WRAP_OPTIONS);
387 result.put(new SettingsGroup(WRAPPING_FOR_STATEMENT), ContainerUtil.immutableList(
388 new CodeStyleSettingPresentation("ALIGN_MULTILINE_FOR", ApplicationBundle.message("wrapping.align.when.multiline")),
389 new CodeStyleSettingPresentation("FOR_STATEMENT_LPAREN_ON_NEXT_LINE",
390 ApplicationBundle.message("wrapping.new.line.after.lpar")),
391 new CodeStyleSettingPresentation("FOR_STATEMENT_RPAREN_ON_NEXT_LINE", ApplicationBundle.message("wrapping.rpar.on.new.line")),
392 new CodeStyleSelectSettingPresentation("FOR_BRACE_FORCE", ApplicationBundle.message("wrapping.force.braces"), BRACE_VALUES,
396 result.put(new SettingsGroup(WRAPPING_WHILE_STATEMENT), ContainerUtil.<CodeStyleSettingPresentation>immutableList(
397 new CodeStyleSelectSettingPresentation("WHILE_BRACE_FORCE", ApplicationBundle.message("wrapping.force.braces"), BRACE_VALUES,
401 result.put(new SettingsGroup(WRAPPING_DOWHILE_STATEMENT), ContainerUtil.immutableList(
402 new CodeStyleSelectSettingPresentation("DOWHILE_BRACE_FORCE", ApplicationBundle.message("wrapping.force.braces"), BRACE_VALUES,
404 new CodeStyleSettingPresentation("WHILE_ON_NEW_LINE", ApplicationBundle.message("wrapping.while.on.new.line"))
407 result.put(new SettingsGroup(WRAPPING_SWITCH_STATEMENT), ContainerUtil.immutableList(
408 new CodeStyleSettingPresentation("INDENT_CASE_FROM_SWITCH", ApplicationBundle.message("wrapping.indent.case.from.switch")),
409 new CodeStyleSettingPresentation("INDENT_BREAK_FROM_CASE", ApplicationBundle.message("wrapping.indent.break.from.case"))
412 putGroupTop(result, "RESOURCE_LIST_WRAP", WRAPPING_TRY_RESOURCE_LIST, WRAP_VALUES, WRAP_OPTIONS);
413 result.put(new SettingsGroup(WRAPPING_TRY_RESOURCE_LIST), ContainerUtil.immutableList(
414 new CodeStyleSettingPresentation("ALIGN_MULTILINE_RESOURCES", ApplicationBundle.message("wrapping.align.when.multiline")),
415 new CodeStyleSettingPresentation("RESOURCE_LIST_LPAREN_ON_NEXT_LINE",
416 ApplicationBundle.message("wrapping.new.line.after.lpar")),
417 new CodeStyleSettingPresentation("RESOURCE_LIST_RPAREN_ON_NEXT_LINE", ApplicationBundle.message("wrapping.rpar.on.new.line"))
420 result.put(new SettingsGroup(WRAPPING_TRY_STATEMENT), ContainerUtil.immutableList(
421 new CodeStyleSettingPresentation("CATCH_ON_NEW_LINE", ApplicationBundle.message("wrapping.catch.on.new.line")),
422 new CodeStyleSettingPresentation("FINALLY_ON_NEW_LINE", ApplicationBundle.message("wrapping.finally.on.new.line"))
425 putGroupTop(result, "BINARY_OPERATION_WRAP", WRAPPING_BINARY_OPERATION, WRAP_VALUES, WRAP_OPTIONS);
426 result.put(new SettingsGroup(WRAPPING_BINARY_OPERATION), ContainerUtil.immutableList(
427 new CodeStyleSettingPresentation("ALIGN_MULTILINE_BINARY_OPERATION",
428 ApplicationBundle.message("wrapping.align.when.multiline")),
429 new CodeStyleSettingPresentation("BINARY_OPERATION_SIGN_ON_NEXT_LINE",
430 ApplicationBundle.message("wrapping.operation.sign.on.next.line")),
431 new CodeStyleSettingPresentation("ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION",
432 ApplicationBundle.message("wrapping.align.parenthesised.when.multiline")),
433 new CodeStyleSettingPresentation("PARENTHESES_EXPRESSION_LPAREN_WRAP",
434 ApplicationBundle.message("wrapping.new.line.after.lpar")),
435 new CodeStyleSettingPresentation("PARENTHESES_EXPRESSION_RPAREN_WRAP", ApplicationBundle.message("wrapping.rpar.on.new.line"))
438 putGroupTop(result, "ASSIGNMENT_WRAP", WRAPPING_ASSIGNMENT, WRAP_VALUES, WRAP_OPTIONS);
439 result.put(new SettingsGroup(WRAPPING_ASSIGNMENT), ContainerUtil.immutableList(
440 new CodeStyleSettingPresentation("ALIGN_MULTILINE_ASSIGNMENT", ApplicationBundle.message("wrapping.align.when.multiline")),
441 new CodeStyleSettingPresentation("PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE",
442 ApplicationBundle.message("wrapping.assignment.sign.on.next.line"))
445 result.put(new SettingsGroup(WRAPPING_FIELDS_VARIABLES_GROUPS), ContainerUtil.immutableList(
446 new CodeStyleSettingPresentation("ALIGN_GROUP_FIELD_DECLARATIONS",
447 ApplicationBundle.message("wrapping.align.fields.in.columns")),
448 new CodeStyleSettingPresentation("ALIGN_CONSECUTIVE_VARIABLE_DECLARATIONS",
449 ApplicationBundle.message("wrapping.align.variables.in.columns"))
452 putGroupTop(result, "TERNARY_OPERATION_WRAP", WRAPPING_TERNARY_OPERATION, WRAP_VALUES, WRAP_OPTIONS);
453 result.put(new SettingsGroup(WRAPPING_TERNARY_OPERATION), ContainerUtil.immutableList(
454 new CodeStyleSettingPresentation("ALIGN_MULTILINE_TERNARY_OPERATION",
455 ApplicationBundle.message("wrapping.align.when.multiline")),
456 new CodeStyleSettingPresentation("TERNARY_OPERATION_SIGNS_ON_NEXT_LINE",
457 ApplicationBundle.message("wrapping.quest.and.colon.signs.on.next.line"))
460 putGroupTop(result, "ARRAY_INITIALIZER_WRAP", WRAPPING_ARRAY_INITIALIZER, WRAP_VALUES, WRAP_OPTIONS);
461 result.put(new SettingsGroup(WRAPPING_ARRAY_INITIALIZER), ContainerUtil.immutableList(
462 new CodeStyleSettingPresentation("ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION",
463 ApplicationBundle.message("wrapping.align.when.multiline")),
464 new CodeStyleSettingPresentation("ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE",
465 ApplicationBundle.message("wrapping.new.line.after.lbrace")),
466 new CodeStyleSettingPresentation("ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE",
467 ApplicationBundle.message("wrapping.rbrace.on.new.line"))
470 result.put(new SettingsGroup(WRAPPING_MODIFIER_LIST), ContainerUtil.immutableList(
471 new CodeStyleSettingPresentation("MODIFIER_LIST_WRAP", ApplicationBundle.message("wrapping.after.modifier.list"))
474 putGroupTop(result, "ASSERT_STATEMENT_WRAP", WRAPPING_ASSERT_STATEMENT, WRAP_VALUES, WRAP_OPTIONS);
475 result.put(new SettingsGroup(WRAPPING_ASSERT_STATEMENT), ContainerUtil.immutableList(
476 new CodeStyleSettingPresentation("ASSERT_STATEMENT_COLON_ON_NEXT_LINE",
477 ApplicationBundle.message("wrapping.colon.signs.on.next.line"))
480 putGroupTop(result, "ENUM_CONSTANTS_WRAP", ApplicationBundle.message("wrapping.enum.constants"), WRAP_VALUES, WRAP_OPTIONS);
481 putGroupTop(result, "CLASS_ANNOTATION_WRAP", ApplicationBundle.message("wrapping.classes.annotation"), WRAP_VALUES, WRAP_OPTIONS);
482 putGroupTop(result, "METHOD_ANNOTATION_WRAP", ApplicationBundle.message("wrapping.methods.annotation"), WRAP_VALUES, WRAP_OPTIONS);
483 putGroupTop(result, "FIELD_ANNOTATION_WRAP", ApplicationBundle.message("wrapping.fields.annotation"), WRAP_VALUES, WRAP_OPTIONS);
484 putGroupTop(result, "PARAMETER_ANNOTATION_WRAP", ApplicationBundle.message("wrapping.parameters.annotation"), WRAP_VALUES, WRAP_OPTIONS);
485 putGroupTop(result, "VARIABLE_ANNOTATION_WRAP", ApplicationBundle.message("wrapping.local.variables.annotation"), WRAP_VALUES,
487 WRAPPING_AND_BRACES_STANDARD_SETTINGS = Collections.unmodifiableMap(result);
489 //-----------------------------------INDENT_SETTINGS-----------------------------------------------------
491 result = ContainerUtil.newLinkedHashMap();
492 result.put(new SettingsGroup(null), ContainerUtil.immutableList(
493 new CodeStyleSettingPresentation("INDENT_SIZE", ApplicationBundle.message("editbox.indent.indent"))
495 result.put(new SettingsGroup(null), ContainerUtil.immutableList(
496 new CodeStyleSettingPresentation("CONTINUATION_INDENT_SIZE", ApplicationBundle.message("editbox.indent.continuation.indent"))
498 result.put(new SettingsGroup(null), ContainerUtil.immutableList(
499 new CodeStyleSettingPresentation("TAB_SIZE", ApplicationBundle.message("editbox.indent.tab.size"))
501 INDENT_STANDARD_SETTINGS = Collections.unmodifiableMap(result);
505 * Returns an immutable map containing all standard settings in a mapping of type (group -> settings contained in the group).
506 * Notice that lists containing settings for a specific group are also immutable. Use copies to make modifications.
507 * @param settingsType type to get standard settings for
508 * @return mapping setting groups to contained setting presentations
511 public static Map<SettingsGroup, List<CodeStyleSettingPresentation>> getStandardSettings(LanguageCodeStyleSettingsProvider.SettingsType settingsType) {
512 switch (settingsType) {
513 case BLANK_LINES_SETTINGS:
514 return BLANK_LINES_STANDARD_SETTINGS;
515 case SPACING_SETTINGS:
516 return SPACING_STANDARD_SETTINGS;
517 case WRAPPING_AND_BRACES_SETTINGS:
518 return WRAPPING_AND_BRACES_STANDARD_SETTINGS;
519 case INDENT_SETTINGS:
520 return INDENT_STANDARD_SETTINGS;
521 case LANGUAGE_SPECIFIC:
523 return ContainerUtil.newLinkedHashMap();