IDEA-370122 Logical Structure: support option "Always select opened element"

GitOrigin-RevId: b16a09d5d45927996d02f6bb981663464a0fa55b
This commit is contained in:
Anton Kozub
2025-09-02 17:59:35 +00:00
committed by intellij-monorepo-bot
parent 786625aa4c
commit 5991c4a01e
3 changed files with 13 additions and 3 deletions
@@ -11,7 +11,8 @@
*f:com.intellij.ide.structureView.logical.LogicalStructureTreeElementProvider$Companion
- f:getTreeElement(java.lang.Object):com.intellij.ide.structureView.StructureViewTreeElement
*:com.intellij.ide.structureView.logical.model.ExtendedLogicalObject
- a:isTheSameParent(java.lang.Object):Z
- canRepresentPsiElement(com.intellij.psi.PsiElement):Z
- isTheSameParent(java.lang.Object):Z
*:com.intellij.ide.structureView.logical.model.LogicalContainer
- a:getElements():java.util.List
*a:com.intellij.ide.structureView.logical.model.LogicalModelPresentationProvider
@@ -90,7 +90,10 @@ class LogicalStructureViewModel private constructor(psiFile: PsiFile, editor: Ed
if (treeElement.element == targetElement) {
return TreeVisitor.Action.INTERRUPT
}
else if (treeElement.element?.containingFile != targetElement.containingFile) {
(treeElement.getLogicalAssembledModel().model as? ExtendedLogicalObject)?.let {
if (it.canRepresentPsiElement(targetElement)) return TreeVisitor.Action.INTERRUPT
}
if (treeElement.element?.containingFile != targetElement.containingFile) {
return TreeVisitor.Action.SKIP_CHILDREN
}
return TreeVisitor.Action.CONTINUE
@@ -1,6 +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.psi.PsiElement
import org.jetbrains.annotations.ApiStatus
/**
@@ -14,6 +15,11 @@ interface ExtendedLogicalObject {
* @return true - if elements are not equally themselves but are the same if threat them as parents.
* This equality can break common rules for usual "equal", for example, symmetry rule
*/
fun isTheSameParent(other: Any?): Boolean
fun isTheSameParent(other: Any?): Boolean = false
/**
* If the element can represent additional elements different from what it is targeting
*/
fun canRepresentPsiElement(psiElement: PsiElement): Boolean = false
}