Search in sources :

Example 56 with CodeStyleSettings

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

the class LightIdeaTestFixtureImpl method tearDown.

@Override
public void tearDown() throws Exception {
    Project project = getProject();
    CodeStyleSettingsManager.getInstance(project).dropTemporarySettings();
    CodeStyleSettings oldCodeStyleSettings = myOldCodeStyleSettings;
    myOldCodeStyleSettings = null;
    new RunAll().append(() -> UsefulTestCase.doCheckForSettingsDamage(oldCodeStyleSettings, getCurrentCodeStyleSettings())).append(() -> LightPlatformTestCase.doTearDown(project, LightPlatformTestCase.getApplication())).append(() -> LightPlatformTestCase.checkEditorsReleased()).append(super::tearDown).append(() -> InjectedLanguageManagerImpl.checkInjectorsAreDisposed(project)).append(() -> PersistentFS.getInstance().clearIdCache()).append(() -> PlatformTestCase.cleanupApplicationCaches(project)).run();
}
Also used : Project(com.intellij.openapi.project.Project) CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings)

Example 57 with CodeStyleSettings

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

the class FlexAutoImportsTest method testWrapImportStatement.

@JSTestOptions({ JSTestOption.WithFlexSdk })
public void testWrapImportStatement() throws Throwable {
    CodeStyleSettings currentSettings = CodeStyleSettingsManager.getSettings(myFixture.getProject());
    int m = currentSettings.getDefaultRightMargin();
    currentSettings.setDefaultRightMargin(20);
    try {
        JSTestUtils.addClassesToProject(myFixture, true, "wwwwww.wwwwwwwwwwwww.wwwwwwwww.Wwwwwwwwwwwwwwwwwwww");
        launchImportIntention(AS_FILE_EXTENSION, "wwwwww.wwwwwwwwwwwww.wwwwwwwww.Wwwwwwwwwwwwwwwwwwww");
    } finally {
        currentSettings.setDefaultRightMargin(m);
    }
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) JSTestOptions(com.intellij.lang.javascript.JSTestOptions)

Example 58 with CodeStyleSettings

use of com.intellij.psi.codeStyle.CodeStyleSettings 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 59 with CodeStyleSettings

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

the class CodeStyleSettingsUtilImpl method showCodeStyleSettings.

/**
   * Shows code style settings suitable for the project passed. I.e. it shows project code style page if one
   * is configured to use own code style scheme or global one in other case.
   * @param project
   * @return Returns true if settings were modified during editing session.
   */
@Override
public boolean showCodeStyleSettings(Project project, final Class pageToSelect) {
    CodeStyleSettingsManager settingsManager = CodeStyleSettingsManager.getInstance(project);
    CodeStyleSettings savedSettings = settingsManager.getCurrentSettings().clone();
    final CodeStyleSchemesConfigurable configurable = new CodeStyleSchemesConfigurable(project);
    ShowSettingsUtil.getInstance().editConfigurable(project, configurable, () -> {
        if (pageToSelect != null) {
            configurable.selectPage(pageToSelect);
        }
    });
    return !savedSettings.equals(settingsManager.getCurrentSettings());
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings) CodeStyleSettingsManager(com.intellij.psi.codeStyle.CodeStyleSettingsManager)

Example 60 with CodeStyleSettings

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

the class CodeStyleSchemesModel method reset.

public void reset() {
    myUsePerProjectSettings = getProjectSettings().USE_PER_PROJECT_SETTINGS;
    mySettingsToClone.clear();
    mySchemes.clear();
    ContainerUtil.addAll(mySchemes, CodeStyleSchemesImpl.getSchemeManager().getAllSchemes());
    myGlobalSelected = CodeStyleSchemes.getInstance().findPreferredScheme(getProjectSettings().PREFERRED_PROJECT_CODE_STYLE);
    CodeStyleSettings perProjectSettings = getProjectSettings().PER_PROJECT_SETTINGS;
    if (perProjectSettings != null) {
        myProjectScheme.setCodeStyleSettings(perProjectSettings);
    }
    myDispatcher.getMulticaster().schemeListChanged();
    myDispatcher.getMulticaster().currentSchemeChanged(this);
}
Also used : CodeStyleSettings(com.intellij.psi.codeStyle.CodeStyleSettings)

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