use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class ProblematicWhitespaceInspectionTest method testSmartTabsInFile.
public void testSmartTabsInFile() {
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
final CommonCodeStyleSettings.IndentOptions options = settings.getIndentOptions(JavaFileType.INSTANCE);
options.USE_TAB_CHARACTER = true;
options.SMART_TABS = true;
doTest("/*File 'X.java' uses spaces for indentation*/class X {\n" + " \tString s;\n" + "}\n/**/");
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class ProblematicWhitespaceInspectionTest method testSmartTabsInFile3.
public void testSmartTabsInFile3() {
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
final CommonCodeStyleSettings.IndentOptions options = settings.getIndentOptions(JavaFileType.INSTANCE);
options.USE_TAB_CHARACTER = true;
options.SMART_TABS = true;
doTest("/*File 'X.java' uses spaces for indentation*/class X {\n" + "\tvoid aaa(boolean a, boolean b, boolean c) {\n" + "\t\taaa(true,\n" + "\t \t true,\n" + "\t\t true);\n" + "\t}\n" + "}\n/**/");
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class ProblematicWhitespaceInspectionTest method testTabsInFile2.
public void testTabsInFile2() {
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
settings.getIndentOptions(JavaFileType.INSTANCE).USE_TAB_CHARACTER = true;
doTest("class X {\n" + "\tString s;\n" + "}\n");
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class ProblematicWhitespaceInspectionTest method testHtml.
public void testHtml() {
final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
settings.getIndentOptions(HtmlFileType.INSTANCE).USE_TAB_CHARACTER = false;
myFixture.configureByText("X.html", "<warning descr=\"File 'X.html' uses tabs for indentation\"><html>\n" + "\t<body></body>\n" + "</html></warning>");
myFixture.testHighlighting(true, false, false);
}
use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-community by JetBrains.
the class EclipseCodeStyleImportWorker method setProgrammatically.
private static void setProgrammatically(@NotNull Object object, @NotNull String key, @NotNull String value) throws SchemeImportException {
if (key.contains("alignment") && value.matches("\\d*") && object instanceof CommonCodeStyleSettings) {
if (setAlignmentAndWrappingOptions((CommonCodeStyleSettings) object, key, value))
return;
}
if (object instanceof CodeStyleSettings) {
CodeStyleSettings settings = (CodeStyleSettings) object;
if (OPTION_REMOVE_JAVADOC_BLANK_LINES.equals(key)) {
settings.JD_KEEP_EMPTY_LINES = !valueToBoolean(key, value);
} else if (OPTION_NEW_LINE_AT_EOF.equals(key)) {
EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
editorSettings.setEnsureNewLineAtEOF(valueToBoolean(key, value));
}
} else if (object instanceof CommonCodeStyleSettings) {
CommonCodeStyleSettings commonSettings = (CommonCodeStyleSettings) object;
if (OPTION_SPACE_AFTER_BINARY_OPERATOR.equals(key)) {
boolean addSpace = valueToBoolean(key, value);
commonSettings.SPACE_AROUND_ADDITIVE_OPERATORS = commonSettings.SPACE_AROUND_BITWISE_OPERATORS = commonSettings.SPACE_AROUND_LOGICAL_OPERATORS = commonSettings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS = commonSettings.SPACE_AROUND_RELATIONAL_OPERATORS = commonSettings.SPACE_AROUND_SHIFT_OPERATORS = commonSettings.SPACE_AROUND_EQUALITY_OPERATORS = addSpace;
} else if (OPTION_INDENT_CLASS_BODY_DECL.equals(key)) {
commonSettings.DO_NOT_INDENT_TOP_LEVEL_CLASS_MEMBERS = !valueToBoolean(key, value);
} else if (OPTION_BLANK_LINES_BEFORE_FIRST_DECLARATION_IN_CLASS.equals(key)) {
int intValue = valueToInt(value);
commonSettings.BLANK_LINES_AFTER_CLASS_HEADER = intValue;
commonSettings.BLANK_LINES_AFTER_ANONYMOUS_CLASS_HEADER = intValue;
} else if (OPTION_EMPTY_LINES_TO_PRESERVE.equals(key)) {
int intValue = valueToInt(value);
commonSettings.KEEP_BLANK_LINES_IN_CODE = intValue;
commonSettings.KEEP_BLANK_LINES_IN_DECLARATIONS = intValue;
commonSettings.KEEP_BLANK_LINES_BEFORE_RBRACE = intValue;
} else if (OPTION_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK.equals(key)) {
boolean insertSpace = valueToBoolean(key, value);
commonSettings.SPACE_BEFORE_ELSE_KEYWORD = insertSpace;
commonSettings.SPACE_BEFORE_CATCH_KEYWORD = insertSpace;
commonSettings.SPACE_BEFORE_FINALLY_KEYWORD = insertSpace;
} else if (OPTION_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK.equals(key)) {
boolean insertSpace = valueToBoolean(key, value);
commonSettings.SPACE_BEFORE_IF_LBRACE = insertSpace;
commonSettings.SPACE_BEFORE_FOR_LBRACE = insertSpace;
commonSettings.SPACE_BEFORE_WHILE_LBRACE = insertSpace;
commonSettings.SPACE_BEFORE_DO_LBRACE = insertSpace;
commonSettings.SPACE_BEFORE_TRY_LBRACE = insertSpace;
commonSettings.SPACE_BEFORE_CATCH_LBRACE = insertSpace;
commonSettings.SPACE_BEFORE_FINALLY_LBRACE = insertSpace;
commonSettings.SPACE_BEFORE_SYNCHRONIZED_LBRACE = insertSpace;
} else if (OPTION_JOIN_WRAPPED_LINES.equals(key)) {
commonSettings.KEEP_LINE_BREAKS = !valueToBoolean(key, value);
}
} else if (object instanceof CommonCodeStyleSettings.IndentOptions) {
CommonCodeStyleSettings.IndentOptions indentOptions = (CommonCodeStyleSettings.IndentOptions) object;
if (OPTION_TAB_CHAR.equals(key)) {
if (TAB_CHAR_TAB.equals(value) || TAB_CHAR_MIXED.equals(value)) {
indentOptions.USE_TAB_CHARACTER = true;
} else if (TAB_CHAR_SPACE.equals(value)) {
indentOptions.USE_TAB_CHARACTER = false;
}
} else if (OPTION_CONTINUATION_INDENT.equals(key)) {
indentOptions.CONTINUATION_INDENT_SIZE = indentOptions.TAB_SIZE * valueToInt(value);
} else if (OPTION_TAB_SIZE.equals(key)) {
int newTabSize = valueToInt(value);
int continuationTabs = indentOptions.TAB_SIZE > 0 ? indentOptions.CONTINUATION_INDENT_SIZE / indentOptions.TAB_SIZE : -1;
indentOptions.TAB_SIZE = newTabSize;
if (continuationTabs >= 0) {
indentOptions.CONTINUATION_INDENT_SIZE = continuationTabs * newTabSize;
}
}
}
}
Aggregations