feat(solid_generator): cross-instance @SolidQuery consumption in build() - #112
Merged
Merged
Conversation
…build() Let a widget's build() read another class's @SolidQuery method through a constructor-injected or @SolidEnvironment field (e.g. viewModel.customers()) and get a SignalBuilder wrap + flutter_solidart import, matching the cross-instance @SolidState support that already existed. Adds a new classQueryNames cross-class registry (query counterpart of classRegistry), threaded through the build-method rewrite path only; call sites stay byte-identical since the lowered call still resolves through Resource<T>.call(). Hardens the new registry with the same origin/library-URI disambiguation (#110-style) the @SolidState registry already has, so a same-simple-name collision across two imported files can't cause a wrong-class match. Adds two golden fixtures: a pure-consumer widget cross-instance query read, and a same-name-collision disambiguation case proving the real query gets wrapped while a same-named non-query method on a different class does not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A widget's
build()can now read another class's@SolidQuerymethod cross-instance — e.g. a view reading its injected view model's query:Previously only the class declaring a
@SolidQuerycould consume it, even though cross-instance@SolidStatereads already worked. Such a cross-instance query read got noSignalBuilderwrap (not reactive) and noflutter_solidartimport (theResourceStateextension accessors did not resolve).How
classQueryNames), populated for every query-bearing class including pure-query classes with no@SolidStatemembers.value_rewriterrecognizesreceiver.query()(receiver's resolved type is a query-bearing class) as a tracked read — recording the offset only, with no source edit, so thequery()call site and thequery.refreshtear-off stay byte-identical. The existingcomputeWrapPlanthen wraps the enclosing widget subtree, and the import is spliced in off the emitted-wrap flag.@SolidStateregistry (Name-keyed registry cannot disambiguate a local plain class from a foreign reactive class with the same name #110 parity): an ambiguous simple name resolves only on a receiver's resolved-library match, so a same-named non-query method is never spuriously tracked.Tests
cross_file_pure_consumer_widget_query(the core feature) andcross_file_query_qualified_registry_disambiguation(proves a real query is wrapped while a same-named ordinary method on a different class is not), plus idempotency checks.Releases
solid_generator3.0.0-dev.6.