Skip to main content

Module node

Module node 

Source
Expand description

Code node representation.

A CodeNode is our abstraction over raw AST nodes. It captures the semantically meaningful parts of code: what it is, where it lives, and enough metadata to be useful for graph construction.

Structs§

CodeNode
A code entity extracted from source.

Enums§

NodeKind
The kind of code entity this node represents.
TypeRelationKind
A type relationship stored on a node until the graph builder resolves it.
Visibility
Visibility of a code entity.

Constants§

EXTENDS_REF_PREFIX
Prefix on CodeNode::references for a superclass name.
FIELD_REF_PREFIX
Prefix for a field’s type stored on a struct node: field:draft:Draft.
IMPLEMENTS_REF_PREFIX
Prefix on CodeNode::references for an implemented interface or trait.
IMPORT_ALIAS_REF_PREFIX
Prefix on an import node’s references for a name imported under another name: alias:to_minor:money_to_minor_units for from money import money_to_minor_units as to_minor.
LOCAL_BINDING_REF_PREFIX
Prefix for a name the file binds itself (a variable, a parameter, a destructured value), recorded on an import node with an empty module.
MODULE_FILE_REF
A reference on the empty-module import node of a JavaScript or TypeScript file that is a module: it has a top-level import or export statement (TypeScript draws the line the same way), or a top-level CommonJS module.exports / exports.f assignment. A file without one is a script, whose top-level names are globals.
RETURNS_REF_PREFIX
Prefix for the type a function returns, stored on its node: returns:PreparedDraft for -> Option<mac::PreparedDraft>. Stripped like a field type, with Self already replaced by the impl type.
RUNTIME_BINDING_REF_PREFIX
Prefix for a name an import node records as bound at run time from a value its module produced: bound:setFilters:setFilters for const { setFilters } = useListFilters() after import { useListFilters } from "./hooks".

Functions§

clean_type_name
Strips pointers, references, and generic arguments from a type name.
field_ref
Encodes a struct field’s type as a reference.
field_type_ref
Splits a field:name:Type reference into the field name and its type.
import_alias
Splits an alias:local:imported reference into the local name and the imported name.
import_alias_ref
Encodes an aliased import as a reference on the import node.
import_qualified_name
The qualified name of an import node: its module, then the byte where the statement starts (./hooks@120). The node’s name stays the module.
local_binding
The name in a local:name reference.
local_binding_ref
Encodes a name the file binds itself.
return_type_ref
The return type recorded by a returns:Type reference.
returns_ref
Encodes a function’s (stripped) return type as a reference.
runtime_binding
Splits a bound:local:name reference into the local name and the name to look for in the module.
runtime_binding_ref
Encodes a name bound from a value its module produced.
type_relation_ref
Splits an extends: / implements: reference into its kind and type name.
typed_receiver
Splits a typed receiver reference into the method name and the receiver’s type path (Type or Type.field.field).
typed_receiver_ref
Encodes a method call whose receiver’s type is known from the code: .run_started@Draft, or .run_started@AppState.draft for a call on a field of a value of type AppState.