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 @@ - +