Add event details and subscriber APIs - #49
Conversation
71f3adc to
f2cd55d
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f2cd55d091
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR extends the SwiftLexicon event system by introducing a bracketed K/EventDetail representation (including parsing), adding an Events.Subscriber helper for managing subscriptions, and updating SwiftUI integration to use the new subscription model. It also removes the prior “throw String” error fallback across the repo by introducing a dedicated LexiconError, and tightens TaskPaper parsing via explicit options.
Changes:
- Add
EventDetail+ bracketedKrendering/parsing, plus updated JSON event description behavior for stable nested JSON rendering. - Introduce
Events.Subscriberand refactor SwiftUI event hooks (events(...),onEvent,onEvents) to avoid duplicate subscriptions. - Replace
String: Errorusage withLexiconError, and addTaskPaper.Optionsto gate “plain text outline” lemma parsing.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Sources/Lexicon/util/String.swift | Introduces LexiconError and removes String-as-Error fallback. |
| Sources/Lexicon/util/Optional.swift | Updates thrown errors to use LexiconError. |
| Sources/Lexicon/TaskPaper.swift | Adds TaskPaper.Options and makes lemma-colon requirements configurable. |
| Sources/SwiftLexicon/K.swift | Adds bracketed K string output, EventDetail, and bracketed parsing. |
| Sources/SwiftLexicon/Event.swift | Adds Event.detail; changes JSON event description formatting for arrays/objects. |
| Sources/SwiftLexicon/Events.swift | Adds Events.Subscriber, makes Events Identifiable, and makes EventSubscription.cancel() idempotent. |
| Sources/SwiftLexicon/SwiftUI.swift | Refactors SwiftUI event environment + modifiers to use Events.Subscriber. |
| Tests/SwiftLexiconTests/* | Adds coverage for bracketed parsing, subscriber behavior, and SwiftUI hooks. |
| Tests/LexiconTests/* | Updates tests to throw LexiconError; refactors CLI replay to use EventDetail(bracketed:); adds TaskPaper option tests; adds string sorting tests. |
| Tests/LexiconGeneratorsTests/* | Updates generator tests’ error throwing and resource loading to use LexiconError. |
| Sources/lexicon-generate/CodeGenerator.swift | Uses LexiconError for conflict reporting. |
| Package.swift | Adds SwiftLexicon dependency to LexiconTests. |
Comments suppressed due to low confidence (2)
Tests/LexiconTests/CLI™.swift:99
failureErrordoesn’t throw, sothrow try failureError(...)is unnecessary (and becomes a warning/error under stricter settings).
Tests/LexiconTests/CLI™.swift:105failureErroris declaredthrowsand usestry LexiconError(...), butLexiconError’s initializer is non-throwing. Droppingthrows/tryavoids unnecessary error-handling noise.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
03124c1 to
c685cf5
Compare
c685cf5 to
760a19c
Compare
Adds bracketed
K/EventDetailparsing, anEvents.Subscriberabstraction, and refreshed SwiftUI event hooks. Also removes the string-as-error fallback and tightens TaskPaper parsing options.Validation:
swift test --filter KBracketedTests --filter EventSubscriptionSetBuilderTests --filter EventSubscriberTests --filter SwiftUISupportTests --filter CLI™ --filter TaskPaper™ --filter StringSortingTests --filter GoGeneratorTests --filter RustGeneratorTests --filter LexiconLSPCommandTests --filter LexiconCLICommandTests