Module: lib/compiler/atlas/build

Turns what the compiler already knows into Atlas nodes and edges.

Nothing in this module re-reads or re-parses a file the compiler has already handled. addComponentUnit is handed the exact objects ComponentParser.parse produced on its way to generating a class; addBridgeUnit is handed the descriptor analyzeBridge produced on its way to emitting a bridge. That is the whole design intent: Atlas is retention, not a second analysis pass.

The one thing it does read for itself is the template — and only because the template the compiler validates has already been rewritten past the point where offsets mean anything. See source.js.

Source:

Members

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

Node kinds that own members.

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

Methods

(static) addBridgeUnit(model, descriptor, context) → {string}

Adds a bridge and everything it declares to the model.

Parameters:
Name Type Description
model object

The AppModel being built.

descriptor object

A descriptor from analyzeBridge.

context object

{rootDir, source, bridges}.

Source:
Returns:

The bridge's node id.

Type
string

(static) addComponentUnit(model, unit) → {string}

Adds a component or page and everything it declares to the model.

Parameters:
Name Type Description
model object

The AppModel being built.

unit object

Everything ComponentParser already extracted.

Properties
Name Type Attributes Description
name string

The class name.

kind string

component or page.

filePath string

Absolute path to the source file.

rootDir string

The project root.

content string

The original source, before any transformation.

state object

Declared state.

computed object

Computed expressions by name.

methods object

Action bodies by name.

resources object

Resource declarations by name.

contracts Set:.<string:> <optional>

Declared contracts.

actionModifiers Object:.<string:, object:> <optional>

Rewind modifiers by action name.

bridgeBindings Array:.<object:> <optional>

Imported bridges.

bridges Map:.<string:, object:> <optional>

Every bridge, by absolute path.

Source:
Returns:

The unit's node id.

Type
string

(static) addRenderEdges(model, unit) → {void}

Records which components a template renders.

Kept separate from the expression walk because the compiler resolves child components by class name after every component has been discovered, so this runs once the model knows what exists.

Parameters:
Name Type Description
model object

The AppModel being built.

unit object

{ownerId, content, file, known} where known maps a class name to its node id.

Source:
Returns:
Type
void

(static) analyzeExpression(model, options) → {void}

Records the edges one scanned expression implies.

Shared by every expression site — computed, action, resource, template binding, event handler, bridge member — so that a read means the same thing wherever it was written.

Parameters:
Name Type Description
model object

The AppModel being built.

options object

The analysis site.

Properties
Name Type Attributes Description
from string

The node id the expression belongs to.

code string

The expression source.

scope object

The resolution scope.

loc object

{file, line, column} of the site.

writeBack boolean <optional>

Treat reads as read-and-write, for two-way bindings.

Source:
Returns:
Type
void

(static) isOwnerKind(kind) → {boolean}

Whether a node kind owns members.

Parameters:
Name Type Description
kind string

A node kind.

Source:
Returns:

True for components, pages and bridges.

Type
boolean

(static) relativePath(filePath, rootDir) → {string}

Converts a project-absolute path to the form Atlas reports.

Parameters:
Name Type Description
filePath string

An absolute path.

rootDir string

The project root.

Source:
Returns:

A root-relative, forward-slashed path.

Type
string

(inner) addTemplateRelationships(model, unit) → {void}

Walks a component's template and records what each construct relates to.

Runs over the masked original source, so every node's location is the line and column the developer wrote, not an offset into a rewritten string.

Parameters:
Name Type Description
model object

The AppModel being built.

unit object

The component context.

Source:
Returns:
Type
void

(inner) findBridgeDescriptor(bridges, name) → {object|null}

Finds a bridge descriptor by declared name.

Parameters:
Name Type Description
bridges Map:.<string:, object:> | undefined

Descriptors by absolute path.

name string

The bridge's declared name.

Source:
Returns:

The descriptor.

Type
object | null

(inner) recordRewindEffects(model, nodeIdentifier, body, baseLine) → {void}

Records what a rewind of this action could not undo.

Scanned here, where the body is in hand, rather than in the diagnostics pass: the findings are a few objects per atomic action, and keeping them on the node means the diagnostic never has to re-read a file the compiler has already read — and means the cached fragment carries them too.

Only atomic actions are scanned. An ordinary action has nothing to report, because nothing is claiming its effects will be undone.

Parameters:
Name Type Description
model object

The AppModel being built.

nodeIdentifier string

The action's node id.

body string

The action body source.

baseLine number

The line the body starts on in its file.

Source:
Returns:
Type
void

(inner) recordSubscriptions(model, options) → {void}

Records bridge.on('event', …) subscriptions.

The compiler already extracts these to warn about events a bridge never emits (AVX_W38). Atlas keeps the relationship rather than only the warning.

Parameters:
Name Type Description
model object

The AppModel being built.

options object

{from, body, importedBridges, file, line}.

Source:
Returns:
Type
void

(inner) targetId(target) → {string}

Maps a resolved target descriptor to a node id.

Parameters:
Name Type Description
target object

{kind, owner, name} from resolveReference.

Source:
Returns:

The node id.

Type
string