Search in sources :

Example 11 with XmlCodeStyleSettings

use of com.intellij.psi.formatter.xml.XmlCodeStyleSettings in project intellij-plugins by JetBrains.

the class FlexOptimizeImportsTest method testAmbiguous3.

@JSTestOptions({ JSTestOption.WithJsSupportLoader, JSTestOption.WithFlexSdk })
public void testAmbiguous3() throws Throwable {
    final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
    XmlCodeStyleSettings xmlSettings = styleSettings.getCustomSettings(XmlCodeStyleSettings.class);
    int aroundCDataBefore = xmlSettings.XML_WHITE_SPACE_AROUND_CDATA;
    xmlSettings.XML_WHITE_SPACE_AROUND_CDATA = XmlCodeStyleSettings.WS_AROUND_CDATA_NEW_LINES;
    JSTestUtils.addClassesToProject(myFixture, true, "com.a.ClassB", "com.b.ClassB");
    runOptimizeAction(MXML_FILE_EXTENSION);
    xmlSettings.XML_WHITE_SPACE_AROUND_CDATA = aroundCDataBefore;
}
Also used : JSCodeStyleSettings(com.intellij.lang.javascript.formatter.JSCodeStyleSettings) 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) JSTestOptions(com.intellij.lang.javascript.JSTestOptions)

Example 12 with XmlCodeStyleSettings

use of com.intellij.psi.formatter.xml.XmlCodeStyleSettings 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)

Example 13 with XmlCodeStyleSettings

use of com.intellij.psi.formatter.xml.XmlCodeStyleSettings in project intellij-plugins by JetBrains.

the class ActionScriptFormatterTest method testCdataDamaged.

public void testCdataDamaged() throws Exception {
    final CodeStyleSettings styleSettings = CodeStyleSettingsManager.getSettings(getProject());
    final XmlCodeStyleSettings xmlSettings = styleSettings.getCustomSettings(XmlCodeStyleSettings.class);
    int before = styleSettings.getTabSize(StdFileTypes.XML);
    int aroundCDataBefore = xmlSettings.XML_WHITE_SPACE_AROUND_CDATA;
    try {
        styleSettings.getIndentOptions(StdFileTypes.XML).TAB_SIZE = 4;
        xmlSettings.XML_WHITE_SPACE_AROUND_CDATA = XmlCodeStyleSettings.WS_AROUND_CDATA_NEW_LINES;
        myUseReformatText = true;
        doTestFromFile("mxml");
    } finally {
        styleSettings.getIndentOptions(StdFileTypes.XML).TAB_SIZE = before;
        xmlSettings.XML_WHITE_SPACE_AROUND_CDATA = aroundCDataBefore;
        myUseReformatText = false;
    }
}
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)

Example 14 with XmlCodeStyleSettings

use of com.intellij.psi.formatter.xml.XmlCodeStyleSettings in project intellij-community by JetBrains.

the class Xslt2RefactoringTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(myFixture.getProject()).getCurrentSettings();
    XmlCodeStyleSettings xmlSettings = settings.getCustomSettings(XmlCodeStyleSettings.class);
    xmlSettings.XML_SPACE_INSIDE_EMPTY_TAG = true;
    settings.getIndentOptions(StdFileTypes.XML).INDENT_SIZE = 2;
}
Also used : XmlCodeStyleSettings(com.intellij.psi.formatter.xml.XmlCodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) XmlCodeStyleSettings(com.intellij.psi.formatter.xml.XmlCodeStyleSettings)

Example 15 with XmlCodeStyleSettings

use of com.intellij.psi.formatter.xml.XmlCodeStyleSettings in project android by JetBrains.

the class AndroidXmlPredefinedCodeStyle method apply.

@Override
public void apply(CodeStyleSettings settings) {
    final CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptions(XmlFileType.INSTANCE);
    indentOptions.CONTINUATION_INDENT_SIZE = indentOptions.INDENT_SIZE;
    XmlCodeStyleSettings xmlSettings = settings.getCustomSettings(XmlCodeStyleSettings.class);
    xmlSettings.XML_ALIGN_ATTRIBUTES = false;
    xmlSettings.XML_SPACE_INSIDE_EMPTY_TAG = true;
    xmlSettings.XML_KEEP_LINE_BREAKS = false;
    final AndroidXmlCodeStyleSettings androidSettings = AndroidXmlCodeStyleSettings.getInstance(settings);
    androidSettings.USE_CUSTOM_SETTINGS = true;
    androidSettings.LAYOUT_SETTINGS = new AndroidXmlCodeStyleSettings.LayoutSettings();
    androidSettings.MANIFEST_SETTINGS = new AndroidXmlCodeStyleSettings.ManifestSettings();
    androidSettings.VALUE_RESOURCE_FILE_SETTINGS = new AndroidXmlCodeStyleSettings.ValueResourceFileSettings();
    androidSettings.OTHER_SETTINGS = new AndroidXmlCodeStyleSettings.OtherSettings();
    // arrangement
    final List<StdArrangementMatchRule> rules = new ArrayList<StdArrangementMatchRule>();
    rules.add(attrArrangementRule("xmlns:android", "^$", KEEP));
    rules.add(attrArrangementRule("xmlns:.*", "^$", BY_NAME));
    rules.add(attrArrangementRule(".*:id", SdkConstants.NS_RESOURCES, KEEP));
    rules.add(attrArrangementRule(".*:name", SdkConstants.NS_RESOURCES, KEEP));
    rules.add(attrArrangementRule("name", "^$", KEEP));
    rules.add(attrArrangementRule("style", "^$", KEEP));
    rules.add(attrArrangementRule(".*", "^$", BY_NAME));
    rules.add(attrArrangementRule(".*:layout_width", SdkConstants.NS_RESOURCES, KEEP));
    rules.add(attrArrangementRule(".*:layout_height", SdkConstants.NS_RESOURCES, KEEP));
    rules.add(attrArrangementRule(".*:layout_.*", SdkConstants.NS_RESOURCES, BY_NAME));
    rules.add(attrArrangementRule(".*:width", SdkConstants.NS_RESOURCES, BY_NAME));
    rules.add(attrArrangementRule(".*:height", SdkConstants.NS_RESOURCES, BY_NAME));
    rules.add(attrArrangementRule(".*", SdkConstants.NS_RESOURCES, BY_NAME));
    rules.add(attrArrangementRule(".*", ".*", BY_NAME));
    // TODO: Should sort name:"color",namespace:"" to the end (primarily for color state lists)
    final CommonCodeStyleSettings xmlCommonSettings = settings.getCommonSettings(XMLLanguage.INSTANCE);
    xmlCommonSettings.setArrangementSettings(StdArrangementSettings.createByMatchRules(ContainerUtil.<ArrangementGroupingRule>emptyList(), rules));
    xmlCommonSettings.FORCE_REARRANGE_MODE = CommonCodeStyleSettings.REARRANGE_ALWAYS;
}
Also used : ArrangementGroupingRule(com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule) CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) ArrayList(java.util.ArrayList) XmlCodeStyleSettings(com.intellij.psi.formatter.xml.XmlCodeStyleSettings) StdArrangementMatchRule(com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule)

Aggregations

XmlCodeStyleSettings (com.intellij.psi.formatter.xml.XmlCodeStyleSettings)23 AndroidXmlCodeStyleSettings (org.jetbrains.android.formatter.AndroidXmlCodeStyleSettings)10 CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)9 ECMA4CodeStyleSettings (com.intellij.lang.javascript.formatter.ECMA4CodeStyleSettings)6 JSCodeStyleSettings (com.intellij.lang.javascript.formatter.JSCodeStyleSettings)6 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)5 JSTestOptions (com.intellij.lang.javascript.JSTestOptions)2 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ArrangementGroupingRule (com.intellij.psi.codeStyle.arrangement.group.ArrangementGroupingRule)1 StdArrangementMatchRule (com.intellij.psi.codeStyle.arrangement.match.StdArrangementMatchRule)1 ArrayList (java.util.ArrayList)1 ChooseFileIntentionAction (org.jetbrains.idea.maven.dom.intentions.ChooseFileIntentionAction)1 MavenDomDependency (org.jetbrains.idea.maven.dom.model.MavenDomDependency)1 MavenDomProjectModel (org.jetbrains.idea.maven.dom.model.MavenDomProjectModel)1