identity

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

func (*Scope) Key

func (s *Scope) Key() string

Key names the project a scope binds to, for scope-equality grouping.

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

func Build(model *semantics.Model, res *resolve.Resolver, roots ...*symbols.Scope) *Table

Build computes the identity side table of every named symbol under the given roots, in root order.

func (*Table) Info

func (t *Table) Info(sym *symbols.Symbol) (*Info, bool)

Info returns the identity of sym, if the table holds it.

func (*Table) Symbols

func (t *Table) Symbols() []*symbols.Symbol

Symbols returns the table's symbols in deterministic walk order.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL