Module: lib/compiler/atlas/diagnostics

The findings Atlas can safely derive from the model.

Both diagnostics here are absence claims — "nothing reads this", "nothing invokes this" — and an absence claim is only as good as the completeness of the search behind it. Atlas knows exactly where its search was incomplete, because it recorded every relationship it could not resolve, so each rule checks that record before concluding anything.

The rule this file exists to enforce: a diagnostic must never conclude "never read" from a body the analyser could not follow. A false AVX_W40 on a state key that is read through a computed member would teach a developer to stop trusting the whole feature, which costs far more than the warnings it suppresses.

Source:

Members

(static, constant) RUNTIME_INVOKED_ACTIONS :Set:.<string:>

Actions the runtime calls by name, so nothing in a template needs to.

AvenxComponent looks each of these up in the component's own methods when the corresponding lifecycle moment arrives (see #runHooks), which means an <action name="onMount"> is reachable even though no call site exists.

Type:
  • Set:.<string:>
Source:

(inner, constant) BLOCKING_REASONS :Set:.<string:>

Unresolved reasons that could be concealing the very relationship a diagnostic is about to claim does not exist.

A dynamic member could be the read. A shadowed identifier means a body was not followed. A spread could carry the value out. An unknown identifier could be the missing link. None of them can be ruled out, so none of them may be ignored.

Type:
  • Set:.<string:>
Source:

Methods

(static) analysisIsComplete(model, target) → {boolean}

Whether analysis was complete enough to make an absence claim about a node.

Parameters:
Name Type Description
model object

The model.

target object

The node being reasoned about.

Source:
Returns:

True when nothing unresolved could be hiding the relationship.

Type
boolean

(static) findUnreachableActions(model) → {Array:.<object:>}

Finds actions no supported invocation surface can reach.

The surfaces are the ones the compiler can see: a template handler or binding, another action, a computed, a resource, a guard, a bridge member, and the lifecycle names the runtime calls by itself.

Parameters:
Name Type Description
model object

The model.

Source:
Returns:

Findings, each with the unreachable action node.

Type
Array:.<object:>

(static) findUnreadState(model) → {Array:.<object:>}

Finds state that nothing in the application reads.

Parameters:
Name Type Description
model object

The model.

Source:
Returns:

Findings, each with the node and its writers.

Type
Array:.<object:>

(static) reportAtlasDiagnostics(model, configopt) → {Object}

Reports Atlas findings through the compiler's warning machinery.

Routed through reportWarning so both codes honour the warnings setting in avenx.config.json — including being escalated to build failures — and appear in avenx check --json like every other diagnostic.

Parameters:
Name Type Attributes Description
model object

The model.

config object <optional>

The project configuration.

Source:
Returns:

What was reported.

Type
Object

(inner) blockingUnits(model, target) → {Set:.<string:>}

The units whose incomplete analysis could hide a relationship to target.

For a component's own state that is the component itself. For a bridge's state or actions it is the bridge plus every unit that imports it, directly or through another bridge — anywhere a consumer could be reaching the member in a way the analyser could not follow.

Parameters:
Name Type Description
model object

The model.

target object

The node being reasoned about.

Source:
Returns:

Unit ids whose unresolved entries block a conclusion.

Type
Set:.<string:>

(inner) inUnimportedBridge(model, node) → {boolean}

Whether a node belongs to a bridge that nothing imports.

Such a bridge is already reported, once, as omitted from the bundle. Adding a warning for every state key and action inside it piles noise on a fact that has been stated — and it fires on a freshly scaffolded bridge, before the developer has had a chance to import it, which is the worst possible first impression for a diagnostic. Once something imports the bridge, its members are worth checking individually again.

Parameters:
Name Type Description
model object

The model.

node object

The node being reasoned about.

Source:
Returns:

True when the owning bridge has no consumers.

Type
boolean

(inner) ownerName(model, ownerId) → {string}

Formats an owner id for a message: bridge:cart reads as cart.

Parameters:
Name Type Description
model object

The model.

ownerId string | null | undefined

The owner node id.

Source:
Returns:

A display name.

Type
string

(inner) unitOf(model, siteId) → {string|null}

Resolves the unit an expression site belongs to.

Parameters:
Name Type Description
model object

The model.

siteId string

A node id recorded as an unresolved entry's owner.

Source:
Returns:

The owning component, page or bridge id.

Type
string | null