Java Code Examples for com.intellij.psi.codeStyle.CodeStyleSettings#clone()

The following examples show how to use com.intellij.psi.codeStyle.CodeStyleSettings#clone() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodeStyleSchemeImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void init(@Nullable CodeStyleScheme parentScheme, Element root) {
  if (parentScheme == null) {
    myCodeStyleSettings = new CodeStyleSettings();
  }
  else {
    CodeStyleSettings parentSettings = parentScheme.getCodeStyleSettings();
    myCodeStyleSettings = parentSettings.clone();
    while (parentSettings.getParentSettings() != null) {
      parentSettings = parentSettings.getParentSettings();
    }
    myCodeStyleSettings.setParentSettings(parentSettings);
  }
  if (root != null) {
    try {
      readExternal(root);
    }
    catch (InvalidDataException e) {
      LOG.error(e);
    }
  }
}
 
Example 2
Source File: BashFormatterTestCase.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
protected void setSettings(Project project) {
    Assert.assertNull(myTempSettings);
    CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);
    myTempSettings = settings.clone();

    CodeStyleSettings.IndentOptions gr = myTempSettings.getIndentOptions(BashFileType.BASH_FILE_TYPE);
    Assert.assertNotSame(gr, settings.OTHER_INDENT_OPTIONS);
    gr.INDENT_SIZE = 2;
    gr.CONTINUATION_INDENT_SIZE = 4;
    gr.TAB_SIZE = 2;
    myTempSettings.CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND = 3;

    CodeStyleSettingsManager.getInstance(project).setTemporarySettings(myTempSettings);
}
 
Example 3
Source File: HaxeFormatterTest.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Override
public void setTestStyleSettings() {
  Project project = getProject();
  CodeStyleSettings currSettings = CodeStyleSettingsManager.getSettings(project);
  assertNotNull(currSettings);
  CodeStyleSettings tempSettings = currSettings.clone();
  CodeStyleSettings.IndentOptions indentOptions = tempSettings.getIndentOptions(HaxeFileType.HAXE_FILE_TYPE);
  assertNotNull(indentOptions);
  defineStyleSettings(tempSettings);
  CodeStyleSettingsManager.getInstance(project).setTemporarySettings(tempSettings);
}
 
Example 4
Source File: HaxeCodeInsightFixtureTestCase.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public void setTestStyleSettings(int indent) {
  Project project = getProject();
  CodeStyleSettings currSettings = CodeStyleSettingsManager.getSettings(project);
  assertNotNull(currSettings);
  CodeStyleSettings tempSettings = currSettings.clone();
  CodeStyleSettings.IndentOptions indentOptions = tempSettings.getIndentOptions(HaxeFileType.HAXE_FILE_TYPE);
  indentOptions.INDENT_SIZE = indent;
  assertNotNull(indentOptions);
  CodeStyleSettingsManager.getInstance(project).setTemporarySettings(tempSettings);
}
 
Example 5
Source File: XQueryFormattingModelBuilderTest.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private void setTestStyleSettings() {
    CodeStyleSettingsManager settingsManager = CodeStyleSettingsManager.getInstance(getProject());
    CodeStyleSettings currSettings = settingsManager.getCurrentSettings();
    Assert.assertNotNull(currSettings);
    myTemporarySettings = currSettings.clone();
    CodeStyleSettings.IndentOptions indentOptions = myTemporarySettings.getIndentOptions(XQueryFileType.INSTANCE);
    Assert.assertNotNull(indentOptions);
    settingsManager.setTemporarySettings(myTemporarySettings);
}
 
Example 6
Source File: CodeStyleSchemesConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void apply() throws ConfigurationException {
  if (!myApplyCompleted) {
    try {
      super.apply();

      for (CodeStyleScheme scheme : new ArrayList<>(myModel.getSchemes())) {
        final boolean isDefaultModified = CodeStyleSchemesModel.cannotBeModified(scheme) && isSchemeModified(scheme);
        if (isDefaultModified) {
          CodeStyleScheme newscheme = myModel.createNewScheme(null, scheme);
          CodeStyleSettings settingsWillBeModified = scheme.getCodeStyleSettings();
          CodeStyleSettings notModifiedSettings = settingsWillBeModified.clone();
          ((CodeStyleSchemeImpl)scheme).setCodeStyleSettings(notModifiedSettings);
          ((CodeStyleSchemeImpl)newscheme).setCodeStyleSettings(settingsWillBeModified);
          myModel.addScheme(newscheme, false);

          if (myModel.getSelectedScheme() == scheme) {
            myModel.selectScheme(newscheme, this);
          }

        }
      }

      for (CodeStyleConfigurableWrapper panel : myPanels) {
        panel.applyPanel();
      }

      myModel.apply();
      EditorFactory.getInstance().refreshAllEditors();
    }
    finally {
      myApplyCompleted = true;
    }
  }
}