Documentation
¶
Overview ¶
Package identity computes the effective repository identity of the symbols of an analyzed model: the id of an element's IdentityMetadata::ElementId annotation when it carries one, the id derived from its qualified name otherwise, plus the project scope its nearest enclosing ProjectRef declares. It is a side table keyed by symbol; the AST is never touched.
Index ¶
Constants ¶
const ( ElementIdFQN = "IdentityMetadata::ElementId" ProjectRefFQN = "IdentityMetadata::ProjectRef" )
FQNs of the identity metadata definitions in the bundled library.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Declaration ¶
type Declaration struct {
// ID is the annotation's evaluated id; meaningful when Declared.
ID string
// Declared reports the id evaluated to a constant string.
Declared bool
// About marks an `about`-form annotation stated away from the element.
About bool
// Node is the annotating node itself, so a consumer that absorbs the
// annotation into identity can identify it in the tree.
Node ast.Node
// Span locates the annotating node, for diagnostics.
Span source.Span
// Scope is where the annotating node is declared; for an `about`-form
// annotation that may be another document than the element's.
Scope *symbols.Scope
}
Declaration is one ElementId annotation of an element, whether written inline (`@ElementId {...}`) or from elsewhere (`metadata : ElementId about x;`).
type Info ¶
type Info struct {
Symbol *symbols.Symbol
// FQN is the symbol's qualified name, which the derived id encodes.
FQN string
// EffectiveID is the annotated id when declared, the derived id otherwise.
EffectiveID string
// Annotated reports an ElementId annotation on the element.
Annotated bool
// Declared reports that the annotation's id evaluated to a constant
// string; when false the derived id stands.
Declared bool
// DeclaredID is the evaluated ElementId id, possibly empty.
DeclaredID string
// AnnotationSpan locates the ElementId annotation, for diagnostics.
AnnotationSpan source.Span
// Declarations lists every ElementId annotation of the element, inline
// ones first, `about`-form ones after.
Declarations []Declaration
// Scope is the nearest enclosing ProjectRef binding; nil when unbound.
Scope *Scope
}
Info is one symbol's identity: its effective id, whether an ElementId annotation declared it, and the project scope it resolves against.
type Scope ¶
type Scope struct {
ProjectID string
Branch string
Org string
// Symbol is the namespace carrying the ProjectRef annotation.
Symbol *symbols.Symbol
// Declarations lists every ProjectRef annotation of the namespace, inline
// ones first, `about`-form ones after. The first supplies the binding.
Declarations []ScopeDeclaration
}
Scope is one ProjectRef annotation's project binding. Two scopes name the same project when org and projectId agree; branch selects a version of one project, never another identity, so it plays no part in equality.
type ScopeDeclaration ¶
type ScopeDeclaration struct {
ProjectID string
Branch string
Org string
// Node is the annotating node itself, so a consumer that absorbs the
// annotation into provenance can identify it in the tree.
Node ast.Node
// Span locates the annotating node, for diagnostics.
Span source.Span
// Scope is where the annotating node is declared.
Scope *symbols.Scope
}
ScopeDeclaration is one ProjectRef annotation of a namespace, whether written inline or from elsewhere with an `about` clause.
func (ScopeDeclaration) Key ¶
func (d ScopeDeclaration) Key() string
Key names the project a declaration binds to; branch selects a version of one project, never another identity, so it plays no part.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is the identity side table of one analyzed scope tree.
func Build ¶
Build computes the identity side table of every named symbol under the given roots, in root order.