Search in sources :

Example 56 with CommonCodeStyleSettings

use of com.intellij.psi.codeStyle.CommonCodeStyleSettings in project intellij-community by JetBrains.

the class JavaFormatterTest method testSpacesBeforeLBrace.

public void testSpacesBeforeLBrace() throws Exception {
    final CommonCodeStyleSettings settings = getSettings();
    settings.SPACE_BEFORE_CLASS_LBRACE = true;
    settings.SPACE_BEFORE_METHOD_LBRACE = true;
    settings.SPACE_BEFORE_IF_LBRACE = true;
    settings.SPACE_BEFORE_ELSE_LBRACE = true;
    settings.SPACE_BEFORE_WHILE_LBRACE = true;
    settings.SPACE_BEFORE_FOR_LBRACE = true;
    settings.SPACE_BEFORE_DO_LBRACE = true;
    settings.SPACE_BEFORE_SWITCH_LBRACE = true;
    settings.SPACE_BEFORE_TRY_LBRACE = true;
    settings.SPACE_BEFORE_CATCH_LBRACE = true;
    settings.SPACE_BEFORE_FINALLY_LBRACE = true;
    settings.SPACE_BEFORE_SYNCHRONIZED_LBRACE = true;
    settings.SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE = true;
    doTest();
    settings.SPACE_BEFORE_CLASS_LBRACE = false;
    settings.SPACE_BEFORE_METHOD_LBRACE = false;
    settings.SPACE_BEFORE_IF_LBRACE = false;
    settings.SPACE_BEFORE_ELSE_LBRACE = false;
    settings.SPACE_BEFORE_WHILE_LBRACE = false;
    settings.SPACE_BEFORE_FOR_LBRACE = false;
    settings.SPACE_BEFORE_DO_LBRACE = false;
    settings.SPACE_BEFORE_SWITCH_LBRACE = false;
    settings.SPACE_BEFORE_TRY_LBRACE = false;
    settings.SPACE_BEFORE_CATCH_LBRACE = false;
    settings.SPACE_BEFORE_FINALLY_LBRACE = false;
    settings.SPACE_BEFORE_SYNCHRONIZED_LBRACE = false;
    settings.SPACE_BEFORE_ARRAY_INITIALIZER_LBRACE = false;
    doTest("SpacesBeforeLBrace.java", "SpacesBeforeLBrace.java");
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings)

Example 57 with CommonCodeStyleSettings

use of com.intellij.psi.codeStyle.CommonCodeStyleSettings in project intellij-community by JetBrains.

the class JavaFormatterTest method testSCR259.

public void testSCR259() throws Exception {
    myTextRange = new TextRange(36, 60);
    final CommonCodeStyleSettings settings = getSettings();
    settings.IF_BRACE_FORCE = CommonCodeStyleSettings.FORCE_BRACES_ALWAYS;
    settings.KEEP_LINE_BREAKS = false;
    doTest();
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) TextRange(com.intellij.openapi.util.TextRange)

Example 58 with CommonCodeStyleSettings

use of com.intellij.psi.codeStyle.CommonCodeStyleSettings in project intellij-community by JetBrains.

the class JavaFormatterTest method testStringBinaryOperation.

public void testStringBinaryOperation() throws Exception {
    final CommonCodeStyleSettings settings = getSettings();
    settings.ALIGN_MULTILINE_ASSIGNMENT = false;
    settings.ALIGN_MULTILINE_BINARY_OPERATION = false;
    doTextTest("class Foo {\n" + "    void foo () {\n" + "String s = \"abc\" +\n" + "\"def\";" + "    }\n" + "}", "class Foo {\n" + "    void foo() {\n" + "        String s = \"abc\" +\n" + "                \"def\";\n" + "    }\n" + "}");
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings)

Example 59 with CommonCodeStyleSettings

use of com.intellij.psi.codeStyle.CommonCodeStyleSettings in project intellij-community by JetBrains.

the class JavaFormatterTest method testSCR1535.

public void testSCR1535() throws Exception {
    final CommonCodeStyleSettings settings = getSettings();
    settings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
    settings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
    settings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;
    doTextTest("public class Foo {\n" + "    public int foo() {\n" + "        if (a) {\n" + "            return;\n" + "        }\n" + "    }\n" + "}", "public class Foo\n" + "{\n" + "    public int foo()\n" + "    {\n" + "        if (a)\n" + "        {\n" + "            return;\n" + "        }\n" + "    }\n" + "}");
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings)

Example 60 with CommonCodeStyleSettings

use of com.intellij.psi.codeStyle.CommonCodeStyleSettings in project intellij-community by JetBrains.

the class JavaFormatterTest method testSpaceAroundField.

public void testSpaceAroundField() throws Exception {
    final CommonCodeStyleSettings settings = getSettings();
    settings.BLANK_LINES_AROUND_FIELD = 1;
    doTextTest("class Foo {\n" + "    boolean a;\n" + "    {\n" + "        if (a) {\n" + "        } else {\n" + "\n" + "        }\n" + "        a = 2;\n" + "    }\n" + "}", "class Foo {\n" + "    boolean a;\n" + "\n" + "    {\n" + "        if (a) {\n" + "        } else {\n" + "\n" + "        }\n" + "        a = 2;\n" + "    }\n" + "}");
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings)

Aggregations

CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)202 CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)19 TextRange (com.intellij.openapi.util.TextRange)5 PsiElement (com.intellij.psi.PsiElement)5 ASTNode (com.intellij.lang.ASTNode)4 Editor (com.intellij.openapi.editor.Editor)4 JavaCodeStyleSettings (com.intellij.psi.codeStyle.JavaCodeStyleSettings)4 EditorSettingsExternalizable (com.intellij.openapi.editor.ex.EditorSettingsExternalizable)3 PsiFile (com.intellij.psi.PsiFile)3 File (java.io.File)3 Matcher (java.util.regex.Matcher)3 NonNls (org.jetbrains.annotations.NonNls)3 NotNull (org.jetbrains.annotations.NotNull)3 Document (com.intellij.openapi.editor.Document)2 Project (com.intellij.openapi.project.Project)2 CodeStyleManager (com.intellij.psi.codeStyle.CodeStyleManager)2 ArrangementGroupingRule (com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule)2 IElementType (com.intellij.psi.tree.IElementType)2 Nullable (org.jetbrains.annotations.Nullable)2 GroovyCodeStyleSettings (org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings)2