From 8a8de5d80119d3d67772370f6cda3faa863312de Mon Sep 17 00:00:00 2001 From: lisonge Date: Mon, 8 Jan 2024 10:55:23 +0800 Subject: [PATCH] feat(selector): export connectKeys --- .../kotlin/li/songe/selector/CommonSelector.kt | 1 + .../commonMain/kotlin/li/songe/selector/Selector.kt | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/selector/src/commonMain/kotlin/li/songe/selector/CommonSelector.kt b/selector/src/commonMain/kotlin/li/songe/selector/CommonSelector.kt index 4fb6e28..6a82b0c 100644 --- a/selector/src/commonMain/kotlin/li/songe/selector/CommonSelector.kt +++ b/selector/src/commonMain/kotlin/li/songe/selector/CommonSelector.kt @@ -11,6 +11,7 @@ class CommonSelector private constructor( ) { val tracks = selector.tracks val trackIndex = selector.trackIndex + val connectKeys = selector.connectKeys fun match(node: T, transform: CommonTransform): T? { return selector.match(node, transform.transform) diff --git a/selector/src/commonMain/kotlin/li/songe/selector/Selector.kt b/selector/src/commonMain/kotlin/li/songe/selector/Selector.kt index 4f494c5..433d150 100644 --- a/selector/src/commonMain/kotlin/li/songe/selector/Selector.kt +++ b/selector/src/commonMain/kotlin/li/songe/selector/Selector.kt @@ -23,6 +23,17 @@ class Selector internal constructor(private val propertyWrapper: PropertyWrapper if (i < 0) 0 else i } + val connectKeys by lazy { + var c = propertyWrapper.to + val keys = mutableListOf() + while (c != null) { + c!!.connectSegment.connectExpression + keys.add(c!!.connectSegment.operator.key) + c = c?.to?.to + } + keys.toTypedArray() + } + fun match( node: T, transform: Transform,