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
- Variables
- func DerivedID(namespace, name string) string
- func ElementID(lang Language, qualifiedName string) string
- func ElementIdAbout(path, id string) string
- func ElementIdInline(id string) string
- func EscapeName(name string) string
- func LibraryVersion(model *semantics.Model, res *resolve.Resolver, name string) string
- func NamespaceOf(name string) string
- func OwningMembershipID(lang Language, qualifiedName string) string
- func ProjectRefAbout(path, projectID string) string
- func ProjectRefInline(projectID string) string
- func Root(sym *symbols.Symbol) *symbols.Symbol
- func RootPackageNames(root *ast.RootNamespace) (names []string, ok bool)
- func UnresolvedElementID(qualifiedName string) string
- type Catalog
- func (c *Catalog) DocumentKind(doc string) source.Kind
- func (c *Catalog) DocumentRootedAt(roots []LibraryRoot) string
- func (c *Catalog) Element(id string) (*LibraryElement, bool)
- func (c *Catalog) ElementNamed(fqn string) (*LibraryElement, bool)
- func (c *Catalog) Elements() []*LibraryElement
- func (c *Catalog) NamesEveryRoot(root *ast.RootNamespace) bool
- func (c *Catalog) OwningMembership(id string) (*LibraryElement, bool)
- func (c *Catalog) RootNamed(fqn string) (*LibraryElement, bool)
- func (c *Catalog) VersionOf(model *semantics.Model, res *resolve.Resolver, name string) string
- type Declaration
- type Info
- type Language
- type LibraryElement
- type LibraryRoot
- type Scope
- type ScopeDeclaration
- type Source
- type Table
Constants ¶
const ( ElementIdFQN = "IdentityMetadata::ElementId" ProjectRefFQN = "IdentityMetadata::ProjectRef" )
FQNs of the identity metadata definitions in the bundled library.
const Separator = "::"
Separator joins the segments of a qualified name.
Variables ¶
var NamespaceOID = mustParse("6ba7b812-9dad-11d1-80b4-00c04fd430c8")
NamespaceOID is the RFC 4122 name space for OIDs, under which the pilot and toolkit mint the ids of references that resolved to no library element.
var NamespaceURL = mustParse("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
NamespaceURL is the RFC 4122 name space for URLs, the root of every library id.
Functions ¶
func ElementID ¶
ElementID is the normative id of the library element with the given qualified name (segments as declared, the first its library package); "" for none.
func ElementIdAbout ¶
ElementIdAbout renders a standalone ElementId annotation naming its element by the qualified path that resolves to it where the annotation is written.
func ElementIdInline ¶
ElementIdInline renders an ElementId annotation for the body of the element it identifies.
func EscapeName ¶
EscapeName spells a name as the pilot's qualified names do: an ASCII identifier or `$` as is, anything else single-quoted with control and quote characters escaped.
func LibraryVersion ¶
LibraryVersion is the bundled library document the named indexed document is a version of, judged against the library the index holds apart from it: over a base, a copy indexed under a library file's own name is judged against that file.
func NamespaceOf ¶
NamespaceOf is the uuid5 id namespace minted under the URL name space for name — the root a document's uuid element ids derive under.
func OwningMembershipID ¶
OwningMembershipID is the normative id of the OwningMembership owning the library element with the given qualified name, a library package included.
func ProjectRefAbout ¶
ProjectRefAbout renders a standalone ProjectRef annotation naming the namespace it binds by qualified path.
func ProjectRefInline ¶
ProjectRefInline renders a ProjectRef annotation for the body of the namespace it binds.
func Root ¶
Root is the outermost declaration enclosing sym, sym itself at a root; a ProjectRef written there binds sym's whole document subtree.
func RootPackageNames ¶
func RootPackageNames(root *ast.RootNamespace) (names []string, ok bool)
RootPackageNames lists the declared names of the parsed document's roots when every one is a package; ok is false for no document or a root that is not one.
func UnresolvedElementID ¶
UnresolvedElementID is the id an interchange document mints for a name that resolved to nothing: uuid5(NamespaceOID, "unresolved:"+qualifiedName).
Types ¶
type Catalog ¶
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; roots holds every library document's top-level packages, id or none, and kinds each document's language.
func LibraryCatalog ¶
LibraryCatalog is the catalog of the library idx holds, shared by every overlay that shows its base's library documents as the base does.
func (*Catalog) DocumentKind ¶
DocumentKind is the language the named library document is written in.
func (*Catalog) DocumentRootedAt ¶
func (c *Catalog) DocumentRootedAt(roots []LibraryRoot) string
DocumentRootedAt is the library document declaring every root as a top-level package under its name and its id, or with its package keywords where none is stated; "" when the roots are not one library document's.
func (*Catalog) Element ¶
func (c *Catalog) Element(id string) (*LibraryElement, bool)
Element is the library element whose normative id is id.
func (*Catalog) ElementNamed ¶
func (c *Catalog) ElementNamed(fqn string) (*LibraryElement, bool)
ElementNamed is the library element whose qualified name is fqn.
func (*Catalog) Elements ¶
func (c *Catalog) Elements() []*LibraryElement
Elements lists the catalogued elements in library walk order.
func (*Catalog) NamesEveryRoot ¶
func (c *Catalog) NamesEveryRoot(root *ast.RootNamespace) bool
NamesEveryRoot reports whether every root of the parsed document is a package named as a library document's top-level package: the cheap test a document must pass before DocumentRootedAt is worth asking, and one a user file rarely does.
func (*Catalog) OwningMembership ¶
func (c *Catalog) OwningMembership(id string) (*LibraryElement, bool)
OwningMembership is the library element whose owning membership has normative id id.
func (*Catalog) RootNamed ¶
func (c *Catalog) RootNamed(fqn string) (*LibraryElement, bool)
RootNamed is the top-level package of a library document named fqn; its ID is "" when the document's tier has no normative language. A name more than one library document declares at its top names no single document, so it is not found.
func (*Catalog) VersionOf ¶
VersionOf is the catalogued library document the named indexed document is a version of (see DocumentRootedAt); a root's id is the one an annotation declares, since an unannotated package states none. The document must be indexed unmarked, so its roots read as the user's declarations, and in the library document's language, which is what its text was parsed as.
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 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 ¶
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) OwningMembershipID ¶
OwningMembershipID is the normative id of the membership owning a standard library element; "" for any other, whose membership id derives from its own.
type Language ¶
type Language uint8
Language is the half of the standard library an element belongs to, which picks the prefix its library package's id is minted under.
func LibraryLanguage ¶
func LibraryLanguage(tier symbols.LibraryTier) (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.
type LibraryElement ¶
type LibraryElement struct {
Symbol *symbols.Symbol
FQN string
Language 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 LibraryRoot ¶
type LibraryRoot struct {
QName, ID string
// Pkg reports a root written as a package; Library and Standard are its keywords.
Pkg, Library, Standard bool
}
LibraryRoot is one root of a document, as library recognition reads it: its qualified name, the id it states ("" for none), and how it is declared.
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.