Skip to main content

Module provider_stub

Module provider_stub 

Source
Expand description

#2100 slice 4: generate a provider stub. For a capability declared in this file that nothing in its context provides, the action scaffolds provides Cap = CapImpl { … } right below the declaration, with every operation’s signature copied and its body a typed default.

It is offered as a quick fix on bynk.exports.capability_not_provided (an exported capability with no provider) and on bynk.capability.not_provided (a required capability with no provider), and as a refactor with the cursor on the capability’s name. The editor’s analysis runs as the bundle target, so it raises bynk.capability.not_provided only in a bundle with a composition root (compose.ts), as bynk check does; the Workers form, raised for every context on --target workers, never reaches the editor. So the refactor is what covers a required capability elsewhere.

The language has no placeholder expression, so a stub body must be a value that type-checks (DECISION B re-checks the edit). Each body is a default of the operation’s return type: the unrefined scalars, (), None, [], or one of those inside an Effect. A capability with an operation returning anything else (a record, a user sum, a Result) gets no action. So does a derived capability, one declared outside a context, or one with generic operations (whose type parameters the stub would have to repeat).

Whether a capability already has a provider is read from the committed index’s implementation edges, so a provider in a sibling file counts. Like fill-arms, the action is listed without an edit, and codeAction/resolve computes and re-checks it. A bynk-fmt-canonical file is re-formatted and the edit narrowed to the changed region.

Structs§

Plan
A planned stub: the capability, the provider’s name, and the edits.
Request
One capability the request points at, and how: through a “no provider” diagnostic (a quick fix) or its declaration’s name (a refactor).
Target
What a listed stub action’s data names.

Functions§

listed
The listed (unresolved) action for plan.
plan
The stub for capability in text, or None when there is none to offer (see the module docs).
requested
The capabilities at requested, by diagnostic first, each named once.