本文整理匯總了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);
}