com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider Java Examples

The following examples show how to use com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider. 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: CodeStyleSettingPresentation.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an immutable map containing all standard settings in a mapping of type (group -> settings contained in the group).
 * Notice that lists containing settings for a specific group are also immutable. Use copies to make modifications.
 *
 * @param settingsType type to get standard settings for
 * @return mapping setting groups to contained setting presentations
 */
@Nonnull
public static Map<SettingsGroup, List<CodeStyleSettingPresentation>> getStandardSettings(LanguageCodeStyleSettingsProvider.SettingsType settingsType) {
  switch (settingsType) {
    case BLANK_LINES_SETTINGS:
      return BLANK_LINES_STANDARD_SETTINGS;
    case SPACING_SETTINGS:
      return SPACING_STANDARD_SETTINGS;
    case WRAPPING_AND_BRACES_SETTINGS:
      return WRAPPING_AND_BRACES_STANDARD_SETTINGS;
    case INDENT_SETTINGS:
      return INDENT_STANDARD_SETTINGS;
    case LANGUAGE_SPECIFIC:
  }
  return ContainerUtil.newLinkedHashMap();
}
 
Example #2
Source File: SmartIndentOptionsEditor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public SmartIndentOptionsEditor(@Nullable LanguageCodeStyleSettingsProvider provider) {
  super(provider);
  myContinuationOption = createContinuationOption(CONTINUATION_INDENT_LABEL, options -> options.CONTINUATION_INDENT_SIZE, (options, value) -> options.CONTINUATION_INDENT_SIZE = value,
                                                  DEFAULT_CONTINUATION_INDENT_SIZE);
  myContinuationOption.setSupported(true);

  myDeclarationParameterIndentOption =
          createContinuationOption("Declaration parameter indent:", options -> options.DECLARATION_PARAMETER_INDENT, (options, value) -> options.DECLARATION_PARAMETER_INDENT = value, -1);
  myGenericTypeParameterIndentOption =
          createContinuationOption("Generic type parameter indent:", options -> options.GENERIC_TYPE_PARAMETER_INDENT, (options, value) -> options.GENERIC_TYPE_PARAMETER_INDENT = value, -1);
  myCallParameterIndentOption = createContinuationOption("Call parameter indent:", options -> options.CALL_PARAMETER_INDENT, (options, value) -> options.CALL_PARAMETER_INDENT = value, -1);
  myChainedCallIndentOption = createContinuationOption("Chained call indent:", options -> options.CHAINED_CALL_INDENT, (options, value) -> options.CHAINED_CALL_INDENT = value, -1);
  myArrayElementIndentOption = createContinuationOption("Array element indent:", options -> options.ARRAY_ELEMENT_INDENT, (options, value) -> options.ARRAY_ELEMENT_INDENT = value, -1);
}
 
Example #3
Source File: FixDocCommentAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void reformatCommentKeepingEmptyTags(@Nonnull PsiFile file, @Nonnull Project project, int start, int end) {
  CodeStyleSettings tempSettings = CodeStyle.getSettings(file).clone();
  LanguageCodeStyleSettingsProvider langProvider = LanguageCodeStyleSettingsProvider.forLanguage(file.getLanguage());
  if (langProvider != null) {
    DocCommentSettings docCommentSettings = langProvider.getDocCommentSettings(tempSettings);
    docCommentSettings.setRemoveEmptyTags(false);
  }
  CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project);
  CodeStyle.doWithTemporarySettings(project, tempSettings, () -> codeStyleManager.reformatText(file, start, end));
}
 
Example #4
Source File: CommenterForm.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void customizeSettings() {
  setAllOptionsVisible(false);
  LanguageCodeStyleSettingsProvider settingsProvider = LanguageCodeStyleSettingsProvider.forLanguage(myLanguage);
  if (settingsProvider != null) {
    settingsProvider.customizeSettings(this, LanguageCodeStyleSettingsProvider.SettingsType.COMMENTER_SETTINGS);
  }
  myCommenterPanel.setVisible(myLineCommentAtFirstColumnCb.isVisible() || myLineCommentAddSpaceCb.isVisible() || myBlockCommentAtFirstJBCheckBox.isVisible());
}
 
Example #5
Source File: CustomizableLanguageCodeStylePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected String getPreviewText() {
  if (getDefaultLanguage() == null) return "";
  String sample = LanguageCodeStyleSettingsProvider.getCodeSample(getDefaultLanguage(), getSettingsType());
  if (sample == null) return "";
  return sample;
}
 
Example #6
Source File: BuckLanguageCodeStyleSettingsProvider.java    From buck with Apache License 2.0 4 votes vote down vote up
@Override
public String getCodeSample(LanguageCodeStyleSettingsProvider.SettingsType settingsType) {
  return BuckFileUtil.getSampleBuckFile();
}
 
Example #7
Source File: CodeStyleSpacesPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public LanguageCodeStyleSettingsProvider.SettingsType getSettingsType() {
  return LanguageCodeStyleSettingsProvider.SettingsType.SPACING_SETTINGS;
}
 
Example #8
Source File: CustomizableLanguageCodeStylePanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected void customizeSettings() {
  LanguageCodeStyleSettingsProvider provider = LanguageCodeStyleSettingsProvider.forLanguage(getDefaultLanguage());
  if (provider != null) {
    provider.customizeSettings(this, getSettingsType());
  }
}
 
Example #9
Source File: CustomizableLanguageCodeStylePanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected int getRightMargin() {
  if (getDefaultLanguage() == null) return -1;
  return LanguageCodeStyleSettingsProvider.getRightMargin(getDefaultLanguage(), getSettingsType());
}
 
Example #10
Source File: CustomizableLanguageCodeStylePanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
protected String getFileExt() {
  String fileExt = LanguageCodeStyleSettingsProvider.getFileExt(getDefaultLanguage());
  if (fileExt != null) return fileExt;
  return super.getFileExt();
}
 
Example #11
Source File: CodeStyleBlankLinesPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public LanguageCodeStyleSettingsProvider.SettingsType getSettingsType() {
  return LanguageCodeStyleSettingsProvider.SettingsType.BLANK_LINES_SETTINGS;
}
 
Example #12
Source File: IndentOptionsEditor.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * @param provider The provider which will be used to customize the indent options editor. If {@code null} is passed, no customization
 *                 will be carried out and thus all the available options will be shown.
 */
public IndentOptionsEditor(@Nullable LanguageCodeStyleSettingsProvider provider) {
  myProvider = provider;
}
 
Example #13
Source File: CustomizableLanguageCodeStylePanel.java    From consulo with Apache License 2.0 votes vote down vote up
public abstract LanguageCodeStyleSettingsProvider.SettingsType getSettingsType();