IDEA-247635 Introduced CodeStyleSettingsCustomizableOptions

IDEA-CR-66127

GitOrigin-RevId: 78222111b4d45f7956b13c776f46436857df2769
This commit is contained in:
Alexandr Evstigneev
2020-08-20 11:02:06 +03:00
committed by intellij-monorepo-bot
parent b291287ff4
commit 6f3fe697e9
2 changed files with 199 additions and 66 deletions

View File

@@ -1,7 +1,6 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.psi.codeStyle;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.openapi.util.NlsContexts;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
@@ -214,57 +213,98 @@ public interface CodeStyleSettingsCustomizable {
BLOCK_COMMENT_AT_FIRST_COLUMN
}
@Nls String SPACES_AROUND_OPERATORS = ApplicationBundle.message("group.spaces.around.operators");
@Nls String SPACES_BEFORE_PARENTHESES = ApplicationBundle.message("group.spaces.before.parentheses");
@Nls String SPACES_BEFORE_LEFT_BRACE = ApplicationBundle.message("group.spaces.before.left.brace");
@Nls String SPACES_BEFORE_KEYWORD = ApplicationBundle.message("group.spaces.after.right.brace");
@Nls String SPACES_WITHIN = ApplicationBundle.message("group.spaces.within");
@Nls String SPACES_IN_TERNARY_OPERATOR = ApplicationBundle.message("group.spaces.in.ternary.operator");
@Nls String SPACES_WITHIN_TYPE_ARGUMENTS = ApplicationBundle.message("group.spaces.in.type.arguments");
@Nls String SPACES_IN_TYPE_ARGUMENTS = ApplicationBundle.message("group.spaces.in.type.arguments.block");
@Nls String SPACES_IN_TYPE_PARAMETERS = ApplicationBundle.message("group.spaces.in.type.parameters.block");
@Nls String SPACES_OTHER = ApplicationBundle.message("group.spaces.other");
/**
* @deprecated Options blow are not locale-friendly, please use ones from {@link CodeStyleSettingsCustomizableOptions#getInstance()} instead
*/
@Deprecated
@Nls String SPACES_AROUND_OPERATORS = CodeStyleSettingsCustomizableOptions.getInstance().SPACES_AROUND_OPERATORS;
@Deprecated
@Nls String SPACES_BEFORE_PARENTHESES = CodeStyleSettingsCustomizableOptions.getInstance().SPACES_BEFORE_PARENTHESES;
@Deprecated
@Nls String SPACES_BEFORE_LEFT_BRACE = CodeStyleSettingsCustomizableOptions.getInstance().SPACES_BEFORE_LEFT_BRACE;
@Deprecated
@Nls String SPACES_BEFORE_KEYWORD = CodeStyleSettingsCustomizableOptions.getInstance().SPACES_BEFORE_KEYWORD;
@Deprecated
@Nls String SPACES_WITHIN = CodeStyleSettingsCustomizableOptions.getInstance().SPACES_WITHIN;
@Deprecated
@Nls String SPACES_IN_TERNARY_OPERATOR = CodeStyleSettingsCustomizableOptions.getInstance().SPACES_IN_TERNARY_OPERATOR;
@Deprecated
@Nls String SPACES_WITHIN_TYPE_ARGUMENTS = CodeStyleSettingsCustomizableOptions.getInstance().SPACES_WITHIN_TYPE_ARGUMENTS;
@Deprecated
@Nls String SPACES_IN_TYPE_ARGUMENTS = CodeStyleSettingsCustomizableOptions.getInstance().SPACES_IN_TYPE_ARGUMENTS;
@Deprecated
@Nls String SPACES_IN_TYPE_PARAMETERS = CodeStyleSettingsCustomizableOptions.getInstance().SPACES_IN_TYPE_PARAMETERS;
@Deprecated
@Nls String SPACES_OTHER = CodeStyleSettingsCustomizableOptions.getInstance().SPACES_OTHER;
@Nls String BLANK_LINES_KEEP = ApplicationBundle.message("title.keep.blank.lines");
@Nls String BLANK_LINES = ApplicationBundle.message("title.minimum.blank.lines");
@Deprecated
@Nls String BLANK_LINES_KEEP = CodeStyleSettingsCustomizableOptions.getInstance().BLANK_LINES_KEEP;
@Deprecated
@Nls String BLANK_LINES = CodeStyleSettingsCustomizableOptions.getInstance().BLANK_LINES;
@Nls String WRAPPING_KEEP = ApplicationBundle.message("wrapping.keep.when.reformatting");
@Nls String WRAPPING_BRACES = ApplicationBundle.message("wrapping.brace.placement");
@Nls String WRAPPING_COMMENTS = ApplicationBundle.message("wrapping.comments");
@Nls String WRAPPING_METHOD_PARAMETERS = ApplicationBundle.message("wrapping.method.parameters");
@Nls String WRAPPING_METHOD_PARENTHESES = ApplicationBundle.message("wrapping.method.parentheses");
@Nls String WRAPPING_METHOD_ARGUMENTS_WRAPPING = ApplicationBundle.message("wrapping.method.arguments");
@Nls String WRAPPING_CALL_CHAIN = ApplicationBundle.message("wrapping.chained.method.calls");
@Nls String WRAPPING_IF_STATEMENT = ApplicationBundle.message("wrapping.if.statement");
@Nls String WRAPPING_FOR_STATEMENT = ApplicationBundle.message("wrapping.for.statement");
@Nls String WRAPPING_WHILE_STATEMENT = ApplicationBundle.message("wrapping.while.statement");
@Nls String WRAPPING_DOWHILE_STATEMENT = ApplicationBundle.message("wrapping.dowhile.statement");
@Nls String WRAPPING_SWITCH_STATEMENT = ApplicationBundle.message("wrapping.switch.statement");
@Nls String WRAPPING_TRY_STATEMENT = ApplicationBundle.message("wrapping.try.statement");
@Nls String WRAPPING_TRY_RESOURCE_LIST = ApplicationBundle.message("wrapping.try.resources");
@Nls String WRAPPING_BINARY_OPERATION = ApplicationBundle.message("wrapping.binary.operations");
@Nls String WRAPPING_EXTENDS_LIST = ApplicationBundle.message("wrapping.extends.implements.list");
@Nls String WRAPPING_EXTENDS_KEYWORD = ApplicationBundle.message("wrapping.extends.implements.keyword");
@Nls String WRAPPING_THROWS_LIST = ApplicationBundle.message("wrapping.throws.list");
@Nls String WRAPPING_THROWS_KEYWORD = ApplicationBundle.message("wrapping.throws.keyword");
@Nls String WRAPPING_TERNARY_OPERATION = ApplicationBundle.message("wrapping.ternary.operation");
@Nls String WRAPPING_ASSIGNMENT = ApplicationBundle.message("wrapping.assignment.statement");
@Nls String WRAPPING_FIELDS_VARIABLES_GROUPS = ApplicationBundle.message("checkbox.align.multiline.fields.groups");
@Nls String WRAPPING_ARRAY_INITIALIZER = ApplicationBundle.message("wrapping.array.initializer");
@Nls String WRAPPING_MODIFIER_LIST = ApplicationBundle.message("wrapping.modifier.list");
@Nls String WRAPPING_ASSERT_STATEMENT = ApplicationBundle.message("wrapping.assert.statement");
@Deprecated
@Nls String WRAPPING_KEEP = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_KEEP;
@Deprecated
@Nls String WRAPPING_BRACES = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_BRACES;
@Deprecated
@Nls String WRAPPING_COMMENTS = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_COMMENTS;
@Deprecated
@Nls String WRAPPING_METHOD_PARAMETERS = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_METHOD_PARAMETERS;
@Deprecated
@Nls String WRAPPING_METHOD_PARENTHESES = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_METHOD_PARENTHESES;
@Deprecated
@Nls String WRAPPING_METHOD_ARGUMENTS_WRAPPING = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_METHOD_ARGUMENTS_WRAPPING;
@Deprecated
@Nls String WRAPPING_CALL_CHAIN = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_CALL_CHAIN;
@Deprecated
@Nls String WRAPPING_IF_STATEMENT = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_IF_STATEMENT;
@Deprecated
@Nls String WRAPPING_FOR_STATEMENT = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_FOR_STATEMENT;
@Deprecated
@Nls String WRAPPING_WHILE_STATEMENT = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_WHILE_STATEMENT;
@Deprecated
@Nls String WRAPPING_DOWHILE_STATEMENT = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_DOWHILE_STATEMENT;
@Deprecated
@Nls String WRAPPING_SWITCH_STATEMENT = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_SWITCH_STATEMENT;
@Deprecated
@Nls String WRAPPING_TRY_STATEMENT = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_TRY_STATEMENT;
@Deprecated
@Nls String WRAPPING_TRY_RESOURCE_LIST = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_TRY_RESOURCE_LIST;
@Deprecated
@Nls String WRAPPING_BINARY_OPERATION = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_BINARY_OPERATION;
@Deprecated
@Nls String WRAPPING_EXTENDS_LIST = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_EXTENDS_LIST;
@Deprecated
@Nls String WRAPPING_EXTENDS_KEYWORD = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_EXTENDS_KEYWORD;
@Deprecated
@Nls String WRAPPING_THROWS_LIST = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_THROWS_LIST;
@Deprecated
@Nls String WRAPPING_THROWS_KEYWORD = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_THROWS_KEYWORD;
@Deprecated
@Nls String WRAPPING_TERNARY_OPERATION = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_TERNARY_OPERATION;
@Deprecated
@Nls String WRAPPING_ASSIGNMENT = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_ASSIGNMENT;
@Deprecated
@Nls String WRAPPING_FIELDS_VARIABLES_GROUPS = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_FIELDS_VARIABLES_GROUPS;
@Deprecated
@Nls String WRAPPING_ARRAY_INITIALIZER = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_ARRAY_INITIALIZER;
@Deprecated
@Nls String WRAPPING_MODIFIER_LIST = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_MODIFIER_LIST;
@Deprecated
@Nls String WRAPPING_ASSERT_STATEMENT = CodeStyleSettingsCustomizableOptions.getInstance().WRAPPING_ASSERT_STATEMENT;
/**
* @deprecated use {@link CodeStyleSettingsCustomizableOptions#WRAP_OPTIONS} instead
*/
@Deprecated
@Nls String[] WRAP_OPTIONS = CodeStyleSettingsCustomizableOptions.getInstance().WRAP_OPTIONS;
/**
* @deprecated use {@link CodeStyleSettingsCustomizableOptions#WRAP_OPTIONS_FOR_SINGLETON} instead
*/
@Deprecated
@Nls String[] WRAP_OPTIONS_FOR_SINGLETON = CodeStyleSettingsCustomizableOptions.getInstance().WRAP_OPTIONS_FOR_SINGLETON;
String @Nls [] WRAP_OPTIONS = {
ApplicationBundle.message("wrapping.do.not.wrap"),
ApplicationBundle.message("wrapping.wrap.if.long"),
ApplicationBundle.message("wrapping.chop.down.if.long"),
ApplicationBundle.message("wrapping.wrap.always")
};
String @Nls [] WRAP_OPTIONS_FOR_SINGLETON = {
ApplicationBundle.message("wrapping.do.not.wrap"),
ApplicationBundle.message("wrapping.wrap.if.long"),
ApplicationBundle.message("wrapping.wrap.always")
};
int[] WRAP_VALUES = {CommonCodeStyleSettings.DO_NOT_WRAP,
CommonCodeStyleSettings.WRAP_AS_NEEDED,
CommonCodeStyleSettings.WRAP_AS_NEEDED |
@@ -274,23 +314,25 @@ public interface CodeStyleSettingsCustomizable {
int[] WRAP_VALUES_FOR_SINGLETON = {CommonCodeStyleSettings.DO_NOT_WRAP,
CommonCodeStyleSettings.WRAP_AS_NEEDED,
CommonCodeStyleSettings.WRAP_ALWAYS};
String[] BRACE_OPTIONS = {
ApplicationBundle.message("wrapping.force.braces.do.not.force"),
ApplicationBundle.message("wrapping.force.braces.when.multiline"),
ApplicationBundle.message("wrapping.force.braces.always")
};
/**
* @deprecated use {@link CodeStyleSettingsCustomizableOptions#BRACE_OPTIONS} instead
*/
@Deprecated
@Nls String[] BRACE_OPTIONS = CodeStyleSettingsCustomizableOptions.getInstance().BRACE_OPTIONS;
int[] BRACE_VALUES = {
CommonCodeStyleSettings.DO_NOT_FORCE,
CommonCodeStyleSettings.FORCE_BRACES_IF_MULTILINE,
CommonCodeStyleSettings.FORCE_BRACES_ALWAYS
};
String @Nls [] BRACE_PLACEMENT_OPTIONS = {
ApplicationBundle.message("wrapping.brace.placement.end.of.line"),
ApplicationBundle.message("wrapping.brace.placement.next.line.if.wrapped"),
ApplicationBundle.message("wrapping.brace.placement.next.line"),
ApplicationBundle.message("wrapping.brace.placement.next.line.shifted"),
ApplicationBundle.message("wrapping.brace.placement.next.line.each.shifted")
};
/**
* @deprecated use {@link CodeStyleSettingsCustomizableOptions#BRACE_PLACEMENT_OPTIONS} instead
*/
@Deprecated
@Nls String[] BRACE_PLACEMENT_OPTIONS = CodeStyleSettingsCustomizableOptions.getInstance().BRACE_PLACEMENT_OPTIONS;
int[] BRACE_PLACEMENT_VALUES = {
CommonCodeStyleSettings.END_OF_LINE,
CommonCodeStyleSettings.NEXT_LINE_IF_WRAPPED,
@@ -299,11 +341,12 @@ public interface CodeStyleSettingsCustomizable {
CommonCodeStyleSettings.NEXT_LINE_SHIFTED2
};
String @Nls [] WRAP_ON_TYPING_OPTIONS = {
ApplicationBundle.message("wrapping.wrap.on.typing.no.wrap"),
ApplicationBundle.message("wrapping.wrap.on.typing.wrap"),
ApplicationBundle.message("wrapping.wrap.on.typing.default")
};
/**
* @deprecated use {@link CodeStyleSettingsCustomizableOptions#WRAP_ON_TYPING_OPTIONS} instead
*/
@Deprecated
@Nls String[] WRAP_ON_TYPING_OPTIONS = CodeStyleSettingsCustomizableOptions.getInstance().WRAP_ON_TYPING_OPTIONS;
int[] WRAP_ON_TYPING_VALUES = {
CommonCodeStyleSettings.WrapOnTyping.NO_WRAP.intValue,
CommonCodeStyleSettings.WrapOnTyping.WRAP.intValue,

View File

@@ -0,0 +1,90 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.psi.codeStyle;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.util.LocaleSensitiveApplicationCacheService;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
public final class CodeStyleSettingsCustomizableOptions {
private CodeStyleSettingsCustomizableOptions() {
}
public final @Nls String SPACES_AROUND_OPERATORS = ApplicationBundle.message("group.spaces.around.operators");
public final @Nls String SPACES_BEFORE_PARENTHESES = ApplicationBundle.message("group.spaces.before.parentheses");
public final @Nls String SPACES_BEFORE_LEFT_BRACE = ApplicationBundle.message("group.spaces.before.left.brace");
public final @Nls String SPACES_BEFORE_KEYWORD = ApplicationBundle.message("group.spaces.after.right.brace");
public final @Nls String SPACES_WITHIN = ApplicationBundle.message("group.spaces.within");
public final @Nls String SPACES_IN_TERNARY_OPERATOR = ApplicationBundle.message("group.spaces.in.ternary.operator");
public final @Nls String SPACES_WITHIN_TYPE_ARGUMENTS = ApplicationBundle.message("group.spaces.in.type.arguments");
public final @Nls String SPACES_IN_TYPE_ARGUMENTS = ApplicationBundle.message("group.spaces.in.type.arguments.block");
public final @Nls String SPACES_IN_TYPE_PARAMETERS = ApplicationBundle.message("group.spaces.in.type.parameters.block");
public final @Nls String SPACES_OTHER = ApplicationBundle.message("group.spaces.other");
public final @Nls String BLANK_LINES_KEEP = ApplicationBundle.message("title.keep.blank.lines");
public final @Nls String BLANK_LINES = ApplicationBundle.message("title.minimum.blank.lines");
public final @Nls String WRAPPING_KEEP = ApplicationBundle.message("wrapping.keep.when.reformatting");
public final @Nls String WRAPPING_BRACES = ApplicationBundle.message("wrapping.brace.placement");
public final @Nls String WRAPPING_COMMENTS = ApplicationBundle.message("wrapping.comments");
public final @Nls String WRAPPING_METHOD_PARAMETERS = ApplicationBundle.message("wrapping.method.parameters");
public final @Nls String WRAPPING_METHOD_PARENTHESES = ApplicationBundle.message("wrapping.method.parentheses");
public final @Nls String WRAPPING_METHOD_ARGUMENTS_WRAPPING = ApplicationBundle.message("wrapping.method.arguments");
public final @Nls String WRAPPING_CALL_CHAIN = ApplicationBundle.message("wrapping.chained.method.calls");
public final @Nls String WRAPPING_IF_STATEMENT = ApplicationBundle.message("wrapping.if.statement");
public final @Nls String WRAPPING_FOR_STATEMENT = ApplicationBundle.message("wrapping.for.statement");
public final @Nls String WRAPPING_WHILE_STATEMENT = ApplicationBundle.message("wrapping.while.statement");
public final @Nls String WRAPPING_DOWHILE_STATEMENT = ApplicationBundle.message("wrapping.dowhile.statement");
public final @Nls String WRAPPING_SWITCH_STATEMENT = ApplicationBundle.message("wrapping.switch.statement");
public final @Nls String WRAPPING_TRY_STATEMENT = ApplicationBundle.message("wrapping.try.statement");
public final @Nls String WRAPPING_TRY_RESOURCE_LIST = ApplicationBundle.message("wrapping.try.resources");
public final @Nls String WRAPPING_BINARY_OPERATION = ApplicationBundle.message("wrapping.binary.operations");
public final @Nls String WRAPPING_EXTENDS_LIST = ApplicationBundle.message("wrapping.extends.implements.list");
public final @Nls String WRAPPING_EXTENDS_KEYWORD = ApplicationBundle.message("wrapping.extends.implements.keyword");
public final @Nls String WRAPPING_THROWS_LIST = ApplicationBundle.message("wrapping.throws.list");
public final @Nls String WRAPPING_THROWS_KEYWORD = ApplicationBundle.message("wrapping.throws.keyword");
public final @Nls String WRAPPING_TERNARY_OPERATION = ApplicationBundle.message("wrapping.ternary.operation");
public final @Nls String WRAPPING_ASSIGNMENT = ApplicationBundle.message("wrapping.assignment.statement");
public final @Nls String WRAPPING_FIELDS_VARIABLES_GROUPS = ApplicationBundle.message("checkbox.align.multiline.fields.groups");
public final @Nls String WRAPPING_ARRAY_INITIALIZER = ApplicationBundle.message("wrapping.array.initializer");
public final @Nls String WRAPPING_MODIFIER_LIST = ApplicationBundle.message("wrapping.modifier.list");
public final @Nls String WRAPPING_ASSERT_STATEMENT = ApplicationBundle.message("wrapping.assert.statement");
public final @Nls String[] WRAP_OPTIONS = {
ApplicationBundle.message("wrapping.do.not.wrap"),
ApplicationBundle.message("wrapping.wrap.if.long"),
ApplicationBundle.message("wrapping.chop.down.if.long"),
ApplicationBundle.message("wrapping.wrap.always")
};
public final @Nls String[] WRAP_OPTIONS_FOR_SINGLETON = {
ApplicationBundle.message("wrapping.do.not.wrap"),
ApplicationBundle.message("wrapping.wrap.if.long"),
ApplicationBundle.message("wrapping.wrap.always")
};
public final @Nls String[] BRACE_OPTIONS = {
ApplicationBundle.message("wrapping.force.braces.do.not.force"),
ApplicationBundle.message("wrapping.force.braces.when.multiline"),
ApplicationBundle.message("wrapping.force.braces.always")
};
public final @Nls String[] BRACE_PLACEMENT_OPTIONS = {
ApplicationBundle.message("wrapping.brace.placement.end.of.line"),
ApplicationBundle.message("wrapping.brace.placement.next.line.if.wrapped"),
ApplicationBundle.message("wrapping.brace.placement.next.line"),
ApplicationBundle.message("wrapping.brace.placement.next.line.shifted"),
ApplicationBundle.message("wrapping.brace.placement.next.line.each.shifted")
};
public final @Nls String[] WRAP_ON_TYPING_OPTIONS = {
ApplicationBundle.message("wrapping.wrap.on.typing.no.wrap"),
ApplicationBundle.message("wrapping.wrap.on.typing.wrap"),
ApplicationBundle.message("wrapping.wrap.on.typing.default")
};
public static @NotNull CodeStyleSettingsCustomizableOptions getInstance() {
return LocaleSensitiveApplicationCacheService.getInstance().getData(CodeStyleSettingsCustomizableOptions.class,
CodeStyleSettingsCustomizableOptions::new);
}
}