类com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider源码实例Demo

下面列出了怎么用com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider的API类实例代码及写法,或者点击链接到github查看源代码。


/**
 * 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();
}
 

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);
}
 
源代码3 项目: consulo   文件: FixDocCommentAction.java

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));
}
 
源代码4 项目: consulo   文件: CommenterForm.java

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());
}
 

@Override
protected String getPreviewText() {
  if (getDefaultLanguage() == null) return "";
  String sample = LanguageCodeStyleSettingsProvider.getCodeSample(getDefaultLanguage(), getSettingsType());
  if (sample == null) return "";
  return sample;
}
 

@Override
public String getCodeSample(LanguageCodeStyleSettingsProvider.SettingsType settingsType) {
  return BuckFileUtil.getSampleBuckFile();
}
 
源代码7 项目: consulo   文件: CodeStyleSpacesPanel.java

@Override
public LanguageCodeStyleSettingsProvider.SettingsType getSettingsType() {
  return LanguageCodeStyleSettingsProvider.SettingsType.SPACING_SETTINGS;
}
 

protected void customizeSettings() {
  LanguageCodeStyleSettingsProvider provider = LanguageCodeStyleSettingsProvider.forLanguage(getDefaultLanguage());
  if (provider != null) {
    provider.customizeSettings(this, getSettingsType());
  }
}
 

@Override
protected int getRightMargin() {
  if (getDefaultLanguage() == null) return -1;
  return LanguageCodeStyleSettingsProvider.getRightMargin(getDefaultLanguage(), getSettingsType());
}
 

@Override
protected String getFileExt() {
  String fileExt = LanguageCodeStyleSettingsProvider.getFileExt(getDefaultLanguage());
  if (fileExt != null) return fileExt;
  return super.getFileExt();
}
 
源代码11 项目: consulo   文件: CodeStyleBlankLinesPanel.java

@Override
public LanguageCodeStyleSettingsProvider.SettingsType getSettingsType() {
  return LanguageCodeStyleSettingsProvider.SettingsType.BLANK_LINES_SETTINGS;
}
 
源代码12 项目: consulo   文件: IndentOptionsEditor.java

/**
 * @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;
}
 

public abstract LanguageCodeStyleSettingsProvider.SettingsType getSettingsType(); 
 类所在包
 类方法
 同包方法