Search in sources :

Example 86 with CodeStyleSettings

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

the class JavaFormatterTest method testCommentAfterDeclaration.

public void testCommentAfterDeclaration() throws Exception {
    CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject());
    CommonCodeStyleSettings javaSettings = codeStyleSettings.getCommonSettings(JavaLanguage.INSTANCE);
    int oldMargin = codeStyleSettings.getDefaultRightMargin();
    int oldWrap = javaSettings.ASSIGNMENT_WRAP;
    try {
        codeStyleSettings.setDefaultRightMargin(20);
        javaSettings.ASSIGNMENT_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED;
        doMethodTest("int i=0; //comment comment", "int i =\n" + "        0; //comment comment");
    } finally {
        codeStyleSettings.setDefaultRightMargin(oldMargin);
        javaSettings.ASSIGNMENT_WRAP = oldWrap;
    }
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings)

Example 87 with CodeStyleSettings

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

the class JavaFormatterTest method testFormatterOnOffTagsWithRegexp.

public void testFormatterOnOffTagsWithRegexp() throws Exception {
    CodeStyleSettings settings = getSettings().getRootSettings();
    settings.FORMATTER_TAGS_ENABLED = true;
    settings.FORMATTER_TAGS_ACCEPT_REGEXP = true;
    settings.FORMATTER_OFF_TAG = "not.*format";
    settings.FORMATTER_ON_TAG = "end.*fragment";
    doTest();
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings)

Example 88 with CodeStyleSettings

use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-plugins by JetBrains.

the class HbFormatterIndentTest method testFormattingInsideDoNotIndentElems1.

public void testFormattingInsideDoNotIndentElems1() {
    CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
    settings.HTML_DO_NOT_INDENT_CHILDREN_OF = "body";
    doStringBasedTest("<body>\n" + "{{#foo}}\n" + "<div></div>\n" + "{{/foo}}\n" + "</body>", "<body>\n" + "{{#foo}}\n" + "    <div></div>\n" + "{{/foo}}\n" + "</body>");
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings)

Example 89 with CodeStyleSettings

use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-plugins by JetBrains.

the class ActionScriptFormatterTest method testSpaceBeforeTypeColon.

public void testSpaceBeforeTypeColon() throws Exception {
    final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings();
    final JSCodeStyleSettings jsSettings = settings.getCustomSettings(ECMA4CodeStyleSettings.class);
    boolean spaceBeforeTypeColon = jsSettings.SPACE_BEFORE_TYPE_COLON;
    boolean spaceAfterTypeColon = jsSettings.SPACE_AFTER_TYPE_COLON;
    jsSettings.SPACE_BEFORE_TYPE_COLON = true;
    jsSettings.SPACE_AFTER_TYPE_COLON = false;
    doTest("package aaa {\n" + "class XXX {\n" + "    private var _field:int;\n" + "    function get field():int {\n" + "        return _field;\n" + "    }\n" + "\n" + "    function set field(val:int):void {\n" + "        varName = val;\n" + "    }\n" + "}", "package aaa {\n" + "class XXX {\n" + "    private var _field :int;\n" + "    function get field() :int {\n" + "        return _field;\n" + "    }\n" + "\n" + "    function set field(val :int) :void {\n" + "        varName = val;\n" + "    }\n" + "}", ".as");
    jsSettings.SPACE_BEFORE_TYPE_COLON = spaceBeforeTypeColon;
    jsSettings.SPACE_AFTER_TYPE_COLON = spaceAfterTypeColon;
}
Also used : JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings) CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) XmlCodeStyleSettings(com.intellij.psi.formatter.xml.XmlCodeStyleSettings) ECMA4CodeStyleSettings(com.intellij.lang.javascript.formatter.ECMA4CodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings)

Example 90 with CodeStyleSettings

use of com.intellij.psi.codeStyle.CodeStyleSettings in project intellij-plugins by JetBrains.

the class ActionScriptFormatterTest method testCDATAFormattingOptions1.

public void testCDATAFormattingOptions1() throws Exception {
    final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings();
    final XmlCodeStyleSettings xmlSettings = settings.getCustomSettings(XmlCodeStyleSettings.class);
    int currCDATAWhitespace = xmlSettings.XML_WHITE_SPACE_AROUND_CDATA;
    xmlSettings.XML_WHITE_SPACE_AROUND_CDATA = XmlCodeStyleSettings.WS_AROUND_CDATA_NEW_LINES;
    doTestFromFile("mxml");
    xmlSettings.XML_WHITE_SPACE_AROUND_CDATA = currCDATAWhitespace;
}
Also used : JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings) CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) XmlCodeStyleSettings(com.intellij.psi.formatter.xml.XmlCodeStyleSettings) ECMA4CodeStyleSettings(com.intellij.lang.javascript.formatter.ECMA4CodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) XmlCodeStyleSettings(com.intellij.psi.formatter.xml.XmlCodeStyleSettings)

Aggregations

CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)190 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)84 Project (com.intellij.openapi.project.Project)12 XmlCodeStyleSettings (com.intellij.psi.formatter.xml.XmlCodeStyleSettings)12 ECMA4CodeStyleSettings (com.intellij.lang.javascript.formatter.ECMA4CodeStyleSettings)9 JSCodeStyleSettings (com.intellij.lang.javascript.formatter.JSCodeStyleSettings)9 Document (com.intellij.openapi.editor.Document)9 JavaCodeStyleSettings (com.intellij.psi.codeStyle.JavaCodeStyleSettings)9 NotNull (org.jetbrains.annotations.NotNull)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 PsiFile (com.intellij.psi.PsiFile)5 Nullable (org.jetbrains.annotations.Nullable)5 FormattingModel (com.intellij.formatting.FormattingModel)4 PsiElement (com.intellij.psi.PsiElement)4 CodeStyleSettingsManager (com.intellij.psi.codeStyle.CodeStyleSettingsManager)4 File (java.io.File)4 FormattingModelBuilder (com.intellij.formatting.FormattingModelBuilder)3 ASTNode (com.intellij.lang.ASTNode)3 Language (com.intellij.lang.Language)3 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)3