Documentation
¶
Overview ¶
Package naming derives the qualified names the export, the query API and the symbol facts share: a declared name per segment, `@N` for an unnamed member.
Index ¶
- Constants
- func Before(file *source.SourceFile, node, inner ast.Node) string
- func BodyMembers(n *ast.Usage) []ast.Node
- func CutSegment(qname string) (segment, rest string, more bool)
- func Declared(fqn string) string
- func DeclaredPrefixes(node ast.Node) []*ast.PrefixMetadata
- func Escaped(qname string) string
- func Introducer(file *source.SourceFile, node, inner ast.Node) string
- func IsPositionalIdentity(name string) bool
- func NodeStatement(n *ast.Usage) ast.Node
- func PlainNodeHead(n *ast.Usage) bool
- func Positional(owner string, index int) string
- func PositionalIdentities(index *symbols.Index, docs []Document, identifies func(*symbols.Symbol) bool) (map[*symbols.Symbol]string, map[string]*symbols.Symbol)
- func PositionalSegment(segment string) bool
- func Qualify(owner string, name Name, index int) string
- func QuotedSegment(name string) string
- func Recorded(identity string) string
- func Segment(name string) string
- func Segments(qname string) []string
- func ShorthandRelationship(n *ast.Usage) bool
- func StateBody(n *ast.StateNode) []ast.Node
- func TransitionMembers(n *ast.TransitionMember) []ast.Node
- func TriggerPayload(file *source.SourceFile, n *ast.TransitionMember) *ast.Usage
- func Unquote(segment string) string
- func UnwrapMember(member ast.Node) (ast.Node, ast.Visibility)
- func WithoutComments(text string) string
- type Document
- type Name
- type PayloadCollision
- type Table
Constants ¶
const TriggerSegment = "@trigger"
TriggerSegment is the segment under which a transition's trigger action owns its payload parameter.
Variables ¶
This section is empty.
Functions ¶
func Before ¶
func Before(file *source.SourceFile, node, inner ast.Node) string
Before returns the text of file written between the start of node and the start of inner, trimmed.
func BodyMembers ¶
BodyMembers returns the members written in a usage's body: a payload declared inline by `of name : Type` is parsed as a member but belongs to the head.
func CutSegment ¶
CutSegment splits the first segment of a qualified identity off the rest.
func Declared ¶
Declared spells a qualified name the index records as an identity: a declared name reading as an `@N` address quoted (Segment), so it stays apart from the unnamed member at that position.
func DeclaredPrefixes ¶
func DeclaredPrefixes(node ast.Node) []*ast.PrefixMetadata
DeclaredPrefixes returns the `#M` prefix annotations a declaration carries.
func Escaped ¶
Escaped spells a qualified identity as Element::qualifiedName reads (KerML 1.1 §8.3.2.1.2 escapedName): a basic name bare, another name single-quoted, a positional `@N` as it is.
func Introducer ¶
func Introducer(file *source.SourceFile, node, inner ast.Node) string
Introducer returns the keyword written immediately before inner, which is what the clause inner belongs to was introduced with.
func IsPositionalIdentity ¶
IsPositionalIdentity reports whether a name contains a canonical `@N` segment.
func NodeStatement ¶
NodeStatement is the statement an action node is written as, which the node is (`action s send x to r;` is one SendActionUsage named s, SysML.xtext SendNode; `action a assign x := y;` one AssignmentActionUsage, AssignmentNode), or nil for any other usage: a node chaining further statements with `then`, or one whose declaration says more than its visibility and name (`#M action a : A assign …`), which the statement's notation cannot write back and so keeps the action it is declared as.
func PlainNodeHead ¶
PlainNodeHead reports whether an action node declares nothing but its visibility and name: no prefix, modifier, specialization, multiplicity or value.
func Positional ¶
Positional addresses an unnamed declaration by its position in its owner, which keeps every element identifiable.
func PositionalIdentities ¶
func PositionalIdentities(index *symbols.Index, docs []Document, identifies func(*symbols.Symbol) bool) (map[*symbols.Symbol]string, map[string]*symbols.Symbol)
PositionalIdentities names the declared symbols of docs that no qualified identity names (identifies reports those), by their position: `Owner::@N`.
func PositionalSegment ¶
PositionalSegment reports a canonical `@N` segment: a non-negative decimal without sign or leading zeros.
func Qualify ¶
Qualify builds the qualified name of a member under the name it has, which the empty unrestricted name is too; one without a name is addressed as Positional.
func QuotedSegment ¶
QuotedSegment is a declared name as a quoted identity segment (identity.QuotedSegment), which Unquote reads back.
func Recorded ¶
Recorded is the spelling the index records for an identity: Segment's quoting removed.
func ShorthandRelationship ¶
ShorthandRelationship reports a `bind` shorthand, which declares no name.
func StateBody ¶
StateBody lists what a state owns in written order: its entry, do and exit actions, its substates and its regions.
func TransitionMembers ¶
func TransitionMembers(n *ast.TransitionMember) []ast.Node
TransitionMembers lists what a transition owns in written order: the actions of its `do` effect, then the members of its body.
func TriggerPayload ¶
func TriggerPayload(file *source.SourceFile, n *ast.TransitionMember) *ast.Usage
TriggerPayload is the payload parameter a transition's trigger declares, nil for a trigger with no AcceptActionUsage form (a call event, `when <name>`).
func Unquote ¶
Unquote is the declared name an identity segment stands for: Segment's quoting and escapes removed, a bare or positional segment as it is.
func UnwrapMember ¶
UnwrapMember returns the declaration inside a membership wrapper together with the visibility the wrapper declared.
func WithoutComments ¶
WithoutComments replaces every comment with a space, told apart by the lexer the parser reads them with, so each shape scanned over text excludes them.
Types ¶
type Document ¶
type Document struct {
File *source.SourceFile
Root *ast.RootNamespace
Scope *symbols.Scope
}
Document is one document of an index: its source, the tree the index was built from, and its root scope.
type Name ¶
Name is a name a declaration may have: Text is the empty unrestricted name when it is empty and Named, and no name at all when not Named (KerML §8.2.2.3).
func BehaviorNameAndMembers ¶
BehaviorNameAndMembers returns the name a behavioral node declares and the members it owns, for the nodes DeclaredNameAndMembers does not cover itself.
func DeclaredNameAndMembers ¶
DeclaredNameAndMembers returns the name a declaration introduces and the members it owns, for the node kinds that have either.
func MemberName ¶
MemberName is a member's declared name, else the one its naming feature lends it (KerML Feature::effectiveName): `render tree;` is tree, as the symbol table has it.
type PayloadCollision ¶
PayloadCollision is the error of a flow payload identified as a body member is too, which no naming can tell apart.
func (*PayloadCollision) Error ¶
func (e *PayloadCollision) Error() string
type Table ¶
type Table struct {
// FQN is the qualified name of each member node, which is how a succession
// end the notation leaves unnamed addresses the member it binds.
FQN map[ast.Node]string
// Positional is the name a graph stating no effective names gives a member
// (a declared name claimed among declared names, else its position).
Positional map[ast.Node]string
// Declared holds every qualified name a member of the document claimed.
Declared map[string]bool
// Absorbed marks the FinalNode a member-attached `then` introduces: the
// target end of the following succession, written as that edge, not itself.
Absorbed map[ast.Node]bool
// TargetTransitions marks the `then x;` edges of state bodies that are TargetTransitionUsages
// (ast.IsStateTargetTransition): a TransitionUsage owning the succession, not the succession itself.
TargetTransitions map[ast.Node]bool
// Preceding is the member a `then` after each member sequences from: the last
// member before it that is not itself an edge, as the parser reads it.
Preceding map[ast.Node]ast.Node
// Introduced is the member a member-attached `then` sequences to: the one
// written right after the keyword, whose edge follows it in the body.
Introduced map[ast.Node]ast.Node
// Payloads holds the PayloadFeature each flow's `of` clause declares, keyed
// by the flow: the declared feature of `of p : T`, or one made up for `of T`.
Payloads map[*ast.Usage]*ast.Usage
PayloadFeatures map[*ast.Usage]bool
// contains filtered or unexported fields
}
Table is the qualified-name side table of one document: the name of every member node, by which the export, the query API and the symbol facts address it.
func Build ¶
func Build(file *source.SourceFile, root *ast.RootNamespace, model *semantics.Model, ids *identity.Table) (*Table, error)
Build names every member of root. The identity table says which annotations were consumed into element ids, which then take no position among members.
func (*Table) CrossFeatureIndex ¶
CrossFeatureIndex is the position an end's cross feature takes among the members it owns: after its kept body members and its prefix annotations.
func (*Table) EffectiveName ¶
EffectiveName is MemberName completed by the model: a feature its clause leaves nameless is named by the feature it implicitly redefines (KerML 1.1 §8.3.3.3).
func (*Table) Kept ¶
Kept filters members to the ones that take a position: every member but a consumed identity annotation.