in intellij/src/main/kotlin/motif/intellij/hierarchy/ScopePropertyHierarchyBrowser.kt [137:197]
override fun createHierarchyTreeStructure(
typeName: String,
psiElement: PsiElement,
): HierarchyTreeStructure? {
if (psiElement is PsiClass && isMotifScopeClass(psiElement)) {
val scopeType: PsiType = PsiElementFactory.SERVICE.getInstance(project).createType(psiElement)
val type: IrType = IntelliJType(project, scopeType)
val scope: Scope = graph.getScope(type) ?: return null
return when (hierarchyType) {
PropertyHierarchyType.CONSUME -> {
val descriptor: HierarchyNodeDescriptor =
ScopeHierarchySinksSectionDescriptor(
project,
graph,
null,
(scope.clazz as IntelliJClass).psiClass,
scope,
)
ScopeHierarchyTreeStructure(project, graph, descriptor)
}
PropertyHierarchyType.PROVIDE -> {
val descriptor: HierarchyNodeDescriptor =
ScopeHierarchySourcesSectionDescriptor(
project,
graph,
null,
(scope.clazz as IntelliJClass).psiClass,
scope,
)
ScopeHierarchyTreeStructure(project, graph, descriptor)
}
PropertyHierarchyType.CONSUME_AND_PROVIDE -> {
val descriptor: HierarchyNodeDescriptor =
ScopeHierarchySourcesAndSinksSectionDescriptor(
project,
graph,
null,
(scope.clazz as IntelliJClass).psiClass,
scope,
)
ScopeHierarchyTreeStructure(project, graph, descriptor)
}
PropertyHierarchyType.DEPENDENCIES -> {
val descriptor: HierarchyNodeDescriptor =
ScopeHierarchyDependenciesSectionDescriptor(
project,
graph,
null,
(scope.clazz as IntelliJClass).psiClass,
scope,
)
ScopeHierarchyTreeStructure(project, graph, descriptor)
}
}
} else {
val descriptor: HierarchyNodeDescriptor =
ScopeHierarchySimpleDescriptor(project, graph, null, psiElement, LABEL_NO_SCOPE)
return ScopeHierarchyTreeStructure(project, graph, descriptor)
}
return null
}