diff --git a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsProjectLoader.java b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsProjectLoader.java index 1ea6666fb070..98b7f30e788a 100644 --- a/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsProjectLoader.java +++ b/jps/model-serialization/src/org/jetbrains/jps/model/serialization/JpsProjectLoader.java @@ -17,7 +17,6 @@ package org.jetbrains.jps.model.serialization; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.JDOMUtil; -import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileFilters; import com.intellij.openapi.util.io.FileUtil; @@ -64,9 +63,7 @@ public class JpsProjectLoader extends JpsLoaderBase { private static final Logger LOG = Logger.getInstance(JpsProjectLoader.class); private static final BoundedTaskExecutor ourThreadPool = new BoundedTaskExecutor(SharedThreadPool.getInstance(), Runtime.getRuntime().availableProcessors()); public static final String CLASSPATH_ATTRIBUTE = "classpath"; - public static final Key CLASSPATH_ATTRIBUTE_KEY = Key.create(CLASSPATH_ATTRIBUTE); public static final String CLASSPATH_DIR_ATTRIBUTE = "classpath-dir"; - public static final Key CLASSPATH_DIR_ATTRIBUTE_KEY = Key.create(CLASSPATH_DIR_ATTRIBUTE); private final JpsProject myProject; private final Map myPathVariables; diff --git a/platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ModuleFileData.java b/platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ModuleFileData.java index b139924a0c3f..76a997237e37 100644 --- a/platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ModuleFileData.java +++ b/platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ModuleFileData.java @@ -18,19 +18,17 @@ package com.intellij.openapi.components.impl.stores; import com.intellij.openapi.components.PathMacroSubstitutor; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.OptionManager; -import com.intellij.openapi.module.impl.ModuleManagerImpl; -import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.util.keyFMap.KeyFMap; import org.jdom.Attribute; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Set; +import java.util.TreeMap; final class ModuleFileData extends BaseFileConfigurableStoreImpl.BaseStorageData implements OptionManager { - private KeyFMap options; + private TreeMap options; private final Module myModule; private boolean dirty = true; @@ -39,7 +37,7 @@ final class ModuleFileData extends BaseFileConfigurableStoreImpl.BaseStorageData super(rootElementName); myModule = module; - options = KeyFMap.EMPTY_MAP; + options = new TreeMap(); } @Override @@ -52,7 +50,7 @@ final class ModuleFileData extends BaseFileConfigurableStoreImpl.BaseStorageData myModule = storageData.myModule; dirty = storageData.dirty; - options = storageData.options; + options = new TreeMap(storageData.options); } @Override @@ -62,7 +60,7 @@ final class ModuleFileData extends BaseFileConfigurableStoreImpl.BaseStorageData for (Attribute attribute : rootElement.getAttributes()) { String name = attribute.getName(); if (!name.equals(BaseFileConfigurableStoreImpl.VERSION_OPTION) && !StringUtil.isEmpty(name)) { - options = options.plus(ModuleManagerImpl.createOptionKey(name), attribute.getValue()); + options.put(name, attribute.getValue()); } } @@ -72,11 +70,10 @@ final class ModuleFileData extends BaseFileConfigurableStoreImpl.BaseStorageData @Override protected void writeOptions(@NotNull Element root, @NotNull String versionString) { if (!options.isEmpty()) { - //noinspection unchecked - for (Key key : options.getKeys()) { + for (String key : options.keySet()) { String value = options.get(key); if (value != null) { - root.setAttribute(key.toString(), value); + root.setAttribute(key, value); } } } @@ -95,7 +92,7 @@ final class ModuleFileData extends BaseFileConfigurableStoreImpl.BaseStorageData @Override public Set getChangedComponentNames(@NotNull StorageData newStorageData, @Nullable PathMacroSubstitutor substitutor) { final ModuleFileData data = (ModuleFileData)newStorageData; - if (options != data.options) { + if (!options.equals(data.options)) { return null; } @@ -103,27 +100,22 @@ final class ModuleFileData extends BaseFileConfigurableStoreImpl.BaseStorageData } @Override - public void setOption(@NotNull Key key, @NotNull String optionValue) { - if (optionValue.equals(options.get(key))) { - return; + public void setOption(@NotNull String key, @NotNull String value) { + if (!value.equals(options.put(key, value))) { + dirty = true; } - - options = options.plus(key, optionValue); - dirty = true; } @Override - public void clearOption(@NotNull Key key) { - KeyFMap newOptions = options.minus(key); - if (newOptions != options) { - options = newOptions; + public void clearOption(@NotNull String key) { + if (options.remove(key) != null) { dirty = true; } } @Override @Nullable - public String getOptionValue(@NotNull Key key) { + public String getOptionValue(@NotNull String key) { return options.get(key); } } diff --git a/platform/core-api/src/com/intellij/openapi/module/Module.java b/platform/core-api/src/com/intellij/openapi/module/Module.java index 130e1839524c..a4b103af3815 100644 --- a/platform/core-api/src/com/intellij/openapi/module/Module.java +++ b/platform/core-api/src/com/intellij/openapi/module/Module.java @@ -19,7 +19,6 @@ import com.intellij.openapi.Disposable; import com.intellij.openapi.components.ComponentManager; import com.intellij.openapi.extensions.AreaInstance; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.search.GlobalSearchScope; import org.jetbrains.annotations.NonNls; @@ -40,8 +39,6 @@ public interface Module extends ComponentManager, AreaInstance, Disposable, Opti @NonNls String ELEMENT_TYPE = "type"; - Key ELEMENT_TYPE_KEY = Key.create("type"); - /** * Returns the VirtualFile for the module .iml file. * @@ -81,17 +78,6 @@ public interface Module extends ComponentManager, AreaInstance, Disposable, Opti boolean isLoaded(); - @Deprecated - void setOption(@NotNull String optionName, @NotNull String optionValue); - - @SuppressWarnings("unused") - @Deprecated - void clearOption(@NotNull String optionName); - - @Nullable - @Deprecated - String getOptionValue(@NotNull String optionName); - /** * Returns module scope including sources and tests, excluding libraries and dependencies. * diff --git a/platform/core-api/src/com/intellij/openapi/module/OptionManager.java b/platform/core-api/src/com/intellij/openapi/module/OptionManager.java index a56dc7a7ab88..9beb80685b7a 100644 --- a/platform/core-api/src/com/intellij/openapi/module/OptionManager.java +++ b/platform/core-api/src/com/intellij/openapi/module/OptionManager.java @@ -15,7 +15,6 @@ */ package com.intellij.openapi.module; -import com.intellij.openapi.util.Key; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -25,7 +24,7 @@ public interface OptionManager { * * @param key the name of the custom option. */ - void clearOption(@NotNull Key key); + void clearOption(@NotNull String key); /** * Sets a custom option for this module. @@ -33,7 +32,7 @@ public interface OptionManager { * @param key the name of the custom option. * @param value the value of the custom option. */ - void setOption(@NotNull Key key, @NotNull String value); + void setOption(@NotNull String key, @NotNull String value); /** * Gets the value of a custom option for this module. @@ -42,5 +41,5 @@ public interface OptionManager { * @return the value of the custom option, or null if no value has been set. */ @Nullable - String getOptionValue(@NotNull Key key); + String getOptionValue(@NotNull String key); } diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java index 0ac9421aec3d..df5401bfeaae 100644 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/settings/AbstractExternalSystemLocalSettings.java @@ -255,11 +255,11 @@ public abstract class AbstractExternalSystemLocalSettings { pathsToForget.remove(projectSettings.getExternalProjectPath()); } for (Module module : myPlatformFacade.getModules(myProject)) { - String id = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID); + String id = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY); if (!myExternalSystemId.toString().equals(id)) { continue; } - pathsToForget.remove(module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH)); + pathsToForget.remove(module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY)); } if (!pathsToForget.isEmpty()) { diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java index e05739e65bd3..bba9f84b0cb1 100644 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemApiUtil.java @@ -782,42 +782,42 @@ public class ExternalSystemApiUtil { @Contract(value = "_, null -> false", pure=true) public static boolean isExternalSystemAwareModule(@NotNull ProjectSystemId systemId, @Nullable Module module) { - return module != null && !module.isDisposed() && systemId.getId().equals(module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID)); + return module != null && !module.isDisposed() && systemId.getId().equals(module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY)); } @Contract(value = "_, null -> false", pure=true) public static boolean isExternalSystemAwareModule(@NotNull String systemId, @Nullable Module module) { - return module != null && !module.isDisposed() && systemId.equals(module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID)); + return module != null && !module.isDisposed() && systemId.equals(module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY)); } @Nullable @Contract(pure=true) public static String getExternalProjectPath(@Nullable Module module) { - return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH) : null; + return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY) : null; } @Nullable @Contract(pure=true) public static String getExternalRootProjectPath(@Nullable Module module) { - return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH) : null; + return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY) : null; } @Nullable @Contract(pure=true) public static String getExternalProjectId(@Nullable Module module) { - return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_ID) : null; + return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_ID_KEY) : null; } @Nullable @Contract(pure=true) public static String getExternalProjectGroup(@Nullable Module module) { - return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_GROUP) : null; + return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_GROUP_KEY) : null; } @Nullable @Contract(pure=true) public static String getExternalProjectVersion(@Nullable Module module) { - return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_VERSION) : null; + return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_VERSION_KEY) : null; } public static void subscribe(@NotNull Project project, diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java index 6d6c813c9e92..932fbfb95d57 100644 --- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java +++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/util/ExternalSystemConstants.java @@ -15,7 +15,6 @@ */ package com.intellij.openapi.externalSystem.util; -import com.intellij.openapi.util.Key; import com.intellij.util.SystemProperties; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -25,23 +24,14 @@ import org.jetbrains.annotations.NotNull; * @since 4/16/13 11:44 AM */ public class ExternalSystemConstants { + @NonNls @NotNull public static final String EXTERNAL_SYSTEM_ID_KEY = "external.system.id"; - public static final Key EXTERNAL_SYSTEM_ID = Key.create(EXTERNAL_SYSTEM_ID_KEY); - @NonNls @NotNull public static final String LINKED_PROJECT_PATH_KEY = "external.linked.project.path"; - public static final Key LINKED_PROJECT_PATH = Key.create(LINKED_PROJECT_PATH_KEY); - @NonNls @NotNull public static final String ROOT_PROJECT_PATH_KEY = "external.root.project.path"; - public static final Key ROOT_PROJECT_PATH = Key.create(ROOT_PROJECT_PATH_KEY); - @NonNls @NotNull public static final String LINKED_PROJECT_ID_KEY = "external.linked.project.id"; - public static final Key LINKED_PROJECT_ID = Key.create(LINKED_PROJECT_ID_KEY); @NonNls @NotNull public static final String EXTERNAL_SYSTEM_MODULE_GROUP_KEY = "external.system.module.group"; - public static final Key EXTERNAL_SYSTEM_MODULE_GROUP = Key.create(EXTERNAL_SYSTEM_MODULE_GROUP_KEY); - @NonNls @NotNull public static final String EXTERNAL_SYSTEM_MODULE_VERSION_KEY = "external.system.module.version"; - public static final Key EXTERNAL_SYSTEM_MODULE_VERSION = Key.create(EXTERNAL_SYSTEM_MODULE_VERSION_KEY); @NonNls @NotNull public static final String TOOL_WINDOW_TOOLBAR_ACTIONS_GROUP_ID = "ExternalSystem.ToolWindow.Toolbar"; @NonNls @NotNull public static final String TREE_ACTIONS_GROUP_ID = "ExternalSystem.Tree.Context"; @@ -71,6 +61,4 @@ public class ExternalSystemConstants { public static final int UNORDERED = 1000; public static final int TEXT_FIELD_WIDTH_IN_COLUMNS = 20; - - public static final Key MAVEN_MODULE_KEY = Key.create("org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule"); } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemBeforeRunTaskProvider.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemBeforeRunTaskProvider.java index 07424005c42c..9394a8d636a1 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemBeforeRunTaskProvider.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/execution/ExternalSystemBeforeRunTaskProvider.java @@ -210,9 +210,9 @@ public abstract class ExternalSystemBeforeRunTaskProvider extends BeforeRunTaskP String desc = StringUtil.join(task.getTaskExecutionSettings().getTaskNames(), " "); for (Module module : ModuleManager.getInstance(myProject).getModules()) { - if (!mySystemId.toString().equals(module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID))) continue; + if (!mySystemId.toString().equals(module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY))) continue; - if (StringUtil.equals(externalProjectPath, module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH))) { + if (StringUtil.equals(externalProjectPath, module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY))) { desc = module.getName() + ": " + desc; break; } diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java index d860aee66bc7..68fc46b8d802 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java @@ -122,7 +122,7 @@ public class ContentRootDataService extends AbstractProjectDataService { } public static boolean is(@NotNull Module module, @NotNull ModuleType moduleType) { - return moduleType.getId().equals(module.getOptionValue(Module.ELEMENT_TYPE_KEY)); + return moduleType.getId().equals(module.getOptionValue(Module.ELEMENT_TYPE)); } @NotNull @@ -121,7 +121,7 @@ public abstract class ModuleType { if (instance == null) { return EMPTY; } - return instance.findByID(module.getOptionValue(Module.ELEMENT_TYPE_KEY)); + return instance.findByID(module.getOptionValue(Module.ELEMENT_TYPE)); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleImpl.java b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleImpl.java index ffa1306c5563..55c7019f6900 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleImpl.java @@ -37,7 +37,6 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.impl.storage.ClasspathStorage; -import com.intellij.openapi.util.Key; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.*; @@ -52,8 +51,6 @@ import java.io.IOException; import java.util.List; import java.util.Map; -import static com.intellij.openapi.module.impl.ModuleManagerImpl.createOptionKey; - /** * @author max */ @@ -250,12 +247,7 @@ public class ModuleImpl extends PlatformComponentManagerImpl implements ModuleEx } @Override - public void setOption(@NotNull String optionName, @NotNull String optionValue) { - setOption(createOptionKey(optionName), optionValue); - } - - @Override - public void setOption(@NotNull Key key, @NotNull String value) { + public void setOption(@NotNull String key, @NotNull String value) { OptionManager manager = getOptionManager(); if (manager != null) { manager.setOption(key, value); @@ -274,12 +266,7 @@ public class ModuleImpl extends PlatformComponentManagerImpl implements ModuleEx } @Override - public void clearOption(@NotNull String optionName) { - clearOption(createOptionKey(optionName)); - } - - @Override - public void clearOption(@NotNull Key key) { + public void clearOption(@NotNull String key) { OptionManager manager = getOptionManager(); if (manager != null) { manager.clearOption(key); @@ -287,13 +274,7 @@ public class ModuleImpl extends PlatformComponentManagerImpl implements ModuleEx } @Override - public String getOptionValue(@NotNull String optionName) { - return getOptionValue(createOptionKey(optionName)); - } - - @Nullable - @Override - public String getOptionValue(@NotNull Key key) { + public String getOptionValue(@NotNull String key) { OptionManager manager = getOptionManager(); return manager == null ? null : manager.getOptionValue(key); } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java index 953cb63cf0a4..f1ab953b469f 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java @@ -184,7 +184,7 @@ public class ClasspathStorage extends StateStorageBase optionName, @NotNull String optionValue) { - throw new UnsupportedOperationException(); - } - - @Override - public void clearOption(@NotNull Key key) { - throw new UnsupportedOperationException(); - } - - @Nullable - @Override - public String getOptionValue(@NotNull Key key) { - throw new UnsupportedOperationException(); - } - @NotNull @Override public GlobalSearchScope getModuleScope() { diff --git a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java index 181b53d0a57a..5aad6723bb1d 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/module/impl/ModuleManagerImpl.java @@ -97,22 +97,11 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project myMessageBus = messageBus; } - @NotNull - public static Key createOptionKey(@NotNull String name) { - if (name.equals(Module.ELEMENT_TYPE)) { - return Module.ELEMENT_TYPE_KEY; - } - else { - return Key.create(name); - } - } - protected void cleanCachedStuff() { myCachedModuleComparator = null; myCachedSortedModules = null; } - @Override @NotNull public String getComponentName() { @@ -721,10 +710,10 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project initModule(module, filePath, new Runnable() { @Override public void run() { - newModule.setOption(Module.ELEMENT_TYPE_KEY, moduleTypeId); + newModule.setOption(Module.ELEMENT_TYPE, moduleTypeId); if (options != null) { for (Map.Entry option : options.entrySet()) { - newModule.setOption(createOptionKey(option.getKey()), option.getValue()); + newModule.setOption(option.getKey(), option.getValue()); } } } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/storage/ClassPathStorageUtil.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/storage/ClassPathStorageUtil.java index 84b7324ced65..4ed52d91044b 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/storage/ClassPathStorageUtil.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/storage/ClassPathStorageUtil.java @@ -29,7 +29,7 @@ public class ClassPathStorageUtil { @NotNull public static String getStorageType(@NotNull Module module) { - String id = module.getOptionValue(JpsProjectLoader.CLASSPATH_DIR_ATTRIBUTE_KEY); + String id = module.getOptionValue(JpsProjectLoader.CLASSPATH_ATTRIBUTE); return id == null ? DEFAULT_STORAGE : id; } } diff --git a/platform/testFramework/src/com/intellij/mock/MockModule.java b/platform/testFramework/src/com/intellij/mock/MockModule.java index 3ea1bf9f79fc..2b0fc2c77dc9 100644 --- a/platform/testFramework/src/com/intellij/mock/MockModule.java +++ b/platform/testFramework/src/com/intellij/mock/MockModule.java @@ -18,7 +18,6 @@ package com.intellij.mock; import com.intellij.openapi.Disposable; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.search.GlobalSearchScope; import org.jetbrains.annotations.NotNull; @@ -144,20 +143,4 @@ public class MockModule extends MockComponentManager implements Module { public void clearOption(@NotNull String optionName) { throw new UnsupportedOperationException("Method clearOption is not yet implemented in " + getClass().getName()); } - - @Override - public void setOption(@NotNull Key optionName, @NotNull String optionValue) { - throw new UnsupportedOperationException(); - } - - @Override - public void clearOption(@NotNull Key key) { - throw new UnsupportedOperationException(); - } - - @Nullable - @Override - public String getOptionValue(@NotNull Key key) { - throw new UnsupportedOperationException(); - } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java index 54b742ac88ed..db49112ba273 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java @@ -167,12 +167,12 @@ public class UseDistributionWithSourcesNotificationProvider extends EditorNotifi @Nullable private static String getRootProjectPath(@NotNull Module module) { - String externalSystemId = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID); + String externalSystemId = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY); if (externalSystemId == null || !GradleConstants.SYSTEM_ID.toString().equals(externalSystemId)) { return null; } - String path = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); + String path = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY); return StringUtil.isEmpty(path) ? null : path; } } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradlePositionManager.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradlePositionManager.java index 440c8115ea77..9982d7acacc3 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradlePositionManager.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradlePositionManager.java @@ -129,7 +129,7 @@ public class GradlePositionManager extends ScriptPositionManagerHelper { @Nullable private ClassLoader createGradleClassLoader(@NotNull Module module) { - String rootProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); + String rootProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY); if (StringUtil.isEmpty(rootProjectPath)) { return null; } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java index 02e39df578b8..4e8b6431eb9d 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleResourceCompilerConfigurationGenerator.java @@ -195,7 +195,7 @@ public class GradleResourceCompilerConfigurationGenerator { if (shouldBeBuiltByExternalSystem(module)) continue; - final String gradleProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); + final String gradleProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY); assert gradleProjectPath != null; final ExternalProject externalRootProject = lazyExternalProjectMap.get(gradleProjectPath); if (externalRootProject == null) { diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java index 3a9054c7e9ab..4deb28ab7399 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java @@ -220,7 +220,7 @@ public class GradleScriptType extends GroovyRunnableScriptType { if (module == null) { throw new CantRunException("Target module is undefined"); } - String rootProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); + String rootProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY); if (StringUtil.isEmpty(rootProjectPath)) { throw new CantRunException(String.format("Module '%s' is not backed by gradle", module.getName())); } @@ -321,7 +321,7 @@ public class GradleScriptType extends GroovyRunnableScriptType { GlobalSearchScope result = GlobalSearchScope.EMPTY_SCOPE; final Module module = ModuleUtilCore.findModuleForPsiElement(file); if (module != null) { - String externalSystemId = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID); + String externalSystemId = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY); if(!GradleConstants.SYSTEM_ID.toString().equals(externalSystemId)) return baseScope; for (OrderEntry entry : ModuleRootManager.getInstance(module).getOrderEntries()) { @@ -331,7 +331,7 @@ public class GradleScriptType extends GroovyRunnableScriptType { } } - String modulePath = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH); + String modulePath = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY); if(modulePath == null) return result; files = GradleBuildClasspathManager.getInstance(file.getProject()).getModuleClasspathEntries(modulePath); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/GradleOrderEnumeratorHandler.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/GradleOrderEnumeratorHandler.java index c51af93d22a7..38fd08bc062e 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/GradleOrderEnumeratorHandler.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/GradleOrderEnumeratorHandler.java @@ -78,7 +78,7 @@ public class GradleOrderEnumeratorHandler extends OrderEnumerationHandler { if (!type.equals(OrderRootType.CLASSES)) return false; if (!ExternalSystemApiUtil.isExternalSystemAwareModule(GradleConstants.SYSTEM_ID, rootModel.getModule())) return false; - final String gradleProjectPath = rootModel.getModule().getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); + final String gradleProjectPath = rootModel.getModule().getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY); if (gradleProjectPath == null) { LOG.error("Root project path of the Gradle project not found for " + rootModel.getModule()); return false; diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/AllInPackageGradleConfigurationProducer.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/AllInPackageGradleConfigurationProducer.java index 687ef93f10e9..f2f7364112e2 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/AllInPackageGradleConfigurationProducer.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/AllInPackageGradleConfigurationProducer.java @@ -57,12 +57,12 @@ public class AllInPackageGradleConfigurationProducer extends GradleTestRunConfig if (module == null) return false; if (!StringUtil.equals( - module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), + module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY), GradleConstants.SYSTEM_ID.toString())) { return false; } - final String linkedGradleProject = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH); + final String linkedGradleProject = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY); if (linkedGradleProject == null) return false; configuration.getSettings().setExternalProjectPath(linkedGradleProject); configuration.getSettings().setTaskNames(TASKS_TO_RUN); @@ -88,7 +88,7 @@ public class AllInPackageGradleConfigurationProducer extends GradleTestRunConfig if (context.getModule() == null) return false; if (!StringUtil.equals( - context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH), + context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY), configuration.getSettings().getExternalProjectPath())) { return false; } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/TestClassGradleConfigurationProducer.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/TestClassGradleConfigurationProducer.java index ad03d7dca910..48da3ad6d502 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/TestClassGradleConfigurationProducer.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/TestClassGradleConfigurationProducer.java @@ -74,12 +74,12 @@ public class TestClassGradleConfigurationProducer extends GradleTestRunConfigura if (context.getModule() == null) return false; if (!StringUtil.equals( - context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY), GradleConstants.SYSTEM_ID.toString())) { return false; } - configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH)); + configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY)); configuration.getSettings().setTaskNames(TASKS_TO_RUN); configuration.getSettings() .setScriptParameters(String.format("--tests %s", testClass.getQualifiedName())); @@ -112,7 +112,7 @@ public class TestClassGradleConfigurationProducer extends GradleTestRunConfigura if (context.getModule() == null) return false; if (!StringUtil.equals( - context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH), + context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY), configuration.getSettings().getExternalProjectPath())) { return false; } @@ -129,7 +129,7 @@ public class TestClassGradleConfigurationProducer extends GradleTestRunConfigura @Override protected void runForClasses(List classes, PsiMethod method, ConfigurationContext context, Runnable performRunnable) { if (!StringUtil.equals( - context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY), GradleConstants.SYSTEM_ID.toString())) { return; } @@ -145,7 +145,7 @@ public class TestClassGradleConfigurationProducer extends GradleTestRunConfigura ConfigurationContext context, Runnable performRunnable) { if (!StringUtil.equals( - context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY), GradleConstants.SYSTEM_ID.toString())) { return; } @@ -163,12 +163,12 @@ public class TestClassGradleConfigurationProducer extends GradleTestRunConfigura @NotNull ConfigurationContext context, @NotNull PsiClass... containingClasses) { if (!StringUtil.equals( - context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY), GradleConstants.SYSTEM_ID.toString())) { return false; } - configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH)); + configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY)); configuration.getSettings().setTaskNames(TASKS_TO_RUN); StringBuilder buf = new StringBuilder(); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/TestMethodGradleConfigurationProducer.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/TestMethodGradleConfigurationProducer.java index ec51646fa3ea..56db79e36239 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/TestMethodGradleConfigurationProducer.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/test/runner/TestMethodGradleConfigurationProducer.java @@ -100,7 +100,7 @@ public class TestMethodGradleConfigurationProducer extends GradleTestRunConfigur if (context.getModule() == null) return false; if (!StringUtil.equals( - context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH), + context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY), configuration.getSettings().getExternalProjectPath())) { return false; } @@ -119,7 +119,7 @@ public class TestMethodGradleConfigurationProducer extends GradleTestRunConfigur @Override protected void runForClasses(List classes, PsiMethod method, ConfigurationContext context, Runnable performRunnable) { if (!StringUtil.equals( - context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY), GradleConstants.SYSTEM_ID.toString())) { return; } @@ -135,7 +135,7 @@ public class TestMethodGradleConfigurationProducer extends GradleTestRunConfigur ConfigurationContext context, Runnable performRunnable) { if (!StringUtil.equals( - context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY), GradleConstants.SYSTEM_ID.toString())) { return; } @@ -154,12 +154,12 @@ public class TestMethodGradleConfigurationProducer extends GradleTestRunConfigur @NotNull PsiMethod psiMethod, @NotNull PsiClass... containingClasses) { if (!StringUtil.equals( - context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY), GradleConstants.SYSTEM_ID.toString())) { return false; } - configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH)); + configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY)); configuration.getSettings().setTaskNames(TASKS_TO_RUN); StringBuilder buf = new StringBuilder(); diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/GradleInstallationManager.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/GradleInstallationManager.java index 3a784c168077..dc9bc4c9c2d2 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/GradleInstallationManager.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/GradleInstallationManager.java @@ -462,7 +462,7 @@ public class GradleInstallationManager { if(rootProjectPath == null) { for (Module module : myPlatformFacade.getModules(project)) { - rootProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); + rootProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY); List result = findGradleSdkClasspath(project, rootProjectPath); if(!result.isEmpty()) return result; } diff --git a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleImplicitContributor.java b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleImplicitContributor.java index 644c01b17649..24fb16278359 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleImplicitContributor.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/resolve/GradleImplicitContributor.java @@ -158,7 +158,7 @@ public class GradleImplicitContributor implements GradleMethodContextContributor Module module = ModuleUtilCore.findModuleForPsiElement(place); if (module == null) return; - String path = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); + String path = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY); GradleLocalSettings localSettings = GradleLocalSettings.getInstance(place.getProject()); Collection taskPojos = localSettings.getAvailableTasks().get(path); if (taskPojos == null) return; diff --git a/plugins/maven/maven.iml b/plugins/maven/maven.iml index 18c1a4219a19..5703e18b8299 100644 --- a/plugins/maven/maven.iml +++ b/plugins/maven/maven.iml @@ -75,7 +75,6 @@ - diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java index 199e780e0538..88f9d24b06fc 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/MavenProjectsManager.java @@ -27,7 +27,6 @@ import com.intellij.openapi.compiler.CompileContext; import com.intellij.openapi.compiler.CompileTask; import com.intellij.openapi.compiler.CompilerManager; import com.intellij.openapi.components.*; -import com.intellij.openapi.externalSystem.util.ExternalSystemConstants; import com.intellij.openapi.fileEditor.FileDocumentManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.DumbAwareRunnable; @@ -530,7 +529,7 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent public boolean isMavenizedModule(final Module m) { AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock(); try { - return !m.isDisposed() && "true".equals(m.getOptionValue(ExternalSystemConstants.MAVEN_MODULE_KEY)); + return !m.isDisposed() && "true".equals(m.getOptionValue(getMavenizedModuleOptionName())); } finally { accessToken.finish(); @@ -543,22 +542,26 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent if (m.isDisposed()) continue; if (mavenized) { - m.setOption(ExternalSystemConstants.MAVEN_MODULE_KEY, "true"); + m.setOption(getMavenizedModuleOptionName(), "true"); // clear external system API options // see com.intellij.openapi.externalSystem.service.project.manage.ModuleDataService#setModuleOptions - m.clearOption(ExternalSystemConstants.EXTERNAL_SYSTEM_ID); - m.clearOption(ExternalSystemConstants.LINKED_PROJECT_PATH); - m.clearOption(ExternalSystemConstants.ROOT_PROJECT_PATH); - m.clearOption(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_GROUP); - m.clearOption(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_VERSION); + m.clearOption("external.system.id"); + m.clearOption("external.linked.project.path"); + m.clearOption("external.root.project.path"); + m.clearOption("external.system.module.group"); + m.clearOption("external.system.module.version"); } else { - m.clearOption(ExternalSystemConstants.MAVEN_MODULE_KEY); + m.clearOption(getMavenizedModuleOptionName()); } } } + private static String getMavenizedModuleOptionName() { + return "org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule"; + } + @TestOnly public void resetManagedFilesAndProfilesInTests(List files, MavenExplicitProfiles profiles) { myWatcher.resetManagedFilesAndProfilesInTests(files, profiles);