metamodel

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 14 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 metamodel evaluates derived SysML and KerML metamodel properties over a resolved semantic model, optionally using graph-stated structure.

Index

Constants

View Source
const ExtensionMetaclassPrefix = "sysx:"

ExtensionMetaclassPrefix marks a Structure metaclass outside the SysML vocabulary; the evaluator treats such an element's SysML metaclass as unknown.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnotationStructure added in v0.13.0

type AnnotationStructure interface {
	Annotations(Element) ([]Element, bool)
}

AnnotationStructure lists the Annotation relationships whose annotatedElement is the element: the inverse an element filter needs to find metadata stated `about` it.

type Element

type Element struct {
	Symbol       *symbols.Symbol
	Node         ast.Node
	Container    *symbols.Symbol
	Membership   Membership
	IsMembership bool
	Aspect       string
}

Element is a semantic element and the membership that owns it, when it has one.

func ElementOf

func ElementOf(sym *symbols.Symbol) Element

ElementOf creates a handle for a declared symbol.

func MembershipElement

func MembershipElement(membership Membership) Element

MembershipElement creates a handle for a membership that is itself an element.

func NodeOf

func NodeOf(node ast.Node) Element

NodeOf creates a handle for an AST-backed element without a symbol.

func (Element) Key

func (e Element) Key() ElementKey

Key returns the canonical identity of an element.

type ElementIdentityStructure

type ElementIdentityStructure interface {
	ElementIdentity(Element) (string, bool)
}

ElementIdentityStructure optionally supplies stable API identities for elements whose derived values contain an ID rather than an element handle.

type ElementKey

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

ElementKey identifies an element independently of its container and embedded membership.

type Evaluator

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

Evaluator derives metamodel properties from a resolved semantic model.

func New

func New(res *resolve.Resolver, model *semantics.Model, options ...Options) *Evaluator

New creates an evaluator over the resolver and semantic model for one model.

func (*Evaluator) Explain

func (e *Evaluator) Explain(el Element, definingClass, name string) (Reason, bool)

Explain returns a recorded cause without evaluating the property.

func (*Evaluator) Property

func (e *Evaluator) Property(el Element, definingClass, name string) (Value, bool)

Property returns a faithfully derived property value when the evaluator serves it.

func (*Evaluator) PropertyReadOnly

func (e *Evaluator) PropertyReadOnly(el Element, definingClass, name string) (Value, bool)

PropertyReadOnly returns a derived value whose sequence is shared with the evaluator cache; callers must not modify Values or any nested sequence.

func (*Evaluator) PropertyReadOnlyUncached added in v0.13.0

func (e *Evaluator) PropertyReadOnlyUncached(el Element, definingClass, name string) (Value, bool)

PropertyReadOnlyUncached returns a derived value the caller must not modify and leaves the result cache alone; the dependencies it derives are cached as usual.

type ImpliedRedefinitionStructure added in v0.13.0

type ImpliedRedefinitionStructure interface {
	ImpliedRedefinedFeatures(Element) ([]Element, bool)
}

ImpliedRedefinitionStructure optionally states the features an element redefines by its role (subject, objective, actor, stakeholder, rendering; SysML v2 §8.3.21-§8.3.26) unwritten.

type LibraryMembershipResolver added in v0.13.0

type LibraryMembershipResolver interface {
	LibraryMember(membership Element) (*symbols.Symbol, bool)
}

LibraryMembershipResolver is the optional part of a Structure that names the library symbol a reference to a library membership stands for: the member that membership owns.

type LibrarySymbolResolver added in v0.13.0

type LibrarySymbolResolver interface {
	LibrarySymbol(Element) (*symbols.Symbol, bool)
}

LibrarySymbolResolver optionally resolves a structure element that merely references a library element to that element's semantic symbol.

type Membership

type Membership struct {
	Symbol  *symbols.Symbol
	Node    ast.Node
	Member  *symbols.Symbol
	Owner   *symbols.Symbol
	Feature bool
	Aspect  string
	// contains filtered or unexported fields
}

Membership identifies an element's membership without depending on an export format.

func (Membership) Key

func (m Membership) Key() MembershipKey

Key returns the canonical identity of a membership.

func (Membership) Metaclass

func (m Membership) Metaclass() string

Metaclass returns the membership metaclass when it is known.

type MembershipKey

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

MembershipKey identifies a membership independently of its feature flag.

type Omission

type Omission struct {
	DefiningClass string
	Property      string
	Reason        string
}

Omission explains why a derived property has no faithful evaluator rule.

func Omitted

func Omitted() []Omission

Omitted returns a copy of the derived properties not served by the evaluator and the semantic facts their derivations require.

type Options

type Options struct {
	Structure Structure
}

Options supplies graph-stated structure used by the evaluator. When Structure is nil, the evaluator serves properties derivable from the semantic model.

type QualifiedNameStructure

type QualifiedNameStructure interface {
	QualifiedName(Element) (string, bool)
}

QualifiedNameStructure supplies canonical names when graph containment is unavailable.

type Reason

type Reason struct {
	Category   ReasonCategory
	Detail     string
	Dependency string
}

Reason records the decision that made a property derivation unsupported.

func (Reason) String

func (r Reason) String() string

String formats the category and its identifying detail.

type ReasonCategory

type ReasonCategory string

ReasonCategory identifies why a property derivation is unsupported.

const (
	ReasonNoRule                              ReasonCategory = "no-rule"
	ReasonUnresolvedReference                 ReasonCategory = "unresolved-reference"
	ReasonLibraryTargetWithoutCatalogIdentity ReasonCategory = "library-target-without-catalog-identity"
	ReasonDependsOnUnsupported                ReasonCategory = "depends-on-unsupported"
	ReasonUnrepresentedEndpoint               ReasonCategory = "unrepresented-endpoint"
	ReasonUnrepresentedElement                ReasonCategory = "unrepresented-element"
	ReasonUnresolvedOperatorFunction          ReasonCategory = "unresolved-operator-function"
	ReasonMissingStructure                    ReasonCategory = "missing-structure"
	ReasonMissingSemanticModel                ReasonCategory = "missing-semantic-model"
	ReasonNotApplicable                       ReasonCategory = "not-applicable"
	ReasonIncompleteStructure                 ReasonCategory = "incomplete-structure"
	ReasonImpliedRelationshipNotMaterialized  ReasonCategory = "implied-relationship-not-materialized"
	ReasonValueStatedUnderRedefinedProperty   ReasonCategory = "value-stated-under-redefined-property"
)

type Rule

type Rule struct {
	DefiningClass string
	Property      string
	Constraint    string
	Basis         string
}

Rule describes the basis for an evaluator-served property.

func Rules

func Rules() []Rule

Rules returns a copy of the property derivations the evaluator can faithfully compute.

type StatedAttributeStructure

type StatedAttributeStructure interface {
	StatedAttribute(el Element, property string) (Value, bool)
}

StatedAttributeStructure distinguishes graph values from metamodel defaults.

type Structure

type Structure interface {
	Metaclass(Element) (string, bool)
	Specializes(sub, super string) bool
	OwnedRelationships(Element) ([]Element, bool)
	OwningRelationship(Element) (Element, bool, bool)
	OwnedRelatedElements(Element) ([]Element, bool)
	OwningRelatedElement(Element) (Element, bool, bool)
	RelatedElements(rel Element, property string) ([]Element, bool)
	Attribute(el Element, property string) (Value, bool)
}

Structure supplies graph-stated metaclass, relationship, endpoint, and attribute facts used when a property cannot be derived from resolved semantics.

type SymbolStructure added in v0.13.0

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

SymbolStructure is a Structure projected lazily from the symbols of a resolved model: declared symbols and the relationship and expression symbols the semantic model reflects, with no graph in between.

func NewSymbolStructure added in v0.13.0

func NewSymbolStructure(res *resolve.Resolver, model *semantics.Model) *SymbolStructure

NewSymbolStructure makes the symbol-backed structure of the model res and model were analyzed as.

func (*SymbolStructure) Annotations added in v0.13.0

func (s *SymbolStructure) Annotations(element Element) ([]Element, bool)

Annotations lists the Annotations whose annotatedElement is the element, a library element's included: its own, then those of metadata stated `about` it.

func (*SymbolStructure) Attribute added in v0.13.0

func (s *SymbolStructure) Attribute(element Element, property string) (Value, bool)

func (*SymbolStructure) DerivedName added in v0.13.0

func (s *SymbolStructure) DerivedName(element Element) (string, bool)

func (*SymbolStructure) ElementFor added in v0.13.0

func (s *SymbolStructure) ElementFor(sym *symbols.Symbol) Element

ElementFor is the handle standing for sym, placed on first use.

func (*SymbolStructure) ElementIdentity added in v0.13.0

func (s *SymbolStructure) ElementIdentity(element Element) (string, bool)

func (*SymbolStructure) HasStatedRelatedElement added in v0.13.0

func (s *SymbolStructure) HasStatedRelatedElement(element Element, property string) bool

func (*SymbolStructure) HasUnresolvedRelatedElement added in v0.13.0

func (s *SymbolStructure) HasUnresolvedRelatedElement(element Element, property string) bool

func (*SymbolStructure) ImpliedRedefinedFeatures added in v0.13.0

func (s *SymbolStructure) ImpliedRedefinedFeatures(element Element) ([]Element, bool)

func (*SymbolStructure) LibraryMember added in v0.13.0

func (s *SymbolStructure) LibraryMember(membership Element) (*symbols.Symbol, bool)

LibraryMember is the library symbol whose membership a library membership's handle names: the member an owning membership owns, or the alias a Membership is.

func (*SymbolStructure) LibrarySymbol added in v0.13.0

func (s *SymbolStructure) LibrarySymbol(element Element) (*symbols.Symbol, bool)

func (*SymbolStructure) Metaclass added in v0.13.0

func (s *SymbolStructure) Metaclass(element Element) (string, bool)

Exported reads take s.mu once; the *Locked bodies and their helpers assume it is held.

func (*SymbolStructure) OwnedRelatedElements added in v0.13.0

func (s *SymbolStructure) OwnedRelatedElements(element Element) ([]Element, bool)

func (*SymbolStructure) OwnedRelationships added in v0.13.0

func (s *SymbolStructure) OwnedRelationships(element Element) ([]Element, bool)

func (*SymbolStructure) OwningRelatedElement added in v0.13.0

func (s *SymbolStructure) OwningRelatedElement(element Element) (Element, bool, bool)

func (*SymbolStructure) OwningRelationship added in v0.13.0

func (s *SymbolStructure) OwningRelationship(element Element) (Element, bool, bool)

func (*SymbolStructure) QualifiedName added in v0.13.0

func (s *SymbolStructure) QualifiedName(element Element) (string, bool)

func (*SymbolStructure) RelatedElements added in v0.13.0

func (s *SymbolStructure) RelatedElements(element Element, property string) ([]Element, bool)

func (*SymbolStructure) SetIdentities added in v0.13.0

func (s *SymbolStructure) SetIdentities(identities func(*symbols.Symbol) (string, bool))

SetIdentities makes the structure spell its elements by identities, the one id scheme the API element form writes for named and anonymous elements alike.

func (*SymbolStructure) Specializes added in v0.13.0

func (s *SymbolStructure) Specializes(sub, super string) bool

Specializes reports whether the metaclass sub is super or conforms to it in the loaded metamodel libraries.

func (*SymbolStructure) StatedAttribute added in v0.13.0

func (s *SymbolStructure) StatedAttribute(element Element, property string) (Value, bool)

func (*SymbolStructure) StatedRelatedElements added in v0.13.0

func (s *SymbolStructure) StatedRelatedElements(element Element, property string) ([]Element, bool)

func (*SymbolStructure) SymbolOf added in v0.13.0

func (s *SymbolStructure) SymbolOf(element Element) (*symbols.Symbol, bool)

type Value

type Value struct {
	Kind       ValueKind
	Element    Element
	Membership Membership
	String     string
	Boolean    bool
	Integer    int64
	Real       float64
	Enum       string
	Values     []Value
	Success    bool
}

Value is a semantic value returned by a property derivation.

type ValueKind

type ValueKind uint8

ValueKind identifies the semantic value stored in Value.

const (
	InvalidValue ValueKind = iota
	NullValue
	ElementValue
	MembershipValue
	StringValue
	BooleanValue
	IntegerValue
	RealValue
	EnumValue
	SequenceValue
)

Jump to

Keyboard shortcuts

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