Added code style setting presentation to space settings
[idea/community.git] / platform / lang-api / src / com / intellij / psi / codeStyle / presentation / CodeStyleSettingPresentation.java
1 /*
2  * Copyright 2000-2015 JetBrains s.r.o.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package com.intellij.psi.codeStyle.presentation;
17
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.*;
25
26 import java.util.Collections;
27 import java.util.List;
28 import java.util.Map;
29
30 /**
31  * @author Roman.Shein
32  * @since 15.09.2015.
33  */
34 public class CodeStyleSettingPresentation {
35
36   public static class SettingsGroup {
37     @Nullable
38     public final String name;
39
40     public SettingsGroup(@Nullable String name) {
41       this.name = name;
42     }
43
44     @Override
45     public boolean equals(Object o) {
46       if (o instanceof SettingsGroup) {
47         SettingsGroup other = (SettingsGroup) o;
48         return name != null && name.equals(other.name);
49       } else {
50         return false;
51       }
52     }
53
54     @Override
55     public int hashCode() {
56       return name == null ? 0 : name.hashCode();
57     }
58
59     public boolean isNull() {
60       return name == null;
61     }
62   }
63
64   @NotNull
65   protected String myFieldName;
66
67   @NotNull
68   protected String myUiName;
69
70   public CodeStyleSettingPresentation(@NotNull String fieldName, @NotNull String uiName) {
71     myFieldName = fieldName;
72     myUiName = uiName;
73   }
74
75   @NotNull
76   public String getFieldName() {
77     return myFieldName;
78   }
79
80   @NotNull
81   public String getUiName() {
82     return myUiName;
83   }
84
85   public void setUiName(@NotNull String newName) {
86     myUiName = newName;
87   }
88
89   @NotNull
90   public String getValueUiName(@NotNull Object value) {
91     return value.toString();
92   }
93
94   @Override
95   public boolean equals(Object o) {
96     return (o instanceof CodeStyleSettingPresentation) && ((CodeStyleSettingPresentation)o).getFieldName().equals(getFieldName());
97   }
98
99   @Override
100   public int hashCode() {
101     return myFieldName.hashCode();
102   }
103
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)
109     ));
110   }
111
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;
116   static {
117
118     //-----------------------------------BLANK_LINES_SETTINGS-----------------------------------------------------
119
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"))
127     ));
128
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"))
149     ));
150     BLANK_LINES_STANDARD_SETTINGS = Collections.unmodifiableMap(result);
151
152     //-----------------------------------SPACING_SETTINGS-----------------------------------------------------
153
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"))
173     ));
174
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"))
196     ));
197
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"))
217     ));
218
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"))
224     ));
225
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"))
257     ));
258
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"))
264     ));
265
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"))
269     ));
270
271     result.put(new SettingsGroup(SPACES_IN_TYPE_ARGUMENTS), ContainerUtil.immutableList(
272       new CodeStyleSettingPresentation("SPACE_BEFORE_TYPE_PARAMETER_LIST", ApplicationBundle.message("checkbox.spaces.before.opening.angle.bracket"))
273     ));
274
275     result.put(new SettingsGroup(SPACES_IN_TYPE_PARAMETERS), ContainerUtil.<CodeStyleSettingPresentation>immutableList());
276
277     result.put(new SettingsGroup(SPACES_OTHER), ContainerUtil.immutableList(
278       new CodeStyleSettingPresentation("SPACE_BEFORE_COMMA", ApplicationBundle.message("checkbox.spaces.before.comma")),
279       new CodeStyleSettingPresentation("SPACE_AFTER_COMMA", ApplicationBundle.message("checkbox.spaces.after.comma")),
280       new CodeStyleSettingPresentation("SPACE_BEFORE_SEMICOLON", ApplicationBundle.message("checkbox.spaces.before.semicolon")),
281       new CodeStyleSettingPresentation("SPACE_AFTER_SEMICOLON", ApplicationBundle.message("checkbox.spaces.after.semicolon")),
282       new CodeStyleSettingPresentation("SPACE_AFTER_TYPE_CAST", ApplicationBundle.message("checkbox.spaces.after.type.cast"))
283     ));
284     SPACING_STANDARD_SETTINGS = Collections.unmodifiableMap(result);
285
286     //-----------------------------------WRAPPING_AND_BRACES_SETTINGS-----------------------------------------------------
287
288     result = ContainerUtil.newLinkedHashMap();
289     result.put(new SettingsGroup(null), ContainerUtil.<CodeStyleSettingPresentation>immutableList(
290       new CodeStyleBoundedIntegerSettingPresentation("RIGHT_MARGIN", ApplicationBundle.message("editbox.right.margin.columns"), 0, 999,
291                                                      -1,
292                                                      ApplicationBundle.message("settings.code.style.default.general"))
293     ));
294
295     putGroupTop(result, "WRAP_ON_TYPING", ApplicationBundle.message("wrapping.wrap.on.typing"), WRAP_ON_TYPING_VALUES,
296                 WRAP_ON_TYPING_OPTIONS);
297
298     result.put(new SettingsGroup(WRAPPING_KEEP), ContainerUtil.immutableList(
299       new CodeStyleSettingPresentation("KEEP_LINE_BREAKS", ApplicationBundle.message("wrapping.keep.line.breaks")),
300       new CodeStyleSettingPresentation("KEEP_FIRST_COLUMN_COMMENT",
301                                        ApplicationBundle.message("wrapping.keep.comment.at.first.column")),
302       new CodeStyleSettingPresentation("KEEP_CONTROL_STATEMENT_IN_ONE_LINE",
303                                        ApplicationBundle.message("checkbox.keep.when.reformatting.control.statement.in.one.line")),
304       new CodeStyleSettingPresentation("KEEP_MULTIPLE_EXPRESSIONS_IN_ONE_LINE",
305                                        ApplicationBundle.message("wrapping.keep.multiple.expressions.in.one.line")),
306       new CodeStyleSettingPresentation("KEEP_SIMPLE_BLOCKS_IN_ONE_LINE",
307                                        ApplicationBundle.message("wrapping.keep.simple.blocks.in.one.line")),
308       new CodeStyleSettingPresentation("KEEP_SIMPLE_METHODS_IN_ONE_LINE",
309                                        ApplicationBundle.message("wrapping.keep.simple.methods.in.one.line")),
310       new CodeStyleSettingPresentation("KEEP_SIMPLE_CLASSES_IN_ONE_LINE",
311                                        ApplicationBundle.message("wrapping.keep.simple.classes.in.one.line"))
312     ));
313
314     result.put(new SettingsGroup(null), ContainerUtil.immutableList(
315       new CodeStyleSettingPresentation("WRAP_LONG_LINES", ApplicationBundle.message("wrapping.long.lines"))
316     ));
317
318     result.put(new SettingsGroup(WRAPPING_COMMENTS), ContainerUtil.immutableList(
319       new CodeStyleSettingPresentation("WRAP_COMMENTS", ApplicationBundle.message("wrapping.comments.wrap.at.right.margin"))
320     ));
321
322     result.put(new SettingsGroup(WRAPPING_BRACES), ContainerUtil.<CodeStyleSettingPresentation>immutableList(
323       new CodeStyleSelectSettingPresentation("CLASS_BRACE_STYLE",
324                                              ApplicationBundle.message("wrapping.brace.placement.class.declaration"),
325                                              BRACE_PLACEMENT_VALUES, BRACE_PLACEMENT_OPTIONS),
326       new CodeStyleSelectSettingPresentation("METHOD_BRACE_STYLE",
327                                              ApplicationBundle.message("wrapping.brace.placement.method.declaration"),
328                                              BRACE_PLACEMENT_VALUES, BRACE_PLACEMENT_OPTIONS),
329       new CodeStyleSelectSettingPresentation("BRACE_STYLE", ApplicationBundle.message("wrapping.brace.placement.other"),
330                                              BRACE_PLACEMENT_VALUES, BRACE_PLACEMENT_OPTIONS)
331
332     ));
333
334     putGroupTop(result, "EXTENDS_LIST_WRAP", WRAPPING_EXTENDS_LIST, WRAP_VALUES, WRAP_OPTIONS);
335     result.put(new SettingsGroup(WRAPPING_EXTENDS_LIST), ContainerUtil.immutableList(
336       new CodeStyleSettingPresentation("ALIGN_MULTILINE_EXTENDS_LIST", ApplicationBundle.message("wrapping.align.when.multiline"))
337     ));
338
339     putGroupTop(result, "EXTENDS_KEYWORD_WRAP", WRAPPING_EXTENDS_KEYWORD, WRAP_VALUES_FOR_SINGLETON, WRAP_OPTIONS_FOR_SINGLETON);
340
341     putGroupTop(result, "THROWS_LIST_WRAP", WRAPPING_THROWS_LIST, WRAP_VALUES, WRAP_OPTIONS);
342     result.put(new SettingsGroup(WRAPPING_THROWS_LIST), ContainerUtil.immutableList(
343       new CodeStyleSettingPresentation("ALIGN_MULTILINE_THROWS_LIST", ApplicationBundle.message("wrapping.align.when.multiline")),
344       new CodeStyleSettingPresentation("ALIGN_THROWS_KEYWORD", ApplicationBundle.message("wrapping.align.throws.keyword"))
345     ));
346
347     putGroupTop(result, "THROWS_KEYWORD_WRAP", WRAPPING_THROWS_KEYWORD, WRAP_VALUES_FOR_SINGLETON, WRAP_OPTIONS_FOR_SINGLETON);
348
349     putGroupTop(result, "METHOD_PARAMETERS_WRAP", WRAPPING_METHOD_PARAMETERS, WRAP_VALUES, WRAP_OPTIONS);
350     result.put(new SettingsGroup(WRAPPING_METHOD_PARAMETERS), ContainerUtil.immutableList(
351       new CodeStyleSettingPresentation("ALIGN_MULTILINE_PARAMETERS", ApplicationBundle.message("wrapping.align.when.multiline")),
352       new CodeStyleSettingPresentation("METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE",
353                                        ApplicationBundle.message("wrapping.new.line.after.lpar")),
354       new CodeStyleSettingPresentation("METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE",
355                                        ApplicationBundle.message("wrapping.rpar.on.new.line"))
356     ));
357
358     putGroupTop(result, "CALL_PARAMETERS_WRAP", WRAPPING_METHOD_ARGUMENTS_WRAPPING, WRAP_VALUES, WRAP_OPTIONS);
359     result.put(new SettingsGroup(WRAPPING_METHOD_ARGUMENTS_WRAPPING), ContainerUtil.immutableList(
360       new CodeStyleSettingPresentation("ALIGN_MULTILINE_PARAMETERS_IN_CALLS",
361                                        ApplicationBundle.message("wrapping.align.when.multiline")),
362       new CodeStyleSettingPresentation("PREFER_PARAMETERS_WRAP",
363                                        ApplicationBundle.message("wrapping.take.priority.over.call.chain.wrapping")),
364       new CodeStyleSettingPresentation("CALL_PARAMETERS_LPAREN_ON_NEXT_LINE",
365                                        ApplicationBundle.message("wrapping.new.line.after.lpar")),
366       new CodeStyleSettingPresentation("CALL_PARAMETERS_RPAREN_ON_NEXT_LINE", ApplicationBundle.message("wrapping.rpar.on.new.line"))
367     ));
368
369     result.put(new SettingsGroup(WRAPPING_METHOD_PARENTHESES), ContainerUtil.immutableList(
370       new CodeStyleSettingPresentation("ALIGN_MULTILINE_METHOD_BRACKETS", ApplicationBundle.message("wrapping.align.when.multiline"))
371     ));
372
373     putGroupTop(result, "METHOD_CALL_CHAIN_WRAP", WRAPPING_CALL_CHAIN, WRAP_VALUES, WRAP_OPTIONS);
374     result.put(new SettingsGroup(WRAPPING_CALL_CHAIN), ContainerUtil.immutableList(
375       new CodeStyleSettingPresentation("WRAP_FIRST_METHOD_IN_CALL_CHAIN",
376                                        ApplicationBundle.message("wrapping.chained.method.call.first.on.new.line")),
377       new CodeStyleSettingPresentation("ALIGN_MULTILINE_CHAINED_METHODS", ApplicationBundle.message("wrapping.align.when.multiline"))
378     ));
379
380     result.put(new SettingsGroup(WRAPPING_IF_STATEMENT), ContainerUtil.immutableList(
381       new CodeStyleSelectSettingPresentation("IF_BRACE_FORCE", ApplicationBundle.message("wrapping.force.braces"), BRACE_VALUES,
382                                              BRACE_OPTIONS),
383       new CodeStyleSettingPresentation("ELSE_ON_NEW_LINE", ApplicationBundle.message("wrapping.else.on.new.line")),
384       new CodeStyleSettingPresentation("SPECIAL_ELSE_IF_TREATMENT",
385                                        ApplicationBundle.message("wrapping.special.else.if.braces.treatment"))
386     ));
387
388     putGroupTop(result, "FOR_STATEMENT_WRAP", WRAPPING_FOR_STATEMENT, WRAP_VALUES, WRAP_OPTIONS);
389     result.put(new SettingsGroup(WRAPPING_FOR_STATEMENT), ContainerUtil.immutableList(
390       new CodeStyleSettingPresentation("ALIGN_MULTILINE_FOR", ApplicationBundle.message("wrapping.align.when.multiline")),
391       new CodeStyleSettingPresentation("FOR_STATEMENT_LPAREN_ON_NEXT_LINE",
392                                        ApplicationBundle.message("wrapping.new.line.after.lpar")),
393       new CodeStyleSettingPresentation("FOR_STATEMENT_RPAREN_ON_NEXT_LINE", ApplicationBundle.message("wrapping.rpar.on.new.line")),
394       new CodeStyleSelectSettingPresentation("FOR_BRACE_FORCE", ApplicationBundle.message("wrapping.force.braces"), BRACE_VALUES,
395                                              BRACE_OPTIONS)
396     ));
397
398     result.put(new SettingsGroup(WRAPPING_WHILE_STATEMENT), ContainerUtil.<CodeStyleSettingPresentation>immutableList(
399       new CodeStyleSelectSettingPresentation("WHILE_BRACE_FORCE", ApplicationBundle.message("wrapping.force.braces"), BRACE_VALUES,
400                                              BRACE_OPTIONS)
401     ));
402
403     result.put(new SettingsGroup(WRAPPING_DOWHILE_STATEMENT), ContainerUtil.immutableList(
404       new CodeStyleSelectSettingPresentation("DOWHILE_BRACE_FORCE", ApplicationBundle.message("wrapping.force.braces"), BRACE_VALUES,
405                                              BRACE_OPTIONS),
406       new CodeStyleSettingPresentation("WHILE_ON_NEW_LINE", ApplicationBundle.message("wrapping.while.on.new.line"))
407     ));
408
409     result.put(new SettingsGroup(WRAPPING_SWITCH_STATEMENT), ContainerUtil.immutableList(
410       new CodeStyleSettingPresentation("INDENT_CASE_FROM_SWITCH", ApplicationBundle.message("wrapping.indent.case.from.switch")),
411       new CodeStyleSettingPresentation("INDENT_BREAK_FROM_CASE", ApplicationBundle.message("wrapping.indent.break.from.case"))
412     ));
413
414     putGroupTop(result, "RESOURCE_LIST_WRAP", WRAPPING_TRY_RESOURCE_LIST, WRAP_VALUES, WRAP_OPTIONS);
415     result.put(new SettingsGroup(WRAPPING_TRY_RESOURCE_LIST), ContainerUtil.immutableList(
416       new CodeStyleSettingPresentation("ALIGN_MULTILINE_RESOURCES", ApplicationBundle.message("wrapping.align.when.multiline")),
417       new CodeStyleSettingPresentation("RESOURCE_LIST_LPAREN_ON_NEXT_LINE",
418                                        ApplicationBundle.message("wrapping.new.line.after.lpar")),
419       new CodeStyleSettingPresentation("RESOURCE_LIST_RPAREN_ON_NEXT_LINE", ApplicationBundle.message("wrapping.rpar.on.new.line"))
420     ));
421
422     result.put(new SettingsGroup(WRAPPING_TRY_STATEMENT), ContainerUtil.immutableList(
423       new CodeStyleSettingPresentation("CATCH_ON_NEW_LINE", ApplicationBundle.message("wrapping.catch.on.new.line")),
424       new CodeStyleSettingPresentation("FINALLY_ON_NEW_LINE", ApplicationBundle.message("wrapping.finally.on.new.line"))
425     ));
426
427     putGroupTop(result, "BINARY_OPERATION_WRAP", WRAPPING_BINARY_OPERATION, WRAP_VALUES, WRAP_OPTIONS);
428     result.put(new SettingsGroup(WRAPPING_BINARY_OPERATION), ContainerUtil.immutableList(
429       new CodeStyleSettingPresentation("ALIGN_MULTILINE_BINARY_OPERATION",
430                                        ApplicationBundle.message("wrapping.align.when.multiline")),
431       new CodeStyleSettingPresentation("BINARY_OPERATION_SIGN_ON_NEXT_LINE",
432                                        ApplicationBundle.message("wrapping.operation.sign.on.next.line")),
433       new CodeStyleSettingPresentation("ALIGN_MULTILINE_PARENTHESIZED_EXPRESSION",
434                                        ApplicationBundle.message("wrapping.align.parenthesised.when.multiline")),
435       new CodeStyleSettingPresentation("PARENTHESES_EXPRESSION_LPAREN_WRAP",
436                                        ApplicationBundle.message("wrapping.new.line.after.lpar")),
437       new CodeStyleSettingPresentation("PARENTHESES_EXPRESSION_RPAREN_WRAP", ApplicationBundle.message("wrapping.rpar.on.new.line"))
438     ));
439
440     putGroupTop(result, "ASSIGNMENT_WRAP", WRAPPING_ASSIGNMENT, WRAP_VALUES, WRAP_OPTIONS);
441     result.put(new SettingsGroup(WRAPPING_ASSIGNMENT), ContainerUtil.immutableList(
442       new CodeStyleSettingPresentation("ALIGN_MULTILINE_ASSIGNMENT", ApplicationBundle.message("wrapping.align.when.multiline")),
443       new CodeStyleSettingPresentation("PLACE_ASSIGNMENT_SIGN_ON_NEXT_LINE",
444                                        ApplicationBundle.message("wrapping.assignment.sign.on.next.line"))
445     ));
446
447     result.put(new SettingsGroup(WRAPPING_FIELDS_VARIABLES_GROUPS), ContainerUtil.immutableList(
448       new CodeStyleSettingPresentation("ALIGN_GROUP_FIELD_DECLARATIONS",
449                                        ApplicationBundle.message("wrapping.align.fields.in.columns")),
450       new CodeStyleSettingPresentation("ALIGN_CONSECUTIVE_VARIABLE_DECLARATIONS",
451                                        ApplicationBundle.message("wrapping.align.variables.in.columns"))
452     ));
453
454     putGroupTop(result, "TERNARY_OPERATION_WRAP", WRAPPING_TERNARY_OPERATION, WRAP_VALUES, WRAP_OPTIONS);
455     result.put(new SettingsGroup(WRAPPING_TERNARY_OPERATION), ContainerUtil.immutableList(
456       new CodeStyleSettingPresentation("ALIGN_MULTILINE_TERNARY_OPERATION",
457                                        ApplicationBundle.message("wrapping.align.when.multiline")),
458       new CodeStyleSettingPresentation("TERNARY_OPERATION_SIGNS_ON_NEXT_LINE",
459                                        ApplicationBundle.message("wrapping.quest.and.colon.signs.on.next.line"))
460     ));
461
462     putGroupTop(result, "ARRAY_INITIALIZER_WRAP", WRAPPING_ARRAY_INITIALIZER, WRAP_VALUES, WRAP_OPTIONS);
463     result.put(new SettingsGroup(WRAPPING_ARRAY_INITIALIZER), ContainerUtil.immutableList(
464       new CodeStyleSettingPresentation("ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION",
465                                        ApplicationBundle.message("wrapping.align.when.multiline")),
466       new CodeStyleSettingPresentation("ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE",
467                                        ApplicationBundle.message("wrapping.new.line.after.lbrace")),
468       new CodeStyleSettingPresentation("ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE",
469                                        ApplicationBundle.message("wrapping.rbrace.on.new.line"))
470     ));
471
472     result.put(new SettingsGroup(WRAPPING_MODIFIER_LIST), ContainerUtil.immutableList(
473       new CodeStyleSettingPresentation("MODIFIER_LIST_WRAP", ApplicationBundle.message("wrapping.after.modifier.list"))
474     ));
475
476     putGroupTop(result, "ASSERT_STATEMENT_WRAP", WRAPPING_ASSERT_STATEMENT, WRAP_VALUES, WRAP_OPTIONS);
477     result.put(new SettingsGroup(WRAPPING_ASSERT_STATEMENT), ContainerUtil.immutableList(
478       new CodeStyleSettingPresentation("ASSERT_STATEMENT_COLON_ON_NEXT_LINE",
479                                        ApplicationBundle.message("wrapping.colon.signs.on.next.line"))
480     ));
481
482     putGroupTop(result, "ENUM_CONSTANTS_WRAP", ApplicationBundle.message("wrapping.enum.constants"), WRAP_VALUES, WRAP_OPTIONS);
483     putGroupTop(result, "CLASS_ANNOTATION_WRAP", ApplicationBundle.message("wrapping.classes.annotation"), WRAP_VALUES, WRAP_OPTIONS);
484     putGroupTop(result, "METHOD_ANNOTATION_WRAP", ApplicationBundle.message("wrapping.methods.annotation"), WRAP_VALUES, WRAP_OPTIONS);
485     putGroupTop(result, "FIELD_ANNOTATION_WRAP", ApplicationBundle.message("wrapping.fields.annotation"), WRAP_VALUES, WRAP_OPTIONS);
486     putGroupTop(result, "PARAMETER_ANNOTATION_WRAP", ApplicationBundle.message("wrapping.parameters.annotation"), WRAP_VALUES, WRAP_OPTIONS);
487     putGroupTop(result, "VARIABLE_ANNOTATION_WRAP", ApplicationBundle.message("wrapping.local.variables.annotation"), WRAP_VALUES,
488                 WRAP_OPTIONS);
489     WRAPPING_AND_BRACES_STANDARD_SETTINGS = Collections.unmodifiableMap(result);
490
491     //-----------------------------------INDENT_SETTINGS-----------------------------------------------------
492
493     result = ContainerUtil.newLinkedHashMap();
494     result.put(new SettingsGroup(null), ContainerUtil.immutableList(
495       new CodeStyleSettingPresentation("INDENT_SIZE", ApplicationBundle.message("editbox.indent.indent"))
496     ));
497     result.put(new SettingsGroup(null), ContainerUtil.immutableList(
498       new CodeStyleSettingPresentation("CONTINUATION_INDENT_SIZE", ApplicationBundle.message("editbox.indent.continuation.indent"))
499     ));
500     result.put(new SettingsGroup(null), ContainerUtil.immutableList(
501       new CodeStyleSettingPresentation("TAB_SIZE", ApplicationBundle.message("editbox.indent.tab.size"))
502     ));
503     INDENT_STANDARD_SETTINGS = Collections.unmodifiableMap(result);
504   }
505
506   /**
507    * Returns an immutable map containing all standard settings in a mapping of type (group -> settings contained in the group).
508    * Notice that lists containing settings for a specific group are also immutable. Use copies to make modifications.
509    * @param settingsType type to get standard settings for
510    * @return mapping setting groups to contained setting presentations
511    */
512   @NotNull
513   public static Map<SettingsGroup, List<CodeStyleSettingPresentation>> getStandardSettings(LanguageCodeStyleSettingsProvider.SettingsType settingsType) {
514     switch (settingsType) {
515       case BLANK_LINES_SETTINGS:
516         return BLANK_LINES_STANDARD_SETTINGS;
517       case SPACING_SETTINGS:
518         return SPACING_STANDARD_SETTINGS;
519       case WRAPPING_AND_BRACES_SETTINGS:
520         return WRAPPING_AND_BRACES_STANDARD_SETTINGS;
521       case INDENT_SETTINGS:
522         return INDENT_STANDARD_SETTINGS;
523       case LANGUAGE_SPECIFIC:
524     }
525     return ContainerUtil.newLinkedHashMap();
526   }
527 }