Search in sources :

Example 1 with CodeStyleSettings

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

the class YAMLCodeStyleSettingsProvider method createSettingsPage.

@NotNull
@Override
public Configurable createSettingsPage(final CodeStyleSettings settings, final CodeStyleSettings originalSettings) {
    return new CodeStyleAbstractConfigurable(settings, originalSettings, YAMLLanguage.INSTANCE.getDisplayName()) {

        @Override
        protected CodeStyleAbstractPanel createPanel(final CodeStyleSettings settings) {
            final CodeStyleSettings currentSettings = getCurrentSettings();
            final CodeStyleSettings settings1 = settings;
            return new TabbedLanguageCodeStylePanel(YAMLLanguage.INSTANCE, currentSettings, settings1) {

                @Override
                protected void initTabs(final CodeStyleSettings settings) {
                    addIndentOptionsTab(settings);
                }
            };
        }

        @Override
        public String getHelpTopic() {
            return "reference.settingsdialog.codestyle.yaml";
        }
    };
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) CodeStyleAbstractConfigurable(com.intellij.application.options.CodeStyleAbstractConfigurable) TabbedLanguageCodeStylePanel(com.intellij.application.options.TabbedLanguageCodeStylePanel) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with CodeStyleSettings

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

the class PyInlineLocalTest method testResultExceedsRightMargin.

// PY-12409
public void testResultExceedsRightMargin() {
    final CodeStyleSettings settings = getCodeStyleSettings();
    final CommonCodeStyleSettings commonSettings = settings.getCommonSettings(PythonLanguage.getInstance());
    final int oldRightMargin = settings.getRightMargin(PythonLanguage.getInstance());
    final boolean oldWrapLongLines = commonSettings.WRAP_LONG_LINES;
    settings.setRightMargin(PythonLanguage.getInstance(), 80);
    commonSettings.WRAP_LONG_LINES = true;
    try {
        doTest();
    } finally {
        commonSettings.WRAP_LONG_LINES = oldWrapLongLines;
        settings.setRightMargin(PythonLanguage.getInstance(), oldRightMargin);
    }
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings)

Example 3 with CodeStyleSettings

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

the class XmlTypedHandlersTest method testSingleQuotes.

public void testSingleQuotes() {
    final CodeStyleSettings settings = getCurrentCodeStyleSettings();
    final CodeStyleSettings.QuoteStyle quote = settings.HTML_QUOTE_STYLE;
    try {
        settings.HTML_QUOTE_STYLE = CodeStyleSettings.QuoteStyle.Single;
        myFixture.configureByText(HtmlFileType.INSTANCE, "<foo bar<caret>");
        myFixture.type('=');
        myFixture.checkResult("<foo bar='<caret>'");
    } finally {
        CodeStyleSchemes.getInstance().getCurrentScheme().getCodeStyleSettings().HTML_QUOTE_STYLE = quote;
    }
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings)

Example 4 with CodeStyleSettings

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

the class XmlFormatterTestCase method testDontKeepLineBreaksInText.

public void testDontKeepLineBreaksInText() throws Throwable {
    final CodeStyleSettings settings = getSettings();
    final XmlCodeStyleSettings xmlSettings = settings.getCustomSettings(XmlCodeStyleSettings.class);
    settings.setDefaultRightMargin(15);
    settings.HTML_KEEP_LINE_BREAKS_IN_TEXT = false;
    xmlSettings.XML_KEEP_LINE_BREAKS_IN_TEXT = false;
    doTextTest("<tag>aaa\nbbb\nccc\nddd\n</tag>", "<tag>aaa bbb\n    ccc ddd\n</tag>");
    settings.HTML_TEXT_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
    xmlSettings.XML_TEXT_WRAP = CommonCodeStyleSettings.DO_NOT_WRAP;
    doTextTest("<tag>aaa\nbbb\nccc\nddd\n</tag>", "<tag>aaa bbb ccc ddd\n</tag>");
}
Also used : XmlCodeStyleSettings(com.intellij.psi.formatter.xml.XmlCodeStyleSettings) CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) XmlCodeStyleSettings(com.intellij.psi.formatter.xml.XmlCodeStyleSettings)

Example 5 with CodeStyleSettings

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

the class XmlEditorTest method testHardWrap.

public void testHardWrap() throws Exception {
    configureFromFileText("a.xml", "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" + "<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\">\n" + "<g>\n" + "        <path clip-path=\"url(#SVGID_2_)\" fill=\"#ffffff\" stroke=\"<selection>#000000</selection>\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-miterlimit=\"10\" d=\"M19.333,8.333V12c0,1.519-7.333,4-7.333,4s-7.333-2.481-7.333-4V8.333\"/>\n" + "</g>\n" + "</svg>");
    CodeStyleSettings clone = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().clone();
    clone.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
    try {
        CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(clone);
        EditorTestUtil.performTypingAction(getEditor(), 'x');
    } finally {
        CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
    }
    checkResultByText("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" + "<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\">\n" + "<g>\n" + "        <path clip-path=\"url(#SVGID_2_)\" fill=\"#ffffff\" stroke=\"x\" stroke-width=\"2\" stroke-linecap=\"round\" \n" + "              stroke-linejoin=\"round\" stroke-miterlimit=\"10\" d=\"M19.333,8.333V12c0,1.519-7.333,4-7.333,4s-7.333-2.481-7.333-4V8.333\"/>\n" + "</g>\n" + "</svg>");
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings)

Aggregations

CodeStyleSettings (com.intellij.psi.codeStyle.CodeStyleSettings)194 CommonCodeStyleSettings (com.intellij.psi.codeStyle.CommonCodeStyleSettings)85 Project (com.intellij.openapi.project.Project)13 XmlCodeStyleSettings (com.intellij.psi.formatter.xml.XmlCodeStyleSettings)12 Document (com.intellij.openapi.editor.Document)10 ECMA4CodeStyleSettings (com.intellij.lang.javascript.formatter.ECMA4CodeStyleSettings)9 JSCodeStyleSettings (com.intellij.lang.javascript.formatter.JSCodeStyleSettings)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 IOException (java.io.IOException)4 CodeStyleAbstractConfigurable (com.intellij.application.options.CodeStyleAbstractConfigurable)3 TabbedLanguageCodeStylePanel (com.intellij.application.options.TabbedLanguageCodeStylePanel)3 FormattingModelBuilder (com.intellij.formatting.FormattingModelBuilder)3