当前位置: 首页>>代码示例>>Java>>正文


Java CodeStyleSettings.getIndentOptionsByFile方法代码示例

本文整理汇总了Java中com.intellij.psi.codeStyle.CodeStyleSettings.getIndentOptionsByFile方法的典型用法代码示例。如果您正苦于以下问题:Java CodeStyleSettings.getIndentOptionsByFile方法的具体用法?Java CodeStyleSettings.getIndentOptionsByFile怎么用?Java CodeStyleSettings.getIndentOptionsByFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.codeStyle.CodeStyleSettings的用法示例。


在下文中一共展示了CodeStyleSettings.getIndentOptionsByFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doProcess

import com.intellij.psi.codeStyle.CodeStyleSettings; //导入方法依赖的package包/类
@NotNull
private static TextRange doProcess(@NotNull PsiElement source, @NotNull TextRange range, @NotNull CodeStyleSettings settings) {
  ASTNode node = source.getNode();
  if (node == null) {
    return range;
  }

  Language language = source.getLanguage();
  if (language != JavaLanguage.INSTANCE) {
    // We had the only complaint for tabs not being converted to spaces for now. It was for the java code which has
    // a single block for the multi-line comment. This check should be removed if it is decided to generalize
    // this logic to other languages as well.
    return range;
  }

  if (!source.isValid()) return range;
  PsiFile file = source.getContainingFile();
  CommonCodeStyleSettings.IndentOptions indentOptions = settings.getIndentOptionsByFile(file, range);

  boolean useTabs = indentOptions.USE_TAB_CHARACTER;
  boolean smartTabs = indentOptions.SMART_TABS;
  int tabWidth = indentOptions.TAB_SIZE;
  return processViaPsi(node, range, new TreeHelperImpl(), useTabs, smartTabs, tabWidth);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:TabPostFormatProcessor.java

示例2: reinitDocumentIndentOptions

import com.intellij.psi.codeStyle.CodeStyleSettings; //导入方法依赖的package包/类
private void reinitDocumentIndentOptions() {
  if (myEditor == null) return;
  final Project project = myEditor.getProject();
  final DocumentEx document = myEditor.getDocument();

  if (project == null || project.isDisposed()) return;

  final PsiDocumentManager psiManager = PsiDocumentManager.getInstance(project);
  final PsiFile file = psiManager.getPsiFile(document);
  if (file == null) return;

  CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(project).getCurrentSettings();
  CommonCodeStyleSettings.IndentOptions options = settings.getIndentOptionsByFile(file);

  if (CodeStyleSettings.isRecalculateForCommittedDocument(options)) {
    PsiDocumentManager.getInstance(project).performForCommittedDocument(document, new Runnable() {
      @Override
      public void run() {
        CodeStyleSettingsManager.updateDocumentIndentOptions(project, document);
      }
    });
  }
  else {
    CodeStyleSettingsManager.updateDocumentIndentOptions(project, document);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:SettingsImpl.java

示例3: ImportsFormatter

import com.intellij.psi.codeStyle.CodeStyleSettings; //导入方法依赖的package包/类
public ImportsFormatter(@NotNull CodeStyleSettings settings, @NotNull PsiFile file) {
  myPostProcessor = new PostFormatProcessorHelper(settings);
  myDocumentModel = FormattingDocumentModelImpl.createOn(file);
  myIndentOptions = settings.getIndentOptionsByFile(file);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:ImportsFormatter.java


注:本文中的com.intellij.psi.codeStyle.CodeStyleSettings.getIndentOptionsByFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。