當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。