mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
IJPL-797 move isModuleContentRoot to NavBarItemPresentationData
GitOrigin-RevId: 532d427643778c49a123ed30ca5b605b759a0aac
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9363d37df3
commit
7ace24a63c
@@ -55,15 +55,13 @@ open class DefaultNavBarItem<out T>(val data: T) : NavBarItem {
|
||||
val text: String = fromOldExtensions { ext -> ext.getPresentableText(data, false) } ?: getText(false)
|
||||
val popupText: String = fromOldExtensions { ext -> ext.getPresentableText(data, true) } ?: getText(true)
|
||||
|
||||
val textAttributes = getTextAttributes()
|
||||
|
||||
val hasContainingFile = (data as? PsiElement)?.containingFile != null
|
||||
return NavBarItemPresentationData(
|
||||
icon,
|
||||
text,
|
||||
popupText,
|
||||
textAttributes,
|
||||
hasContainingFile
|
||||
textAttributes = getTextAttributes(),
|
||||
hasContainingFile = data is PsiElement && data.containingFile != null,
|
||||
isModuleContentRoot = data is PsiDirectory && data.isModuleContentRoot()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ class IdeNavBarVmItem @RequiresReadLock constructor(
|
||||
|
||||
override val presentation: NavBarItemPresentationData = item.presentation() as NavBarItemPresentationData
|
||||
|
||||
override val isModuleContentRoot: Boolean = item.isModuleContentRoot()
|
||||
|
||||
override suspend fun children(): List<NavBarVmItem>? {
|
||||
return fetch {
|
||||
childItems()
|
||||
|
||||
@@ -9,16 +9,9 @@ import com.intellij.psi.PsiDirectory
|
||||
import com.intellij.psi.PsiDirectoryContainer
|
||||
import com.intellij.psi.PsiManager
|
||||
|
||||
internal fun NavBarItem.isModuleContentRoot(): Boolean {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed()
|
||||
if (this is PsiNavBarItem) {
|
||||
val psi = data
|
||||
if (psi is PsiDirectory) {
|
||||
val dir = psi.virtualFile
|
||||
return dir.parent == null || ProjectRootsUtil.isModuleContentRoot(dir, psi.project)
|
||||
}
|
||||
}
|
||||
return false
|
||||
internal fun PsiDirectory.isModuleContentRoot(): Boolean {
|
||||
val dir = this.virtualFile
|
||||
return dir.parent == null || ProjectRootsUtil.isModuleContentRoot(dir, project)
|
||||
}
|
||||
|
||||
internal fun NavBarItem.psiDirectories(): List<PsiDirectory> {
|
||||
|
||||
@@ -215,7 +215,7 @@ internal class NavBarItemComponent(
|
||||
|
||||
private fun effectiveIcon(presentation: NavBarItemPresentationData): Icon? {
|
||||
return when {
|
||||
ExperimentalUI.isNewUI() && vm.isModuleContentRoot -> ExpUiIcons.Nodes.Module8x8
|
||||
ExperimentalUI.isNewUI() && presentation.isModuleContentRoot -> ExpUiIcons.Nodes.Module8x8
|
||||
Registry.`is`("navBar.show.icons") || vm.isLast || presentation.hasContainingFile -> presentation.icon
|
||||
else -> null
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@ interface NavBarItemVm {
|
||||
|
||||
val presentation: NavBarItemPresentationData
|
||||
|
||||
val isModuleContentRoot: Boolean
|
||||
|
||||
val isFirst: Boolean
|
||||
|
||||
val isLast: Boolean
|
||||
|
||||
@@ -177,8 +177,6 @@ class NavBarVmImpl(
|
||||
|
||||
override val presentation: NavBarItemPresentationData get() = item.presentation as NavBarItemPresentationData
|
||||
|
||||
override val isModuleContentRoot: Boolean get() = item.isModuleContentRoot
|
||||
|
||||
override val isFirst: Boolean get() = index == 0
|
||||
|
||||
override val isLast: Boolean get() = index == items.value.lastIndex
|
||||
|
||||
@@ -12,4 +12,3 @@ com.intellij.platform.navbar.NavBarVmItem
|
||||
- bs:expand$suspendImpl(com.intellij.platform.navbar.NavBarVmItem,kotlin.coroutines.Continuation):java.lang.Object
|
||||
- a:getPresentation():com.intellij.platform.navbar.NavBarItemPresentation
|
||||
- a:hashCode():I
|
||||
- isModuleContentRoot():Z
|
||||
|
||||
@@ -19,11 +19,12 @@ fun NavBarItemPresentation(
|
||||
popupText: @Nls String? = text,
|
||||
textAttributes: SimpleTextAttributes = SimpleTextAttributes.REGULAR_ATTRIBUTES,
|
||||
): NavBarItemPresentation {
|
||||
return NavBarItemPresentationData(icon, text, popupText, textAttributes, hasContainingFile = false)
|
||||
return NavBarItemPresentationData(icon, text, popupText, textAttributes, hasContainingFile = false, isModuleContentRoot = false)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hasContainingFile if `true`, [icon] will be displayed, otherwise `false` the icon will be displayed if the item is the last item.
|
||||
* @param isModuleContentRoot if `true`, a special icon will be displayed regardless of [icon] and [hasContainingFile].
|
||||
*/
|
||||
@Internal // plugins are not supposed to read the presentation, they are only supposed to provide it
|
||||
data class NavBarItemPresentationData(
|
||||
@@ -32,6 +33,7 @@ data class NavBarItemPresentationData(
|
||||
val popupText: @Nls String?,
|
||||
val textAttributes: SimpleTextAttributes?,
|
||||
val hasContainingFile: Boolean,
|
||||
val isModuleContentRoot: Boolean,
|
||||
) : NavBarItemPresentation {
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,8 +19,6 @@ interface NavBarVmItem {
|
||||
|
||||
val presentation: NavBarItemPresentation
|
||||
|
||||
val isModuleContentRoot: Boolean get() = false
|
||||
|
||||
suspend fun children(): List<NavBarVmItem>?
|
||||
|
||||
suspend fun expand(): NavBarItemExpandResult? {
|
||||
|
||||
Reference in New Issue
Block a user