Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from gkd-kit:main #6

Merged
merged 1 commit into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions selector/src/commonMain/kotlin/li/songe/selector/Version.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,12 @@ internal object ParserSet {
ExtSyntaxError.assert(source, i, prefix)
val startChar = source[i]
i++
if (i >= source.length) {
ExtSyntaxError.throwError(source, i, "any char")
}
var data = ""
while (source[i] != startChar) {
if (i == source.length - 1) {
if (i >= source.length - 1) {
ExtSyntaxError.assert(source, i, startChar.toString())
break
}
Expand Down Expand Up @@ -442,7 +445,10 @@ internal object ParserSet {
val selectorList = mutableListOf<Pair<ConnectSegment, PropertySegment>>()
while (i < source.length && whiteCharParser.prefix.contains(source[i])) {
i += whiteCharStrictParser(source, i).length
val combinator = if (combinatorParser.prefix.contains((source[i]))) {
if (i >= source.length) {
break
}
val combinator = if (combinatorParser.prefix.contains(source[i])) {
val combinatorResult = combinatorParser(source, i)
i += combinatorResult.length
i += whiteCharStrictParser(source, i).length
Expand Down
16 changes: 11 additions & 5 deletions selector/src/jvmTest/kotlin/li/songe/selector/ParserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,9 @@ class ParserTest {
}

@Test
fun check_query(){
fun check_query() {
val projectCwd = File("../").absolutePath
val text =
"@TextView[text^='跳过'] + LinearLayout TextView[text*=`跳转`]"
val text = "@TextView[text^='跳过'] + LinearLayout TextView[text*=`跳转`]"
val selector = Selector.parse(text)
println("selector: $selector")
println(selector.trackIndex)
Expand All @@ -94,8 +93,8 @@ class ParserTest {
}
}
val transform = Transform<TestNode>(getAttr = { node, name ->
if (name=="_id") return@Transform node.id
if (name=="_pid") return@Transform node.pid
if (name == "_id") return@Transform node.id
if (name == "_pid") return@Transform node.pid
val value = node.attr[name] ?: return@Transform null
if (value is JsonNull) return@Transform null
value.intOrNull ?: value.booleanOrNull ?: value.content
Expand All @@ -106,4 +105,11 @@ class ParserTest {
println("target_size: " + targets.size)
println(targets.firstOrNull())
}

@Test
fun check_quote() {
// https://github.com/gkd-kit/inspect/issues/7
val selector = Selector.parse("a[a=''] ")
println("check_quote:$selector")
}
}