mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[gradle] group module nodes according to idea module grouping IDEA-202466
This commit is contained in:
+18
-3
@@ -2,7 +2,7 @@ package com.intellij.openapi.externalSystem.model.project;
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.util.PathUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -12,6 +12,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.intellij.openapi.util.text.StringUtil.*;
|
||||
|
||||
/**
|
||||
* @author Denis Zhdanov
|
||||
*/
|
||||
@@ -226,12 +228,25 @@ public class ModuleData extends AbstractNamedData implements Named, ExternalConf
|
||||
|
||||
@Nullable
|
||||
public String getIdeGrouping() {
|
||||
return getLinkedExternalProjectPath();
|
||||
if (myIdeModuleGroup != null) {
|
||||
return join(myIdeModuleGroup, ".");
|
||||
} else {
|
||||
return getInternalName();
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getIdeParentGrouping() {
|
||||
return PathUtil.getParentPath(getLinkedExternalProjectPath());
|
||||
if (myIdeModuleGroup != null) {
|
||||
return nullize(join(ArrayUtil.remove(myIdeModuleGroup, myIdeModuleGroup.length - 1), "."));
|
||||
} else {
|
||||
final String name = getInternalName();
|
||||
if (name.lastIndexOf(".") > 0) {
|
||||
return substringBeforeLast(name, ".");
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-1
@@ -21,6 +21,7 @@ public class ProjectData extends AbstractNamedData implements ExternalConfigPath
|
||||
@Nullable private String myDescription;
|
||||
private String myGroup;
|
||||
private String myVersion;
|
||||
private String myIdeGrouping;
|
||||
|
||||
@Deprecated
|
||||
public ProjectData(@NotNull ProjectSystemId owner,
|
||||
@@ -64,7 +65,11 @@ public class ProjectData extends AbstractNamedData implements ExternalConfigPath
|
||||
|
||||
@Nullable
|
||||
public String getIdeGrouping() {
|
||||
return getLinkedExternalProjectPath();
|
||||
return myIdeGrouping;
|
||||
}
|
||||
|
||||
public void setIdeGrouping(@Nullable String ideGrouping) {
|
||||
myIdeGrouping = ideGrouping;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class ModuleNode extends ExternalSystemNode<ModuleData> {
|
||||
@Override
|
||||
protected List<? extends ExternalSystemNode> doBuildChildren() {
|
||||
List<ExternalSystemNode<?>> myChildNodes = ContainerUtil.newArrayList();
|
||||
if (!myIsRoot && getExternalProjectsView().getGroupModules()) {
|
||||
if (getExternalProjectsView().getGroupModules()) {
|
||||
List<ModuleNode> childModules = ContainerUtil.findAll(
|
||||
myAllModules,
|
||||
module -> module != this && StringUtil.equals(module.getIdeParentGrouping(), getIdeGrouping())
|
||||
|
||||
+13
-1
@@ -54,12 +54,17 @@ public class ProjectNode extends ExternalSystemNode<ProjectData> {
|
||||
@NotNull
|
||||
@Override
|
||||
protected List<? extends ExternalSystemNode> doBuildChildren() {
|
||||
setIdeGrouping(null);
|
||||
final List<? extends ExternalSystemNode> children = super.doBuildChildren();
|
||||
final List<ExternalSystemNode> visibleChildren = ContainerUtil.filter(children, node -> node.isVisible());
|
||||
if (visibleChildren.size() == 1 && visibleChildren.get(0).getName().equals(getName())) {
|
||||
singleModuleProject = true;
|
||||
final ExternalSystemNode node = visibleChildren.get(0);
|
||||
if (node instanceof ModuleNode) {
|
||||
setIdeGrouping(((ModuleNode)node).getIdeGrouping());
|
||||
}
|
||||
//noinspection unchecked
|
||||
return visibleChildren.get(0).doBuildChildren();
|
||||
return node.doBuildChildren();
|
||||
}
|
||||
else {
|
||||
singleModuleProject = false;
|
||||
@@ -110,6 +115,13 @@ public class ProjectNode extends ExternalSystemNode<ProjectData> {
|
||||
return data.getIdeGrouping();
|
||||
}
|
||||
|
||||
private void setIdeGrouping(@Nullable String ideGrouping) {
|
||||
ProjectData data = getData();
|
||||
if (data != null) {
|
||||
data.setIdeGrouping(ideGrouping);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
@NonNls
|
||||
|
||||
Reference in New Issue
Block a user