mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
module options management — use Key instead of string keys
extract checkUnknownMacros, don't validate macros for components during init (it is illegal, should be on project initialized)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
+4
-1
@@ -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<String> CLASSPATH_ATTRIBUTE_KEY = Key.create(CLASSPATH_ATTRIBUTE);
|
||||
public static final String CLASSPATH_DIR_ATTRIBUTE = "classpath-dir";
|
||||
public static final Key<String> CLASSPATH_DIR_ATTRIBUTE_KEY = Key.create(CLASSPATH_DIR_ATTRIBUTE);
|
||||
private final JpsProject myProject;
|
||||
private final Map<String, String> myPathVariables;
|
||||
|
||||
|
||||
+1
-1
@@ -386,7 +386,7 @@ public class ProjectStoreImpl extends BaseFileConfigurableStoreImpl implements I
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected XmlElementStorage getMainStorage() {
|
||||
public XmlElementStorage getMainStorage() {
|
||||
return getProjectFileStorage();
|
||||
}
|
||||
|
||||
|
||||
@@ -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<String> ELEMENT_TYPE_KEY = Key.create("type");
|
||||
|
||||
/**
|
||||
* Returns the <code>VirtualFile</code> 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<String> 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<String> 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<String> key);
|
||||
|
||||
/**
|
||||
* Returns module scope including sources and tests, excluding libraries and dependencies.
|
||||
|
||||
+3
-3
@@ -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()) {
|
||||
|
||||
+8
-9
@@ -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,
|
||||
|
||||
+15
-2
@@ -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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> MAVEN_MODULE_KEY = Key.create("org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule");
|
||||
}
|
||||
|
||||
+3
-3
@@ -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;
|
||||
}
|
||||
|
||||
+2
-2
@@ -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<ContentRo
|
||||
AbstractExternalSystemSettings externalSystemSettings =
|
||||
ExternalSystemApiUtil.getSettings(module.getProject(), projectSystemId);
|
||||
|
||||
String path = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY);
|
||||
String path = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH);
|
||||
if (path != null) {
|
||||
ExternalProjectSettings projectSettings = externalSystemSettings.getLinkedProjectSettings(path);
|
||||
createEmptyContentRootDirectories = projectSettings != null && projectSettings.isCreateEmptyContentRootDirectories();
|
||||
|
||||
+28
-13
@@ -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 com.intellij.openapi.externalSystem.service.project.manage;
|
||||
|
||||
import com.intellij.openapi.application.Application;
|
||||
@@ -387,12 +402,12 @@ public class ModuleDataService extends AbstractProjectDataService<ModuleData, Mo
|
||||
}
|
||||
|
||||
public static void unlinkModuleFromExternalSystem(@NotNull Module module) {
|
||||
module.clearOption(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
|
||||
module.clearOption(ExternalSystemConstants.LINKED_PROJECT_ID_KEY);
|
||||
module.clearOption(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY);
|
||||
module.clearOption(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY);
|
||||
module.clearOption(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_GROUP_KEY);
|
||||
module.clearOption(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_VERSION_KEY);
|
||||
module.clearOption(ExternalSystemConstants.EXTERNAL_SYSTEM_ID);
|
||||
module.clearOption(ExternalSystemConstants.LINKED_PROJECT_ID);
|
||||
module.clearOption(ExternalSystemConstants.LINKED_PROJECT_PATH);
|
||||
module.clearOption(ExternalSystemConstants.ROOT_PROJECT_PATH);
|
||||
module.clearOption(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_GROUP);
|
||||
module.clearOption(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_VERSION);
|
||||
}
|
||||
|
||||
private class ImportModulesTask implements Runnable {
|
||||
@@ -435,20 +450,20 @@ public class ModuleDataService extends AbstractProjectDataService<ModuleData, Mo
|
||||
ModuleData moduleData = moduleDataNode.getData();
|
||||
module.putUserData(MODULE_DATA_KEY, moduleData);
|
||||
|
||||
module.setOption(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY, moduleData.getOwner().toString());
|
||||
module.setOption(ExternalSystemConstants.LINKED_PROJECT_ID_KEY, moduleData.getId());
|
||||
module.setOption(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY, moduleData.getLinkedExternalProjectPath());
|
||||
module.setOption(ExternalSystemConstants.EXTERNAL_SYSTEM_ID, moduleData.getOwner().toString());
|
||||
module.setOption(ExternalSystemConstants.LINKED_PROJECT_ID, moduleData.getId());
|
||||
module.setOption(ExternalSystemConstants.LINKED_PROJECT_PATH, moduleData.getLinkedExternalProjectPath());
|
||||
final ProjectData projectData = moduleDataNode.getData(ProjectKeys.PROJECT);
|
||||
module.setOption(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY, projectData != null ? projectData.getLinkedExternalProjectPath() : "");
|
||||
module.setOption(ExternalSystemConstants.ROOT_PROJECT_PATH, projectData != null ? projectData.getLinkedExternalProjectPath() : "");
|
||||
|
||||
if (moduleData.getGroup() != null) {
|
||||
module.setOption(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_GROUP_KEY, moduleData.getGroup());
|
||||
module.setOption(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_GROUP, moduleData.getGroup());
|
||||
}
|
||||
if (moduleData.getVersion() != null) {
|
||||
module.setOption(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_VERSION_KEY, moduleData.getVersion());
|
||||
module.setOption(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_VERSION, moduleData.getVersion());
|
||||
}
|
||||
|
||||
// clear maven option
|
||||
module.clearOption("org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule");
|
||||
module.clearOption(ExternalSystemConstants.MAVEN_MODULE_KEY);
|
||||
}
|
||||
}
|
||||
|
||||
+9
-14
@@ -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.
|
||||
@@ -53,7 +53,6 @@ import com.intellij.openapi.externalSystem.service.project.PlatformFacade;
|
||||
import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemTaskActivator;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ModuleDataService;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager;
|
||||
import com.intellij.openapi.externalSystem.service.settings.ExternalSystemConfigLocator;
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
|
||||
@@ -70,8 +69,10 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.StandardFileSystems;
|
||||
@@ -82,28 +83,22 @@ import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowManagerEx;
|
||||
import com.intellij.openapi.wm.impl.ToolWindowImpl;
|
||||
import com.intellij.ui.CheckBoxList;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.DisposeAwareRunnable;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.SmartList;
|
||||
import com.intellij.util.concurrency.Semaphore;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.TObjectHashingStrategy;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.executeOnEdtUnderWriteAction;
|
||||
|
||||
@@ -913,7 +908,7 @@ public class ExternalSystemUtil {
|
||||
|
||||
PlatformFacade platformFacade = ServiceManager.getService(PlatformFacade.class);
|
||||
for (Module module : platformFacade.getModules(ideProject)) {
|
||||
String path = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY);
|
||||
String path = module.getOptionValue(ExternalSystemConstants.LINKED_PROJECT_PATH);
|
||||
if (!StringUtil.isEmpty(path) && !externalModulePaths.remove(path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -116,7 +116,7 @@ public abstract class ModuleType<T extends ModuleBuilder> {
|
||||
if (instance == null) {
|
||||
return EMPTY;
|
||||
}
|
||||
return instance.findByID(module.getOptionValue(Module.ELEMENT_TYPE));
|
||||
return instance.findByID(module.getOptionValue(Module.ELEMENT_TYPE_KEY));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-12
@@ -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<String> key, @NotNull String value);
|
||||
|
||||
void setOption(@NotNull String optionName, @NotNull String optionValue);
|
||||
void clearOption(@NotNull Key<String> key);
|
||||
|
||||
void clearOption(@NotNull String optionName);
|
||||
|
||||
String getOptionValue(@NotNull String optionName);
|
||||
String getOptionValue(@NotNull Key<String> key);
|
||||
}
|
||||
|
||||
+39
-66
@@ -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<String> 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<String, String> 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<String, String>();
|
||||
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<String, String>(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<String, String> entry : myOptions.entrySet()) {
|
||||
root.setAttribute(entry.getKey(), entry.getValue());
|
||||
if (!options.isEmpty()) {
|
||||
//noinspection unchecked
|
||||
for (Key<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> 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<String> key) {
|
||||
try {
|
||||
return getMainStorageData().getOptionValue(optionName);
|
||||
return getMainStorageData().getOptionValue(key);
|
||||
}
|
||||
catch (StateStorageException e) {
|
||||
LOG.error(e);
|
||||
|
||||
@@ -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<String, String> options) {
|
||||
if (!super.isComponentSuitable(options)) return false;
|
||||
if (options == null) return true;
|
||||
protected boolean isComponentSuitable(@Nullable Map<String, String> options) {
|
||||
if (!super.isComponentSuitable(options)) {
|
||||
return false;
|
||||
}
|
||||
if (options == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Set<String> 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<String> parseOptionValue(String optionValue) {
|
||||
if (optionValue == null) return new ArrayList<String>(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<String> 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<String> 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<String> key) {
|
||||
return getStateStore().getOptionValue(key);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -184,7 +184,7 @@ public class ClasspathStorage extends StateStorageBase<ClasspathStorage.MyStorag
|
||||
@NotNull
|
||||
public static String getStorageRootFromOptions(@NotNull Module module) {
|
||||
String moduleRoot = getModuleDir(module);
|
||||
String storageRef = module.getOptionValue(JpsProjectLoader.CLASSPATH_DIR_ATTRIBUTE);
|
||||
String storageRef = module.getOptionValue(JpsProjectLoader.CLASSPATH_DIR_ATTRIBUTE_KEY);
|
||||
if (storageRef == null) {
|
||||
return moduleRoot;
|
||||
}
|
||||
@@ -212,12 +212,12 @@ public class ClasspathStorage extends StateStorageBase<ClasspathStorage.MyStorag
|
||||
|
||||
provider = getProvider(storageId);
|
||||
if (provider == null) {
|
||||
module.clearOption(JpsProjectLoader.CLASSPATH_ATTRIBUTE);
|
||||
module.clearOption(JpsProjectLoader.CLASSPATH_DIR_ATTRIBUTE);
|
||||
module.clearOption(JpsProjectLoader.CLASSPATH_ATTRIBUTE_KEY);
|
||||
module.clearOption(JpsProjectLoader.CLASSPATH_DIR_ATTRIBUTE_KEY);
|
||||
}
|
||||
else {
|
||||
module.setOption(JpsProjectLoader.CLASSPATH_ATTRIBUTE, storageId);
|
||||
module.setOption(JpsProjectLoader.CLASSPATH_DIR_ATTRIBUTE, provider.getContentRoot(model));
|
||||
module.setOption(JpsProjectLoader.CLASSPATH_ATTRIBUTE_KEY, storageId);
|
||||
module.setOption(JpsProjectLoader.CLASSPATH_DIR_ATTRIBUTE_KEY, provider.getContentRoot(model));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ abstract class BaseFileConfigurableStoreImpl extends ComponentStoreImpl {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract XmlElementStorage getMainStorage();
|
||||
public abstract XmlElementStorage getMainStorage();
|
||||
|
||||
@Nullable
|
||||
static List<String> getConversionProblemsStorage() {
|
||||
|
||||
+24
-25
@@ -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 <T> String initPersistentComponent(@NotNull PersistentStateComponent<T> component, @Nullable Set<StateStorage> 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<T> stateClass = ComponentSerializationUtil.getStateClass(component.getClass());
|
||||
@@ -329,8 +330,6 @@ public abstract class ComponentStoreImpl implements IComponentStore {
|
||||
component.loadState(state);
|
||||
}
|
||||
|
||||
validateUnusedMacros(name, true);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
+19
-8
@@ -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) {
|
||||
|
||||
+1
-12
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<String> optionName, @NotNull String optionValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearOption(@NotNull Key<String> key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getOptionValue(@NotNull Key<String> key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public GlobalSearchScope getModuleScope() {
|
||||
|
||||
+13
-3
@@ -97,6 +97,16 @@ public abstract class ModuleManagerImpl extends ModuleManager implements Project
|
||||
myMessageBus = messageBus;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Key<String> 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<String,String> option : options.entrySet()) {
|
||||
module.setOption(option.getKey(),option.getValue());
|
||||
for (Map.Entry<String, String> option : options.entrySet()) {
|
||||
module.setOption(createOptionKey(option.getKey()), option.getValue());
|
||||
}
|
||||
}
|
||||
initModule(module);
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String> optionName, @NotNull String optionValue) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearOption(@NotNull Key<String> key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getOptionValue(@NotNull Key<String> key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
+6
-3
@@ -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;
|
||||
|
||||
+5
-4
@@ -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;
|
||||
}
|
||||
|
||||
+8
-8
@@ -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<PsiClass> 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();
|
||||
|
||||
+6
-6
@@ -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<PsiClass> 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();
|
||||
|
||||
+16
-1
@@ -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<File> result = findGradleSdkClasspath(project, rootProjectPath);
|
||||
if(!result.isEmpty()) return result;
|
||||
}
|
||||
|
||||
+2
-2
@@ -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<ExternalTaskPojo> taskPojos = localSettings.getAvailableTasks().get(path);
|
||||
if (taskPojos == null) return;
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
<orderEntry type="module" module-name="external-system-impl" />
|
||||
<orderEntry type="library" name="Slf4j" level="project" />
|
||||
<orderEntry type="library" name="Log4J" level="project" />
|
||||
<orderEntry type="module" module-name="external-system-api" />
|
||||
</component>
|
||||
<component name="copyright">
|
||||
<Base>
|
||||
|
||||
+9
-12
@@ -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<VirtualFile> files, MavenExplicitProfiles profiles) {
|
||||
myWatcher.resetManagedFilesAndProfilesInTests(files, profiles);
|
||||
|
||||
Reference in New Issue
Block a user