mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[uast] IDEA-330019 UAST: withUastParentOrSelf patterns are visible in highlighting
GitOrigin-RevId: 83a276ddbcd4d0f287a0015373852846394cbec2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
358c1ab00a
commit
6c893c44ed
@@ -18,6 +18,7 @@ import com.intellij.util.containers.ContainerUtil
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.uast.*
|
||||
import org.jetbrains.uast.expressions.UInjectionHost
|
||||
|
||||
fun literalExpression(): ULiteralExpressionPattern = ULiteralExpressionPattern()
|
||||
|
||||
@@ -90,6 +91,17 @@ open class UElementPattern<T : UElement, Self : UElementPattern<T, Self>>(clazz:
|
||||
parentPattern.accepts(it, context) || it.uastParent?.let { parentPattern.accepts(it, context) } ?: false
|
||||
}
|
||||
|
||||
fun withStringRoomExpressionOrSelf(parentPattern: ElementPattern<out UElement>): Self = filterWithContext { it, context ->
|
||||
if (it !is UInjectionHost) return@filterWithContext false
|
||||
|
||||
if (parentPattern.accepts(it, context)) return@filterWithContext true
|
||||
|
||||
val room = it.getStringRoomExpression()
|
||||
if (room === it) return@filterWithContext false
|
||||
|
||||
parentPattern.accepts(room, context)
|
||||
}
|
||||
|
||||
class Capture<T : UElement>(clazz: Class<T>) : UElementPattern<T, Capture<T>>(clazz)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user