naming

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: 12 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 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

View Source
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

func BodyMembers(n *ast.Usage) []ast.Node

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

func CutSegment(qname string) (segment, rest string, more bool)

CutSegment splits the first segment of a qualified identity off the rest.

func Declared

func Declared(fqn string) string

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

func Escaped(qname string) string

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

func IsPositionalIdentity(name string) bool

IsPositionalIdentity reports whether a name contains a canonical `@N` segment.

func NodeStatement

func NodeStatement(n *ast.Usage) ast.Node

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

func PlainNodeHead(n *ast.Usage) bool

PlainNodeHead reports whether an action node declares nothing but its visibility and name: no prefix, modifier, specialization, multiplicity or value.

func Positional

func Positional(owner string, index int) string

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

func PositionalSegment(segment string) bool

PositionalSegment reports a canonical `@N` segment: a non-negative decimal without sign or leading zeros.

func Qualify

func Qualify(owner string, name Name, index int) string

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

func QuotedSegment(name string) string

QuotedSegment is a declared name as a quoted identity segment (identity.QuotedSegment), which Unquote reads back.

func Recorded

func Recorded(identity string) string

Recorded is the spelling the index records for an identity: Segment's quoting removed.

func Segment

func Segment(name string) string

Segment is the identity segment of a declared name (identity.Segment).

func Segments

func Segments(qname string) []string

Segments splits a qualified identity at the `::` outside its quoted segments.

func ShorthandRelationship

func ShorthandRelationship(n *ast.Usage) bool

ShorthandRelationship reports a `bind` shorthand, which declares no name.

func StateBody

func StateBody(n *ast.StateNode) []ast.Node

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

func Unquote(segment string) string

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

func UnwrapMember(member ast.Node) (ast.Node, ast.Visibility)

UnwrapMember returns the declaration inside a membership wrapper together with the visibility the wrapper declared.

func WithoutComments

func WithoutComments(text string) string

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

type Name struct {
	Text  string
	Named bool
}

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

func BehaviorNameAndMembers(node ast.Node) (Name, []ast.Node, bool)

BehaviorNameAndMembers returns the name a behavioral node declares and the members it owns, for the nodes DeclaredNameAndMembers does not cover itself.

func DeclaredNameAndMembers

func DeclaredNameAndMembers(node ast.Node) (Name, []ast.Node)

DeclaredNameAndMembers returns the name a declaration introduces and the members it owns, for the node kinds that have either.

func MemberName

func MemberName(node ast.Node) Name

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.

func NameOf

func NameOf(text string) Name

NameOf is the name text states: none when it is empty.

func ParamName

func ParamName(node ast.Node) Name

ParamName is the name a parameter declaration introduces.

type PayloadCollision

type PayloadCollision struct {
	Payload *ast.Usage
	Name    string
}

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

func (t *Table) CrossFeatureIndex(u *ast.Usage) int

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

func (t *Table) EffectiveName(node ast.Node) Name

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

func (t *Table) Kept(members []ast.Node) []ast.Node

Kept filters members to the ones that take a position: every member but a consumed identity annotation.

func (*Table) PayloadOf

func (t *Table) PayloadOf(u *ast.Usage) *ast.Usage

PayloadOf returns the PayloadFeature a flow's `of` clause declares, or nil: `of T` and `of T[1]` state only its typing, so a feature is made up to carry them.

func (*Table) Skip

func (t *Table) Skip(node ast.Node) bool

Skip reports whether node is an identity annotation consumed into element ids rather than a member of the model.

Jump to

Keyboard shortcuts

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