Search in sources :

Example 31 with CodeStyleSettings

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

the class JsonCodeStyleSettingsProvider method createSettingsPage.

@NotNull
@Override
public Configurable createSettingsPage(CodeStyleSettings settings, CodeStyleSettings originalSettings) {
    return new CodeStyleAbstractConfigurable(settings, originalSettings, "JSON") {

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

                @Override
                protected void initTabs(CodeStyleSettings settings) {
                    addIndentOptionsTab(settings);
                    addSpacesTab(settings);
                    addBlankLinesTab(settings);
                    addWrappingAndBracesTab(settings);
                    addTab(new JsonCodeStylePanel(settings));
                }
            };
        }

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

Example 32 with CodeStyleSettings

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

the class ProblematicWhitespaceInspectionTest method testTabsInFile.

public void testTabsInFile() {
    final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
    settings.getIndentOptions(JavaFileType.INSTANCE).USE_TAB_CHARACTER = false;
    doTest("/*File 'X.java' uses tabs for indentation*/class X {\n" + "\tString s;\n" + "}\n/**/");
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings)

Example 33 with CodeStyleSettings

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

the class UnnecessaryFullyQualifiedNameFixTest method doTest.

private void doTest(@Language("JAVA") @NotNull @NonNls String before, @Language("JAVA") @NotNull @NonNls String after, @MagicConstant(intValues = { JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_ALWAYS, JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_IF_NOT_IMPORTED, JavaCodeStyleSettings.SHORTEN_NAMES_ALWAYS_AND_ADD_IMPORT }) int classNamesInJavadoc, String fileName) {
    final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
    final JavaCodeStyleSettings javaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class);
    final int oldClassNamesInJavadoc = javaSettings.CLASS_NAMES_IN_JAVADOC;
    try {
        javaSettings.CLASS_NAMES_IN_JAVADOC = classNamesInJavadoc;
        doTest(InspectionGadgetsBundle.message("unnecessary.fully.qualified.name.replace.quickfix"), before, after, fileName);
    } finally {
        javaSettings.CLASS_NAMES_IN_JAVADOC = oldClassNamesInJavadoc;
    }
}
Also used : JavaCodeStyleSettings(com.intellij.psi.codeStyle.JavaCodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) JavaCodeStyleSettings(com.intellij.psi.codeStyle.JavaCodeStyleSettings)

Example 34 with CodeStyleSettings

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

the class SuspiciousGetterSetterInspectionTest method testSuspiciousGetterSetter.

public void testSuspiciousGetterSetter() {
    final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings();
    final String oldPrefix = settings.FIELD_NAME_PREFIX;
    try {
        settings.FIELD_NAME_PREFIX = "my";
        doTest();
    } finally {
        settings.FIELD_NAME_PREFIX = oldPrefix;
    }
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings)

Example 35 with CodeStyleSettings

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

the class ProblematicWhitespaceInspectionTest method testSmartTabsInFile2.

public void testSmartTabsInFile2() {
    final CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(getProject());
    final CommonCodeStyleSettings.IndentOptions options = settings.getIndentOptions(JavaFileType.INSTANCE);
    options.USE_TAB_CHARACTER = true;
    options.SMART_TABS = true;
    doTest("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");
}
Also used : CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) CommonCodeStyleSettings(com.intellij.psi.codeStyle.CommonCodeStyleSettings)

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