From d1b7e01039a4dceaf5f429cef29aeecf085d05fc Mon Sep 17 00:00:00 2001 From: Dmitry Batrak Date: Tue, 10 Sep 2019 11:19:43 +0300 Subject: [PATCH] Reverting commit 4f326053, it breaks compilation GitOrigin-RevId: e506e1af36d8b316d7c02df6fd72c9607469955b --- .../codeStyle/CodeStyleSettingsManager.java | 4 +- .../ProjectCodeStyleSettingsManager.java | 41 +++++++++++-------- .../src/META-INF/LangExtensions.xml | 2 +- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsManager.java b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsManager.java index 0165a2beccae..954f0a48151f 100644 --- a/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsManager.java +++ b/platform/lang-api/src/com/intellij/psi/codeStyle/CodeStyleSettingsManager.java @@ -42,7 +42,9 @@ public class CodeStyleSettingsManager implements PersistentStateComponent mySettingsMap = new HashMap<>(); private static final NotificationGroup NOTIFICATION_GROUP = new NotificationGroup("Code style settings migration", NotificationDisplayType.STICKY_BALLOON, true); - public ProjectCodeStyleSettingsManager(Project project) { + public ProjectCodeStyleSettingsManager() { setMainProjectCodeStyle(null); - initProjectSettings(project); - //noinspection deprecation - getCurrentSettings(); // cache default scheme } - private void initProjectSettings(@NotNull Project project) { - LegacyCodeStyleSettingsManager legacySettingsManager = ServiceManager.getService(project, LegacyCodeStyleSettingsManager.class); - if (legacySettingsManager != null && legacySettingsManager.getState() != null) { - loadState(legacySettingsManager.getState()); - if (!project.isDefault() && - !ApplicationManager.getApplication().isUnitTestMode() && - !ApplicationManager.getApplication().isHeadlessEnvironment()) { - saveProjectAndNotify(project); + void initProjectSettings(@NotNull Project project) { + if (!myIsLoaded) { + synchronized (LEGACY_SETTINGS_IMPORT_LOCK) { + if (!myIsLoaded) { + LegacyCodeStyleSettingsManager legacySettingsManager = ServiceManager.getService(project, LegacyCodeStyleSettingsManager.class); + if (legacySettingsManager != null && legacySettingsManager.getState() != null) { + loadState(legacySettingsManager.getState()); + if (!project.isDefault() && + !ApplicationManager.getApplication().isUnitTestMode() && + !ApplicationManager.getApplication().isHeadlessEnvironment()) { + saveProjectAndNotify(project); + } + LOG.info("Imported old project code style settings."); + } + else { + initDefaults(); + LOG.info("Initialized from default code style settings."); + } + } } - LOG.info("Imported old project code style settings."); - } - else { - initDefaults(); - LOG.info("Initialized from default code style settings."); } } @@ -93,6 +98,7 @@ public class ProjectCodeStyleSettingsManager extends CodeStyleSettingsManager { USE_PER_PROJECT_SETTINGS = appCodeStyleSettingsManager.USE_PER_PROJECT_SETTINGS; PREFERRED_PROJECT_CODE_STYLE = appCodeStyleSettingsManager.PREFERRED_PROJECT_CODE_STYLE; } + myIsLoaded = true; } @Override @@ -110,6 +116,7 @@ public class ProjectCodeStyleSettingsManager extends CodeStyleSettingsManager { mySettingsMap.put(name, settings); } } + myIsLoaded = true; } private void updateFromOldProjectSettings() { diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml index 0392312e165f..2fa53ad759c8 100644 --- a/platform/platform-resources/src/META-INF/LangExtensions.xml +++ b/platform/platform-resources/src/META-INF/LangExtensions.xml @@ -219,7 +219,7 @@ - +