From fc99d5cffc64bce5d961bc8b6cf99f81700ef5a4 Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Wed, 4 Mar 2015 17:52:00 +0300 Subject: [PATCH] Deprecate FormattingModelBuilderEx.getIndentOptionsToUse(), replaced with FileIndentOptionsProvider. --- .../intellij/formatting/FormattingModelBuilderEx.java | 4 ++++ .../psi/impl/source/codeStyle/CodeFormatterFacade.java | 9 ++------- .../impl/source/codeStyle/CodeStyleManagerRunnable.java | 8 +------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/formatting/FormattingModelBuilderEx.java b/platform/lang-impl/src/com/intellij/formatting/FormattingModelBuilderEx.java index f08c374d36b4..0b0c83851740 100644 --- a/platform/lang-impl/src/com/intellij/formatting/FormattingModelBuilderEx.java +++ b/platform/lang-impl/src/com/intellij/formatting/FormattingModelBuilderEx.java @@ -50,8 +50,12 @@ public interface FormattingModelBuilderEx extends FormattingModelBuilder { * @param settings code style settings holder * @return indent options to use for the target formatting operation (if any adjustment is required); * null to trigger default algorithm usage + * @deprecated Use FileIndentOptionsProvider instead. + * @see com.intellij.psi.codeStyle.FileIndentOptionsProvider */ + @SuppressWarnings("UnusedDeclaration") @Nullable + @Deprecated CommonCodeStyleSettings.IndentOptions getIndentOptionsToUse(@NotNull PsiFile file, @NotNull FormatTextRanges ranges, @NotNull CodeStyleSettings settings); diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java index dc24b2b1d583..f1cf75b4a2fe 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeFormatterFacade.java @@ -237,13 +237,8 @@ public class CodeFormatterFacade { formatter.setProgressTask(new FormattingProgressTask(project, file, document)); } - CommonCodeStyleSettings.IndentOptions indentOptions = null; - if (builder instanceof FormattingModelBuilderEx) { - indentOptions = ((FormattingModelBuilderEx)builder).getIndentOptionsToUse(file, ranges, mySettings); - } - if (indentOptions == null) { - indentOptions = mySettings.getIndentOptionsByFile(file, textRanges.size() == 1 ? textRanges.get(0).getTextRange() : null); - } + CommonCodeStyleSettings.IndentOptions indentOptions = + mySettings.getIndentOptionsByFile(file, textRanges.size() == 1 ? textRanges.get(0).getTextRange() : null); formatter.format(model, mySettings, indentOptions, ranges); for (FormatTextRanges.FormatTextRange range : textRanges) { diff --git a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerRunnable.java b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerRunnable.java index f3e6df48ae1c..c220e5078f27 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerRunnable.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerRunnable.java @@ -94,13 +94,7 @@ abstract class CodeStyleManagerRunnable { mySettings = CodeStyleSettingsManager.getSettings(myCodeStyleManager.getProject()); mySignificantRange = offset != -1 ? getSignificantRange(file, offset) : null; - - if (builder instanceof FormattingModelBuilderEx) { - myIndentOptions = ((FormattingModelBuilderEx)builder).getIndentOptionsToUse(file, new FormatTextRanges(mySignificantRange, true), mySettings); - } - if (myIndentOptions == null) { - myIndentOptions = mySettings.getIndentOptionsByFile(file); - } + myIndentOptions = mySettings.getIndentOptionsByFile(file, mySignificantRange); myModel = CoreFormatterUtil.buildModel(builder, file, mySettings, myMode);