private static Collection<? extends PackagingSourceItem> createModuleItems( ArtifactEditorContext editorContext, Artifact artifact, @NotNull String[] groupPath) { final Module[] modules = editorContext.getModulesProvider().getModules(); final List<PackagingSourceItem> items = new ArrayList<PackagingSourceItem>(); Set<String> groups = new HashSet<String>(); for (Module module : modules) { String[] path = ModuleManager.getInstance(editorContext.getProject()).getModuleGroupPath(module); if (path == null) { path = ArrayUtil.EMPTY_STRING_ARRAY; } if (Comparing.equal(path, groupPath)) { items.add(new ModuleSourceItemGroup(module)); } else if (ArrayUtil.startsWith(path, groupPath)) { groups.add(path[groupPath.length]); } } for (String group : groups) { items.add(0, new ModuleGroupItem(ArrayUtil.append(groupPath, group))); } return items; }