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 AliasMembershipID(ownerID, metaclass string, index int) string
- func AnonymousMemberID(ownerID, metaclass string, ordinal int) string
- func AnonymousMemberOwningMembershipID(ownerID, metaclass string, ordinal int) string
- 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 OwningMembershipMetaclass(model *semantics.Model, sym *symbols.Symbol) string
- func ProjectRefAbout(path, projectID string) string
- func ProjectRefInline(projectID string) string
- func QualifiedSegments(names []string) string
- func QuotedSegment(name string) string
- func Root(sym *symbols.Symbol) *symbols.Symbol
- func RootPackageNames(root *ast.RootNamespace) (names []string, ok bool)
- func Segment(name string) string
- func UnresolvedElementID(qualifiedName string) string
- type AliasMembership
- type AnonymousIndex
- type AnonymousMember
- 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) ElementForSymbol(sym *symbols.Symbol) (*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 ExtensionPrefix = "https://github.com/Open-MBEE/OpenSysML-Extensions-Library/"
ExtensionPrefix is the URL the OpenSysML extension-library package ids hash under: the libraries' upstream home, as the OMG libraries hash under their specification URL. Not the pilot's choice: loaded as a library directory, the pilot hashes any library under the SysML specification URL.
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 AliasMembershipID ¶ added in v0.13.0
AliasMembershipID is this implementation's id for the Membership of a library alias: uuid5 under its owner's id of metaclass and index among such memberships; the pilot publishes no rule for these.
func AnonymousMemberID ¶ added in v0.13.0
AnonymousMemberID is this implementation's id for an unnamed library member: uuid5 under its owner's id of metaclass and declaration ordinal; the pilot publishes no rule for these.
func AnonymousMemberOwningMembershipID ¶ added in v0.13.0
AnonymousMemberOwningMembershipID is the id of the OwningMembership owning the anonymous library member AnonymousMemberID names.
func ElementID ¶
ElementID is the fixed id of the library element with the given qualified name (segments as declared, the first its library package); "" for none. Normative for a KerML or SysML element, this implementation's for an OpenSysML one.
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 KerML 1.1 §8.3.2.1.2 escapedName does: an identifier or `$` as is, anything else, the empty name included, 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 fixed id of the OwningMembership owning the library element with the given qualified name, a library package included.
func OwningMembershipMetaclass ¶ added in v0.13.0
OwningMembershipMetaclass is the metaclass of the membership through which a library element's owner owns it (FeatureMembership, OwningMembership, …), or "".
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 QualifiedSegments ¶ added in v0.13.0
QualifiedSegments joins declared names, outermost first, as the qualified identity a derived element id encodes.
func QuotedSegment ¶ added in v0.13.0
QuotedSegment is a declared name as a quoted identity segment, its quote and backslash escaped, which Unquote reads back.
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 Segment ¶ added in v0.13.0
Segment is the identity segment of a declared name: quoted when it is empty or would otherwise read as an unnamed member's `@N` address or as several segments.
func UnresolvedElementID ¶
UnresolvedElementID is the id an interchange document mints for a name that resolved to nothing: uuid5(NamespaceOID, "unresolved:"+qualifiedName).
Types ¶
type AliasMembership ¶ added in v0.13.0
type AliasMembership struct {
Symbol *symbols.Symbol
Owner *LibraryElement
ID string
Path string
}
AliasMembership is the Membership a named library element owns for an alias: the id this implementation mints for it and the positional path the pilot's exporter keys it by.
func AliasMembershipOf ¶ added in v0.13.0
func AliasMembershipOf(model *semantics.Model, catalog *Catalog, sym *symbols.Symbol) (AliasMembership, bool)
AliasMembershipOf describes the membership of sym, an alias a named library element declares, placed among the owner's memberships of the same metaclass; ok is false for anything else.
type AnonymousIndex ¶ added in v0.13.0
type AnonymousIndex struct {
// contains filtered or unexported fields
}
AnonymousIndex finds the unnamed members of the bundled library by the ids this implementation mints for them, which a version-5 UUID cannot be reversed to.
func AnonymousMemberIndex ¶ added in v0.13.0
func AnonymousMemberIndex(model *semantics.Model, catalog *Catalog) *AnonymousIndex
AnonymousMemberIndex indexes every unnamed member a named element of catalog owns, declared or implied, by element id and by owning-membership id, and every alias membership by its id.
func (*AnonymousIndex) AliasMembership ¶ added in v0.13.0
func (i *AnonymousIndex) AliasMembership(id string) (AliasMembership, bool)
AliasMembership is the membership of a library alias with the given minted id.
func (*AnonymousIndex) Element ¶ added in v0.13.0
func (i *AnonymousIndex) Element(id string) (AnonymousMember, bool)
Element is the unnamed member with the given element id.
func (*AnonymousIndex) Member ¶ added in v0.13.0
func (i *AnonymousIndex) Member(sym *symbols.Symbol) (AnonymousMember, bool)
Member is the indexed unnamed member declared by sym, as AnonymousMemberOf derives it.
func (*AnonymousIndex) OwningMembership ¶ added in v0.13.0
func (i *AnonymousIndex) OwningMembership(id string) (AnonymousMember, bool)
OwningMembership is the unnamed member whose owning membership has the given id.
type AnonymousMember ¶ added in v0.13.0
type AnonymousMember struct {
Symbol *symbols.Symbol
Owner *LibraryElement
Metaclass string
MembershipMetaclass string
ID string
OwningMembershipID string
Path string
MembershipPath string
}
AnonymousMember is an unnamed member of a named library element: the ids this implementation mints for it and the positional paths that name it, in the form the pilot's exporter keys unnamed elements by (owner/Metaclass[i], i counting the owner's preceding owned elements, or relationships, of the same metaclass).
func AnonymousMemberOf ¶ added in v0.13.0
func AnonymousMemberOf(model *semantics.Model, catalog *Catalog, sym *symbols.Symbol) (AnonymousMember, bool)
AnonymousMemberOf describes sym, an unnamed member (declared or implied) a named library element owns, placed by the owner's ownedMember order; ok is false for a named symbol — a parameter named by the one its position redefines included — or an anonymous owner.
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 LibraryCatalogWithOpenSysML ¶ added in v0.11.0
LibraryCatalogWithOpenSysML combines normative and OpenSysML extension IDs for graph and API-JSON serialization without changing the normative catalog.
func OpenSysMLLibraryCatalog ¶ added in v0.11.0
OpenSysMLLibraryCatalog catalogs the bundled OpenSysML extension elements separately from elements whose IDs are verified by the normative library XMI.
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) ElementForSymbol ¶ added in v0.11.0
func (c *Catalog) ElementForSymbol(sym *symbols.Symbol) (*LibraryElement, bool)
ElementForSymbol is the catalogued library element declared by sym.
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 fixed id of a bundled
// library element otherwise, the derived id failing both.
EffectiveID string
// Source is which of the four EffectiveID is.
Source Source
// Language is the library a fixed id is minted under; zero otherwise.
Language Language
// MembershipID is the id this implementation mints for the owning membership
// of an unnamed library member; "" where the membership id follows the name.
MembershipID 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, 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) Fixed ¶ added in v0.11.0
Fixed reports an effective id a bundled library fixes for the element: the norm's for a standard library element, this implementation's for an extension's.
func (*Info) OwningMembershipID ¶
OwningMembershipID is the fixed id of the membership owning a bundled 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 library a bundled tier's ids are fixed under: Kernel is KerML, Systems and Domain are SysML, this implementation's extensions are OpenSysML; an unplaced library tier and the workspace are none.
type LibraryElement ¶
type LibraryElement struct {
Symbol *symbols.Symbol
FQN string
Language Language
ID string
OwningMembershipID string
}
LibraryElement is one named element of a bundled library and the ids fixed for it and for the membership that owns it: the norm's for the standard library, this implementation's for its extension libraries.
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 Source ¶
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 // SourceExtension is the UUID this implementation fixes for a named element // of its own extension libraries, derived as a normative id under their URL. SourceExtension )
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.