mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-104500 Gradle: Allow to reuse common logic for other external systems
1. 'external-system' is split into 'external-system-api' and 'external-system-impl'; 2. Legacy code is removed;
This commit is contained in:
@@ -254,6 +254,7 @@ binding.setVariable("platformApiModules", [
|
||||
"usageView",
|
||||
"xdebugger-api",
|
||||
"xml-openapi",
|
||||
"external-system-api",
|
||||
])
|
||||
|
||||
|
||||
@@ -276,7 +277,7 @@ binding.setVariable("platformImplementationModules", [
|
||||
"images",
|
||||
"RegExpSupport",
|
||||
"dvcs",
|
||||
"external-system"
|
||||
"external-system-impl"
|
||||
])
|
||||
|
||||
binding.setVariable("layoutMacApp", { String path, String ch, Map args ->
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
<orderEntry type="module" module-name="core-impl" exported="" />
|
||||
<orderEntry type="module" module-name="resources-en" />
|
||||
<orderEntry type="library" name="asm4" level="project" />
|
||||
<orderEntry type="module" module-name="openapi" />
|
||||
<orderEntry type="module" module-name="external-system-api" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
|
||||
+8
-13
@@ -13,14 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.externalSystem.model.project;
|
||||
package com.intellij.externalSystem;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.Key;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.ProjectId;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.model.project.AbstractProjectEntityData;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -34,7 +33,9 @@ import java.util.regex.Pattern;
|
||||
* @since 4/12/13 12:27 PM
|
||||
*/
|
||||
public class JavaProjectData extends AbstractProjectEntityData {
|
||||
|
||||
|
||||
@NotNull public static final Key<JavaProjectData> KEY = Key.create(JavaProjectData.class);
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#" + JavaProjectData.class.getName());
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -53,19 +54,13 @@ public class JavaProjectData extends AbstractProjectEntityData {
|
||||
myCompileOutputPath = compileOutputPath;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectEntityId getId(@Nullable DataNode<?> dataNode) {
|
||||
return new ProjectId(getOwner());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getCompileOutputPath() {
|
||||
return myCompileOutputPath;
|
||||
}
|
||||
|
||||
public void setCompileOutputPath(@NotNull String compileOutputPath) {
|
||||
myCompileOutputPath = ExternalSystemUtil.toCanonicalPath(compileOutputPath);
|
||||
myCompileOutputPath = ExternalSystemApiUtil.toCanonicalPath(compileOutputPath);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
+36
-12
@@ -13,25 +13,26 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.openapi.externalSystem.service.project.manage;
|
||||
package com.intellij.externalSystem;
|
||||
|
||||
import com.intellij.ide.impl.NewProjectUtil;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.Key;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.JavaProjectData;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataService;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.roots.ex.ProjectRootManagerEx;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
@@ -42,7 +43,7 @@ public class JavaProjectDataService implements ProjectDataService<JavaProjectDat
|
||||
@NotNull
|
||||
@Override
|
||||
public Key<JavaProjectData> getTargetDataKey() {
|
||||
return ProjectKeys.JAVA_PROJECT;
|
||||
return JavaProjectData.KEY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,13 +56,19 @@ public class JavaProjectDataService implements ProjectDataService<JavaProjectDat
|
||||
// JDK.
|
||||
JavaSdkVersion version = projectData.getJdkVersion();
|
||||
JavaSdk javaSdk = JavaSdk.getInstance();
|
||||
Sdk sdk = ProjectRootManagerEx.getInstanceEx(project).getProjectSdk();
|
||||
ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
|
||||
Sdk sdk = rootManager.getProjectSdk();
|
||||
if (sdk instanceof JavaSdk) {
|
||||
JavaSdkVersion currentVersion = javaSdk.getVersion(sdk);
|
||||
if (currentVersion == null || !currentVersion.isAtLeast(version)) {
|
||||
Sdk newJdk = ExternalSystemUtil.findJdk(version);
|
||||
Sdk newJdk = findJdk(version);
|
||||
if (newJdk != null) {
|
||||
NewProjectUtil.applyJdkToProject(project, newJdk);
|
||||
rootManager.setProjectSdk(sdk);
|
||||
LanguageLevel level = version.getMaxLanguageLevel();
|
||||
LanguageLevelProjectExtension ext = LanguageLevelProjectExtension.getInstance(project);
|
||||
if (level.compareTo(ext.getLanguageLevel()) < 0) {
|
||||
ext.setLanguageLevel(level);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,6 +76,23 @@ public class JavaProjectDataService implements ProjectDataService<JavaProjectDat
|
||||
setLanguageLevel(projectData.getLanguageLevel(), project, synchronous);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Sdk findJdk(@NotNull JavaSdkVersion version) {
|
||||
JavaSdk javaSdk = JavaSdk.getInstance();
|
||||
List<Sdk> javaSdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk);
|
||||
Sdk candidate = null;
|
||||
for (Sdk sdk : javaSdks) {
|
||||
JavaSdkVersion v = javaSdk.getVersion(sdk);
|
||||
if (v == version) {
|
||||
return sdk;
|
||||
}
|
||||
else if (candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) {
|
||||
candidate = sdk;
|
||||
}
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeData(@NotNull Collection<DataNode<JavaProjectData>> toRemove, @NotNull Project project, boolean synchronous) {
|
||||
}
|
||||
@@ -79,12 +103,12 @@ public class JavaProjectDataService implements ProjectDataService<JavaProjectDat
|
||||
if (languageLevelExtension.getLanguageLevel().isAtLeast(languageLevel)) {
|
||||
return;
|
||||
}
|
||||
ExternalSystemUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, synchronous, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, synchronous, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
languageLevelExtension.setLanguageLevel(languageLevel);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="annotations" exported="" />
|
||||
<orderEntry type="module" module-name="util" exported="" />
|
||||
<orderEntry type="module" module-name="projectModel-api" exported="" />
|
||||
<orderEntry type="module" module-name="platform-api" exported="" />
|
||||
<orderEntry type="module" module-name="lang-api" exported="" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
+1
-1
@@ -3,9 +3,9 @@ package com.intellij.openapi.externalSystem;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.externalSystem.build.ExternalSystemBuildManager;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.service.ParametersEnhancer;
|
||||
import com.intellij.openapi.externalSystem.service.project.ExternalSystemProjectResolver;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings;
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
|
||||
import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsListener;
|
||||
+1
-1
@@ -18,7 +18,7 @@ package com.intellij.openapi.externalSystem.build;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskDescriptor;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.intellij.openapi.externalSystem.model;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 2/7/12 11:19 AM
|
||||
*/
|
||||
public class ExternalSystemDataKeys {
|
||||
|
||||
// TODO den uncomment
|
||||
|
||||
// public static final DataKey<GradleTasksList> RECENT_TASKS_LIST = DataKey.create("gradle.recent.tasks.list");
|
||||
|
||||
// public static final DataKey<GradleTasksModel> ALL_TASKS_MODEL = DataKey.create("gradle.all.tasks.model");
|
||||
|
||||
private ExternalSystemDataKeys() {
|
||||
}
|
||||
}
|
||||
-2
@@ -27,13 +27,11 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ProjectKeys {
|
||||
|
||||
@NotNull public static final Key<ProjectData> PROJECT = Key.create(ProjectData.class);
|
||||
@NotNull public static final Key<JavaProjectData> JAVA_PROJECT = Key.create(JavaProjectData.class);
|
||||
@NotNull public static final Key<ModuleData> MODULE = Key.create(ModuleData.class);
|
||||
@NotNull public static final Key<LibraryData> LIBRARY = Key.create(LibraryData.class);
|
||||
@NotNull public static final Key<ContentRootData> CONTENT_ROOT = Key.create(ContentRootData.class);
|
||||
@NotNull public static final Key<ModuleDependencyData> MODULE_DEPENDENCY = Key.create(ModuleDependencyData.class);
|
||||
@NotNull public static final Key<LibraryDependencyData> LIBRARY_DEPENDENCY = Key.create(LibraryDependencyData.class);
|
||||
@NotNull public static final Key<JarData> JAR = Key.create(JarData.class);
|
||||
|
||||
private ProjectKeys() {
|
||||
}
|
||||
-1
@@ -7,7 +7,6 @@ import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
+3
-22
@@ -1,14 +1,10 @@
|
||||
package com.intellij.openapi.externalSystem.model.project;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.ContentRootId;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
@@ -34,22 +30,7 @@ public class ContentRootData extends AbstractProjectEntityData {
|
||||
*/
|
||||
public ContentRootData(@NotNull ProjectSystemId owner, @NotNull String rootPath) {
|
||||
super(owner);
|
||||
myRootPath = ExternalSystemUtil.toCanonicalPath(rootPath);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ContentRootId getId(@Nullable DataNode<?> dataNode) {
|
||||
if (dataNode == null) {
|
||||
throw new IllegalArgumentException(String.format("Can't build id for %s. Reason: given data holder is undefined", this));
|
||||
}
|
||||
ModuleData moduleData = dataNode.getData(ProjectKeys.MODULE);
|
||||
if (moduleData == null) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"Can't build id for %s. Reason: given data holder doesn't contain information about owner module", this
|
||||
));
|
||||
}
|
||||
return new ContentRootId(getOwner(), moduleData.getName(), getRootPath());
|
||||
myRootPath = ExternalSystemApiUtil.toCanonicalPath(rootPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +57,7 @@ public class ContentRootData extends AbstractProjectEntityData {
|
||||
if (paths == null) {
|
||||
myData.put(type, paths = ContainerUtilRt.newHashSet());
|
||||
}
|
||||
paths.add(ExternalSystemUtil.toCanonicalPath(path));
|
||||
paths.add(ExternalSystemApiUtil.toCanonicalPath(path));
|
||||
return;
|
||||
}
|
||||
if (!ExternalSystemSourceType.EXCLUDED.equals(type)) { // There are external systems which mark output directory as 'excluded' path.
|
||||
+2
-12
@@ -1,13 +1,9 @@
|
||||
package com.intellij.openapi.externalSystem.model.project;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.LibraryId;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -30,12 +26,6 @@ public class LibraryData extends AbstractNamedData implements Named {
|
||||
super(owner, name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectEntityId getId(@Nullable DataNode<?> dataNode) {
|
||||
return new LibraryId(getOwner(), getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<String> getPaths(@NotNull LibraryPathType type) {
|
||||
Set<String> result = myPaths.get(type);
|
||||
@@ -47,7 +37,7 @@ public class LibraryData extends AbstractNamedData implements Named {
|
||||
if (paths == null) {
|
||||
myPaths.put(type, paths = new HashSet<String>());
|
||||
}
|
||||
paths.add(ExternalSystemUtil.toCanonicalPath(path));
|
||||
paths.add(ExternalSystemApiUtil.toCanonicalPath(path));
|
||||
}
|
||||
|
||||
public void forgetAllPaths() {
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.intellij.openapi.externalSystem.model.project;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Not thread-safe.
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since 8/10/11 6:46 PM
|
||||
*/
|
||||
public class LibraryDependencyData extends AbstractDependencyData<LibraryData> implements Named {
|
||||
|
||||
public LibraryDependencyData(@NotNull ModuleData ownerModule, @NotNull LibraryData library) {
|
||||
super(ownerModule, library);
|
||||
}
|
||||
}
|
||||
+3
-12
@@ -1,11 +1,8 @@
|
||||
package com.intellij.openapi.externalSystem.model.project;
|
||||
|
||||
import com.intellij.ide.highlighter.ModuleFileType;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.ModuleId;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -30,19 +27,13 @@ public class ModuleData extends AbstractNamedData implements Named {
|
||||
setModuleFileDirectoryPath(moduleFileDirectoryPath);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectEntityId getId(@Nullable DataNode<?> dataNode) {
|
||||
return new ModuleId(getOwner(), getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getModuleFilePath() {
|
||||
return myModuleFilePath;
|
||||
}
|
||||
|
||||
public void setModuleFileDirectoryPath(@NotNull String path) {
|
||||
myModuleFilePath = ExternalSystemUtil.toCanonicalPath(path + "/" + getName() + ModuleFileType.DOT_DEFAULT_EXTENSION);
|
||||
myModuleFilePath = ExternalSystemApiUtil.toCanonicalPath(path + "/" + getName() + ModuleFileType.DOT_DEFAULT_EXTENSION);
|
||||
}
|
||||
|
||||
public boolean isInheritProjectCompileOutputPath() {
|
||||
@@ -71,7 +62,7 @@ public class ModuleData extends AbstractNamedData implements Named {
|
||||
myCompileOutputPaths.remove(type);
|
||||
return;
|
||||
}
|
||||
myCompileOutputPaths.put(type, ExternalSystemUtil.toCanonicalPath(path));
|
||||
myCompileOutputPaths.put(type, ExternalSystemApiUtil.toCanonicalPath(path));
|
||||
}
|
||||
|
||||
|
||||
-10
@@ -1,10 +1,6 @@
|
||||
package com.intellij.openapi.externalSystem.model.project;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.ModuleDependencyId;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
@@ -26,10 +22,4 @@ public class ModuleDependencyData extends AbstractDependencyData<ModuleData> {
|
||||
public ModuleDependencyData(@NotNull ModuleData ownerModule, @NotNull ModuleData module) {
|
||||
super(ownerModule, module);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectEntityId getId(@Nullable DataNode<?> dataNode) {
|
||||
return new ModuleDependencyId(getOwner(), getOwnerModule().getName(), getName());
|
||||
}
|
||||
}
|
||||
+3
-13
@@ -1,12 +1,8 @@
|
||||
package com.intellij.openapi.externalSystem.model.project;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.ProjectId;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Not thread-safe.
|
||||
@@ -24,13 +20,7 @@ public class ProjectData extends AbstractNamedData {
|
||||
@NotNull String projectFileDirectoryPath)
|
||||
{
|
||||
super(owner, "unnamed");
|
||||
myProjectFileDirectoryPath = ExternalSystemUtil.toCanonicalPath(projectFileDirectoryPath);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ProjectEntityId getId(@Nullable DataNode<?> dataNode) {
|
||||
return new ProjectId(getOwner());
|
||||
myProjectFileDirectoryPath = ExternalSystemApiUtil.toCanonicalPath(projectFileDirectoryPath);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -39,7 +29,7 @@ public class ProjectData extends AbstractNamedData {
|
||||
}
|
||||
|
||||
public void setProjectFileDirectoryPath(@NotNull String projectFileDirectoryPath) {
|
||||
myProjectFileDirectoryPath = ExternalSystemUtil.toCanonicalPath(projectFileDirectoryPath);
|
||||
myProjectFileDirectoryPath = ExternalSystemApiUtil.toCanonicalPath(projectFileDirectoryPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
-12
@@ -1,10 +1,7 @@
|
||||
package com.intellij.openapi.externalSystem.model.project;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
@@ -26,15 +23,6 @@ public interface ProjectEntityData extends Serializable {
|
||||
@NotNull
|
||||
ProjectSystemId getOwner();
|
||||
|
||||
/**
|
||||
* Allows to map current data to its id.
|
||||
*
|
||||
* @param dataNode data holder which holds current data (if any)
|
||||
* @return current data id
|
||||
*/
|
||||
@NotNull
|
||||
ProjectEntityId getId(@Nullable DataNode<?> dataNode);
|
||||
|
||||
/**
|
||||
* Follows contract of {@link PropertyChangeSupport#addPropertyChangeListener(PropertyChangeListener)}
|
||||
*
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.intellij.openapi.externalSystem.service.remote;
|
||||
package com.intellij.openapi.externalSystem.model.settings;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
|
||||
import com.intellij.util.SystemProperties;
|
||||
+2
-3
@@ -15,15 +15,14 @@
|
||||
*/
|
||||
package com.intellij.openapi.externalSystem.service.project;
|
||||
|
||||
import com.intellij.openapi.roots.JavadocOrderRootType;
|
||||
import com.intellij.openapi.externalSystem.model.project.LibraryPathType;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.openapi.externalSystem.model.project.LibraryPathType;
|
||||
|
||||
/**
|
||||
* Strategy for mapping {@link LibraryPathType external library path types} to {@link OrderRootType ide library path types}.
|
||||
* <p/>
|
||||
* Is introduced because {@link JavadocOrderRootType#getInstance() 'real ide doc type'} assumes that project IoC is setup thus
|
||||
* Is introduced because <code>'JavadocOrderRootType.getInstance()'</code> assumes that project IoC is setup thus
|
||||
* make it ineligible for unit testing.
|
||||
* <p/>
|
||||
* Implementations of this interface are expected to be thread-safe.
|
||||
+1
-1
@@ -18,8 +18,8 @@ package com.intellij.openapi.externalSystem.service.project;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
-4
@@ -5,7 +5,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -31,9 +30,6 @@ public interface PlatformFacade {
|
||||
@NotNull
|
||||
LibraryTable getProjectLibraryTable(@NotNull Project project);
|
||||
|
||||
@NotNull
|
||||
LanguageLevel getLanguageLevel(@NotNull Project project);
|
||||
|
||||
@NotNull
|
||||
Collection<Module> getModules(@NotNull Project project);
|
||||
|
||||
+333
@@ -0,0 +1,333 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.util;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemManager;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.Key;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.util.AtomicNotNullLazyValue;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.BooleanFunction;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 4/1/13 1:31 PM
|
||||
*/
|
||||
public class ExternalSystemApiUtil {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#" + ExternalSystemApiUtil.class.getName());
|
||||
|
||||
@NotNull public static final String PATH_SEPARATOR = "/";
|
||||
|
||||
@NotNull private static final Pattern ARTIFACT_PATTERN = Pattern.compile("(?:.*/)?(.+?)(?:-([\\d+](?:\\.[\\d]+)*))?(?:\\.[^\\.]+?)?");
|
||||
|
||||
@NotNull private static final NotNullLazyValue<Map<ProjectSystemId, ExternalSystemManager<?, ?, ?, ?>>> MANAGERS =
|
||||
new AtomicNotNullLazyValue<Map<ProjectSystemId, ExternalSystemManager<?, ?, ?, ?>>>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Map<ProjectSystemId, ExternalSystemManager<?, ?, ?, ?>> compute() {
|
||||
Map<ProjectSystemId, ExternalSystemManager<?, ?, ?, ?>> result = ContainerUtilRt.newHashMap();
|
||||
for (ExternalSystemManager manager : ExternalSystemManager.EP_NAME.getExtensions()) {
|
||||
result.put(manager.getSystemId(), manager);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull public static final Comparator<Object> ORDER_AWARE_COMPARATOR = new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
int order1 = getOrder(o1);
|
||||
int order2 = getOrder(o2);
|
||||
return order1 > order2 ? 1 : order1 < order2 ? -1 : 0;
|
||||
}
|
||||
|
||||
private int getOrder(@NotNull Object o) {
|
||||
Queue<Class<?>> toCheck = new ArrayDeque<Class<?>>();
|
||||
toCheck.add(o.getClass());
|
||||
while (!toCheck.isEmpty()) {
|
||||
Class<?> clazz = toCheck.poll();
|
||||
Order annotation = clazz.getAnnotation(Order.class);
|
||||
if (annotation != null) {
|
||||
return annotation.value();
|
||||
}
|
||||
toCheck.add(clazz.getSuperclass());
|
||||
Class<?>[] interfaces = clazz.getInterfaces();
|
||||
if (interfaces != null) {
|
||||
Collections.addAll(toCheck, interfaces);
|
||||
}
|
||||
}
|
||||
return ExternalSystemConstants.UNORDERED;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private ExternalSystemApiUtil() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String extractNameFromPath(@NotNull String path) {
|
||||
String strippedPath = stripPath(path);
|
||||
final int i = strippedPath.lastIndexOf(PATH_SEPARATOR);
|
||||
final String result;
|
||||
if (i < 0 || i >= strippedPath.length() - 1) {
|
||||
result = strippedPath;
|
||||
}
|
||||
else {
|
||||
result = strippedPath.substring(i + 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String stripPath(@NotNull String path) {
|
||||
String[] endingsToStrip = {"/", "!", ".jar"};
|
||||
StringBuilder buffer = new StringBuilder(path);
|
||||
for (String ending : endingsToStrip) {
|
||||
if (buffer.lastIndexOf(ending) == buffer.length() - ending.length()) {
|
||||
buffer.setLength(buffer.length() - ending.length());
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getLibraryName(@NotNull Library library) {
|
||||
final String result = library.getName();
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
for (OrderRootType type : OrderRootType.getAllTypes()) {
|
||||
for (String url : library.getUrls(type)) {
|
||||
String candidate = extractNameFromPath(url);
|
||||
if (!StringUtil.isEmpty(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert false;
|
||||
return "unknown-lib";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ArtifactInfo parseArtifactInfo(@NotNull String fileName) {
|
||||
Matcher matcher = ARTIFACT_PATTERN.matcher(fileName);
|
||||
if (!matcher.matches()) {
|
||||
return null;
|
||||
}
|
||||
return new ArtifactInfo(matcher.group(1), null, matcher.group(2));
|
||||
}
|
||||
|
||||
public static void orderAwareSort(@NotNull List<?> data) {
|
||||
Collections.sort(data, ORDER_AWARE_COMPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path target path
|
||||
* @return absolute path that points to the same location as the given one and that uses only slashes
|
||||
*/
|
||||
@NotNull
|
||||
public static String toCanonicalPath(@NotNull String path) {
|
||||
return PathUtil.getCanonicalPath(new File(path).getAbsolutePath());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getLocalFileSystemPath(@NotNull VirtualFile file) {
|
||||
if (file.getFileType() == FileTypes.ARCHIVE) {
|
||||
final VirtualFile jar = JarFileSystem.getInstance().getVirtualFileForJar(file);
|
||||
if (jar != null) {
|
||||
return jar.getPath();
|
||||
}
|
||||
}
|
||||
return file.getPath();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ExternalSystemManager<?, ?, ?, ?> getManager(@NotNull ProjectSystemId externalSystemId) {
|
||||
return MANAGERS.getValue().get(externalSystemId);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Map<Key<?>, Collection<DataNode<?>>> group(@NotNull Collection<DataNode<?>> nodes) {
|
||||
if (nodes.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<Key<?>, Collection<DataNode<?>>> result = ContainerUtilRt.newHashMap();
|
||||
for (DataNode<?> node : nodes) {
|
||||
Collection<DataNode<?>> n = result.get(node.getKey());
|
||||
if (n == null) {
|
||||
result.put(node.getKey(), n = ContainerUtilRt.newArrayList());
|
||||
}
|
||||
n.add(node);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <K, V> Map<DataNode<K>, Collection<DataNode<V>>> groupBy(@NotNull Collection<DataNode<V>> nodes, @NotNull Key<K> key) {
|
||||
Map<DataNode<K>, Collection<DataNode<V>>> result = ContainerUtilRt.newHashMap();
|
||||
for (DataNode<V> data : nodes) {
|
||||
DataNode<K> grouper = data.getDataNode(key);
|
||||
if (grouper == null) {
|
||||
LOG.warn(String.format(
|
||||
"Skipping entry '%s' during grouping. Reason: it doesn't provide a value for key %s. Given entries: %s",
|
||||
data, key, nodes
|
||||
));
|
||||
continue;
|
||||
}
|
||||
Collection<DataNode<V>> grouped = result.get(grouper);
|
||||
if (grouped == null) {
|
||||
result.put(grouper, grouped = ContainerUtilRt.newArrayList());
|
||||
}
|
||||
grouped.add(data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@NotNull
|
||||
public static <T> Collection<DataNode<T>> getChildren(@NotNull DataNode<?> node, @NotNull Key<T> key) {
|
||||
Collection<DataNode<T>> result = null;
|
||||
for (DataNode<?> child : node.getChildren()) {
|
||||
if (!key.equals(child.getKey())) {
|
||||
continue;
|
||||
}
|
||||
if (result == null) {
|
||||
result = ContainerUtilRt.newArrayList();
|
||||
}
|
||||
result.add((DataNode<T>)child);
|
||||
}
|
||||
return result == null ? Collections.<DataNode<T>>emptyList() : result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public static <T> DataNode<T> find(@NotNull DataNode<?> node, @NotNull Key<T> key) {
|
||||
for (DataNode<?> child : node.getChildren()) {
|
||||
if (key.equals(child.getKey())) {
|
||||
return (DataNode<T>)child;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public static <T> DataNode<T> find(@NotNull DataNode<?> node, @NotNull Key<T> key, BooleanFunction<DataNode<T>> predicate) {
|
||||
for (DataNode<?> child : node.getChildren()) {
|
||||
if (key.equals(child.getKey()) && predicate.fun((DataNode<T>)child)) {
|
||||
return (DataNode<T>)child;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@NotNull
|
||||
public static <T> Collection<DataNode<T>> findAll(@NotNull DataNode<?> parent, @NotNull Key<T> key) {
|
||||
Collection<DataNode<T>> result = null;
|
||||
for (DataNode<?> child : parent.getChildren()) {
|
||||
if (!key.equals(child.getKey())) {
|
||||
continue;
|
||||
}
|
||||
if (result == null) {
|
||||
result = ContainerUtilRt.newArrayList();
|
||||
}
|
||||
result.add((DataNode<T>)child);
|
||||
}
|
||||
return result == null ? Collections.<DataNode<T>>emptyList() : result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String toReadableName(@NotNull ProjectSystemId id) {
|
||||
return StringUtil.capitalize(id.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static void executeProjectChangeAction(@NotNull Project project,
|
||||
@NotNull final ProjectSystemId externalSystemId,
|
||||
@NotNull Object entityToChange,
|
||||
@NotNull Runnable task)
|
||||
{
|
||||
executeProjectChangeAction(project, externalSystemId, entityToChange, false, task);
|
||||
}
|
||||
|
||||
public static void executeProjectChangeAction(@NotNull Project project,
|
||||
@NotNull final ProjectSystemId externalSystemId,
|
||||
@NotNull Object entityToChange,
|
||||
boolean synchronous,
|
||||
@NotNull Runnable task)
|
||||
{
|
||||
executeProjectChangeAction(project, externalSystemId, Collections.singleton(entityToChange), synchronous, task);
|
||||
}
|
||||
|
||||
public static void executeProjectChangeAction(@NotNull final Project project,
|
||||
@NotNull final ProjectSystemId externalSystemId,
|
||||
@NotNull final Iterable<?> entitiesToChange,
|
||||
@NotNull final Runnable task)
|
||||
{
|
||||
executeProjectChangeAction(project, externalSystemId, entitiesToChange, false, task);
|
||||
}
|
||||
|
||||
public static void executeProjectChangeAction(@NotNull final Project project,
|
||||
@NotNull final ProjectSystemId externalSystemId,
|
||||
@NotNull final Iterable<?> entitiesToChange,
|
||||
boolean synchronous,
|
||||
@NotNull final Runnable task)
|
||||
{
|
||||
Runnable wrappedTask = new Runnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
task.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (synchronous) {
|
||||
if (ApplicationManager.getApplication().isDispatchThread()) {
|
||||
wrappedTask.run();
|
||||
}
|
||||
else {
|
||||
UIUtil.invokeAndWaitIfNeeded(wrappedTask);
|
||||
}
|
||||
}
|
||||
else {
|
||||
UIUtil.invokeLaterIfNeeded(wrappedTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-9
@@ -8,17 +8,13 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="annotations" />
|
||||
<orderEntry type="module" module-name="projectModel-api" />
|
||||
<orderEntry type="module" module-name="platform-api" />
|
||||
<orderEntry type="module" module-name="projectModel-impl" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
<orderEntry type="module" module-name="java-psi-api" />
|
||||
<orderEntry type="module" module-name="openapi" />
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
<orderEntry type="module" module-name="idea-ui" />
|
||||
<orderEntry type="module" module-name="external-system-api" />
|
||||
<orderEntry type="module" module-name="openapi" />
|
||||
<orderEntry type="module" module-name="projectModel-impl" />
|
||||
<orderEntry type="module" module-name="compiler-openapi" />
|
||||
<orderEntry type="module" module-name="compiler-openapi" />
|
||||
<orderEntry type="module" module-name="platform-impl" />
|
||||
<orderEntry type="module" module-name="lang-impl" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.intellij.openapi.externalSystem.model.settings;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
@@ -35,6 +35,6 @@ public enum LocationSettingType {
|
||||
* @return human-readable description of the current setting type
|
||||
*/
|
||||
public String getDescription(@NotNull ProjectSystemId externalSystemId) {
|
||||
return ExternalSystemBundle.message(myKey, ExternalSystemUtil.toReadableName(externalSystemId));
|
||||
return ExternalSystemBundle.message(myKey, ExternalSystemApiUtil.toReadableName(externalSystemId));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -6,8 +6,8 @@ import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager;
|
||||
import com.intellij.openapi.externalSystem.service.RemoteExternalSystemFacade;
|
||||
import com.intellij.openapi.externalSystem.service.notification.ExternalSystemProgressNotificationManager;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
@@ -155,6 +155,6 @@ public abstract class AbstractExternalSystemTask implements ExternalSystemTask {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s task %s: %s", ExternalSystemUtil.toReadableName(myExternalSystemId), myId, myState);
|
||||
return String.format("%s task %s: %s", ExternalSystemApiUtil.toReadableName(myExternalSystemId), myId, myState);
|
||||
}
|
||||
}
|
||||
+3
-15
@@ -5,12 +5,11 @@ import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager;
|
||||
import com.intellij.openapi.externalSystem.service.project.change.ProjectStructureChangesModel;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver;
|
||||
import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -48,10 +47,6 @@ public class ExternalSystemResolveProjectTask extends AbstractExternalSystemTask
|
||||
setState(ExternalSystemTaskState.IN_PROGRESS);
|
||||
|
||||
ExternalSystemSettingsManager settingsManager = ServiceManager.getService(ExternalSystemSettingsManager.class);
|
||||
ProjectStructureChangesModel model = null;
|
||||
if (!ideProject.isDisposed()) {
|
||||
model = ServiceManager.getService(ProjectStructureChangesModel.class);
|
||||
}
|
||||
ExternalSystemExecutionSettings settings = settingsManager.getExecutionSettings(ideProject, getExternalSystemId());
|
||||
DataNode<ProjectData> project = resolver.resolveProjectInfo(getId(), myProjectPath, myResolveLibraries, settings);
|
||||
|
||||
@@ -60,13 +55,6 @@ public class ExternalSystemResolveProjectTask extends AbstractExternalSystemTask
|
||||
}
|
||||
myExternalProject.set(project);
|
||||
setState(ExternalSystemTaskState.FINISHED);
|
||||
|
||||
if (model != null) {
|
||||
// This task may be called during the 'import from gradle' processing, hence, no project-level IoC is up.
|
||||
// Model update is necessary for the correct tool window project structure diff showing but we don't have
|
||||
// gradle tool window on this stage.
|
||||
model.update(project, ideProject, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -77,6 +65,6 @@ public class ExternalSystemResolveProjectTask extends AbstractExternalSystemTask
|
||||
@Override
|
||||
@NotNull
|
||||
protected String wrapProgressText(@NotNull String text) {
|
||||
return ExternalSystemBundle.message("progress.update.text", ExternalSystemUtil.toReadableName(getExternalSystemId()), text);
|
||||
return ExternalSystemBundle.message("progress.update.text", ExternalSystemApiUtil.toReadableName(getExternalSystemId()), text);
|
||||
}
|
||||
}
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
package com.intellij.openapi.externalSystem.service;
|
||||
|
||||
import com.intellij.execution.rmi.RemoteServer;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationEvent;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType;
|
||||
+6
-3
@@ -23,12 +23,14 @@ import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemManager;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
|
||||
import com.intellij.openapi.externalSystem.service.notification.ExternalSystemProgressNotificationManager;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemProgressNotificationManagerImpl;
|
||||
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager;
|
||||
import com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemFacadeWrapper;
|
||||
import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.IntegrationKey;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -153,6 +155,7 @@ public class ExternalSystemFacadeManager {
|
||||
ContainerUtil.addIfNotNull(PathUtil.getJarPathForClass(JavaSdkVersion.class), classPath);
|
||||
ContainerUtil.addIfNotNull(PathUtil.getJarPathForClass(ExtensionPointName.class), classPath);
|
||||
ContainerUtil.addIfNotNull(PathUtil.getJarPathForClass(OpenProjectFileChooserDescriptor.class), classPath);
|
||||
ContainerUtil.addIfNotNull(PathUtil.getJarPathForClass(ExternalSystemTaskNotificationListener.class), classPath);
|
||||
|
||||
// External system module jars
|
||||
ContainerUtil.addIfNotNull(PathUtil.getJarPathForClass(getClass()), classPath);
|
||||
@@ -172,7 +175,7 @@ public class ExternalSystemFacadeManager {
|
||||
|
||||
ProjectSystemId externalSystemId = myTargetExternalSystemId.get();
|
||||
if (externalSystemId != null) {
|
||||
ExternalSystemManager<?, ?, ?, ?> manager = ExternalSystemUtil.getManager(externalSystemId);
|
||||
ExternalSystemManager<?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
|
||||
if (manager != null) {
|
||||
params.getProgramParametersList().add(manager.getProjectResolverClass().getName());
|
||||
params.getProgramParametersList().add(manager.getBuildManagerClass().getName());
|
||||
@@ -260,7 +263,7 @@ public class ExternalSystemFacadeManager {
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@NotNull
|
||||
private RemoteExternalSystemFacade doGetFacade(@NotNull IntegrationKey key, @NotNull Project project) throws Exception {
|
||||
ExternalSystemManager manager = ExternalSystemUtil.getManager(key.getExternalSystemId());
|
||||
ExternalSystemManager manager = ExternalSystemApiUtil.getManager(key.getExternalSystemId());
|
||||
if (project.isDisposed() || manager == null || !manager.isReady(project)) {
|
||||
return RemoteExternalSystemFacade.NULL_OBJECT;
|
||||
}
|
||||
+1
-1
@@ -3,7 +3,7 @@ package com.intellij.openapi.externalSystem.service;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskAware;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemBuildManager;
|
||||
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager;
|
||||
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver;
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.intellij.openapi.externalSystem.service;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskAware;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+2
-8
@@ -1,6 +1,6 @@
|
||||
package com.intellij.openapi.externalSystem.service.project;
|
||||
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -28,12 +28,6 @@ public class PlatformFacadeImpl implements PlatformFacade {
|
||||
return ProjectLibraryTable.getInstance(project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public LanguageLevel getLanguageLevel(@NotNull Project project) {
|
||||
return LanguageLevelProjectExtension.getInstance(project).getLanguageLevel();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<Module> getModules(@NotNull Project project) {
|
||||
@@ -66,6 +60,6 @@ public class PlatformFacadeImpl implements PlatformFacade {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getLocalFileSystemPath(@NotNull VirtualFile file) {
|
||||
return ExternalSystemUtil.getLocalFileSystemPath(file);
|
||||
return ExternalSystemApiUtil.getLocalFileSystemPath(file);
|
||||
}
|
||||
}
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
package com.intellij.openapi.externalSystem.service.project;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.project.ContentRootData;
|
||||
import com.intellij.openapi.externalSystem.model.project.LibraryData;
|
||||
import com.intellij.openapi.externalSystem.model.project.ModuleData;
|
||||
import com.intellij.openapi.externalSystem.model.project.ModuleDependencyData;
|
||||
import com.intellij.openapi.externalSystem.util.ArtifactInfo;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.impl.ModuleLibraryOrderEntryImpl;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* Thread-safe.
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since 2/6/12 3:28 PM
|
||||
*/
|
||||
public class ProjectStructureHelper {
|
||||
|
||||
@NotNull private final PlatformFacade myFacade;
|
||||
@NotNull private final ExternalLibraryPathTypeMapper myLibraryPathTypeMapper;
|
||||
|
||||
public ProjectStructureHelper(@NotNull PlatformFacade facade, @NotNull ExternalLibraryPathTypeMapper mapper) {
|
||||
myFacade = facade;
|
||||
myLibraryPathTypeMapper = mapper;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Module findIdeModule(@NotNull ModuleData module, @NotNull Project ideProject) {
|
||||
return findIdeModule(module.getName(), ideProject);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Module findIdeModule(@NotNull String ideModuleName, @NotNull Project ideProject) {
|
||||
for (Module module : myFacade.getModules(ideProject)) {
|
||||
if (ideModuleName.equals(module.getName())) {
|
||||
return module;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ModuleAwareContentRoot findIdeContentRoot(@NotNull DataNode<ContentRootData> node, @NotNull Project ideProject) {
|
||||
ModuleData moduleData = node.getData(ProjectKeys.MODULE);
|
||||
if (moduleData == null) {
|
||||
return null;
|
||||
}
|
||||
final Module module = findIdeModule(moduleData.getName(), ideProject);
|
||||
if (module == null) {
|
||||
return null;
|
||||
}
|
||||
for (ModuleAwareContentRoot contentRoot : myFacade.getContentRoots(module)) {
|
||||
final VirtualFile file = contentRoot.getFile();
|
||||
if (node.getData().getRootPath().equals(file.getPath())) {
|
||||
return contentRoot;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Library findIdeLibrary(@NotNull final LibraryData library, @NotNull Project ideProject) {
|
||||
return findIdeLibrary(library.getName(), ideProject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gradle library names follow the following pattern: {@code '[base library name]-[library-version]'}.
|
||||
* <p/>
|
||||
* This methods serves as an utility which tries to find a library by it's given base name.
|
||||
*
|
||||
* @param baseName base name of the target library
|
||||
* @param ideProject target ide project
|
||||
* @return target library for the given base name if there is one and only one library for it;
|
||||
* <code>null</code> otherwise (if there are no libraries or more than one library for the given base name)
|
||||
*/
|
||||
@Nullable
|
||||
public Library findIdeLibraryByBaseName(@NotNull String baseName, @NotNull Project ideProject) {
|
||||
final LibraryTable libraryTable = myFacade.getProjectLibraryTable(ideProject);
|
||||
Library result = null;
|
||||
for (Library library : libraryTable.getLibraries()) {
|
||||
ArtifactInfo info = ExternalSystemApiUtil.parseArtifactInfo(ExternalSystemApiUtil.getLibraryName(library));
|
||||
if (info == null || !baseName.equals(info.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (result != null) {
|
||||
return null;
|
||||
}
|
||||
result = library;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Library findIdeLibrary(@NotNull String libraryName, @NotNull Project ideProject) {
|
||||
final LibraryTable libraryTable = myFacade.getProjectLibraryTable(ideProject);
|
||||
for (Library ideLibrary : libraryTable.getLibraries()) {
|
||||
if (libraryName.equals(ExternalSystemApiUtil.getLibraryName(ideLibrary))) {
|
||||
return ideLibrary;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Library findIdeLibrary(@NotNull String libraryName,
|
||||
@NotNull OrderRootType jarType,
|
||||
@NotNull String jarPath,
|
||||
@NotNull Project ideProject)
|
||||
{
|
||||
Library library = findIdeLibrary(libraryName, ideProject);
|
||||
if (library == null) {
|
||||
return null;
|
||||
}
|
||||
for (VirtualFile file : library.getFiles(jarType)) {
|
||||
if (jarPath.equals(ExternalSystemApiUtil.getLocalFileSystemPath(file))) {
|
||||
return library;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public LibraryOrderEntry findIdeLibraryDependency(@NotNull final String moduleName,
|
||||
@NotNull final String libraryName,
|
||||
@NotNull Project ideProject)
|
||||
{
|
||||
final Module ideModule = findIdeModule(moduleName, ideProject);
|
||||
if (ideModule == null) {
|
||||
return null;
|
||||
}
|
||||
RootPolicy<LibraryOrderEntry> visitor = new RootPolicy<LibraryOrderEntry>() {
|
||||
@Override
|
||||
public LibraryOrderEntry visitLibraryOrderEntry(LibraryOrderEntry ideDependency, LibraryOrderEntry value) {
|
||||
if (libraryName.equals(ideDependency.getLibraryName())) {
|
||||
return ideDependency;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
};
|
||||
for (OrderEntry entry : myFacade.getOrderEntries(ideModule)) {
|
||||
final LibraryOrderEntry result = entry.accept(visitor, null);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ModuleLibraryOrderEntryImpl findIdeModuleLocalLibraryDependency(@NotNull final String moduleName,
|
||||
@NotNull final String libraryName,
|
||||
@NotNull Project ideProject)
|
||||
{
|
||||
final Module ideModule = findIdeModule(moduleName, ideProject);
|
||||
if (ideModule == null) {
|
||||
return null;
|
||||
}
|
||||
RootPolicy<ModuleLibraryOrderEntryImpl> visitor = new RootPolicy<ModuleLibraryOrderEntryImpl>() {
|
||||
@Override
|
||||
public ModuleLibraryOrderEntryImpl visitLibraryOrderEntry(LibraryOrderEntry ideDependency, ModuleLibraryOrderEntryImpl value) {
|
||||
Library library = ideDependency.getLibrary();
|
||||
if (library == null) {
|
||||
return value;
|
||||
}
|
||||
if (ideDependency instanceof ModuleLibraryOrderEntryImpl && libraryName.equals(ExternalSystemApiUtil.getLibraryName(library))) {
|
||||
return (ModuleLibraryOrderEntryImpl)ideDependency;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
};
|
||||
for (OrderEntry entry : myFacade.getOrderEntries(ideModule)) {
|
||||
final ModuleLibraryOrderEntryImpl result = entry.accept(visitor, null);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("MethodMayBeStatic")
|
||||
@Nullable
|
||||
public LibraryOrderEntry findIdeLibraryDependency(@NotNull final String libraryName,
|
||||
@NotNull ModifiableRootModel model)
|
||||
{
|
||||
for (OrderEntry entry : model.getOrderEntries()) {
|
||||
if (entry instanceof LibraryOrderEntry) {
|
||||
LibraryOrderEntry candidate = (LibraryOrderEntry)entry;
|
||||
if (libraryName.equals(candidate.getLibraryName())) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ModuleOrderEntry findIdeModuleDependency(@NotNull final ModuleDependencyData gradleDependency, @NotNull Project ideProject) {
|
||||
return findIdeModuleDependency(gradleDependency.getOwnerModule().getName(), gradleDependency.getTarget().getName(), ideProject);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ModuleOrderEntry findIdeModuleDependency(@NotNull final String ownerModuleName,
|
||||
@NotNull final String dependencyModuleName,
|
||||
@NotNull Project ideProject)
|
||||
{
|
||||
final Module ideOwnerModule = findIdeModule(ownerModuleName, ideProject);
|
||||
if (ideOwnerModule == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
RootPolicy<ModuleOrderEntry> visitor = new RootPolicy<ModuleOrderEntry>() {
|
||||
@Override
|
||||
public ModuleOrderEntry visitModuleOrderEntry(ModuleOrderEntry ideDependency, ModuleOrderEntry value) {
|
||||
if (dependencyModuleName.equals(ideDependency.getModuleName())) {
|
||||
return ideDependency;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
};
|
||||
for (OrderEntry orderEntry : myFacade.getOrderEntries(ideOwnerModule)) {
|
||||
final ModuleOrderEntry result = orderEntry.accept(visitor, null);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("MethodMayBeStatic")
|
||||
@Nullable
|
||||
public ModuleOrderEntry findIdeModuleDependency(@NotNull ModuleDependencyData dependency, @NotNull ModifiableRootModel model) {
|
||||
for (OrderEntry entry : model.getOrderEntries()) {
|
||||
if (entry instanceof ModuleOrderEntry) {
|
||||
ModuleOrderEntry candidate = (ModuleOrderEntry)entry;
|
||||
if (dependency.getName().equals(candidate.getModuleName())) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
-9
@@ -1,6 +1,5 @@
|
||||
package com.intellij.openapi.externalSystem.service.project;
|
||||
|
||||
import com.intellij.openapi.externalSystem.service.project.change.ProjectStructureChangesModel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -15,17 +14,14 @@ public class ProjectStructureServices {
|
||||
|
||||
@NotNull private final ProjectStructureHelper myProjectStructureHelper;
|
||||
@NotNull private final PlatformFacade myPlatformFacade;
|
||||
@NotNull private final ProjectStructureChangesModel myChangesModel;
|
||||
@NotNull private final ExternalLibraryPathTypeMapper myLibraryPathTypeMapper;
|
||||
|
||||
public ProjectStructureServices(@NotNull ProjectStructureHelper projectStructureHelper,
|
||||
@NotNull PlatformFacade platformFacade,
|
||||
@NotNull ProjectStructureChangesModel changesModel,
|
||||
@NotNull ExternalLibraryPathTypeMapper mapper)
|
||||
{
|
||||
myProjectStructureHelper = projectStructureHelper;
|
||||
myPlatformFacade = platformFacade;
|
||||
myChangesModel = changesModel;
|
||||
myLibraryPathTypeMapper = mapper;
|
||||
}
|
||||
|
||||
@@ -39,11 +35,6 @@ public class ProjectStructureServices {
|
||||
return myPlatformFacade;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ProjectStructureChangesModel getChangesModel() {
|
||||
return myChangesModel;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExternalLibraryPathTypeMapper getLibraryPathTypeMapper() {
|
||||
return myLibraryPathTypeMapper;
|
||||
+4
-4
@@ -17,7 +17,7 @@ package com.intellij.openapi.externalSystem.service.project.manage;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.AbstractDependencyData;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.*;
|
||||
@@ -37,7 +37,7 @@ public abstract class AbstractDependencyDataService<T extends AbstractDependency
|
||||
return;
|
||||
}
|
||||
for (final ExportableOrderEntry dependency : toRemove) {
|
||||
ExternalSystemUtil.executeProjectChangeAction(module.getProject(), ProjectSystemId.IDE, toRemove, synchronous, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(module.getProject(), ProjectSystemId.IDE, toRemove, synchronous, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
|
||||
@@ -63,7 +63,7 @@ public abstract class AbstractDependencyDataService<T extends AbstractDependency
|
||||
|
||||
public void setScope(@NotNull final DependencyScope scope, @NotNull final ExportableOrderEntry dependency, boolean synchronous) {
|
||||
Project project = dependency.getOwnerModule().getProject();
|
||||
ExternalSystemUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, dependency, synchronous, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, dependency, synchronous, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doForDependency(dependency, new Consumer<ExportableOrderEntry>() {
|
||||
@@ -78,7 +78,7 @@ public abstract class AbstractDependencyDataService<T extends AbstractDependency
|
||||
|
||||
public void setExported(final boolean exported, @NotNull final ExportableOrderEntry dependency, boolean synchronous) {
|
||||
Project project = dependency.getOwnerModule().getProject();
|
||||
ExternalSystemUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, dependency, synchronous, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, dependency, synchronous, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doForDependency(dependency, new Consumer<ExportableOrderEntry>() {
|
||||
+7
-7
@@ -2,15 +2,15 @@ package com.intellij.openapi.externalSystem.service.project.manage;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.Key;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.ContentRootData;
|
||||
import com.intellij.openapi.externalSystem.model.project.ExternalSystemSourceType;
|
||||
import com.intellij.openapi.externalSystem.model.project.ModuleData;
|
||||
import com.intellij.openapi.externalSystem.service.project.ModuleAwareContentRoot;
|
||||
import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
@@ -56,7 +56,7 @@ public class ContentRootDataService implements ProjectDataService<ContentRootDat
|
||||
}
|
||||
|
||||
Map<DataNode<ModuleData>, Collection<DataNode<ContentRootData>>> byModule
|
||||
= ExternalSystemUtil.groupBy(toImport, ProjectKeys.MODULE);
|
||||
= ExternalSystemApiUtil.groupBy(toImport, ProjectKeys.MODULE);
|
||||
for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<ContentRootData>>> entry : byModule.entrySet()) {
|
||||
final Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project);
|
||||
if (module == null) {
|
||||
@@ -76,7 +76,7 @@ public class ContentRootDataService implements ProjectDataService<ContentRootDat
|
||||
@NotNull final Module module,
|
||||
boolean synchronous)
|
||||
{
|
||||
ExternalSystemUtil.executeProjectChangeAction(project, owner, datas, synchronous, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(project, owner, datas, synchronous, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
|
||||
@@ -122,7 +122,7 @@ public class ContentRootDataService implements ProjectDataService<ContentRootDat
|
||||
return;
|
||||
}
|
||||
Map<DataNode<ModuleData>,Collection<DataNode<ContentRootData>>> byModule
|
||||
= ExternalSystemUtil.groupBy(toRemove, ProjectKeys.MODULE);
|
||||
= ExternalSystemApiUtil.groupBy(toRemove, ProjectKeys.MODULE);
|
||||
for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<ContentRootData>>> entry : byModule.entrySet()) {
|
||||
final Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project);
|
||||
if (module == null) {
|
||||
@@ -134,7 +134,7 @@ public class ContentRootDataService implements ProjectDataService<ContentRootDat
|
||||
}
|
||||
List<ModuleAwareContentRoot> contentRoots = ContainerUtilRt.newArrayList();
|
||||
for (DataNode<ContentRootData> holder : entry.getValue()) {
|
||||
ModuleAwareContentRoot contentRoot = myProjectStructureHelper.findIdeContentRoot(holder.getData().getId(holder), project);
|
||||
ModuleAwareContentRoot contentRoot = myProjectStructureHelper.findIdeContentRoot(holder, project);
|
||||
if (contentRoot != null) {
|
||||
contentRoots.add(contentRoot);
|
||||
}
|
||||
@@ -147,7 +147,7 @@ public class ContentRootDataService implements ProjectDataService<ContentRootDat
|
||||
@NotNull Project project,
|
||||
boolean synchronous)
|
||||
{
|
||||
ExternalSystemUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, contentRoots, synchronous, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, contentRoots, synchronous, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (ModuleAwareContentRoot contentRoot : contentRoots) {
|
||||
+12
-30
@@ -5,10 +5,12 @@ import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.Key;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.JarData;
|
||||
import com.intellij.openapi.externalSystem.model.project.LibraryData;
|
||||
import com.intellij.openapi.externalSystem.model.project.LibraryPathType;
|
||||
import com.intellij.openapi.externalSystem.service.project.ExternalLibraryPathTypeMapper;
|
||||
import com.intellij.openapi.externalSystem.service.project.PlatformFacade;
|
||||
import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
@@ -17,16 +19,16 @@ import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import com.intellij.openapi.externalSystem.service.project.PlatformFacade;
|
||||
import com.intellij.openapi.externalSystem.model.project.LibraryPathType;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
@@ -39,17 +41,14 @@ public class LibraryDataService implements ProjectDataService<LibraryData> {
|
||||
@NotNull private final PlatformFacade myPlatformFacade;
|
||||
@NotNull private final ProjectStructureHelper myProjectStructureHelper;
|
||||
@NotNull private final ExternalLibraryPathTypeMapper myLibraryPathTypeMapper;
|
||||
@NotNull private final JarDataService myJarManager;
|
||||
|
||||
public LibraryDataService(@NotNull PlatformFacade platformFacade,
|
||||
@NotNull ProjectStructureHelper helper,
|
||||
@NotNull ExternalLibraryPathTypeMapper mapper,
|
||||
@NotNull JarDataService manager)
|
||||
@NotNull ExternalLibraryPathTypeMapper mapper)
|
||||
{
|
||||
myPlatformFacade = platformFacade;
|
||||
myProjectStructureHelper = helper;
|
||||
myLibraryPathTypeMapper = mapper;
|
||||
myJarManager = manager;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -89,7 +88,7 @@ public class LibraryDataService implements ProjectDataService<LibraryData> {
|
||||
@NotNull final Project project,
|
||||
boolean synchronous)
|
||||
{
|
||||
ExternalSystemUtil.executeProjectChangeAction(project, externalSystemId, libraryName, synchronous, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(project, externalSystemId, libraryName, synchronous, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Is assumed to be called from the EDT.
|
||||
@@ -161,7 +160,7 @@ public class LibraryDataService implements ProjectDataService<LibraryData> {
|
||||
if (libraries.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ExternalSystemUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, libraries, synchronous, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, libraries, synchronous, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final LibraryTable libraryTable = myPlatformFacade.getProjectLibraryTable(project);
|
||||
@@ -192,7 +191,7 @@ public class LibraryDataService implements ProjectDataService<LibraryData> {
|
||||
Set<String> toRemove = ContainerUtilRt.newHashSet();
|
||||
Set<String> toAdd = ContainerUtilRt.newHashSet(externalLibrary.getPaths(LibraryPathType.BINARY));
|
||||
for (VirtualFile ideFile : ideLibrary.getFiles(OrderRootType.CLASSES)) {
|
||||
String idePath = ExternalSystemUtil.getLocalFileSystemPath(ideFile);
|
||||
String idePath = ExternalSystemApiUtil.getLocalFileSystemPath(ideFile);
|
||||
if (!toAdd.remove(idePath)) {
|
||||
toRemove.add(idePath);
|
||||
}
|
||||
@@ -200,23 +199,6 @@ public class LibraryDataService implements ProjectDataService<LibraryData> {
|
||||
if (toRemove.isEmpty() && toAdd.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Function<String, DataNode<JarData>> jarMapper = new Function<String, DataNode<JarData>>() {
|
||||
@Override
|
||||
public DataNode<JarData> fun(String path) {
|
||||
JarData data = new JarData(path, LibraryPathType.BINARY, ideLibrary, null, ProjectSystemId.IDE);
|
||||
return new DataNode<JarData>(ProjectKeys.JAR, data, null);
|
||||
}
|
||||
};
|
||||
|
||||
if (!toRemove.isEmpty()) {
|
||||
List<DataNode<JarData>> jarsToRemove = ContainerUtil.map(toRemove, jarMapper);
|
||||
myJarManager.removeData(jarsToRemove, project, synchronous);
|
||||
}
|
||||
|
||||
if (!toAdd.isEmpty()) {
|
||||
List<DataNode<JarData>> jarsToAdd = ContainerUtil.map(toAdd, jarMapper);
|
||||
myJarManager.importJars(jarsToAdd, ideLibrary, externalLibrary.getOwner(), project, synchronous);
|
||||
}
|
||||
// TODO den implement
|
||||
}
|
||||
}
|
||||
+14
-8
@@ -18,8 +18,8 @@ package com.intellij.openapi.externalSystem.service.project.manage;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.Key;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.LibraryData;
|
||||
import com.intellij.openapi.externalSystem.model.project.LibraryDependencyData;
|
||||
@@ -27,17 +27,23 @@ import com.intellij.openapi.externalSystem.model.project.ModuleData;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.service.project.PlatformFacade;
|
||||
import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.*;
|
||||
import com.intellij.openapi.roots.ExportableOrderEntry;
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootManager;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryTable;
|
||||
import com.intellij.util.BooleanFunction;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.intellij.openapi.externalSystem.model.ProjectKeys.MODULE;
|
||||
|
||||
@@ -77,7 +83,7 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService<
|
||||
return;
|
||||
}
|
||||
|
||||
Map<DataNode<ModuleData>, Collection<DataNode<LibraryDependencyData>>> byModule = ExternalSystemUtil.groupBy(toImport, MODULE);
|
||||
Map<DataNode<ModuleData>, Collection<DataNode<LibraryDependencyData>>> byModule = ExternalSystemApiUtil.groupBy(toImport, MODULE);
|
||||
for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<LibraryDependencyData>>> entry : byModule.entrySet()) {
|
||||
Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project);
|
||||
if (module == null) {
|
||||
@@ -100,7 +106,7 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService<
|
||||
@NotNull final Module module,
|
||||
final boolean synchronous)
|
||||
{
|
||||
ExternalSystemUtil.executeProjectChangeAction(module.getProject(), externalSystemId, nodesToImport, synchronous, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(module.getProject(), externalSystemId, nodesToImport, synchronous, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LibraryTable libraryTable = myPlatformFacade.getProjectLibraryTable(module.getProject());
|
||||
@@ -112,7 +118,7 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService<
|
||||
DataNode<ProjectData> projectNode = dataNode.getDataNode(ProjectKeys.PROJECT);
|
||||
if (projectNode != null) {
|
||||
DataNode<LibraryData> libraryNode =
|
||||
ExternalSystemUtil.find(projectNode, ProjectKeys.LIBRARY, new BooleanFunction<DataNode<LibraryData>>() {
|
||||
ExternalSystemApiUtil.find(projectNode, ProjectKeys.LIBRARY, new BooleanFunction<DataNode<LibraryData>>() {
|
||||
@Override
|
||||
public boolean fun(DataNode<LibraryData> node) {
|
||||
return node.getData().equals(dependencyData.getTarget());
|
||||
@@ -166,7 +172,7 @@ public class LibraryDependencyDataService extends AbstractDependencyDataService<
|
||||
if (toRemove.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<DataNode<ModuleData>, Collection<DataNode<LibraryDependencyData>>> byModule = ExternalSystemUtil.groupBy(toRemove, MODULE);
|
||||
Map<DataNode<ModuleData>, Collection<DataNode<LibraryDependencyData>>> byModule = ExternalSystemApiUtil.groupBy(toRemove, MODULE);
|
||||
for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<LibraryDependencyData>>> entry : byModule.entrySet()) {
|
||||
Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project);
|
||||
if (module == null) {
|
||||
+3
-3
@@ -9,7 +9,7 @@ import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.ModuleData;
|
||||
import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleManager;
|
||||
import com.intellij.openapi.module.StdModuleTypes;
|
||||
@@ -137,7 +137,7 @@ public class ModuleDataService implements ProjectDataService<ModuleData> {
|
||||
if (nodes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
ExternalSystemUtil.executeProjectChangeAction(project, nodes.iterator().next().getData().getOwner(), nodes, true, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(project, nodes.iterator().next().getData().getOwner(), nodes, true, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LocalFileSystem fileSystem = LocalFileSystem.getInstance();
|
||||
@@ -176,7 +176,7 @@ public class ModuleDataService implements ProjectDataService<ModuleData> {
|
||||
return;
|
||||
}
|
||||
Project project = modules.iterator().next().getProject();
|
||||
ExternalSystemUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, modules, synchronous, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, modules, synchronous, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Module module : modules) {
|
||||
+5
-6
@@ -24,7 +24,7 @@ import com.intellij.openapi.externalSystem.model.project.ModuleData;
|
||||
import com.intellij.openapi.externalSystem.model.project.ModuleDependencyData;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ExportableOrderEntry;
|
||||
@@ -66,8 +66,7 @@ public class ModuleDependencyDataService extends AbstractDependencyDataService<M
|
||||
|
||||
@Override
|
||||
public void importData(@NotNull Collection<DataNode<ModuleDependencyData>> toImport, @NotNull Project project, boolean synchronous) {
|
||||
Map<DataNode<ModuleData>, Collection<DataNode<ModuleDependencyData>>> byModule
|
||||
= ExternalSystemUtil.groupBy(toImport, ProjectKeys.MODULE);
|
||||
Map<DataNode<ModuleData>, Collection<DataNode<ModuleDependencyData>>> byModule= ExternalSystemApiUtil.groupBy(toImport, MODULE);
|
||||
for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<ModuleDependencyData>>> entry : byModule.entrySet()) {
|
||||
Module ideModule = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project);
|
||||
if (ideModule == null) {
|
||||
@@ -90,7 +89,7 @@ public class ModuleDependencyDataService extends AbstractDependencyDataService<M
|
||||
@NotNull final Module module,
|
||||
final boolean synchronous)
|
||||
{
|
||||
ExternalSystemUtil.executeProjectChangeAction(module.getProject(), externalSystemId, toImport, synchronous, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(module.getProject(), externalSystemId, toImport, synchronous, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
|
||||
@@ -104,7 +103,7 @@ public class ModuleDependencyDataService extends AbstractDependencyDataService<M
|
||||
DataNode<ProjectData> projectNode = dependencyNode.getDataNode(ProjectKeys.PROJECT);
|
||||
if (projectNode != null) {
|
||||
DataNode<ModuleData> n
|
||||
= ExternalSystemUtil.find(projectNode, ProjectKeys.MODULE, new BooleanFunction<DataNode<ModuleData>>() {
|
||||
= ExternalSystemApiUtil.find(projectNode, MODULE, new BooleanFunction<DataNode<ModuleData>>() {
|
||||
@Override
|
||||
public boolean fun(DataNode<ModuleData> node) {
|
||||
return node.getData().equals(dependencyData.getTarget());
|
||||
@@ -146,7 +145,7 @@ public class ModuleDependencyDataService extends AbstractDependencyDataService<M
|
||||
if (toRemove.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Map<DataNode<ModuleData>, Collection<DataNode<ModuleDependencyData>>> byModule = ExternalSystemUtil.groupBy(toRemove, MODULE);
|
||||
Map<DataNode<ModuleData>, Collection<DataNode<ModuleDependencyData>>> byModule = ExternalSystemApiUtil.groupBy(toRemove, MODULE);
|
||||
for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<ModuleDependencyData>>> entry : byModule.entrySet()) {
|
||||
Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project);
|
||||
if (module == null) {
|
||||
+3
-3
@@ -18,7 +18,7 @@ package com.intellij.openapi.externalSystem.service.project.manage;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.Key;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
@@ -53,7 +53,7 @@ public class ProjectDataManager {
|
||||
}
|
||||
|
||||
for (List<ProjectDataService<?>> services : result.values()) {
|
||||
ExternalSystemUtil.orderAwareSort(services);
|
||||
ExternalSystemApiUtil.orderAwareSort(services);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -62,7 +62,7 @@ public class ProjectDataManager {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> void importData(@NotNull Collection<DataNode<?>> nodes, @NotNull Project project, boolean synchronous) {
|
||||
Map<Key<?>, Collection<DataNode<?>>> grouped = ExternalSystemUtil.group(nodes);
|
||||
Map<Key<?>, Collection<DataNode<?>>> grouped = ExternalSystemApiUtil.group(nodes);
|
||||
for (Map.Entry<Key<?>, Collection<DataNode<?>>> entry : grouped.entrySet()) {
|
||||
// Simple class cast makes ide happy but compiler fails.
|
||||
Collection<DataNode<T>> dummy = ContainerUtilRt.newArrayList();
|
||||
+2
-2
@@ -20,7 +20,7 @@ import com.intellij.openapi.externalSystem.model.Key;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ex.ProjectEx;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -59,7 +59,7 @@ public class ProjectDataServiceImpl implements ProjectDataService<ProjectData> {
|
||||
if (!(project instanceof ProjectEx) || newName.equals(project.getName())) {
|
||||
return;
|
||||
}
|
||||
ExternalSystemUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, project, synchronous, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, project, synchronous, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
((ProjectEx)project).setProjectName(newName);
|
||||
+10
-9
@@ -13,6 +13,7 @@ import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataMan
|
||||
import com.intellij.openapi.externalSystem.service.settings.AbstractExternalProjectConfigurable;
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
|
||||
import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
|
||||
@@ -140,16 +141,16 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractExt
|
||||
onProjectInit(project);
|
||||
|
||||
if (externalProjectNode != null) {
|
||||
ExternalSystemUtil.executeProjectChangeAction(project, myExternalSystemId, project, new Runnable() {
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(project, myExternalSystemId, project, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Collection<DataNode<ModuleData>> modules = ExternalSystemUtil.findAll(externalProjectNode, ProjectKeys.MODULE);
|
||||
Collection<DataNode<ModuleData>> modules = ExternalSystemApiUtil.findAll(externalProjectNode, ProjectKeys.MODULE);
|
||||
myProjectDataManager.importData(ProjectKeys.MODULE, modules, project, true);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -157,7 +158,7 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractExt
|
||||
@Override
|
||||
public void run() {
|
||||
String progressText
|
||||
= ExternalSystemBundle.message("progress.resolve.libraries", ExternalSystemUtil.toReadableName(myExternalSystemId));
|
||||
= ExternalSystemBundle.message("progress.resolve.libraries", ExternalSystemApiUtil.toReadableName(myExternalSystemId));
|
||||
ProgressManager.getInstance().run(
|
||||
new Task.Backgroundable(project, progressText, false) {
|
||||
@Override
|
||||
@@ -207,8 +208,8 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractExt
|
||||
* dependencies information available at the given gradle project
|
||||
*/
|
||||
private void setupLibraries(@NotNull final DataNode<ProjectData> projectWithResolvedLibraries, final Project project) {
|
||||
Collection<DataNode<LibraryData>> libraries = ExternalSystemUtil.findAll(projectWithResolvedLibraries, ProjectKeys.LIBRARY);
|
||||
ExternalSystemUtil.executeProjectChangeAction(project, projectWithResolvedLibraries.getData().getOwner(), libraries, new Runnable() {
|
||||
Collection<DataNode<LibraryData>> libraries = ExternalSystemApiUtil.findAll(projectWithResolvedLibraries, ProjectKeys.LIBRARY);
|
||||
ExternalSystemApiUtil.executeProjectChangeAction(project, projectWithResolvedLibraries.getData().getOwner(), libraries, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProjectRootManagerEx.getInstanceEx(project).mergeRootsChangesDuring(new Runnable() {
|
||||
@@ -270,7 +271,7 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractExt
|
||||
* @throws ConfigurationException if gradle project is not defined and can't be constructed
|
||||
*/
|
||||
public void ensureProjectIsDefined(@NotNull WizardContext wizardContext) throws ConfigurationException {
|
||||
String externalSystemName = ExternalSystemUtil.toReadableName(myExternalSystemId);
|
||||
String externalSystemName = ExternalSystemApiUtil.toReadableName(myExternalSystemId);
|
||||
File projectFile = getProjectFile();
|
||||
if (projectFile == null) {
|
||||
throw new ConfigurationException(ExternalSystemBundle.message("error.project.undefined"));
|
||||
@@ -280,8 +281,8 @@ public abstract class AbstractExternalProjectImportBuilder<C extends AbstractExt
|
||||
final Ref<String> errorDetails = new Ref<String>();
|
||||
try {
|
||||
final Project project = getProject(wizardContext);
|
||||
myExternalProjectNode= ExternalSystemUtil.refreshProject(project, myExternalSystemId, projectFile.getAbsolutePath(), errorReason,
|
||||
errorDetails, false, true);
|
||||
myExternalProjectNode = ExternalSystemUtil.refreshProject(project, myExternalSystemId, projectFile.getAbsolutePath(), errorReason,
|
||||
errorDetails, false, true);
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
throw new ConfigurationException(e.getMessage(), ExternalSystemBundle.message("error.cannot.parse.project", externalSystemName));
|
||||
+1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.externalSystem.service.remote;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType;
|
||||
import com.intellij.openapi.externalSystem.service.RemoteExternalSystemService;
|
||||
+1
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.externalSystem.service.remote;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskDescriptor;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType;
|
||||
+1
@@ -17,6 +17,7 @@ package com.intellij.openapi.externalSystem.service.remote;
|
||||
|
||||
import com.intellij.openapi.externalSystem.build.ExternalSystemBuildManager;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskDescriptor;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.util.Producer;
|
||||
+1
@@ -18,6 +18,7 @@ package com.intellij.openapi.externalSystem.service.remote;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType;
|
||||
import com.intellij.openapi.externalSystem.service.RemoteExternalSystemService;
|
||||
+1
@@ -3,6 +3,7 @@ package com.intellij.openapi.externalSystem.service.remote;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.service.project.ExternalSystemProjectResolver;
|
||||
import com.intellij.util.Producer;
|
||||
+1
-1
@@ -18,7 +18,7 @@ package com.intellij.openapi.externalSystem.service.remote.wrapper;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType;
|
||||
import com.intellij.openapi.externalSystem.service.RemoteExternalSystemService;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package com.intellij.openapi.externalSystem.service.remote.wrapper;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskDescriptor;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemBuildManager;
|
||||
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
+1
-1
@@ -3,7 +3,7 @@ package com.intellij.openapi.externalSystem.service.remote.wrapper;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskType;
|
||||
import com.intellij.openapi.externalSystem.service.RemoteExternalSystemFacade;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemBuildManager;
|
||||
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager;
|
||||
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver;
|
||||
+1
-1
@@ -4,7 +4,7 @@ import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProgressNotificationManager;
|
||||
import com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskNotificationListener;
|
||||
+1
-1
@@ -17,8 +17,8 @@ package com.intellij.openapi.externalSystem.settings;
|
||||
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemManager;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.externalSystem.service.DisposableExternalSystemService;
|
||||
import com.intellij.openapi.externalSystem.service.remote.ExternalSystemExecutionSettings;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.util.Function;
|
||||
-30
@@ -16,16 +16,12 @@
|
||||
package com.intellij.openapi.externalSystem.util;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.GradleSyntheticId;
|
||||
import com.intellij.openapi.externalSystem.model.project.id.ProjectEntityId;
|
||||
import com.intellij.openapi.externalSystem.ui.ProjectStructureNodeDescriptor;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.BalloonBuilder;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
@@ -37,32 +33,6 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class ExternalSystemUiUtil {
|
||||
|
||||
public static final ProjectStructureNodeDescriptor<GradleSyntheticId> DEPENDENCIES_NODE_DESCRIPTOR
|
||||
= buildSyntheticDescriptor(ExternalSystemBundle.message("entity.type.dependencies"));
|
||||
|
||||
public static final ProjectStructureNodeDescriptor<GradleSyntheticId> MODULES_NODE_DESCRIPTOR
|
||||
= buildSyntheticDescriptor(ExternalSystemBundle.message("entity.type.modules"));
|
||||
|
||||
public static final ProjectStructureNodeDescriptor<GradleSyntheticId> LIBRARIES_NODE_DESCRIPTOR
|
||||
= buildSyntheticDescriptor(ExternalSystemBundle.message("entity.type.libraries"));
|
||||
|
||||
private ExternalSystemUiUtil() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T extends ProjectEntityId> ProjectStructureNodeDescriptor<T> buildDescriptor(@NotNull T id, @NotNull String name) {
|
||||
return new ProjectStructureNodeDescriptor<T>(id, name, id.getType().getIcon());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static ProjectStructureNodeDescriptor<GradleSyntheticId> buildSyntheticDescriptor(@NotNull String text) {
|
||||
return buildSyntheticDescriptor(text, null);
|
||||
}
|
||||
|
||||
public static ProjectStructureNodeDescriptor<GradleSyntheticId> buildSyntheticDescriptor(@NotNull String text, @Nullable Icon icon) {
|
||||
return new ProjectStructureNodeDescriptor<GradleSyntheticId>(new GradleSyntheticId(text), text, icon);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks to show balloon that contains information related to the given component.
|
||||
*
|
||||
+7
-325
@@ -24,19 +24,15 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemManager;
|
||||
import com.intellij.openapi.externalSystem.model.DataNode;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemException;
|
||||
import com.intellij.openapi.externalSystem.model.Key;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectEntityData;
|
||||
import com.intellij.openapi.externalSystem.model.task.ExternalSystemResolveProjectTask;
|
||||
import com.intellij.openapi.externalSystem.service.project.ModuleAwareContentRoot;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ProjectEntityChangeListener;
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
|
||||
import com.intellij.openapi.externalSystem.settings.ExternalSystemSettingsManager;
|
||||
import com.intellij.openapi.fileTypes.FileTypes;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
@@ -48,164 +44,36 @@ import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.roots.LibraryOrderEntry;
|
||||
import com.intellij.openapi.roots.ModuleOrderEntry;
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.util.AtomicNotNullLazyValue;
|
||||
import com.intellij.openapi.util.NotNullLazyValue;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.JarFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.util.BooleanFunction;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.PathsList;
|
||||
import com.intellij.util.containers.ContainerUtilRt;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
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;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 4/1/13 1:31 PM
|
||||
* @since 4/22/13 9:36 AM
|
||||
*/
|
||||
public class ExternalSystemUtil {
|
||||
|
||||
private static final Logger LOG = Logger.getInstance("#" + ExternalSystemUtil.class.getName());
|
||||
|
||||
@NotNull public static final String PATH_SEPARATOR = "/";
|
||||
|
||||
@NotNull private static final Pattern ARTIFACT_PATTERN = Pattern.compile("(?:.*/)?(.+?)(?:-([\\d+](?:\\.[\\d]+)*))?(?:\\.[^\\.]+?)?");
|
||||
|
||||
@NotNull private static final NotNullLazyValue<Map<ProjectSystemId, ExternalSystemManager<?, ?, ?, ?>>> MANAGERS =
|
||||
new AtomicNotNullLazyValue<Map<ProjectSystemId, ExternalSystemManager<?, ?, ?, ?>>>() {
|
||||
@NotNull
|
||||
@Override
|
||||
protected Map<ProjectSystemId, ExternalSystemManager<?, ?, ?, ?>> compute() {
|
||||
Map<ProjectSystemId, ExternalSystemManager<?, ?, ?, ?>> result = ContainerUtilRt.newHashMap();
|
||||
for (ExternalSystemManager manager : ExternalSystemManager.EP_NAME.getExtensions()) {
|
||||
result.put(manager.getSystemId(), manager);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull public static final Comparator<Object> ORDER_AWARE_COMPARATOR = new Comparator<Object>() {
|
||||
@Override
|
||||
public int compare(Object o1, Object o2) {
|
||||
int order1 = getOrder(o1);
|
||||
int order2 = getOrder(o2);
|
||||
return order1 > order2 ? 1 : order1 < order2 ? -1 : 0;
|
||||
}
|
||||
|
||||
private int getOrder(@NotNull Object o) {
|
||||
Queue<Class<?>> toCheck = new ArrayDeque<Class<?>>();
|
||||
toCheck.add(o.getClass());
|
||||
while (!toCheck.isEmpty()) {
|
||||
Class<?> clazz = toCheck.poll();
|
||||
Order annotation = clazz.getAnnotation(Order.class);
|
||||
if (annotation != null) {
|
||||
return annotation.value();
|
||||
}
|
||||
toCheck.add(clazz.getSuperclass());
|
||||
Class<?>[] interfaces = clazz.getInterfaces();
|
||||
if (interfaces != null) {
|
||||
Collections.addAll(toCheck, interfaces);
|
||||
}
|
||||
}
|
||||
return ExternalSystemConstants.UNORDERED;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private ExternalSystemUtil() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param path target path
|
||||
* @return absolute path that points to the same location as the given one and that uses only slashes
|
||||
*/
|
||||
@NotNull
|
||||
public static String toCanonicalPath(@NotNull String path) {
|
||||
return PathUtil.getCanonicalPath(new File(path).getAbsolutePath());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String extractNameFromPath(@NotNull String path) {
|
||||
String strippedPath = stripPath(path);
|
||||
final int i = strippedPath.lastIndexOf(PATH_SEPARATOR);
|
||||
final String result;
|
||||
if (i < 0 || i >= strippedPath.length() - 1) {
|
||||
result = strippedPath;
|
||||
}
|
||||
else {
|
||||
result = strippedPath.substring(i + 1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String stripPath(@NotNull String path) {
|
||||
String[] endingsToStrip = {"/", "!", ".jar"};
|
||||
StringBuilder buffer = new StringBuilder(path);
|
||||
for (String ending : endingsToStrip) {
|
||||
if (buffer.lastIndexOf(ending) == buffer.length() - ending.length()) {
|
||||
buffer.setLength(buffer.length() - ending.length());
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getLibraryName(@NotNull Library library) {
|
||||
final String result = library.getName();
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
for (OrderRootType type : OrderRootType.getAllTypes()) {
|
||||
for (String url : library.getUrls(type)) {
|
||||
String candidate = extractNameFromPath(url);
|
||||
if (!StringUtil.isEmpty(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert false;
|
||||
return "unknown-lib";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ArtifactInfo parseArtifactInfo(@NotNull String fileName) {
|
||||
Matcher matcher = ARTIFACT_PATTERN.matcher(fileName);
|
||||
if (!matcher.matches()) {
|
||||
return null;
|
||||
}
|
||||
return new ArtifactInfo(matcher.group(1), null, matcher.group(2));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getLocalFileSystemPath(@NotNull VirtualFile file) {
|
||||
if (file.getFileType() == FileTypes.ARCHIVE) {
|
||||
final VirtualFile jar = JarFileSystem.getInstance().getVirtualFileForJar(file);
|
||||
if (jar != null) {
|
||||
return jar.getPath();
|
||||
}
|
||||
}
|
||||
return file.getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to dispatch given entity via the given visitor.
|
||||
*
|
||||
@@ -248,72 +116,6 @@ public class ExternalSystemUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static void executeProjectChangeAction(@NotNull Project project,
|
||||
@NotNull final ProjectSystemId externalSystemId,
|
||||
@NotNull Object entityToChange,
|
||||
@NotNull Runnable task)
|
||||
{
|
||||
executeProjectChangeAction(project, externalSystemId, entityToChange, false, task);
|
||||
}
|
||||
|
||||
public static void executeProjectChangeAction(@NotNull Project project,
|
||||
@NotNull final ProjectSystemId externalSystemId,
|
||||
@NotNull Object entityToChange,
|
||||
boolean synchronous,
|
||||
@NotNull Runnable task)
|
||||
{
|
||||
executeProjectChangeAction(project, externalSystemId, Collections.singleton(entityToChange), synchronous, task);
|
||||
}
|
||||
|
||||
public static void executeProjectChangeAction(@NotNull final Project project,
|
||||
@NotNull final ProjectSystemId externalSystemId,
|
||||
@NotNull final Iterable<?> entitiesToChange,
|
||||
@NotNull final Runnable task)
|
||||
{
|
||||
executeProjectChangeAction(project, externalSystemId, entitiesToChange, false, task);
|
||||
}
|
||||
|
||||
public static void executeProjectChangeAction(@NotNull final Project project,
|
||||
@NotNull final ProjectSystemId externalSystemId,
|
||||
@NotNull final Iterable<?> entitiesToChange,
|
||||
boolean synchronous,
|
||||
@NotNull final Runnable task)
|
||||
{
|
||||
Runnable wrappedTask = new Runnable() {
|
||||
public void run() {
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final ProjectEntityChangeListener publisher = project.getMessageBus().syncPublisher(ProjectEntityChangeListener.TOPIC);
|
||||
for (Object e : entitiesToChange) {
|
||||
publisher.onChangeStart(e, externalSystemId);
|
||||
}
|
||||
try {
|
||||
task.run();
|
||||
}
|
||||
finally {
|
||||
for (Object e : entitiesToChange) {
|
||||
publisher.onChangeEnd(e, externalSystemId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (synchronous) {
|
||||
if (ApplicationManager.getApplication().isDispatchThread()) {
|
||||
wrappedTask.run();
|
||||
}
|
||||
else {
|
||||
UIUtil.invokeAndWaitIfNeeded(wrappedTask);
|
||||
}
|
||||
}
|
||||
else {
|
||||
UIUtil.invokeLaterIfNeeded(wrappedTask);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getOutdatedEntityName(@NotNull String entityName, @NotNull String gradleVersion, @NotNull String ideVersion) {
|
||||
return String.format("%s (%s -> %s)", entityName, ideVersion, gradleVersion);
|
||||
@@ -380,11 +182,6 @@ public class ExternalSystemUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ExternalSystemManager<?, ?, ?, ?> getManager(@NotNull ProjectSystemId externalSystemId) {
|
||||
return MANAGERS.getValue().get(externalSystemId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures given classpath to reference target i18n bundle file(s).
|
||||
*
|
||||
@@ -427,102 +224,6 @@ public class ExternalSystemUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Map<Key<?>, Collection<DataNode<?>>> group(@NotNull Collection<DataNode<?>> nodes) {
|
||||
if (nodes.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<Key<?>, Collection<DataNode<?>>> result = ContainerUtilRt.newHashMap();
|
||||
for (DataNode<?> node : nodes) {
|
||||
Collection<DataNode<?>> n = result.get(node.getKey());
|
||||
if (n == null) {
|
||||
result.put(node.getKey(), n = ContainerUtilRt.newArrayList());
|
||||
}
|
||||
n.add(node);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <K, V> Map<DataNode<K>, Collection<DataNode<V>>> groupBy(@NotNull Collection<DataNode<V>> nodes, @NotNull Key<K> key) {
|
||||
Map<DataNode<K>, Collection<DataNode<V>>> result = ContainerUtilRt.newHashMap();
|
||||
for (DataNode<V> data : nodes) {
|
||||
DataNode<K> grouper = data.getDataNode(key);
|
||||
if (grouper == null) {
|
||||
LOG.warn(String.format(
|
||||
"Skipping entry '%s' during grouping. Reason: it doesn't provide a value for key %s. Given entries: %s",
|
||||
data, key, nodes
|
||||
));
|
||||
continue;
|
||||
}
|
||||
Collection<DataNode<V>> grouped = result.get(grouper);
|
||||
if (grouped == null) {
|
||||
result.put(grouper, grouped = ContainerUtilRt.newArrayList());
|
||||
}
|
||||
grouped.add(data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@NotNull
|
||||
public static <T> Collection<DataNode<T>> getChildren(@NotNull DataNode<?> node, @NotNull Key<T> key) {
|
||||
Collection<DataNode<T>> result = null;
|
||||
for (DataNode<?> child : node.getChildren()) {
|
||||
if (!key.equals(child.getKey())) {
|
||||
continue;
|
||||
}
|
||||
if (result == null) {
|
||||
result = ContainerUtilRt.newArrayList();
|
||||
}
|
||||
result.add((DataNode<T>)child);
|
||||
}
|
||||
return result == null ? Collections.<DataNode<T>>emptyList() : result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public static <T> DataNode<T> find(@NotNull DataNode<?> node, @NotNull Key<T> key) {
|
||||
for (DataNode<?> child : node.getChildren()) {
|
||||
if (key.equals(child.getKey())) {
|
||||
return (DataNode<T>)child;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public static <T> DataNode<T> find(@NotNull DataNode<?> node, @NotNull Key<T> key, BooleanFunction<DataNode<T>> predicate) {
|
||||
for (DataNode<?> child : node.getChildren()) {
|
||||
if (key.equals(child.getKey()) && predicate.fun((DataNode<T>)child)) {
|
||||
return (DataNode<T>)child;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@NotNull
|
||||
public static <T> Collection<DataNode<T>> findAll(@NotNull DataNode<?> parent, @NotNull Key<T> key) {
|
||||
Collection<DataNode<T>> result = null;
|
||||
for (DataNode<?> child : parent.getChildren()) {
|
||||
if (!key.equals(child.getKey())) {
|
||||
continue;
|
||||
}
|
||||
if (result == null) {
|
||||
result = ContainerUtilRt.newArrayList();
|
||||
}
|
||||
result.add((DataNode<T>)child);
|
||||
}
|
||||
return result == null ? Collections.<DataNode<T>>emptyList() : result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String toReadableName(@NotNull ProjectSystemId id) {
|
||||
return StringUtil.capitalize(id.toString().toLowerCase());
|
||||
}
|
||||
|
||||
public static void refreshProject(@NotNull Project project, @NotNull ProjectSystemId externalSystemId) {
|
||||
refreshProject(project, externalSystemId, new Ref<String>());
|
||||
}
|
||||
@@ -611,7 +312,7 @@ public class ExternalSystemUtil {
|
||||
if (StringUtil.isEmpty(message)) {
|
||||
errorMessageHolder.set(String.format(
|
||||
"Can't resolve %s project at '%s'. Reason: %s",
|
||||
toReadableName(externalSystemId), externalProjectPath, message
|
||||
ExternalSystemApiUtil.toReadableName(externalSystemId), externalProjectPath, message
|
||||
));
|
||||
}
|
||||
else {
|
||||
@@ -634,7 +335,7 @@ public class ExternalSystemUtil {
|
||||
@Override
|
||||
public void run() {
|
||||
if (modal) {
|
||||
String title = ExternalSystemBundle.message("progress.import.text", toReadableName(externalSystemId));
|
||||
String title = ExternalSystemBundle.message("progress.import.text", ExternalSystemApiUtil.toReadableName(externalSystemId));
|
||||
ProgressManager.getInstance().run(new Task.Modal(project, title, false) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
@@ -646,7 +347,7 @@ public class ExternalSystemUtil {
|
||||
});
|
||||
}
|
||||
else {
|
||||
String title = ExternalSystemBundle.message("progress.refresh.text", toReadableName(externalSystemId));
|
||||
String title = ExternalSystemBundle.message("progress.refresh.text", ExternalSystemApiUtil.toReadableName(externalSystemId));
|
||||
ProgressManager.getInstance().run(new Task.Backgroundable(project, title) {
|
||||
@Override
|
||||
public void run(@NotNull ProgressIndicator indicator) {
|
||||
@@ -666,24 +367,5 @@ public class ExternalSystemUtil {
|
||||
void execute(@NotNull ProgressIndicator indicator);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Sdk findJdk(@NotNull JavaSdkVersion version) {
|
||||
JavaSdk javaSdk = JavaSdk.getInstance();
|
||||
List<Sdk> javaSdks = ProjectJdkTable.getInstance().getSdksOfType(javaSdk);
|
||||
Sdk candidate = null;
|
||||
for (Sdk sdk : javaSdks) {
|
||||
JavaSdkVersion v = javaSdk.getVersion(sdk);
|
||||
if (v == version) {
|
||||
return sdk;
|
||||
}
|
||||
else if (candidate == null && v != null && version.getMaxLanguageLevel().isAtLeast(version.getMaxLanguageLevel())) {
|
||||
candidate = sdk;
|
||||
}
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
|
||||
public static void orderAwareSort(@NotNull List<?> data) {
|
||||
Collections.sort(data, ORDER_AWARE_COMPARATOR);
|
||||
}
|
||||
|
||||
}
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
package com.intellij.openapi.externalSystem.model;
|
||||
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.externalSystem.ui.ProjectStructureNode;
|
||||
import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.openapi.externalSystem.ui.ExternalProjectStructureTreeModel;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
* @since 2/7/12 11:19 AM
|
||||
*/
|
||||
public class ExternalSystemDataKeys {
|
||||
|
||||
/** Key for obtaining 'external system project structure' tree. */
|
||||
public static final DataKey<Tree> PROJECT_TREE = DataKey.create("external.system.project.tree");
|
||||
|
||||
/** Key for obtaining 'external system project structure' tree model. */
|
||||
public static final DataKey<ExternalProjectStructureTreeModel> PROJECT_TREE_MODEL = DataKey.create("external.system.project.tree.model");
|
||||
|
||||
/** Key for obtaining currently selected nodes at the 'external system project structure' tree. */
|
||||
public static final DataKey<Collection<ProjectStructureNode<?>>> PROJECT_TREE_SELECTED_NODE
|
||||
= DataKey.create("gradle.sync.tree.node.selected");
|
||||
|
||||
/** Key for obtaining node under mouse cursor at the 'external system project structure' tree. */
|
||||
public static final DataKey<ProjectStructureNode<?>> SYNC_TREE_NODE_UNDER_MOUSE
|
||||
= DataKey.create("gradle.sync.tree.node.under.mouse");
|
||||
|
||||
// TODO den uncomment
|
||||
|
||||
// public static final DataKey<GradleTasksList> RECENT_TASKS_LIST = DataKey.create("gradle.recent.tasks.list");
|
||||
|
||||
// public static final DataKey<GradleTasksModel> ALL_TASKS_MODEL = DataKey.create("gradle.all.tasks.model");
|
||||
|
||||
private ExternalSystemDataKeys() {
|
||||
}
|
||||
}
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright 2000-2013 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.model.project;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* There is a possible case that the same entity (e.g. library or jar) has different versions at external system and ide side.
|
||||
* We treat that not as two entities (external system- and ide-local) but as a single composite entity. This class is a base class
|
||||
* for such types of entities.
|
||||
* <p/>
|
||||
* Thread-safe.
|
||||
*
|
||||
* @author Denis Zhdanov
|
||||
* @since 1/23/13 9:19 AM
|
||||
*/
|
||||
public abstract class AbstractCompositeData<E extends ProjectEntityData, I> extends AbstractProjectEntityData {
|
||||
|
||||
@NotNull private final E myExternalEntity;
|
||||
@NotNull private final I myIdeEntity;
|
||||
|
||||
public AbstractCompositeData(@NotNull E externalEntity, @NotNull I ideEntity) {
|
||||
super(ProjectSystemId.IDE);
|
||||
myExternalEntity = externalEntity;
|
||||
myIdeEntity = ideEntity;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public E getExternalEntity() {
|
||||
return myExternalEntity;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public I getIdeEntity() {
|
||||
return myIdeEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + myExternalEntity.hashCode();
|
||||
result = 31 * result + myIdeEntity.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!super.equals(o)) return false;
|
||||
|
||||
AbstractCompositeData entity = (AbstractCompositeData)o;
|
||||
|
||||
if (!myExternalEntity.equals(entity.myExternalEntity)) return false;
|
||||
if (!myIdeEntity.equals(entity.myIdeEntity)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user