identity

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 9 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 normative UUID of a named standard library element, 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

func ElementIdAbout added in v0.5.0

func ElementIdAbout(path, id string) string

ElementIdAbout renders a standalone ElementId annotation naming its element by the qualified path that resolves to it where the annotation is written.

func ElementIdInline added in v0.5.0

func ElementIdInline(id string) string

ElementIdInline renders an ElementId annotation for the body of the element it identifies.

func LibraryLanguage added in v0.8.0

func LibraryLanguage(tier symbols.LibraryTier) (normative.Language, bool)

LibraryLanguage is the half of the standard library a bundled tier belongs to: Kernel is KerML, Systems and Domain are SysML; extensions and workspace are neither.

func ProjectRefAbout added in v0.5.0

func ProjectRefAbout(path, projectID string) string

ProjectRefAbout renders a standalone ProjectRef annotation naming the namespace it binds by qualified path.

func ProjectRefInline added in v0.5.0

func ProjectRefInline(projectID string) string

ProjectRefInline renders a ProjectRef annotation for the body of the namespace it binds.

func Root added in v0.5.0

func Root(sym *symbols.Symbol) *symbols.Symbol

Root is the outermost declaration enclosing sym, sym itself at a root; a ProjectRef written there binds sym's whole document subtree.

Types

type Catalog added in v0.8.0

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog indexes the normative ids of the bundled library by id: a version-5 UUID cannot be reversed, only looked up. Elements are indexed by name too.

func LibraryCatalog added in v0.8.0

func LibraryCatalog(idx *symbols.Index) *Catalog

LibraryCatalog is the catalog of the library idx holds, shared by every overlay over one base.

func (*Catalog) Element added in v0.8.0

func (c *Catalog) Element(id string) (*LibraryElement, bool)

Element is the library element whose normative id is id.

func (*Catalog) ElementNamed added in v0.8.0

func (c *Catalog) ElementNamed(fqn string) (*LibraryElement, bool)

ElementNamed is the library element whose qualified name is fqn.

func (*Catalog) Elements added in v0.8.0

func (c *Catalog) Elements() []*LibraryElement

Elements lists the catalogued elements in library walk order.

func (*Catalog) OwningMembership added in v0.8.0

func (c *Catalog) OwningMembership(id string) (*LibraryElement, bool)

OwningMembership is the library element whose owning membership has normative id id.

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 normative id of a
	// standard library element otherwise, the derived id failing both.
	EffectiveID string
	// Source is which of the three EffectiveID is.
	Source Source
	// Language is the library half a normative id is minted under; zero otherwise.
	Language normative.Language
	// 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, where it came from, and the project scope it resolves against.

func Of added in v0.5.0

func Of(model *semantics.Model, res *resolve.Resolver, sym *symbols.Symbol) (*Info, bool)

Of computes the identity of one symbol without building a whole table; ok is false for a symbol that has no qualified name to derive an id from.

func (*Info) Normative added in v0.8.0

func (i *Info) Normative() bool

Normative reports an effective id the norm fixes for the element.

func (*Info) OwningMembershipID added in v0.8.0

func (i *Info) OwningMembershipID() string

OwningMembershipID is the normative id of the membership owning a standard library element; "" for any other, whose membership id derives from its own.

type LibraryElement added in v0.8.0

type LibraryElement struct {
	Symbol             *symbols.Symbol
	FQN                string
	Language           normative.Language
	ID                 string
	OwningMembershipID string
}

LibraryElement is one named element of the standard library and the ids the norm fixes for it and for the membership that owns it.

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 Source added in v0.8.0

type Source uint8

Source is where an element's effective id comes from.

const (
	// SourceDerived is the encoding of the qualified name, the default.
	SourceDerived Source = iota
	// SourceNormative is the UUID the norm fixes for a named standard library element.
	SourceNormative
	// SourceDeclared is the id an ElementId annotation declares.
	SourceDeclared
)

func (Source) String added in v0.8.0

func (s Source) String() string

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.

Directories

Path Synopsis
Package normative derives the name-based UUIDs (RFC 4122 v5) KerML fixes for the named elements of the standard library, as the SysML v2 pilot does:
Package normative derives the name-based UUIDs (RFC 4122 v5) KerML fixes for the named elements of the standard library, as the SysML v2 pilot does:

Jump to

Keyboard shortcuts

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