Skip to content

Commit

Permalink
feat(selector): export connectKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Jan 8, 2024
1 parent 7d96c5f commit 8a8de5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class CommonSelector private constructor(
) {
val tracks = selector.tracks
val trackIndex = selector.trackIndex
val connectKeys = selector.connectKeys

fun <T : Any> match(node: T, transform: CommonTransform<T>): T? {
return selector.match(node, transform.transform)
Expand Down
11 changes: 11 additions & 0 deletions selector/src/commonMain/kotlin/li/songe/selector/Selector.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>()
while (c != null) {
c!!.connectSegment.connectExpression
keys.add(c!!.connectSegment.operator.key)
c = c?.to?.to
}
keys.toTypedArray()
}

fun <T> match(
node: T,
transform: Transform<T>,
Expand Down

0 comments on commit 8a8de5d

Please sign in to comment.