mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
IDEA-354490 repository methods regrouping
GitOrigin-RevId: c9bb07ebafdcd4c4e358c350af8c862b728052cd
This commit is contained in:
committed by
intellij-monorepo-bot
parent
19ae9afa1a
commit
c4b455eb43
@@ -3,6 +3,7 @@ package com.intellij.ide.structureView.logical
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.util.ClassExtension
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.ApiStatus.Experimental
|
||||
|
||||
/**
|
||||
@@ -44,6 +45,19 @@ interface ContainerElementsProvider<P, C> : LogicalStructureElementsProvider<P,
|
||||
*/
|
||||
interface ExternalElementsProvider<P, C> : ContainerElementsProvider<P, C>
|
||||
|
||||
/**
|
||||
* Extension for container provider which allows providing grouped elements
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
interface ContainerGroupedElementsProvider<P, G, C> : ContainerElementsProvider<P, C> {
|
||||
|
||||
fun getGroupedElements(parent: P): LinkedHashMap<G, List<C>>
|
||||
|
||||
override fun getElements(parent: P): List<C> {
|
||||
return getGroupedElements(parent).flatMap { it.value }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides logical properties with type [C] for logical object [P]
|
||||
*/
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.ide.structureView.logical.model
|
||||
|
||||
import com.intellij.ide.structureView.logical.ContainerElementsProvider
|
||||
import com.intellij.ide.structureView.logical.ConvertElementsProvider
|
||||
import com.intellij.ide.structureView.logical.LogicalStructureElementsProvider
|
||||
import com.intellij.ide.structureView.logical.PropertyElementProvider
|
||||
import com.intellij.ide.structureView.logical.*
|
||||
import com.intellij.openapi.project.Project
|
||||
|
||||
/**
|
||||
@@ -35,16 +32,22 @@ class LogicalStructureAssembledModel<T> private constructor(
|
||||
* The grouping element in each pair - Any - can be any object, for which a PresentationProvider is registered
|
||||
*/
|
||||
fun getChildrenGrouped(): List<Pair<Any, () -> List<LogicalStructureAssembledModel<*>>>> {
|
||||
return LogicalStructureElementsProvider.getProviders(model!!)
|
||||
.mapNotNull { provider ->
|
||||
if (provider !is ContainerElementsProvider && provider !is PropertyElementProvider) return@mapNotNull null
|
||||
val children = {
|
||||
provider.getElements(model)
|
||||
.map { LogicalStructureAssembledModel(project, it, this) }
|
||||
val result = mutableListOf<Pair<Any, () -> List<LogicalStructureAssembledModel<*>>>>()
|
||||
for (provider in LogicalStructureElementsProvider.getProviders(model!!)) {
|
||||
if (provider !is ContainerElementsProvider && provider !is PropertyElementProvider) continue
|
||||
if (provider is ContainerGroupedElementsProvider<*, *, *>) {
|
||||
for (groupedElement in (provider as ContainerGroupedElementsProvider<T, *, *>).getGroupedElements(model)) {
|
||||
result.add(Pair(groupedElement.key!!) { groupedElement.value.map { LogicalStructureAssembledModel(project, it, this) } })
|
||||
}
|
||||
Pair(provider, children)
|
||||
continue
|
||||
}
|
||||
.toList()
|
||||
val children = {
|
||||
provider.getElements(model)
|
||||
.map { LogicalStructureAssembledModel(project, it, this) }
|
||||
}
|
||||
result.add(Pair(provider, children))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
||||
Reference in New Issue
Block a user