[kyo-data] add Glob - #1856
Conversation
…d CHANGELOG entry The kyo-data README asserted Path.list(glob) and Path.walk(glob) signatures that do not exist. Rewrite the paragraph to state the integration intent without asserting a signature. Also add the missing CHANGELOG entry for Glob.
| override def timeout = Duration.fromJava(java.time.Duration.ofMinutes(3)) | ||
|
|
||
| "allSymbols.count(isGiven) ~= 570 on standard classpath" in { | ||
| "allSymbols.count(isGiven) ~= 576 on standard classpath" in { |
There was a problem hiding this comment.
we should change kyo-tasty tests to work with a fixed classpath
There was a problem hiding this comment.
Agreed, that range assertion is going to keep drifting as the classpath changes. Pinning the tests to a fixed classpath means putting together a stable jar set and rewiring TestClasspaths, which feels like its own PR rather than more off-topic weight on this one. I can do it as a follow-up right after this lands, or in this PR if you prefer.
| * @see [[Glob.all]] | ||
| * @see [[Glob.CaseSensitivity]] | ||
| */ | ||
| opaque type Glob = Glob.Compiled |
There was a problem hiding this comment.
Could we make Glob.Compile the Glob itself?
There was a problem hiding this comment.
Done in 8a121cc. Glob is now the final case class directly, with show and both matches overloads as members; the opaque alias and the Compiled wrapper are gone. Construction stays private[kyo], so the public surface is unchanged.
| case Result.Failure(error) => | ||
| quotes.reflect.report.errorAndAbort(s"invalid glob at offset ${error.offset}: ${error.reason}") | ||
| case Result.Panic(error) => throw error | ||
| case Result.Success(glob) => Glob.expression(glob) |
| * @param reason | ||
| * explanation of the invalid syntax | ||
| */ | ||
| final case class ParseError(offset: Int, reason: String)(using Frame) |
There was a problem hiding this comment.
when printing to the console, this will show up as just ParseError. Can you rename to GlobParseException? "error" can be confused with Java's Error as well
There was a problem hiding this comment.
Renamed to GlobParseException in 8a121cc, hoisted to a top-level type beside Glob so the qualified form does not stutter. kyo-dataJVM and JS suites plus the README doctest are green on the branch.
…ailure From review: the opaque alias over a private Compiled case class added a level of indirection with no hiding benefit, since the constructor and fields were already private[kyo]. Glob is now the final case class directly, carrying show and the two matches overloads as members, with the same equality and the same private construction surface. ParseError becomes GlobParseException, a top-level type beside Glob. A console line now names the failure unambiguously, and the name no longer invites confusion with java.lang.Error or the unrelated ParseError types in kyo-parse and kyo-doctest.
Summary
Glob, a compiled and platform-independent matcher for slash-separated paths*,?, complete-segment**, character classes, alternatives, and escapingGlob.ParseErroraKyoExceptionwith callerFramecontextGlob.showandRender[Glob]glob"..."literals into a versioned embedded automaton without runtime parsing or compilationStack
This is the first PR in the native GitHub stack:
Verification
The 27 shared Glob tests pass on JVM, JavaScript, Native, and Wasm, including an externally consumed 4,096-character literal. The JVM bytecode regression test confirms generated literals call
GlobLiteral.fromEncodedV1and do not callGlob.parse. The completekyo-dataJVM/testsuite, thekyo-dataREADME doctest, and scalafmt checks also pass.