Documentation
¶
Overview ¶
Package export saves a SysML v2 model to a file and converts between the two representations OpenSysML can write: SysML textual notation and RDF Turtle. It also reads a third, SysML v1 in XMI, which is migrated to v2 notation on the way in.
SysML output ¶
Saving a model that came from source writes that source, re-indented by internal/syntax/format. Printing the AST instead would drop comments, notes and anything the parser recorded as an ErrorNode, so a save has to keep the token stream (see the format package doc).
RDF output ¶
The graph uses the SysML vocabulary and element IRIs of the Flexo MMS SysML v2 service (https://www.omg.org/spec/SysML# and urn:sysmlv2:element:), so a converted model loads into that service's triplestore. Elements are addressed by qualified name (`urn:sysmlv2:element:Demo::Vehicle`), which makes the IRIs stable across conversions of the same model rather than newly generated each time.
Each element carries its metaclass as rdf:type and its declaration as SysML metamodel properties: declaredName, declaredShortName, owningNamespace, visibility, direction, the feature flags, the typing and specialization clauses, multiplicity bounds and its value; expression-valued positions are expression trees. Properties the metamodel does not define live in a separate urn:opensysml:sysml: namespace so a consumer can tell them from the standard vocabulary: memberIndex (declaration order, which the notation is sensitive to and RDF is not), hasBody, the end forms of heads that bind ends, and each element's lines as written, comments included, as sourceText and sourceTail.
XMI input ¶
SysML v1 as UML XMI (OMG XMI 2.5.1, the Eclipse UML2 .uml serialization Papyrus writes, or a .mdzip archive holding it) is migrated to v2 notation by internal/translate/migrate, then takes the notation path. XMI is never written.
RDF back to notation ¶
The structural triples are authoritative. An element is written from its source text while that text still states what the graph states — so comments and layout survive a round trip of an unedited model — and canonically where the two disagree or the graph carries no text, as one from another tool does not. docs/reference/rdf-mapping.md documents the mapping and its limitations.
Index ¶
- Constants
- func APIJSONToSysML(data []byte, warn func(string)) ([]byte, error)
- func DerivedSatellite(metaclass string) bool
- func Destination(path string) (target string, info os.FileInfo, err error)
- func ElementGraphWith(file *source.SourceFile, root *ast.RootNamespace, form IDForm) (*rdf.Graph, error)
- func IsNoteProperty(iri string) bool
- func IsSourceRangeProperty(iri string) bool
- func LibraryElementForm(idOrName string) (APIJSONElement, *ElementForm, bool, error)
- func LibraryElementFormNamed(name string) (APIJSONElement, *ElementForm, bool, error)
- func LibraryElementName(id string) (string, bool)
- func LibraryReference(graph *rdf.Graph, subject rdf.Term) bool
- func MappingElementSubject(graph *rdf.Graph, subject rdf.Term) bool
- func MappingMembershipEdgeSubject(graph *rdf.Graph, subject rdf.Term) bool
- func MappingMembershipMemberIsElement(graph *rdf.Graph, membership, member rdf.Term) bool
- func ModelElementGraphWith(documents []ModelDocument, form IDForm) (*rdf.Graph, error)
- func ModelToRDFWith(documents []ModelDocument, form IDForm) (*rdf.Graph, error)
- func NamedAddress(graph *rdf.Graph, subject rdf.Term) (string, bool)
- func NormativeSubject(id, qualifiedName string) bool
- func ReadAPIJSON(data []byte) (*rdf.Graph, error)
- func ReadableElementIDs(documents []ModelDocument, unreadable map[string]error) (*ElementIDs, []ExcludedDocument, error)
- func SynthesizedElementID(sym *symbols.Symbol, ownerID func(*symbols.Symbol) string) (string, bool)
- func SynthesizedElementOwner(id string) (string, bool)
- func TempStem(base string) string
- func ToRDF(file *source.SourceFile, root *ast.RootNamespace) (*rdf.Graph, error)
- func ToRDFWith(file *source.SourceFile, root *ast.RootNamespace, form IDForm) (*rdf.Graph, error)
- func ToSysML(graph *rdf.Graph) ([]byte, error)
- func ToSysMLWarn(graph *rdf.Graph, warn func(string)) ([]byte, error)
- func WriteAPIJSON(graph *rdf.Graph) ([]byte, error)
- func WriteAPIJSONCompact(graph *rdf.Graph, opts CompactAPIJSONOptions) ([]byte, error)
- func WriteAPIJSONTo(out io.Writer, graph *rdf.Graph, options APIJSONOptions) error
- func WriteAPIJSONWithOptions(graph *rdf.Graph, options APIJSONOptions) ([]byte, error)
- func WriteFile(path string, data []byte) (replaced bool, err error)
- func WriteFileFrom(path string, write func(io.Writer) error) (replaced bool, written int64, err error)
- type APIJSONElement
- type APIJSONLibraryReference
- type APIJSONOmission
- type APIJSONOptions
- type APIJSONProperty
- type APIJSONReadError
- type APIJSONReference
- type CompactAPIJSONOptions
- type ElementForm
- func (f *ElementForm) ByID(id string) (APIJSONElement, bool)
- func (f *ElementForm) ByQualifiedName(name string) (APIJSONElement, bool)
- func (f *ElementForm) Elements() []APIJSONElement
- func (f *ElementForm) NameOf(id string) (qualifiedName, metaclass string, ok bool)
- func (f *ElementForm) Omission(id, property string) (metamodel.Reason, bool)
- type ElementIDDocument
- type ElementIDReader
- func (r *ElementIDReader) Read(doc string, decl ast.Node, fqn string) (string, error)
- func (r *ElementIDReader) ReadAddress(id string) (string, bool)
- func (r *ElementIDReader) ReadExpressionPart(doc string, node ast.Node, slot string) (element, membership string, err error)
- func (r *ElementIDReader) ReadOwningMembership(doc string, decl ast.Node, fqn string) (string, error)
- func (r *ElementIDReader) ReadRelationship(doc string, node ast.Node) (string, error)
- type ElementIDs
- func (ids *ElementIDs) AddressOf(id string) (string, bool)
- func (ids *ElementIDs) Documents() []string
- func (ids *ElementIDs) Of(fqn string) (string, bool)
- func (ids *ElementIDs) OfBodyParameter(doc string, body *ast.BodyExpr, name string) (element, membership string, ok bool)
- func (ids *ElementIDs) OfDeclaration(doc string, decl ast.Node, fqn string) (string, bool)
- func (ids *ElementIDs) OfExpressionPart(doc string, node ast.Node, slot string) (element, membership string, ok bool)
- func (ids *ElementIDs) OwningMembershipOfDeclaration(doc string, decl ast.Node, fqn string) (string, bool)
- func (ids *ElementIDs) RelationshipOf(doc string, node ast.Node) (string, bool)
- type ExcludedDocument
- type IDForm
- type ModelDocument
- type PreparedModel
- type Staged
- type SymbolIDs
- type UnsupportedError
Constants ¶
const AnnotationSuffix = "_an"
AnnotationSuffix names the Annotation by which a dependency owns a prefix metadata usage, after the usage it owns, as `_om` names a membership.
const CompactAPIJSONFormat = "api-json-compact/1"
CompactAPIJSONFormat names the document WriteAPIJSONCompact writes.
const NoteClass = rdf.OpenSysML + mNote
NoteClass is the class of a note node: part of an element's lines, no Element.
const RootNamespaceSuffix = "_ns"
RootNamespaceSuffix ends the id of the unnamed Namespace that owns a document's top-level elements in the API element form. An encoded id never ends in a lone '_', so the id collides with no element's or membership's.
Variables ¶
This section is empty.
Functions ¶
func APIJSONToSysML ¶ added in v0.9.2
APIJSONToSysML reads an API element document and converts its owned graph.
func DerivedSatellite ¶
DerivedSatellite reports whether metaclass is one the encoder derives from its side tables rather than a declaration — the materialized relationship elements, a conjugated port definition and its conjugation, a multiplicity range, or the membership relating an expression to its referent. A member element of such a metaclass carries a qualified name and stays addressable.
func Destination ¶
Destination returns the file a save should write and what is there now, which is nil when nothing is. A symlink resolves to what it points at, so saving over a linked model updates the model instead of unlinking it; a link that resolves to nothing is written where it points.
func ElementGraphWith ¶ added in v0.13.0
func ElementGraphWith(file *source.SourceFile, root *ast.RootNamespace, form IDForm) (*rdf.Graph, error)
ElementGraphWith is ToRDFWith for a graph only the element form is written from: it leaves the library members only a completed property references to that writer.
func IsNoteProperty ¶ added in v0.13.0
IsNoteProperty reports whether iri is one of the properties stating a note, which say nothing of the model: layout, like the source text they are read from.
func IsSourceRangeProperty ¶ added in v0.9.2
IsSourceRangeProperty reports whether iri is one of the four integers that place a declaration in its document: layout, which reading ignores.
func LibraryElementForm ¶ added in v0.13.0
func LibraryElementForm(idOrName string) (APIJSONElement, *ElementForm, bool, error)
LibraryElementForm reads a standard-library element by the id a model's form references it under, or by its qualified name: the library document declaring it is converted as a model of its own — which gives its elements their normative ids, as -stdlib conversion does — and the element is read from that form, which is also returned so the element's references can be named. The document is the text of the library the shared index was built from, the configured one (LibraryPathEnvVar) included. False when no library element is known by idOrName.
func LibraryElementFormNamed ¶ added in v0.13.0
func LibraryElementFormNamed(name string) (APIJSONElement, *ElementForm, bool, error)
LibraryElementFormNamed is LibraryElementForm for a qualified name alone: an id names nothing.
func LibraryElementName ¶ added in v0.13.0
LibraryElementName is the qualified name of the standard-library element whose normative id is id, the id a model's form references it under.
func LibraryReference ¶ added in v0.9.2
LibraryReference reports whether subject names a library element the graph references rather than declares: it has no owner or owned relationships.
func MappingElementSubject ¶ added in v0.11.0
MappingElementSubject reports whether the subject is emitted as an Element rather than a reified membership edge.
func MappingMembershipEdgeSubject ¶ added in v0.11.0
MappingMembershipEdgeSubject reports whether the subject is a membership edge rather than a relationship emitted as its own element.
func MappingMembershipMemberIsElement ¶ added in v0.11.0
MappingMembershipMemberIsElement reports whether the forward mapping emits a membership's member as an Element rather than as an expression part.
func ModelElementGraphWith ¶ added in v0.13.0
func ModelElementGraphWith(documents []ModelDocument, form IDForm) (*rdf.Graph, error)
ModelElementGraphWith is ModelToRDFWith for a graph only the element form is written from: it leaves the library members only a completed property references to that writer.
func ModelToRDFWith ¶ added in v0.9.2
func ModelToRDFWith(documents []ModelDocument, form IDForm) (*rdf.Graph, error)
ModelToRDFWith converts the documents of one model to a single graph. They are analyzed together, as a workspace analyzes them, and a reference from one document to an element another declares links the subject that document writes for it, as a reference within one document does. Each document's root elements name it (sysx:sourceDocument), since one graph no longer keeps the documents apart. A Referenced document's elements are left out; its declarations' ids are still checked against those the written documents mint.
func NamedAddress ¶ added in v0.13.0
NamedAddress is the address of a subject that states a qualified name: what its element IRI encodes, where sysml:qualifiedName is the spelling to show.
func NormativeSubject ¶
NormativeSubject reports whether id is the id the norm fixes for the subject a graph names qualifiedName: the library element the encoder writes under that name, or its owning membership, which names nothing. A user element that carries a library uuid is not the library element, so its id stays its own.
func ReadAPIJSON ¶
ReadAPIJSON parses the SysML v2 API's element form — a JSON array of element objects, or a single element object — into the same graph ParseTurtle yields: the "@type" and "@id" of each object and each metamodel key in document order. It is the inverse of WriteAPIJSON, so a graph it builds writes the same elements back; the unnamed root Namespace a document wraps its top-level elements in is dropped, as the Turtle form does not carry it.
func ReadableElementIDs ¶ added in v0.13.0
func ReadableElementIDs(documents []ModelDocument, unreadable map[string]error) (*ElementIDs, []ExcludedDocument, error)
ReadableElementIDs is NewElementIDs without the documents unreadable names and those whose ids cannot be minted or an earlier document declares; each stays analyzed, and they are returned in document order.
func SynthesizedElementID ¶ added in v0.13.0
SynthesizedElementID is the elementId the conversion writes for sym, an element the semantic side tables synthesize; ownerID is the elementId of any element.
func SynthesizedElementOwner ¶ added in v0.13.0
SynthesizedElementOwner decodes the id of an element the conversion mints off its owner's with a suffix of its own — a transition's succession, link parameters and transitionLink — into the owner's qualified name.
func TempStem ¶ added in v0.11.0
TempStem is base cut to fit a temporary file's name beside it, with a dot, a separator and up to twelve random bytes added, without splitting a UTF-8 sequence.
func ToRDF ¶
func ToRDF(file *source.SourceFile, root *ast.RootNamespace) (*rdf.Graph, error)
ToRDF converts a parsed document into an RDF graph. file must be the source the tree was parsed from: every element and expression carries the notation it was written as alongside its structural triples, so the conversion needs the bytes as well as the tree.
func ToRDFWith ¶
func ToRDFWith(file *source.SourceFile, root *ast.RootNamespace, form IDForm) (*rdf.Graph, error)
ToRDFWith is ToRDF with the id form the caller asks for.
func ToSysML ¶
ToSysML converts an RDF graph back into SysML v2 source text. An element comes back as its sysx:sourceText, byte for byte, while that still states what the graph states, and in canonical notation otherwise.
A subject whose metaclass this mapping does not know, or which lacks the properties needed to rebuild its declaration, is reported as an UnsupportedError: a converted file that dropped an element would be worse than a failed conversion.
func ToSysMLWarn ¶ added in v0.9.2
ToSysMLWarn converts a graph to notation and reports non-fatal resolutions.
func WriteAPIJSON ¶
WriteAPIJSON serializes a graph as the SysML v2 API's element form: a JSON array of objects carrying "@type", "@id" and the metamodel properties as keys, with collection values in annotation order.
func WriteAPIJSONCompact ¶ added in v0.10.0
func WriteAPIJSONCompact(graph *rdf.Graph, opts CompactAPIJSONOptions) ([]byte, error)
WriteAPIJSONCompact writes the elements WriteAPIJSON writes in a form built to be small: no indentation, each element id written once, and every reference spelled by the position of its id. The document is one object:
{"format":"api-json-compact/1",
"ids":[<id>, …], // the id table
"elementCount":N, // ids[0..N) are the elements, in order
"elementIdsAreIds":true, // present only when elementId is left out (below)
"referenceKeys":[<key>, …], // keys whose values are only references or reference arrays
"elements":[{"@type":…,…}, …]}
Element i has the id ids[i], so it carries no "@id". Under a reference key a reference is the integer index into ids (an array of them for a collection); anywhere else it is {"@id": <index>}. ids beyond elementCount are elements the conversion references but does not write. Unresolved object-property names are null or omitted, as in the element form. When every element's "elementId" is its "@id", as it is unless a document declared another, "elementId" is left out and "elementIdsAreIds" says so: a reader restores it from the table.
func WriteAPIJSONTo ¶ added in v0.13.0
WriteAPIJSONTo writes API JSON to out one element at a time, so the array is never held whole: each object is encoded compact, indented and written.
func WriteAPIJSONWithOptions ¶ added in v0.11.0
func WriteAPIJSONWithOptions(graph *rdf.Graph, options APIJSONOptions) ([]byte, error)
WriteAPIJSONWithOptions writes API JSON and reports unresolved object properties through options.
func WriteFile ¶
WriteFile writes a converted model to path, reporting whether it replaced a file that was already there.
A regular file is written atomically: the bytes go to a temporary file in the same directory, are flushed, and are renamed over the destination, so an interrupted write leaves the previous model intact rather than a truncated or empty one. An existing file keeps its permissions, and a symlink is written through rather than replaced.
Anything that is not a regular file — a terminal, a pipe, /dev/null, a process substitution — is written directly, since there is no previous content to protect and replacing it by rename would destroy the pipe or device the user pointed at.
Types ¶
type APIJSONElement ¶ added in v0.13.0
type APIJSONElement struct {
ID string
Metaclass string
// QualifiedName is the element's qualifiedName property; empty for an
// unnamed element.
QualifiedName string
Properties []APIJSONProperty
}
APIJSONElement is one object of the element form: its "@id", its "@type" and its properties as the form spells them, in the form's order. The writer's own annotations ("sysx:" keys) are left out.
type APIJSONLibraryReference ¶ added in v0.12.0
type APIJSONLibraryReference struct {
ID string `json:"@id"`
Type string `json:"@type"`
QualifiedName string `json:"qualifiedName"`
// LibraryPath names an unnamed member by position, owner/Metaclass[i], where it has no qualified name.
LibraryPath string `json:"libraryPath,omitempty"`
}
APIJSONLibraryReference names a standard-library element without declaring a root.
type APIJSONOmission ¶ added in v0.11.0
type APIJSONOmission struct {
Subject string
Metaclass string
Property string
Reason metamodel.Reason
}
APIJSONOmission describes a property value an element object omits: an object property whose target could not be resolved, or a completed derived property the metamodel evaluator could not derive for that subject.
type APIJSONOptions ¶ added in v0.11.0
type APIJSONOptions struct {
Omitted func(APIJSONOmission)
Diagnostic func(string)
// IncludeLibraryStubs writes ownerless library elements for legacy readers.
IncludeLibraryStubs bool
// LibraryReferences receives the names of referenced standard-library elements.
LibraryReferences func([]APIJSONLibraryReference)
// InheritedMembers completes the derived families that repeat inherited members
// on every Namespace and Type (apiJSONInheritedFamilies); off, an element carries its owned structure.
InheritedMembers bool
}
APIJSONOptions configures diagnostics collected while writing API JSON.
type APIJSONProperty ¶ added in v0.13.0
APIJSONProperty is one property of an element object. Value is what the JSON would hold: string, bool, int64, float64, nil, an APIJSONReference to an element, a json.Number beyond int64 and float64, or a []any of those in the collection's order.
type APIJSONReadError ¶ added in v0.9.2
type APIJSONReadError struct {
// contains filtered or unexported fields
}
APIJSONReadError reports a failure to parse an API element document.
func (*APIJSONReadError) Error ¶ added in v0.9.2
func (e *APIJSONReadError) Error() string
func (*APIJSONReadError) Unwrap ¶ added in v0.9.2
func (e *APIJSONReadError) Unwrap() error
type APIJSONReference ¶ added in v0.13.0
type APIJSONReference struct {
ID string `json:"@id"`
}
APIJSONReference is the {"@id": <id>} spelling of a reference value.
type CompactAPIJSONOptions ¶ added in v0.10.0
type CompactAPIJSONOptions struct {
// OmitDerived leaves out every property the metamodel derives, except the
// ones named in KeepDerived. A derived property restates what the owned
// properties already say, so a reader that follows ownership, typing and
// specialization does not need it.
OmitDerived bool
// KeepDerived names the derived properties still written when OmitDerived is set.
KeepDerived []string
Omitted func(APIJSONOmission)
Diagnostic func(string)
IncludeLibraryStubs bool
LibraryReferences func([]APIJSONLibraryReference)
// InheritedMembers is APIJSONOptions.InheritedMembers.
InheritedMembers bool
}
CompactAPIJSONOptions chooses what the compact form leaves out.
type ElementForm ¶ added in v0.13.0
type ElementForm struct {
// contains filtered or unexported fields
}
ElementForm is the API element form of a model — the objects WriteAPIJSON writes — indexed for reading one element's properties at a time.
func ModelElementForm ¶ added in v0.13.0
func ModelElementForm(documents []ModelDocument) (*ElementForm, error)
ModelElementForm converts the model's documents to its element form once and indexes the result. An unresolvable object property fails the conversion, as WriteAPIJSON does.
func (*ElementForm) ByID ¶ added in v0.13.0
func (f *ElementForm) ByID(id string) (APIJSONElement, bool)
ByID is the element with the given "@id".
func (*ElementForm) ByQualifiedName ¶ added in v0.13.0
func (f *ElementForm) ByQualifiedName(name string) (APIJSONElement, bool)
ByQualifiedName is the element whose qualifiedName is the given name; the first in the form's order when two identity scopes declare one name.
func (*ElementForm) Elements ¶ added in v0.13.0
func (f *ElementForm) Elements() []APIJSONElement
Elements are every element of the form in the form's order.
func (*ElementForm) NameOf ¶ added in v0.13.0
func (f *ElementForm) NameOf(id string) (qualifiedName, metaclass string, ok bool)
NameOf is the qualified name and metaclass of the element an id refers to: an element of the form, or a standard-library element the form references. An unnamed library member answers its library path in place of a name.
func (*ElementForm) Omission ¶ added in v0.13.0
func (f *ElementForm) Omission(id, property string) (metamodel.Reason, bool)
Omission is why the element id's object carries no value for property: the metamodel evaluator could not derive it for this element, or a reference it holds could not be resolved. A property the object carries, or one that is legitimately empty, has no omission.
type ElementIDDocument ¶ added in v0.12.0
type ElementIDDocument struct {
File *source.SourceFile
Root *ast.RootNamespace
ParseDiags []parser.Diagnostic
}
ElementIDDocument is a document whose elementIds are read: its parse and the parse's errors; one given by its text alone is parsed for the conversion.
type ElementIDReader ¶ added in v0.12.0
type ElementIDReader struct {
// contains filtered or unexported fields
}
ElementIDReader reads the elementId Convert writes for each element of a model, from one conversion of the model made on first use. A model Convert refuses has no ids: the refusal is kept and every read reports it.
func NewElementIDReader ¶ added in v0.12.0
func NewElementIDReader(documents []ElementIDDocument) *ElementIDReader
NewElementIDReader reads the elementIds of the model documents make; a document without text is not written. Nothing is converted until Read.
func (*ElementIDReader) Read ¶ added in v0.12.0
Read is the elementId written for the element declared at decl in document doc, named fqn (ElementIDs.OfDeclaration), or why the model has none.
func (*ElementIDReader) ReadAddress ¶ added in v0.13.0
func (r *ElementIDReader) ReadAddress(id string) (string, bool)
ReadAddress is the address the conversion stated for the element written with id (ElementIDs.AddressOf); none before a conversion, or for a minted or unknown id.
func (*ElementIDReader) ReadExpressionPart ¶ added in v0.12.0
func (r *ElementIDReader) ReadExpressionPart(doc string, node ast.Node, slot string) (element, membership string, err error)
ReadOwningMembership is the elementId of the owning membership of the element declared at decl in doc, named fqn; empty where the conversion writes none. ReadExpressionPart reads the ids of the parameter at slot of the expression written at node, and of the membership that owns it.
func (*ElementIDReader) ReadOwningMembership ¶ added in v0.12.0
func (*ElementIDReader) ReadRelationship ¶ added in v0.12.0
ReadRelationship is the elementId of the relationship element the notation implies at node in doc — a head clause's, a bound end's reference subsetting, a dependency's prefix-metadata annotation; empty where the conversion writes none.
type ElementIDs ¶ added in v0.9.2
type ElementIDs struct {
// contains filtered or unexported fields
}
ElementIDs reports the elementId a conversion of a model writes for each of its elements, in the qualified id form, from the identity tables Convert mints them from (ToRDF's for one document, ModelToRDFWith's for several), so a library file's copy, a declared id and scope qualification come out as written.
func NewElementIDs ¶ added in v0.9.2
func NewElementIDs(documents []ModelDocument) (*ElementIDs, error)
NewElementIDs records the elementId Convert writes for each element of the documents' model from the identity tables the ids are minted from — nothing is written — refusing what the declarations' identity claims refuse in Convert: ids colliding within a document (mintDeclarations) or across documents.
func (*ElementIDs) AddressOf ¶ added in v0.13.0
func (ids *ElementIDs) AddressOf(id string) (string, bool)
AddressOf is the address the conversion stated for the declared element written with id — a qualifiedName, or a positional address (`P::@2::x`); none for a minted or unknown id.
func (*ElementIDs) Documents ¶ added in v0.13.0
func (ids *ElementIDs) Documents() []string
Documents are the names of the documents ids records the elements of, in model order.
func (*ElementIDs) Of ¶ added in v0.9.2
func (ids *ElementIDs) Of(fqn string) (string, bool)
Of is the elementId written for the element named fqn: the model's own as the conversion wrote it, or, for a standard library element the model does not declare, the normative id every reference to it carries. False where the conversion writes none, as for a library element a model annotates with an id of its own, whose references are written by name.
func (*ElementIDs) OfBodyParameter ¶ added in v0.13.0
func (ids *ElementIDs) OfBodyParameter(doc string, body *ast.BodyExpr, name string) (element, membership string, ok bool)
OfBodyParameter is the id written for the named parameter of the expression body at body in doc (`in0`… off the body's owner), and its membership's: a parameter has no node.
func (*ElementIDs) OfDeclaration ¶ added in v0.9.2
func (*ElementIDs) OfExpressionPart ¶ added in v0.12.0
func (ids *ElementIDs) OfExpressionPart(doc string, node ast.Node, slot string) (element, membership string, ok bool)
OfDeclaration is the elementId written for the element declared at decl in document doc, named fqn: the node's own, its span's in a reparse, else Of(fqn). OfExpressionPart is the id written for the parameter at slot of the expression written at node (`in0`… for its operands and type argument, `out` for its result), and of the membership that owns it.
func (*ElementIDs) OwningMembershipOfDeclaration ¶ added in v0.12.0
func (ids *ElementIDs) OwningMembershipOfDeclaration(doc string, decl ast.Node, fqn string) (string, bool)
OwningMembershipOfDeclaration is the elementId written for the owning membership of the element declared at decl in doc, named fqn; false for a root or an unknown element.
func (*ElementIDs) RelationshipOf ¶ added in v0.12.0
RelationshipOf is the elementId written for the relationship element the notation implies at node in document doc (writtenRelationships); false where none is written.
type ExcludedDocument ¶ added in v0.13.0
ExcludedDocument is a document a model was read without, and why.
type IDForm ¶
type IDForm int
IDForm is how the encoder spells the derived ids of elements, memberships and expression nodes that no ElementId annotation declares.
const ( // IDQualifiedName derives each id from the element's qualified name, so an // id reads where its element sits in the model. The default. IDQualifiedName IDForm = iota // IDUUID derives each id as a name-based uuid the way the SysML v2 library // convention does: the model's package namespace is // uuid5(NamespaceURL, elementIRI(root)), and every derived id under it is // uuid5(pkg, the qualified-name-derived local id it otherwise carries). IDUUID )
func ParseIDForm ¶
ParseIDForm reads the -id flag's argument.
type ModelDocument ¶ added in v0.9.2
type ModelDocument struct {
File *source.SourceFile
Root *ast.RootNamespace
// Referenced is a document analyzed with the model but not written: a
// reference into it links the id its element is written under on its own.
Referenced bool
}
ModelDocument is one parsed document of a model converted as a whole.
type PreparedModel ¶ added in v0.13.0
type PreparedModel struct {
// contains filtered or unexported fields
}
PreparedModel serializes shared semantic preparation over immutable documents. Encoders and identity tables are request-local; discard it when replacing the model.
func PrepareModel ¶ added in v0.13.0
func PrepareModel(documents []ModelDocument) *PreparedModel
PrepareModel records an immutable document set. Semantic preparation is lazy.
func (*PreparedModel) ElementGraph ¶ added in v0.13.0
func (p *PreparedModel) ElementGraph(ctx context.Context, selection []string, form IDForm) (*rdf.Graph, error)
ElementGraph is ToRDF for a graph only the element form is written from, as ModelElementGraphWith is ModelToRDFWith.
func (*PreparedModel) ToRDF ¶ added in v0.13.0
func (p *PreparedModel) ToRDF(ctx context.Context, selection []string, form IDForm) (*rdf.Graph, error)
ToRDF writes selected documents, or all when selection is empty, into a fresh graph. Unselected declarations still resolve references and participate in identity checks.
type Staged ¶ added in v0.9.2
type Staged struct {
// contains filtered or unexported fields
}
Staged is a file written beside its destination but not yet renamed over it, so a set of files can be committed together or discarded.
func Stage ¶ added in v0.9.2
Stage writes data to a temporary file beside path, ready to Commit; path must be absent or a regular file, as there is nothing else to rename over.
type SymbolIDs ¶ added in v0.13.0
type SymbolIDs struct {
// contains filtered or unexported fields
}
SymbolIDs spells a model's symbols by the elementIds Convert writes for the elements they reflect (ElementIDs), so a symbol-backed reader and the API element form name one element one way (Symbol resolves back).
func NewSymbolIDs ¶ added in v0.13.0
NewSymbolIDs spells the symbols of model, analyzed over res, by the ids ids records; the documents are those ids was built for.
func (*SymbolIDs) Of ¶ added in v0.13.0
Of is the elementId the conversion writes for the element sym reflects; false where it writes none (a `for` variable, an element the mapping does not cover).
type UnsupportedError ¶
UnsupportedError reports a construct the conversion cannot represent. It names the element so the user can find it, rather than converting a model that silently lost part of itself.
func (*UnsupportedError) Error ¶
func (e *UnsupportedError) Error() string
Source Files
¶
- address.go
- api_json_absence.go
- api_json_booleans.go
- api_json_chain_out.go
- api_json_compact.go
- api_json_derived.go
- api_json_element_form.go
- api_json_graph_index.go
- api_json_in.go
- api_json_library_form.go
- api_json_library_index.go
- api_json_library_references.go
- api_json_names.go
- api_json_out.go
- api_json_structure.go
- behavior.go
- composite.go
- doc.go
- element_ids.go
- end_forms.go
- id_form.go
- kinds.go
- library_names.go
- mapping_qualified_name.go
- mapping_shape.go
- names.go
- names_identity.go
- notes.go
- precedence.go
- prepared_model.go
- rdf_expr.go
- rdf_identity.go
- rdf_in.go
- rdf_in_normative.go
- rdf_in_toolkit.go
- rdf_normative.go
- rdf_out.go
- root_namespace.go
- source_text.go
- symbol_ids.go
- synthesized_ids.go
- verbatim.go
- write.go