From 33d545493861e8436d4a33bb3b895fe3adee9cc8 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 28 Jul 2015 11:13:22 +0200 Subject: [PATCH] get rid of ROOT_CONFIG VS APP_CONFIG disambiguation --- .../compiler/ant/GenerateAntApplication.java | 5 +-- .../src/ApplicationStoreImpl.kt | 4 +- .../src/SchemeManagerFactoryImpl.kt | 9 ++++- .../options/SchemesManagerFactory.java | 3 ++ .../com/intellij/mock/MockApplicationEx.java | 5 +++ .../openapi/application/ex/ApplicationEx.java | 6 ++- .../ide/actions/ExportSettingsAction.java | 1 + .../com/intellij/idea/IdeaApplication.java | 3 +- .../application/impl/ApplicationImpl.java | 14 ++++--- .../openapi/components/StoragePathMacros.java | 9 ++--- .../intellij/idea/IdeaTestApplication.java | 4 ++ .../testFramework/LightPlatformTestCase.java | 2 +- .../impl/HeavyIdeaTestFixtureImpl.java | 2 +- .../git4idea/GitCucumberWorld.java | 2 +- .../importing/GradleImportingTestCase.java | 4 +- .../idea/maven/MavenImportingTestCase.java | 4 +- .../terminal/resources/META-INF/plugin.xml | 1 + .../terminal/resources/META-INF/terminal.xml | 9 +---- .../messages/TerminalBundle.properties | 1 + .../terminal/TerminalOptionsProvider.java | 40 ++----------------- 20 files changed, 56 insertions(+), 72 deletions(-) create mode 100644 plugins/terminal/resources/messages/TerminalBundle.properties diff --git a/java/compiler/impl/src/com/intellij/compiler/ant/GenerateAntApplication.java b/java/compiler/impl/src/com/intellij/compiler/ant/GenerateAntApplication.java index 5a957a28c2d3..7606b26a87bd 100644 --- a/java/compiler/impl/src/com/intellij/compiler/ant/GenerateAntApplication.java +++ b/java/compiler/impl/src/com/intellij/compiler/ant/GenerateAntApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ package com.intellij.compiler.ant; import com.intellij.codeInspection.InspectionsBundle; import com.intellij.compiler.actions.GenerateAntBuildAction; -import com.intellij.openapi.application.PathManager; import com.intellij.openapi.application.ex.ApplicationEx; import com.intellij.openapi.application.ex.ApplicationManagerEx; import com.intellij.openapi.diagnostic.Logger; @@ -52,7 +51,7 @@ public class GenerateAntApplication { try { logMessage(0, "Starting app... "); application.doNotSave(); - application.load(PathManager.getOptionsPath()); + application.load(); logMessageLn(0, "done"); GenerateAntApplication.this.run(); diff --git a/platform/configuration-store-impl/src/ApplicationStoreImpl.kt b/platform/configuration-store-impl/src/ApplicationStoreImpl.kt index daaed3aa56fa..c029bae0543e 100644 --- a/platform/configuration-store-impl/src/ApplicationStoreImpl.kt +++ b/platform/configuration-store-impl/src/ApplicationStoreImpl.kt @@ -66,8 +66,8 @@ class ApplicationStoreImpl(private val application: ApplicationImpl, pathMacroMa } try { - val configPath = expandMacros(StoragePathMacros.ROOT_CONFIG) - if (configPath == StoragePathMacros.ROOT_CONFIG) { + val configPath = expandMacros(ROOT_CONFIG) + if (configPath == ROOT_CONFIG) { LOG.warn("Macros ROOT_CONFIG is not defined") return } diff --git a/platform/configuration-store-impl/src/SchemeManagerFactoryImpl.kt b/platform/configuration-store-impl/src/SchemeManagerFactoryImpl.kt index 963b9fe5f559..fbf21c3a4526 100644 --- a/platform/configuration-store-impl/src/SchemeManagerFactoryImpl.kt +++ b/platform/configuration-store-impl/src/SchemeManagerFactoryImpl.kt @@ -17,8 +17,11 @@ package com.intellij.configurationStore import com.intellij.ide.impl.ProjectUtil import com.intellij.openapi.application.ApplicationManager -import com.intellij.openapi.components.* +import com.intellij.openapi.components.ComponentManager +import com.intellij.openapi.components.RoamingType +import com.intellij.openapi.components.SettingsSavingComponent import com.intellij.openapi.components.impl.stores.StateStorageManager +import com.intellij.openapi.components.stateStore import com.intellij.openapi.options.* import com.intellij.openapi.project.Project import com.intellij.util.SmartList @@ -26,6 +29,8 @@ import com.intellij.util.containers.ContainerUtil import com.intellij.util.lang.CompoundRuntimeException import java.io.File +val ROOT_CONFIG: String = "\$ROOT_CONFIG$" + public abstract class SchemeManagerFactoryBase : SchemesManagerFactory(), SettingsSavingComponent { private val managers = ContainerUtil.createLockFreeCopyOnWriteList>() @@ -72,7 +77,7 @@ private class ApplicationSchemeManagerFactory : SchemeManagerFactoryBase() { override val componentManager: ComponentManager get() = ApplicationManager.getApplication() - override fun pathToFile(path: String, storageManager: StateStorageManager) = File(storageManager.expandMacros("${StoragePathMacros.ROOT_CONFIG}/$path")) + override fun pathToFile(path: String, storageManager: StateStorageManager) = File(storageManager.expandMacros("$ROOT_CONFIG/$path")) } private class ProjectSchemeManagerFactory(private val project: Project) : SchemeManagerFactoryBase() { diff --git a/platform/core-api/src/com/intellij/openapi/options/SchemesManagerFactory.java b/platform/core-api/src/com/intellij/openapi/options/SchemesManagerFactory.java index a24fb5a34256..0992f0610b38 100644 --- a/platform/core-api/src/com/intellij/openapi/options/SchemesManagerFactory.java +++ b/platform/core-api/src/com/intellij/openapi/options/SchemesManagerFactory.java @@ -21,6 +21,9 @@ import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; public abstract class SchemesManagerFactory { + /** + * directoryName — like "keymaps". + */ @NotNull public abstract SchemesManager createSchemesManager(@NotNull String directoryName, @NotNull SchemeProcessor processor, diff --git a/platform/core-impl/src/com/intellij/mock/MockApplicationEx.java b/platform/core-impl/src/com/intellij/mock/MockApplicationEx.java index 1e7345d2826b..9641fc60eefa 100644 --- a/platform/core-impl/src/com/intellij/mock/MockApplicationEx.java +++ b/platform/core-impl/src/com/intellij/mock/MockApplicationEx.java @@ -46,6 +46,11 @@ public class MockApplicationEx extends MockApplication implements ApplicationEx public void load(String path) throws IOException { } + @Override + public void load() throws IOException { + load(null); + } + @Override public boolean isLoaded() { return true; diff --git a/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java b/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java index 5442049d0862..406ddc3f9808 100644 --- a/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java +++ b/platform/core-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java @@ -33,10 +33,12 @@ public interface ApplicationEx extends Application { /** * Loads the application configuration from the specified path * - * @param optionsPath Path to /config folder + * @param configPath Path to /config folder * @throws IOException */ - void load(@Nullable String optionsPath) throws IOException; + void load(@Nullable String configPath) throws IOException; + + void load() throws IOException; boolean isLoaded(); diff --git a/platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java b/platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java index a8123e12bb9e..44f4ff9f8534 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/ExportSettingsAction.java @@ -210,6 +210,7 @@ public class ExportSettingsAction extends AnAction implements DumbAware { String expandedPath = storageManager.expandMacros(stateAnnotation.additionalExportFile()); additionalExportFile = new File(expandedPath); if (!additionalExportFile.exists()) { + //noinspection deprecation additionalExportFile = new File(storageManager.expandMacros(StoragePathMacros.ROOT_CONFIG) + '/' + expandedPath); } diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java index 0945bb3f84a8..6559e8cf473b 100644 --- a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java +++ b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java @@ -178,8 +178,7 @@ public class IdeaApplication { public void run() { try { - ApplicationEx app = ApplicationManagerEx.getApplicationEx(); - app.load(PathManager.getOptionsPath()); + ApplicationManagerEx.getApplicationEx().load(); myLoaded = true; myStarter.main(myArgs); diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index b6308e5354b3..4f688cd5e019 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -452,11 +452,12 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App } @Override - public void load(@Nullable String optionsPath) throws IOException { - load(PathManager.getConfigPath(), optionsPath == null ? PathManager.getOptionsPath() : optionsPath); + public void load() throws IOException { + load(null); } - public void load(@NotNull final String configPath, @NotNull final String optionsPath) throws IOException { + @Override + public void load(@Nullable final String configPath) throws IOException { AccessToken token = HeavyProcessLatch.INSTANCE.processStarted("Loading application components"); try { long t = System.currentTimeMillis(); @@ -472,8 +473,11 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App getPicoContainer().getComponentInstance(ServiceManagerImpl.class); StateStorageManager storageManager = ComponentsPackage.getStateStore(ApplicationImpl.this).getStateStorageManager(); - storageManager.addMacro(StoragePathMacros.APP_CONFIG, optionsPath); - storageManager.addMacro(StoragePathMacros.ROOT_CONFIG, configPath); + + String effectiveConfigPath = configPath == null ? PathManager.getConfigPath() : configPath; + //noinspection deprecation + storageManager.addMacro(StoragePathMacros.ROOT_CONFIG, effectiveConfigPath); + storageManager.addMacro(StoragePathMacros.APP_CONFIG, effectiveConfigPath + "/options"); for (ApplicationLoadListener listener : ApplicationLoadListener.EP_NAME.getExtensions()) { try { diff --git a/platform/projectModel-api/src/com/intellij/openapi/components/StoragePathMacros.java b/platform/projectModel-api/src/com/intellij/openapi/components/StoragePathMacros.java index bd27738ecab4..aa511bee7b62 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/components/StoragePathMacros.java +++ b/platform/projectModel-api/src/com/intellij/openapi/components/StoragePathMacros.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,13 +31,10 @@ import org.jetbrains.annotations.NotNull; * @since 5/2/12 12:57 PM */ public class StoragePathMacros { - /** - * Points to the application-level settings root directory. - */ - @NonNls @NotNull public static final String ROOT_CONFIG = "$ROOT_CONFIG$"; + @Deprecated @NotNull public static final String ROOT_CONFIG = "$ROOT_CONFIG$"; /** - * Points to {@link #ROOT_CONFIG}/options by default. Should be used to store single files and {@link #ROOT_CONFIG} to store subdirectories with many files. + * Points to the application-level options root directory. */ @NonNls @NotNull public static final String APP_CONFIG = "$APP_CONFIG$"; diff --git a/platform/testFramework/src/com/intellij/idea/IdeaTestApplication.java b/platform/testFramework/src/com/intellij/idea/IdeaTestApplication.java index 0b3a954b4d8f..a5fa9f18c981 100644 --- a/platform/testFramework/src/com/intellij/idea/IdeaTestApplication.java +++ b/platform/testFramework/src/com/intellij/idea/IdeaTestApplication.java @@ -46,6 +46,10 @@ public class IdeaTestApplication extends CommandLineApplication implements Dispo return myDataContext == null ? null : myDataContext.getData(dataId); } + public static synchronized IdeaTestApplication getInstance() { + return getInstance(null); + } + public static synchronized IdeaTestApplication getInstance(@Nullable final String configPath) { if (ourInstance == null) { PlatformTestCase.doAutodetectPlatformPrefix(); diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index 84da2cec2b6d..4d7b66de4bb1 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -166,7 +166,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da @NotNull public static IdeaTestApplication initApplication() { - ourApplication = IdeaTestApplication.getInstance(null); + ourApplication = IdeaTestApplication.getInstance(); return ourApplication; } diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java index bc8491f285db..b728b74b0383 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/HeavyIdeaTestFixtureImpl.java @@ -172,7 +172,7 @@ class HeavyIdeaTestFixtureImpl extends BaseFixture implements HeavyIdeaTestFixtu } private void initApplication() throws Exception { - myApplication = IdeaTestApplication.getInstance(null); + myApplication = IdeaTestApplication.getInstance(); myApplication.setDataProvider(new MyDataProvider()); } diff --git a/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java b/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java index cce4cd7dd7de..d2733b600b9b 100644 --- a/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java +++ b/plugins/git4idea/test-stepdefs/git4idea/GitCucumberWorld.java @@ -96,7 +96,7 @@ public class GitCucumberWorld { @Before public void setUp() throws Throwable { - IdeaTestApplication.getInstance(null); + IdeaTestApplication.getInstance(); myTestName = createTestName(); myProjectFixture = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(myTestName).getFixture(); diff --git a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleImportingTestCase.java b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleImportingTestCase.java index 7b2e40efed72..dcc3ab9ea297 100644 --- a/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleImportingTestCase.java +++ b/plugins/gradle/testSources/org/jetbrains/plugins/gradle/importing/GradleImportingTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -153,7 +153,7 @@ public abstract class GradleImportingTestCase extends ExternalSystemImportingTes } }); - roots.add(PathManager.getOptionsPath()); + roots.add(PathManager.getConfigPath()); } @Override diff --git a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java index 8e4ff9d05680..bd55bb31b4d7 100644 --- a/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java +++ b/plugins/maven/src/test/java/org/jetbrains/idea/maven/MavenImportingTestCase.java @@ -64,7 +64,7 @@ public abstract class MavenImportingTestCase extends MavenTestCase { @Override protected void setUp() throws Exception { - VfsRootAccess.allowRootAccess(PathManager.getOptionsPath()); + VfsRootAccess.allowRootAccess(PathManager.getConfigPath()); super.setUp(); myGlobalSettingsFile = MavenWorkspaceSettingsComponent.getInstance(myProject).getSettings().generalSettings.getEffectiveGlobalSettingsIoFile(); @@ -86,7 +86,7 @@ public abstract class MavenImportingTestCase extends MavenTestCase { if (myGlobalSettingsFile != null) { VfsRootAccess.disallowRootAccess(myGlobalSettingsFile.getAbsolutePath()); } - VfsRootAccess.disallowRootAccess(PathManager.getOptionsPath()); + VfsRootAccess.disallowRootAccess(PathManager.getConfigPath()); Messages.setTestDialog(TestDialog.DEFAULT); removeFromLocalRepository("test"); FileUtil.delete(BuildManager.getInstance().getBuildSystemDirectory()); diff --git a/plugins/terminal/resources/META-INF/plugin.xml b/plugins/terminal/resources/META-INF/plugin.xml index 70ffe835c086..18b03fbecd1d 100644 --- a/plugins/terminal/resources/META-INF/plugin.xml +++ b/plugins/terminal/resources/META-INF/plugin.xml @@ -6,6 +6,7 @@ Embedded Terminal com.intellij.modules.platform + messages.TerminalBundle diff --git a/plugins/terminal/resources/META-INF/terminal.xml b/plugins/terminal/resources/META-INF/terminal.xml index 556e0ba4a0cd..e7f4360f44ad 100644 --- a/plugins/terminal/resources/META-INF/terminal.xml +++ b/plugins/terminal/resources/META-INF/terminal.xml @@ -10,6 +10,8 @@ + + @@ -18,11 +20,4 @@ org.jetbrains.plugins.terminal.TerminalView - - - - org.jetbrains.plugins.terminal.TerminalOptionsProvider - org.jetbrains.plugins.terminal.TerminalOptionsProvider - - diff --git a/plugins/terminal/resources/messages/TerminalBundle.properties b/plugins/terminal/resources/messages/TerminalBundle.properties new file mode 100644 index 000000000000..c7f5c9b6c07e --- /dev/null +++ b/plugins/terminal/resources/messages/TerminalBundle.properties @@ -0,0 +1 @@ +exportable.TerminalOptionsProvider.presentable.name=Terminal \ No newline at end of file diff --git a/plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalOptionsProvider.java b/plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalOptionsProvider.java index 8bf9850c4cf6..4102ee44c2e3 100644 --- a/plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalOptionsProvider.java +++ b/plugins/terminal/src/org/jetbrains/plugins/terminal/TerminalOptionsProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2015 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +15,8 @@ */ package org.jetbrains.plugins.terminal; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.PathManager; import com.intellij.openapi.components.*; import com.intellij.openapi.util.SystemInfo; -import org.jetbrains.annotations.NotNull; import java.io.File; @@ -28,16 +25,13 @@ import java.io.File; */ @State( name = "TerminalOptionsProvider", - storages = { - @Storage( - file = StoragePathMacros.APP_CONFIG + "/terminal.xml" - )} + storages = @Storage(file = StoragePathMacros.APP_CONFIG + "/terminal.xml") ) -public class TerminalOptionsProvider implements PersistentStateComponent, ExportableApplicationComponent { +public class TerminalOptionsProvider implements PersistentStateComponent { private State myState = new State(); public static TerminalOptionsProvider getInstance() { - return ApplicationManager.getApplication().getComponent(TerminalOptionsProvider.class); + return ServiceManager.getService(TerminalOptionsProvider.class); } @Override @@ -146,31 +140,5 @@ public class TerminalOptionsProvider implements PersistentStateComponent