本文整理汇总了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);
}
示例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);
}
}
示例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);
}