mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ModuleGrouper: javadocs added, function renamed, moved to API
This commit is contained in:
+1
-1
@@ -121,7 +121,7 @@ public class ModuleSourceItemGroup extends PackagingSourceItem {
|
||||
|
||||
@Override
|
||||
public String getPresentableName() {
|
||||
return ModuleGrouper.instanceFor(myContext.getProject(), myContext.getModifiableModuleModel()).getPresentableName(myModule);
|
||||
return ModuleGrouper.instanceFor(myContext.getProject(), myContext.getModifiableModuleModel()).getShortenedName(myModule);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-2
@@ -640,7 +640,7 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return myFlattenModules ? getModule().getName() : myGrouper.getPresentableName(getModule());
|
||||
return myFlattenModules ? getModule().getName() : myGrouper.getShortenedName(getModule());
|
||||
}
|
||||
|
||||
private Module getModule() {
|
||||
@@ -776,7 +776,8 @@ public class ModuleStructureConfigurable extends BaseStructureConfigurable imple
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
super.update(e);
|
||||
e.getPresentation().setEnabledAndVisible(ModuleGrouperKt.isQualifiedModuleNamesEnabled() && !myContext.getModulesConfigurator().getModuleModel().hasModuleGroups());
|
||||
e.getPresentation().setEnabledAndVisible(
|
||||
ModuleGrouperKt.isQualifiedModuleNamesEnabled() && !myContext.getModulesConfigurator().getModuleModel().hasModuleGroups());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -242,7 +242,7 @@ public class DirectoryChooserModuleTreeView implements DirectoryChooserView {
|
||||
}
|
||||
else if (value instanceof Module) {
|
||||
final Module module = (Module)value;
|
||||
append(myModuleGrouper.getPresentableName(module), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
append(myModuleGrouper.getShortenedName(module), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
setIcon(ModuleType.get(module).getIcon());
|
||||
} else if (value instanceof ModuleGroup) {
|
||||
append(value.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
|
||||
|
||||
@@ -71,7 +71,7 @@ public class ModuleNode extends PackageDependenciesNode implements NavigatableWi
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return myModuleGrouper != null ? myModuleGrouper.getPresentableName(myModule) : myModule.getName();
|
||||
return myModuleGrouper != null ? myModuleGrouper.getShortenedName(myModule) : myModule.getName();
|
||||
}
|
||||
|
||||
public String getModuleName() {
|
||||
|
||||
+3
-3
@@ -29,7 +29,7 @@ class GroupModulesByQualifiedNamesTest : PlatformTestCase() {
|
||||
@Test
|
||||
fun `test single module`() {
|
||||
val module = createModule("a.b.module")
|
||||
assertEquals("module", grouper.getPresentableName(module))
|
||||
assertEquals("module", grouper.getShortenedName(module))
|
||||
|
||||
val parentGroup = ModuleGroup(listOf("a"))
|
||||
assertEmpty(parentGroup.modulesInGroup(grouper, false))
|
||||
@@ -45,8 +45,8 @@ class GroupModulesByQualifiedNamesTest : PlatformTestCase() {
|
||||
val module1 = createModule("a.module1")
|
||||
val module2 = createModule("a.b.module2")
|
||||
|
||||
assertEquals("module1", grouper.getPresentableName(module1))
|
||||
assertEquals("module2", grouper.getPresentableName(module2))
|
||||
assertEquals("module1", grouper.getShortenedName(module1))
|
||||
assertEquals("module2", grouper.getShortenedName(module2))
|
||||
|
||||
val parentGroup = ModuleGroup(listOf("a"))
|
||||
assertSameElements(parentGroup.modulesInGroup(grouper, false), module1)
|
||||
|
||||
+14
-3
@@ -18,15 +18,26 @@ package com.intellij.openapi.module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Use this class to determine how modules show by organized in a tree. It supports the both ways of module grouping: the old one where
|
||||
* groups are specified explicitly and the new one where modules are grouped accordingly to their qualified names.
|
||||
*
|
||||
* @author nik
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
abstract class ModuleGrouper {
|
||||
/**
|
||||
* Returns names of parent groups for a module
|
||||
*/
|
||||
abstract fun getGroupPath(module: Module): List<String>
|
||||
|
||||
abstract fun getPresentableName(module: Module): String
|
||||
/**
|
||||
* Returns name which should be used for a module when it's shown under its group
|
||||
*/
|
||||
abstract fun getShortenedName(module: Module): String
|
||||
|
||||
abstract fun getAllModules(): Array<Module>
|
||||
|
||||
@@ -55,7 +66,7 @@ private class QualifiedNameGrouper(project: Project, model: ModifiableModuleMode
|
||||
return getModuleName(module).split('.').dropLast(1)
|
||||
}
|
||||
|
||||
override fun getPresentableName(module: Module) = StringUtil.getShortName(getModuleName(module))
|
||||
override fun getShortenedName(module: Module) = StringUtil.getShortName(getModuleName(module))
|
||||
}
|
||||
|
||||
private class ExplicitModuleGrouper(project: Project, model: ModifiableModuleModel?): ModuleGrouperBase(project, model) {
|
||||
@@ -64,5 +75,5 @@ private class ExplicitModuleGrouper(project: Project, model: ModifiableModuleMod
|
||||
return if (path != null) Arrays.asList(*path) else emptyList()
|
||||
}
|
||||
|
||||
override fun getPresentableName(module: Module) = getModuleName(module)
|
||||
override fun getShortenedName(module: Module) = getModuleName(module)
|
||||
}
|
||||
@@ -159,9 +159,11 @@ public abstract class ModuleManager extends SimpleModificationTracker {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the path to the group to which the specified module belongs, as an
|
||||
* array of group names starting from the project root.
|
||||
*
|
||||
* Returns the path to the group to which the specified module belongs, as an array of group names starting from the project root.
|
||||
* <p>
|
||||
* <strong>Use {@link com.intellij.openapi.module.ModuleGrouper#getGroupPath()} instead.</strong> Exlicit module groups will be replaced
|
||||
* by automatical module grouping accordingly to qualified names of modules, see https://youtrack.jetbrains.com/issue/IDEA-166061 for details.
|
||||
* </p>
|
||||
* @param module the module for which the path is requested.
|
||||
* @return the path to the group for the module, or null if the module does not belong to any group.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user