Skip to content

feat(solid_generator): cross-instance @SolidQuery consumption in build() - #112

Merged
nank1ro merged 2 commits into
mainfrom
feat/cross-instance-query-consumption
Aug 28, 2026
Merged

nank1ro merged 2 commits into
mainfrom
feat/cross-instance-query-consumption

Conversation

@nank1ro

@nank1ro nank1ro commented Aug 28, 2026

Copy link
Copy Markdown
Owner

What

A widget's build() can now read another class's @SolidQuery method cross-instance — e.g. a view reading its injected view model's query:

isLoading: viewModel.customers().isLoading,
error: viewModel.customers().asError?.error,
totalCount: viewModel.customers().asReady?.value.length ?? 0,
onRetry: viewModel.customers.refresh,

Previously only the class declaring a @SolidQuery could consume it, even though cross-instance @SolidState reads already worked. Such a cross-instance query read got no SignalBuilder wrap (not reactive) and no flutter_solidart import (the ResourceState extension accessors did not resolve).

How

  • New cross-file query-name registry (classQueryNames), populated for every query-bearing class including pure-query classes with no @SolidState members.
  • value_rewriter recognizes receiver.query() (receiver's resolved type is a query-bearing class) as a tracked read — recording the offset only, with no source edit, so the query() call site and the query.refresh tear-off stay byte-identical. The existing computeWrapPlan then wraps the enclosing widget subtree, and the import is spliced in off the emitted-wrap flag.
  • The registry is origin-qualified exactly like the @SolidState registry (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

  • New golden cross_file_pure_consumer_widget_query (the core feature) and cross_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.
  • Full suite green: 356 tests pass.

Releases solid_generator 3.0.0-dev.6.

…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.
@nank1ro
nank1ro merged commit d93f3ea into main Aug 28, 2026
1 check passed
@nank1ro
nank1ro deleted the feat/cross-instance-query-consumption branch August 28, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant