Deprecate more CodeStyleFacade methods in favor of CodeStyle API

This commit is contained in:
Rustam Vishnyakov
2018-04-12 16:25:56 +03:00
parent fe81f8c91c
commit 1c30af9eee
4 changed files with 22 additions and 16 deletions
@@ -16,7 +16,6 @@
package com.intellij.application.options;
import com.intellij.application.options.codeStyle.CodeStyleSchemesModel;
import com.intellij.codeStyle.CodeStyleFacade;
import com.intellij.lang.Language;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationBundle;
@@ -198,7 +197,7 @@ public abstract class CodeStyleAbstractPanel implements Disposable {
private int getAdjustedRightMargin() {
int result = getRightMargin();
return result > 0 ? result : CodeStyleFacade.getInstance(ProjectUtil.guessCurrentProject(getPanel())).getRightMargin(getDefaultLanguage());
return result > 0 ? result : CodeStyle.getSettings(ProjectUtil.guessCurrentProject(getPanel())).getRightMargin(getDefaultLanguage());
}
protected abstract int getRightMargin();
@@ -74,14 +74,9 @@ public class CodeStyleFacadeImpl extends CodeStyleFacade {
return indent != null ? indent : (allowDocCommit ? getLineIndent(editor.getDocument(), offset) : null);
}
/**
* @deprecated Use {@code getLineSeparator()} method of {@link CodeStyle#getSettings(PsiFile)} or
* {@link CodeStyle#getSettings(Project)} if there is no {@code PsiFile}
*/
@Deprecated
@Override
public String getLineSeparator() {
return CodeStyleSettingsManager.getSettings(myProject).getLineSeparator();
return CodeStyle.getSettings(myProject).getLineSeparator();
}
@Override
@@ -96,21 +91,21 @@ public class CodeStyleFacadeImpl extends CodeStyleFacade {
@Override
public int getRightMargin(Language language) {
return CodeStyleSettingsManager.getSettings(myProject).getRightMargin(language);
return CodeStyle.getSettings(myProject).getRightMargin(language);
}
@Override
public int getTabSize(final FileType fileType) {
return CodeStyleSettingsManager.getSettings(myProject).getTabSize(fileType);
return CodeStyle.getSettings(myProject).getTabSize(fileType);
}
@Override
public boolean isSmartTabs(final FileType fileType) {
return CodeStyleSettingsManager.getSettings(myProject).isSmartTabs(fileType);
return CodeStyle.getSettings(myProject).isSmartTabs(fileType);
}
@Override
public boolean useTabCharacter(final FileType fileType) {
return CodeStyleSettingsManager.getSettings(myProject).useTabCharacter(fileType);
return CodeStyle.getSettings(myProject).useTabCharacter(fileType);
}
}
@@ -84,14 +84,25 @@ public abstract class CodeStyleFacade {
*/
public abstract boolean isSmartTabs(final FileType fileType);
/**
* @deprecated Use {@code getRightMargin(Language)} method of {@code CodeStyle.getSettings(PsiFile)} or
* {@code CodeStyle.getSettings(Project)} if there is no {@code PsiFile}
*/
public abstract int getRightMargin(Language language);
/**
* @deprecated Use {@code CodeStyle.getIndentOptions(PsiFile).TAB_SIZE}. See {@code CodeStyle for more information}
*/
public abstract int getTabSize(final FileType fileType);
/**
* @deprecated Use {@code CodeStyle.getIndentOptions(PsiFile).USE_TAB_CHARACTER}. See {@code CodeStyle for more information}
*/
public abstract boolean useTabCharacter(final FileType fileType);
/**
* @deprecated Use {@code CodeStyle.getDefaultLineSeparator()} or {@code CodeStyle.getLineSeparator(Project)}
* @deprecated Use {@code getLineSeparator()} method of {@code CodeStyle.getSettings(PsiFile)} or
* {@code CodeStyle.getSettings(Project)} if there is no {@code PsiFile}
*/
public abstract String getLineSeparator();
@@ -3,7 +3,6 @@
package com.intellij.openapi.editor.impl;
import com.intellij.application.options.CodeStyle;
import com.intellij.codeStyle.CodeStyleFacade;
import com.intellij.lang.Language;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
@@ -212,8 +211,10 @@ public class SettingsImpl implements EditorSettings {
@Override
public int getRightMargin(Project project) {
return myRightMargin != null ? myRightMargin.intValue() :
CodeStyleFacade.getInstance(project).getRightMargin(myLanguage);
if (myRightMargin != null) return myRightMargin.intValue();
return myEditor != null
? CodeStyle.getSettings(myEditor).getRightMargin(myLanguage)
: CodeStyle.getProjectOrDefaultSettings(project).getRightMargin(myLanguage);
}
@Nullable