mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Migration to PsiFile-based code style API
This commit is contained in:
@@ -39,6 +39,7 @@ public class CodeStyle {
|
||||
*/
|
||||
@NotNull
|
||||
public static CodeStyleSettings getDefaultSettings() {
|
||||
//noinspection deprecation
|
||||
return CodeStyleSettingsManager.getInstance().getCurrentSettings();
|
||||
}
|
||||
|
||||
@@ -68,6 +69,19 @@ public class CodeStyle {
|
||||
return getDefaultSettings();
|
||||
}
|
||||
|
||||
|
||||
public static CodeStyleSettings getSettings(@NotNull Editor editor) {
|
||||
Project project = editor.getProject();
|
||||
if (project != null) {
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
|
||||
if (file != null) {
|
||||
return getSettings(file);
|
||||
}
|
||||
return getSettings(project);
|
||||
}
|
||||
return getDefaultSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns language code style settings for the specified editor. If the editor has an associated document and PSI file, returns
|
||||
* settings for the PSI file or {@code null} otherwise.
|
||||
|
||||
@@ -266,7 +266,10 @@ public class SettingsImpl implements EditorSettings {
|
||||
@Override
|
||||
public List<Integer> getSoftMargins() {
|
||||
if (mySoftMargins != null) return mySoftMargins;
|
||||
return CodeStyleSettingsManager.getSettings(myEditor == null ? null : myEditor.getProject()).getSoftMargins(myLanguage);
|
||||
return
|
||||
myEditor == null ?
|
||||
CodeStyle.getDefaultSettings().getSoftMargins(myLanguage) :
|
||||
CodeStyle.getSettings(myEditor).getSoftMargins(myLanguage);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user