From 44571874ece26cd6cda0655a5df0743bcd9efe3b Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 21 Jul 2015 14:17:31 +0200 Subject: [PATCH] =?UTF-8?q?module=20options=20management=20=E2=80=94=20use?= =?UTF-8?q?=20Key=20instead=20of=20string=20keys?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit extract checkUnknownMacros, don't validate macros for components during init (it is illegal, should be on project initialized) --- .../testFramework/ModuleTestCase.java | 5 +- .../model/serialization/JpsProjectLoader.java | 5 +- .../impl/stores/ProjectStoreImpl.java | 2 +- .../com/intellij/openapi/module/Module.java | 26 ++++- .../AbstractExternalSystemLocalSettings.java | 6 +- .../util/ExternalSystemApiUtil.java | 17 ++- .../util/ExternalSystemConstants.java | 17 ++- .../ExternalSystemBeforeRunTaskProvider.java | 6 +- .../manage/ContentRootDataService.java | 4 +- .../project/manage/ModuleDataService.java | 41 ++++--- .../util/ExternalSystemUtil.java | 23 ++-- .../intellij/openapi/module/ModuleType.java | 4 +- .../intellij/openapi/module/ModuleUtil.java | 10 +- .../components/impl/stores/IModuleStore.java | 17 +-- .../impl/stores/ModuleStoreImpl.java | 105 +++++++----------- .../openapi/module/impl/ModuleImpl.java | 93 ++++++++-------- .../module/impl/ModuleManagerComponent.java | 3 +- .../roots/impl/storage/ClasspathStorage.java | 10 +- .../stores/BaseFileConfigurableStoreImpl.java | 2 +- .../impl/stores/ComponentStoreImpl.java | 49 ++++---- .../components/impl/stores/StorageUtil.java | 27 +++-- .../project/impl/ProjectManagerImpl.java | 13 +-- .../src/com/intellij/core/CoreModule.java | 18 +++ .../module/impl/ModuleManagerImpl.java | 16 ++- .../impl/storage/ClassPathStorageUtil.java | 2 +- .../src/com/intellij/mock/MockModule.java | 19 +++- ...butionWithSourcesNotificationProvider.java | 6 +- .../gradle/config/GradlePositionManager.java | 4 +- ...esourceCompilerConfigurationGenerator.java | 2 +- .../gradle/config/GradleScriptType.java | 8 +- .../GradleOrderEnumeratorHandler.java | 9 +- ...lInPackageGradleConfigurationProducer.java | 9 +- .../TestClassGradleConfigurationProducer.java | 16 +-- ...TestMethodGradleConfigurationProducer.java | 12 +- .../service/GradleInstallationManager.java | 17 ++- .../resolve/GradleImplicitContributor.java | 4 +- plugins/maven/maven.iml | 1 + .../maven/project/MavenProjectsManager.java | 21 ++-- 38 files changed, 357 insertions(+), 292 deletions(-) diff --git a/java/testFramework/src/com/intellij/testFramework/ModuleTestCase.java b/java/testFramework/src/com/intellij/testFramework/ModuleTestCase.java index 5c63d391d11b..28d75926c9e0 100644 --- a/java/testFramework/src/com/intellij/testFramework/ModuleTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/ModuleTestCase.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. @@ -18,6 +18,7 @@ package com.intellij.testFramework; import com.intellij.ide.highlighter.ModuleFileType; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.WriteCommandAction; +import com.intellij.openapi.components.ComponentsPackage; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.module.ModuleType; @@ -161,7 +162,7 @@ public abstract class ModuleTestCase extends IdeaTestCase { public void run() { final ProjectImpl project = (ProjectImpl)myProject; project.setOptimiseTestLoadSpeed(false); - ((ModuleImpl)module).getStateStore().initComponent(component, false); + ComponentsPackage.getStateStore(module).initComponent(component, false); project.setOptimiseTestLoadSpeed(true); } }); 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 4fa3ac3d83bb..1ea6666fb070 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 @@ -1,5 +1,5 @@ /* - * Copyright 2000-2012 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,6 +17,7 @@ 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; @@ -63,7 +64,9 @@ 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/ProjectStoreImpl.java b/platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java index 7e7426069712..71369f7bb133 100644 --- a/platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java +++ b/platform/configuration-store-impl/src/com/intellij/openapi/components/impl/stores/ProjectStoreImpl.java @@ -386,7 +386,7 @@ public class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements I @NotNull @Override - protected XmlElementStorage getMainStorage() { + public XmlElementStorage getMainStorage() { return getProjectFileStorage(); } 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 6120cb0d49d3..1748cd062ee2 100644 --- a/platform/core-api/src/com/intellij/openapi/module/Module.java +++ b/platform/core-api/src/com/intellij/openapi/module/Module.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. @@ -19,6 +19,7 @@ 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; @@ -39,6 +40,8 @@ public interface Module extends ComponentManager, AreaInstance, Disposable { @NonNls String ELEMENT_TYPE = "type"; + Key ELEMENT_TYPE_KEY = Key.create("type"); + /** * Returns the VirtualFile for the module .iml file. * @@ -78,29 +81,40 @@ public interface Module extends ComponentManager, AreaInstance, Disposable { boolean isLoaded(); + @Deprecated + void setOption(@NotNull String optionName, @NotNull String optionValue); + /** * Sets a custom option for this module. * * @param optionName the name of the custom option. * @param optionValue the value of the custom option. */ - void setOption(@NotNull String optionName, @NotNull String optionValue); + void setOption(@NotNull Key optionName, @NotNull String optionValue); + + @SuppressWarnings("unused") + @Deprecated + void clearOption(@NotNull String optionName); /** * Removes a custom option from this module. * - * @param optionName the name of the custom option. + * @param key the name of the custom option. */ - void clearOption(@NotNull String optionName); + void clearOption(@NotNull Key key); + + @Nullable + @Deprecated + String getOptionValue(@NotNull String optionName); /** * Gets the value of a custom option for this module. * - * @param optionName the name of the custom option. + * @param key the name of the custom option. * @return the value of the custom option, or null if no value has been set. */ @Nullable - String getOptionValue(@NotNull String optionName); + String getOptionValue(@NotNull Key key); /** * Returns module scope including sources and tests, excluding libraries and dependencies. 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 4d4245648c15..0ac9421aec3d 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 @@ -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. @@ -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_KEY); + String id = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID); if (!myExternalSystemId.toString().equals(id)) { continue; } - pathsToForget.remove(module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY)); + pathsToForget.remove(module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH)); } 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 15854c86b644..e05739e65bd3 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 @@ -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. @@ -56,7 +56,6 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.swing.*; import java.io.File; import java.io.PrintWriter; import java.io.StringWriter; @@ -783,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_KEY)); + return module != null && !module.isDisposed() && systemId.getId().equals(module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID)); } @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_KEY)); + return module != null && !module.isDisposed() && systemId.equals(module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID)); } @Nullable @Contract(pure=true) public static String getExternalProjectPath(@Nullable Module module) { - return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY) : null; + return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH) : null; } @Nullable @Contract(pure=true) public static String getExternalRootProjectPath(@Nullable Module module) { - return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY) : null; + return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH) : null; } @Nullable @Contract(pure=true) public static String getExternalProjectId(@Nullable Module module) { - return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_ID_KEY) : null; + return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_ID) : null; } @Nullable @Contract(pure=true) public static String getExternalProjectGroup(@Nullable Module module) { - return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_GROUP_KEY) : null; + return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_GROUP) : null; } @Nullable @Contract(pure=true) public static String getExternalProjectVersion(@Nullable Module module) { - return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_VERSION_KEY) : null; + return module != null && !module.isDisposed() ? module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_VERSION) : 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 b02ae52faf34..6d6c813c9e92 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 @@ -1,9 +1,10 @@ /* - * 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. * You may obtain a copy of the License at + * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software @@ -14,6 +15,7 @@ */ 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; @@ -23,14 +25,23 @@ 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"; @@ -60,4 +71,6 @@ 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 f3ad64c7b08b..07424005c42c 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 @@ -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. @@ -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_KEY))) continue; + if (!mySystemId.toString().equals(module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID))) continue; - if (StringUtil.equals(externalProjectPath, module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY))) { + if (StringUtil.equals(externalProjectPath, module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH))) { 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 7e04d02d4055..d860aee66bc7 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 @@ -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. @@ -122,7 +122,7 @@ public class ContentRootDataService extends AbstractProjectDataService { if (instance == null) { return EMPTY; } - return instance.findByID(module.getOptionValue(Module.ELEMENT_TYPE)); + return instance.findByID(module.getOptionValue(Module.ELEMENT_TYPE_KEY)); } @NotNull diff --git a/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java b/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java index f79128db39fd..54a87b825afe 100644 --- a/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.java +++ b/platform/lang-api/src/com/intellij/openapi/module/ModuleUtil.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. @@ -19,14 +19,9 @@ */ package com.intellij.openapi.module; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ContentEntry; -import com.intellij.openapi.roots.ModifiableRootModel; -import com.intellij.openapi.roots.ModuleRootManager; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.Key; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.CachedValuesManager; import com.intellij.psi.util.ParameterizedCachedValue; @@ -105,7 +100,6 @@ public class ModuleUtil extends ModuleUtilCore { @Nullable public static ModuleType getModuleType(@NotNull Module module) { - String type = module.getOptionValue(Module.ELEMENT_TYPE); - return ModuleTypeManager.getInstance().findByID(type); + return ModuleType.get(module); } } diff --git a/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/IModuleStore.java b/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/IModuleStore.java index 56e5d6386d10..d8c685847f84 100644 --- a/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/IModuleStore.java +++ b/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/IModuleStore.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. @@ -15,25 +15,18 @@ */ package com.intellij.openapi.components.impl.stores; -import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.util.Key; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public interface IModuleStore extends IComponentStore { void setModuleFilePath(@NotNull String filePath); - @Nullable - VirtualFile getModuleFile(); - @NotNull String getModuleFilePath(); - @NotNull - String getModuleFileName(); + void setOption(@NotNull Key key, @NotNull String value); - void setOption(@NotNull String optionName, @NotNull String optionValue); + void clearOption(@NotNull Key key); - void clearOption(@NotNull String optionName); - - String getOptionValue(@NotNull String optionName); + String getOptionValue(@NotNull Key key); } diff --git a/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStoreImpl.java b/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStoreImpl.java index c936db0d8304..2256ea131ae2 100644 --- a/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStoreImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/components/impl/stores/ModuleStoreImpl.java @@ -15,18 +15,17 @@ */ package com.intellij.openapi.components.impl.stores; -import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleTypeManager; import com.intellij.openapi.module.impl.ModuleImpl; +import com.intellij.openapi.module.impl.ModuleManagerImpl; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ex.ProjectEx; -import com.intellij.openapi.startup.StartupManager; +import com.intellij.openapi.util.Key; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.util.PathUtilRt; +import com.intellij.util.keyFMap.KeyFMap; import com.intellij.util.messages.MessageBus; import org.jdom.Attribute; import org.jdom.Element; @@ -34,10 +33,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; -import java.util.Collection; -import java.util.Map; import java.util.Set; -import java.util.TreeMap; public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IModuleStore { private static final Logger LOG = Logger.getInstance(ModuleStoreImpl.class); @@ -53,7 +49,7 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM @NotNull @Override - protected FileBasedStorage getMainStorage() { + public FileBasedStorage getMainStorage() { FileBasedStorage storage = (FileBasedStorage)getStateStorageManager().getStateStorage(StoragePathMacros.MODULE_FILE, RoamingType.PER_USER); assert storage != null; return storage; @@ -64,36 +60,13 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM return myModule.getProject(); } - public void load() { - String moduleTypeId = getMainStorageData().myOptions.get(Module.ELEMENT_TYPE); - myModule.setOption(Module.ELEMENT_TYPE, ModuleTypeManager.getInstance().findByID(moduleTypeId).getId()); - - if (ApplicationManager.getApplication().isHeadlessEnvironment() || ApplicationManager.getApplication().isUnitTestMode()) { - return; - } - - final TrackingPathMacroSubstitutor substitutor = getStateStorageManager().getMacroSubstitutor(); - if (substitutor != null) { - final Collection macros = substitutor.getUnknownMacros(null); - if (!macros.isEmpty()) { - final Project project = myModule.getProject(); - StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() { - @Override - public void run() { - StorageUtil.notifyUnknownMacros(substitutor, project, null); - } - }); - } - } - } - @Override public ModuleFileData getMainStorageData() { return (ModuleFileData)super.getMainStorageData(); } static class ModuleFileData extends BaseStorageData { - private final Map myOptions; + private KeyFMap options; private final Module myModule; private boolean dirty = true; @@ -102,7 +75,7 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM super(rootElementName); myModule = module; - myOptions = new TreeMap(); + options = KeyFMap.EMPTY_MAP; } @Override @@ -115,16 +88,18 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM myModule = storageData.myModule; dirty = storageData.dirty; - myOptions = new TreeMap(storageData.myOptions); + options = storageData.options; } @Override public void load(@NotNull Element rootElement, @Nullable PathMacroSubstitutor pathMacroSubstitutor, boolean intern) { super.load(rootElement, pathMacroSubstitutor, intern); + KeyFMap options = KeyFMap.EMPTY_MAP; for (Attribute attribute : rootElement.getAttributes()) { - if (!attribute.getName().equals(VERSION_OPTION)) { - myOptions.put(attribute.getName(), attribute.getValue()); + String name = attribute.getName(); + if (!name.equals(VERSION_OPTION) && !StringUtil.isEmpty(name)) { + options.plus(ModuleManagerImpl.createOptionKey(name), attribute.getValue()); } } @@ -133,9 +108,13 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM @Override protected void writeOptions(@NotNull Element root, @NotNull String versionString) { - if (!myOptions.isEmpty()) { - for (Map.Entry entry : myOptions.entrySet()) { - root.setAttribute(entry.getKey(), entry.getValue()); + if (!options.isEmpty()) { + //noinspection unchecked + for (Key key : options.getKeys()) { + String value = options.get(key); + if (value != null) { + root.setAttribute(key.toString(), value); + } } } // need be last for compat reasons @@ -153,27 +132,33 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM @Override public Set getChangedComponentNames(@NotNull StorageData newStorageData, @Nullable PathMacroSubstitutor substitutor) { final ModuleFileData data = (ModuleFileData)newStorageData; - if (!myOptions.equals(data.myOptions)) { + if (options != data.options) { return null; } + return super.getChangedComponentNames(newStorageData, substitutor); } - public void setOption(@NotNull String optionName, @NotNull String optionValue) { - if (!optionValue.equals(myOptions.put(optionName, optionValue))) { - dirty = true; + void setOption(@NotNull Key key, @NotNull String optionValue) { + if (optionValue.equals(options.get(key))) { + return; } + + options = options.plus(key, optionValue); + dirty = true; } - public void clearOption(@NotNull String optionName) { - if (myOptions.remove(optionName) != null) { + public void clearOption(@NotNull Key key) { + KeyFMap newOptions = options.minus(key); + if (newOptions != options) { + options = newOptions; dirty = true; } } @Nullable - public String getOptionValue(@NotNull String optionName) { - return myOptions.get(optionName); + public String getOptionValue(@NotNull Key key) { + return options.get(key); } } @@ -186,12 +171,6 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM storageManager.addMacro(StoragePathMacros.MODULE_FILE, path); } - @Override - @Nullable - public VirtualFile getModuleFile() { - return getMainStorage().getVirtualFile(); - } - @Override @NotNull public String getModuleFilePath() { @@ -199,15 +178,9 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM } @Override - @NotNull - public String getModuleFileName() { - return PathUtilRt.getFileName(getMainStorage().getFilePath()); - } - - @Override - public void setOption(@NotNull String optionName, @NotNull String optionValue) { + public void setOption(@NotNull Key key, @NotNull String value) { try { - getMainStorageData().setOption(optionName, optionValue); + getMainStorageData().setOption(key, value); } catch (StateStorageException e) { LOG.error(e); @@ -215,9 +188,9 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM } @Override - public void clearOption(@NotNull String optionName) { + public void clearOption(@NotNull Key key) { try { - getMainStorageData().clearOption(optionName); + getMainStorageData().clearOption(key); } catch (StateStorageException e) { LOG.error(e); @@ -225,9 +198,9 @@ public class ModuleStoreImpl extends BaseFileConfigurableStoreImpl implements IM } @Override - public String getOptionValue(@NotNull String optionName) { + public String getOptionValue(@NotNull Key key) { try { - return getMainStorageData().getOptionValue(optionName); + return getMainStorageData().getOptionValue(key); } catch (StateStorageException e) { LOG.error(e); 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 df6ae6482d0c..910faf1b0f53 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 @@ -19,6 +19,7 @@ import com.intellij.ide.highlighter.ModuleFileType; import com.intellij.ide.plugins.IdeaPluginDescriptor; import com.intellij.openapi.application.impl.ApplicationInfoImpl; import com.intellij.openapi.components.ComponentConfig; +import com.intellij.openapi.components.ComponentsPackage; import com.intellij.openapi.components.ExtensionAreas; import com.intellij.openapi.components.PathMacroManager; import com.intellij.openapi.components.impl.ModulePathMacroManager; @@ -37,20 +38,22 @@ 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.Comparing; +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.*; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.PathUtil; -import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.picocontainer.MutablePicoContainer; import java.io.File; import java.io.IOException; -import java.util.*; +import java.util.List; +import java.util.Map; + +import static com.intellij.openapi.module.impl.ModuleManagerImpl.createOptionKey; /** * @author max @@ -61,14 +64,10 @@ public class ModuleImpl extends PlatformComponentManagerImpl implements ModuleEx @NotNull private final Project myProject; private boolean isModuleAdded; - @NonNls private static final String OPTION_WORKSPACE = "workspace"; - public static final Object MODULE_RENAMING_REQUESTOR = new Object(); private String myName; - private String myModuleType; - private final ModuleScopeProvider myModuleScopeProvider; public ModuleImpl(@NotNull String filePath, @NotNull Project project) { @@ -79,7 +78,10 @@ public class ModuleImpl extends PlatformComponentManagerImpl implements ModuleEx myProject = project; myModuleScopeProvider = new ModuleScopeProviderImpl(this); - init(filePath); + getStateStore().setModuleFilePath(filePath); + myName = moduleNameByFileName(PathUtil.getFileName(filePath)); + + VirtualFileManager.getInstance().addVirtualFileListener(new MyVirtualFileListener(), this); } @Override @@ -92,14 +94,7 @@ public class ModuleImpl extends PlatformComponentManagerImpl implements ModuleEx @NotNull public ModuleStoreImpl getStateStore() { - return (ModuleStoreImpl)getPicoContainer().getComponentInstance(IComponentStore.class); - } - - private void init(String filePath) { - getStateStore().setModuleFilePath(filePath); - myName = moduleNameByFileName(PathUtil.getFileName(filePath)); - - VirtualFileManager.getInstance().addVirtualFileListener(new MyVirtualFileListener(), this); + return (ModuleStoreImpl)ComponentsPackage.getStateStore(this); } @Override @@ -113,34 +108,38 @@ public class ModuleImpl extends PlatformComponentManagerImpl implements ModuleEx } @Override - protected boolean isComponentSuitable(Map options) { - if (!super.isComponentSuitable(options)) return false; - if (options == null) return true; + protected boolean isComponentSuitable(@Nullable Map options) { + if (!super.isComponentSuitable(options)) { + return false; + } + if (options == null) { + return true; + } - Set optionNames = options.keySet(); - for (String optionName : optionNames) { - if (Comparing.equal(OPTION_WORKSPACE, optionName)) continue; - if (!parseOptionValue(options.get(optionName)).contains(getOptionValue(optionName))) return false; + for (String optionName : options.keySet()) { + if ("workspace".equals(optionName)) { + continue; + } + + String optionValue = options.get(optionName); + if (!StringUtil.isEmpty(optionValue) || StringUtil.split(optionValue, ";").contains(getOptionValue(createOptionKey(optionName)))) { + return false; + } } return true; } - private static List parseOptionValue(String optionValue) { - if (optionValue == null) return new ArrayList(0); - return Arrays.asList(optionValue.split(";")); - } - @Override @Nullable public VirtualFile getModuleFile() { - return getStateStore().getModuleFile(); + return getStateStore().getMainStorage().getVirtualFile(); } @Override public void rename(String newName) { myName = newName; - final VirtualFile file = getStateStore().getModuleFile(); + final VirtualFile file = getStateStore().getMainStorage().getVirtualFile(); try { if (file != null) { ClasspathStorage.moduleRenamed(this, newName); @@ -231,29 +230,33 @@ public class ModuleImpl extends PlatformComponentManagerImpl implements ModuleEx @Override public void setOption(@NotNull String optionName, @NotNull String optionValue) { - if (ELEMENT_TYPE.equals(optionName)) { - myModuleType = optionValue; - } - getStateStore().setOption(optionName, optionValue); + setOption(createOptionKey(optionName), optionValue); + } + + @Override + public void setOption(@NotNull Key key, @NotNull String optionValue) { + getStateStore().setOption(key, optionValue); } @Override public void clearOption(@NotNull String optionName) { - if (ELEMENT_TYPE.equals(optionName)) { - myModuleType = null; - } - getStateStore().clearOption(optionName); + getStateStore().clearOption(createOptionKey(optionName)); + } + + @Override + public void clearOption(@NotNull Key key) { + getStateStore().clearOption(key); } @Override public String getOptionValue(@NotNull String optionName) { - if (ELEMENT_TYPE.equals(optionName)) { - if (myModuleType == null) { - myModuleType = getStateStore().getOptionValue(optionName); - } - return myModuleType; - } - return getStateStore().getOptionValue(optionName); + return getOptionValue(createOptionKey(optionName)); + } + + @Nullable + @Override + public String getOptionValue(@NotNull Key key) { + return getStateStore().getOptionValue(key); } @NotNull diff --git a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java index eab9b48a10ec..235138b03d9d 100644 --- a/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java +++ b/platform/lang-impl/src/com/intellij/openapi/module/impl/ModuleManagerComponent.java @@ -25,6 +25,7 @@ import com.intellij.openapi.components.State; import com.intellij.openapi.components.Storage; import com.intellij.openapi.components.StoragePathMacros; import com.intellij.openapi.components.StorageScheme; +import com.intellij.openapi.components.impl.stores.StorageUtil; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.module.Module; import com.intellij.openapi.module.ModuleType; @@ -120,7 +121,7 @@ public class ModuleManagerComponent extends ModuleManagerImpl { @Override protected ModuleEx createAndLoadModule(@NotNull String filePath) throws IOException { ModuleImpl module = new ModuleImpl(filePath, myProject); - module.getStateStore().load(); + StorageUtil.checkUnknownMacros(module, myProject); return module; } 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 7c16888afe73..e8fbe50ec7f4 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 getConversionProblemsStorage() { diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java index faf27e90cd38..ea3a31d1aa9d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/ComponentStoreImpl.java @@ -71,11 +71,24 @@ public abstract class ComponentStoreImpl implements IComponentStore { AccessToken token = ReadAction.start(); try { + String componentNameIfStateExists; if (component instanceof PersistentStateComponent) { - initPersistentComponent((PersistentStateComponent)component, null, false); + componentNameIfStateExists = initPersistentComponent((PersistentStateComponent)component, null, false); } else { - initJdomExternalizable((JDOMExternalizable)component); + componentNameIfStateExists = initJdomExternalizable((JDOMExternalizable)component); + } + + // if not service, so, component manager will check it later for all components + if (componentNameIfStateExists != null && service) { + Project project = getProject(); + Application app = ApplicationManager.getApplication(); + if (project != null && !app.isHeadlessEnvironment() && !app.isUnitTestMode() && project.isInitialized()) { + TrackingPathMacroSubstitutor substitutor = getStateStorageManager().getMacroSubstitutor(); + if (substitutor != null) { + StorageUtil.notifyUnknownMacros(substitutor, project, componentNameIfStateExists); + } + } } } catch (StateStorageException e) { @@ -214,24 +227,25 @@ public abstract class ComponentStoreImpl implements IComponentStore { } } - private void initJdomExternalizable(@NotNull JDOMExternalizable component) { + @Nullable + private String initJdomExternalizable(@NotNull JDOMExternalizable component) { String componentName = ComponentManagerImpl.getComponentName(component); doAddComponent(componentName, component); if (optimizeTestLoading()) { - return; + return null; } loadJdomDefaults(component, componentName); StateStorage stateStorage = getStateStorageManager().getOldStorage(component, componentName, StateStorageOperation.READ); if (stateStorage == null) { - return; + return null; } Element element = stateStorage.getState(component, componentName, Element.class, null); if (element == null) { - return; + return null; } try { @@ -242,10 +256,10 @@ public abstract class ComponentStoreImpl implements IComponentStore { } catch (InvalidDataException e) { LOG.error(e); - return; + return null; } - validateUnusedMacros(componentName, true); + return componentName; } private void doAddComponent(String componentName, Object component) { @@ -273,20 +287,7 @@ public abstract class ComponentStoreImpl implements IComponentStore { return null; } - private void validateUnusedMacros(@Nullable final String componentName, final boolean service) { - final Project project = getProject(); - if (project == null) return; - - if (!ApplicationManager.getApplication().isHeadlessEnvironment() && !ApplicationManager.getApplication().isUnitTestMode()) { - if (service && componentName != null && project.isInitialized()) { - final TrackingPathMacroSubstitutor substitutor = getStateStorageManager().getMacroSubstitutor(); - if (substitutor != null) { - StorageUtil.notifyUnknownMacros(substitutor, project, componentName); - } - } - } - } - + @Nullable private String initPersistentComponent(@NotNull PersistentStateComponent component, @Nullable Set changedStorages, boolean reloadData) { State stateSpec = StoreUtil.getStateSpec(component); String name = stateSpec.name(); @@ -294,7 +295,7 @@ public abstract class ComponentStoreImpl implements IComponentStore { doAddComponent(name, component); } if (optimizeTestLoading()) { - return name; + return null; } Class stateClass = ComponentSerializationUtil.getStateClass(component.getClass()); @@ -329,8 +330,6 @@ public abstract class ComponentStoreImpl implements IComponentStore { component.loadState(state); } - validateUnusedMacros(name, true); - return name; } diff --git a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java index 1929944edd62..030b39ac084c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/components/impl/stores/StorageUtil.java @@ -19,20 +19,15 @@ import com.intellij.notification.Notification; import com.intellij.notification.NotificationListener; import com.intellij.notification.NotificationType; import com.intellij.notification.NotificationsManager; -import com.intellij.openapi.application.AccessToken; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.application.ApplicationNamesInfo; -import com.intellij.openapi.application.WriteAction; -import com.intellij.openapi.components.RoamingType; -import com.intellij.openapi.components.StateStorage; -import com.intellij.openapi.components.StoragePathMacros; -import com.intellij.openapi.components.TrackingPathMacroSubstitutor; +import com.intellij.openapi.application.*; +import com.intellij.openapi.components.*; import com.intellij.openapi.components.store.ReadOnlyModificationException; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.fileEditor.impl.LoadTextUtil; import com.intellij.openapi.project.Project; import com.intellij.openapi.project.ProjectBundle; import com.intellij.openapi.project.ex.ProjectEx; +import com.intellij.openapi.startup.StartupManager; import com.intellij.openapi.util.JDOMUtil; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.ThrowableComputable; @@ -80,6 +75,22 @@ public class StorageUtil { return event.getRequestor() instanceof StateStorage.SaveSession || event.getRequestor() instanceof StateStorage; } + public static void checkUnknownMacros(@NotNull final ComponentManager componentManager, @NotNull final Project project) { + Application application = ApplicationManager.getApplication(); + if (!application.isHeadlessEnvironment() && !application.isUnitTestMode()) { + // should be invoked last + StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() { + @Override + public void run() { + TrackingPathMacroSubstitutor substitutor = ComponentsPackage.getStateStore(componentManager).getStateStorageManager().getMacroSubstitutor(); + if (substitutor != null) { + notifyUnknownMacros(substitutor, project, null); + } + } + }); + } + } + public static void notifyUnknownMacros(@NotNull TrackingPathMacroSubstitutor substitutor, @NotNull final Project project, @Nullable final String componentName) { diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java index c4b3c5b71753..5dfd108238a3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java @@ -486,18 +486,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements PersistentSt return false; } - if (!application.isHeadlessEnvironment() && !application.isUnitTestMode()) { - // should be invoked last - startupManager.runWhenProjectIsInitialized(new Runnable() { - @Override - public void run() { - TrackingPathMacroSubstitutor substitutor = ((ProjectEx)project).getStateStore().getStateStorageManager().getMacroSubstitutor(); - if (substitutor != null) { - StorageUtil.notifyUnknownMacros(substitutor, project, null); - } - } - }); - } + StorageUtil.checkUnknownMacros(project, project); return true; } diff --git a/platform/projectModel-impl/src/com/intellij/core/CoreModule.java b/platform/projectModel-impl/src/com/intellij/core/CoreModule.java index 22cb2ee198ef..74f523b095de 100644 --- a/platform/projectModel-impl/src/com/intellij/core/CoreModule.java +++ b/platform/projectModel-impl/src/com/intellij/core/CoreModule.java @@ -35,12 +35,14 @@ import com.intellij.openapi.roots.impl.ModuleFileIndexImpl; import com.intellij.openapi.roots.impl.ModuleRootManagerImpl; import com.intellij.openapi.roots.impl.ProjectRootManagerImpl; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.Key; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.PathUtil; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * @author yole @@ -181,6 +183,22 @@ public class CoreModule extends MockComponentManager implements ModuleEx { throw new UnsupportedOperationException(); } + @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(); + } + @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 f0b38d7457eb..e2ee1f0ca4ab 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,6 +97,16 @@ 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; @@ -709,10 +719,10 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project ModuleEx module = getModuleByFilePath(filePath); if (module == null) { module = createModule(filePath); - module.setOption(Module.ELEMENT_TYPE, moduleTypeId); + module.setOption(Module.ELEMENT_TYPE_KEY, moduleTypeId); if (options != null) { - for ( Map.Entry option : options.entrySet()) { - module.setOption(option.getKey(),option.getValue()); + for (Map.Entry option : options.entrySet()) { + module.setOption(createOptionKey(option.getKey()), option.getValue()); } } initModule(module); 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 4ed52d91044b..84b7324ced65 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_ATTRIBUTE); + String id = module.getOptionValue(JpsProjectLoader.CLASSPATH_DIR_ATTRIBUTE_KEY); 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 e0eaf7aac476..3ea1bf9f79fc 100644 --- a/platform/testFramework/src/com/intellij/mock/MockModule.java +++ b/platform/testFramework/src/com/intellij/mock/MockModule.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. @@ -18,6 +18,7 @@ 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; @@ -143,4 +144,20 @@ 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 4b3038107c77..54b742ac88ed 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/codeInsight/UseDistributionWithSourcesNotificationProvider.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. @@ -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_KEY); + String externalSystemId = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID); if (externalSystemId == null || !GradleConstants.SYSTEM_ID.toString().equals(externalSystemId)) { return null; } - String path = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY); + String path = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); 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 29bfbb992cda..440c8115ea77 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradlePositionManager.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradlePositionManager.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. @@ -129,7 +129,7 @@ public class GradlePositionManager extends ScriptPositionManagerHelper { @Nullable private ClassLoader createGradleClassLoader(@NotNull Module module) { - String rootProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY); + String rootProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); 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 4e8b6431eb9d..02e39df578b8 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_KEY); + final String gradleProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); 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 30fb81af6075..3a9054c7e9ab 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/config/GradleScriptType.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. @@ -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_KEY); + String rootProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); 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_KEY); + String externalSystemId = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID); 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_KEY); + String modulePath = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH); 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 3361754f910b..c51af93d22a7 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/GradleOrderEnumeratorHandler.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/execution/GradleOrderEnumeratorHandler.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. @@ -33,7 +33,10 @@ import com.intellij.openapi.roots.ModuleRootModel; import com.intellij.openapi.roots.OrderEnumerationHandler; import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.*; +import com.intellij.openapi.vfs.LocalFileSystem; +import com.intellij.openapi.vfs.VfsUtilCore; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.plugins.gradle.service.project.data.ExternalProjectDataService; @@ -75,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_KEY); + final String gradleProjectPath = rootModel.getModule().getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); 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 237bcb99eef0..687ef93f10e9 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 @@ -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. @@ -29,6 +29,7 @@ import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.gradle.service.execution.GradleExternalTaskConfigurationType; import org.jetbrains.plugins.gradle.util.GradleConstants; + import java.util.List; /** @@ -56,12 +57,12 @@ public class AllInPackageGradleConfigurationProducer extends GradleTestRunConfig if (module == null) return false; if (!StringUtil.equals( - module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY), + module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), GradleConstants.SYSTEM_ID.toString())) { return false; } - final String linkedGradleProject = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY); + final String linkedGradleProject = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH); if (linkedGradleProject == null) return false; configuration.getSettings().setExternalProjectPath(linkedGradleProject); configuration.getSettings().setTaskNames(TASKS_TO_RUN); @@ -87,7 +88,7 @@ public class AllInPackageGradleConfigurationProducer extends GradleTestRunConfig if (context.getModule() == null) return false; if (!StringUtil.equals( - context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY), + context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH), 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 11e0280b00e2..ad03d7dca910 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 @@ -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. @@ -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_KEY), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), GradleConstants.SYSTEM_ID.toString())) { return false; } - configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY)); + configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH)); 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_KEY), + context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH), 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_KEY), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), 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_KEY), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), 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_KEY), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), GradleConstants.SYSTEM_ID.toString())) { return false; } - configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY)); + configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH)); 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 d6a83f2a4df0..ec51646fa3ea 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 @@ -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. @@ -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_KEY), + context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH), 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_KEY), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), 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_KEY), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), 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_KEY), + context.getModule().getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID), GradleConstants.SYSTEM_ID.toString())) { return false; } - configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY)); + configuration.getSettings().setExternalProjectPath(context.getModule().getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH)); 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 f51f8ee90bcc..3a784c168077 100644 --- a/plugins/gradle/src/org/jetbrains/plugins/gradle/service/GradleInstallationManager.java +++ b/plugins/gradle/src/org/jetbrains/plugins/gradle/service/GradleInstallationManager.java @@ -1,3 +1,18 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.jetbrains.plugins.gradle.service; import com.intellij.openapi.externalSystem.service.execution.ExternalSystemJdkException; @@ -447,7 +462,7 @@ public class GradleInstallationManager { if(rootProjectPath == null) { for (Module module : myPlatformFacade.getModules(project)) { - rootProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY); + rootProjectPath = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); 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 4a917ad70443..644c01b17649 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 @@ -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. @@ -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_KEY); + String path = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH); 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 5703e18b8299..18c1a4219a19 100644 --- a/plugins/maven/maven.iml +++ b/plugins/maven/maven.iml @@ -75,6 +75,7 @@ + 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 88f9d24b06fc..199e780e0538 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,6 +27,7 @@ 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; @@ -529,7 +530,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(getMavenizedModuleOptionName())); + return !m.isDisposed() && "true".equals(m.getOptionValue(ExternalSystemConstants.MAVEN_MODULE_KEY)); } finally { accessToken.finish(); @@ -542,26 +543,22 @@ public class MavenProjectsManager extends MavenSimpleProjectComponent if (m.isDisposed()) continue; if (mavenized) { - m.setOption(getMavenizedModuleOptionName(), "true"); + m.setOption(ExternalSystemConstants.MAVEN_MODULE_KEY, "true"); // clear external system API options // see com.intellij.openapi.externalSystem.service.project.manage.ModuleDataService#setModuleOptions - 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"); + 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); } else { - m.clearOption(getMavenizedModuleOptionName()); + m.clearOption(ExternalSystemConstants.MAVEN_MODULE_KEY); } } } - private static String getMavenizedModuleOptionName() { - return "org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule"; - } - @TestOnly public void resetManagedFilesAndProfilesInTests(List files, MavenExplicitProfiles profiles) { myWatcher.resetManagedFilesAndProfilesInTests(files, profiles);