Documentation
¶
Index ¶
- Constants
- Variables
- func Capabilities() []string
- func ComplexToProto(z complex128) *pb.Complex
- func DiagnosticToProto(diag passes.Diagnostic, sf *source.SourceFile) *pb.Diagnostic
- func InstanceGraphToProto(rt *runtime.Context, inst *runtime.Instance, idx *symbols.Index) (*pb.Instance, []*pb.Instance)
- func InstanceToProto(rt *runtime.Context, inst *runtime.Instance, idx *symbols.Index) *pb.Instance
- func ParserDiagnosticToProto(diag parser.Diagnostic, sf *source.SourceFile) *pb.Diagnostic
- func ProtoToComplex(pc *pb.Complex) complex128
- func ProtoToQuantity(pq *pb.Quantity, idx *symbols.Index, sem *semantics.Model) (runtime.Value, error)
- func ProtoToValueIn(pv *pb.Value, idx *symbols.Index, sem *semantics.Model) (runtime.Value, error)
- func QuantityToProto(q *runtime.Quantity) *pb.Quantity
- func QueryPropertyNames() []string
- func SymbolToProtoIn(sym *symbols.Symbol, sc *SymbolContext) *pb.SymbolInfo
- func ValueCarriesComplex(pv *pb.Value) bool
- func ValueToProto(val runtime.Value, idx *symbols.Index) *pb.Value
- func ValueToProtoIn(rt *runtime.Context, val runtime.Value, idx *symbols.Index) *pb.Value
- type Cache
- type CachedDocument
- type CachedModel
- func (m *CachedModel) DocumentRoots() []*symbols.Scope
- func (m *CachedModel) Primary() *CachedDocument
- func (m *CachedModel) PrimaryRoot() *symbols.Scope
- func (m *CachedModel) RuntimeSemantics() (*runtimeSemantics, func())
- func (m *CachedModel) SoleDocument() (*CachedDocument, error)
- func (m *CachedModel) SymbolContext() *SymbolContext
- type ConnectAdapter
- func (a *ConnectAdapter) ApplyEdits(ctx context.Context, req *connect.Request[pb.ApplyEditsRequest]) (*connect.Response[pb.ApplyEditsResponse], error)
- func (a *ConnectAdapter) Convert(ctx context.Context, req *connect.Request[pb.ConvertRequest]) (*connect.Response[pb.ConvertResponse], error)
- func (a *ConnectAdapter) Evaluate(ctx context.Context, req *connect.Request[pb.EvaluateRequest]) (*connect.Response[pb.EvaluateResponse], error)
- func (a *ConnectAdapter) EvaluateCalc(ctx context.Context, req *connect.Request[pb.EvaluateCalcRequest]) (*connect.Response[pb.EvaluateCalcResponse], error)
- func (a *ConnectAdapter) ExecuteAction(ctx context.Context, req *connect.Request[pb.ExecuteActionRequest]) (*connect.Response[pb.ExecuteActionResponse], error)
- func (a *ConnectAdapter) ExecuteState(ctx context.Context, req *connect.Request[pb.ExecuteStateRequest]) (*connect.Response[pb.ExecuteStateResponse], error)
- func (a *ConnectAdapter) GetDiagnostics(ctx context.Context, req *connect.Request[pb.DiagnosticsRequest]) (*connect.Response[pb.DiagnosticsResponse], error)
- func (a *ConnectAdapter) GetServerInfo(ctx context.Context, req *connect.Request[pb.ServerInfoRequest]) (*connect.Response[pb.ServerInfoResponse], error)
- func (a *ConnectAdapter) GetSymbol(ctx context.Context, req *connect.Request[pb.GetSymbolRequest]) (*connect.Response[pb.SymbolResponse], error)
- func (a *ConnectAdapter) Instantiate(ctx context.Context, req *connect.Request[pb.InstantiateRequest]) (*connect.Response[pb.InstantiateResponse], error)
- func (a *ConnectAdapter) ParseFile(ctx context.Context, req *connect.Request[pb.ParseFileRequest]) (*connect.Response[pb.ParseFileResponse], error)
- func (a *ConnectAdapter) ParseSources(ctx context.Context, req *connect.Request[pb.ParseSourcesRequest]) (*connect.Response[pb.ParseSourcesResponse], error)
- func (a *ConnectAdapter) Query(ctx context.Context, req *connect.Request[pb.QueryRequest]) (*connect.Response[pb.QueryResponse], error)
- func (a *ConnectAdapter) RenderDocument(ctx context.Context, req *connect.Request[pb.RenderDocumentRequest]) (*connect.Response[pb.RenderDocumentResponse], error)
- func (a *ConnectAdapter) RunDocumentQuery(ctx context.Context, req *connect.Request[pb.RunDocumentQueryRequest]) (*connect.Response[pb.RunDocumentQueryResponse], error)
- func (a *ConnectAdapter) VerifyConstraint(ctx context.Context, req *connect.Request[pb.VerifyConstraintRequest]) (*connect.Response[pb.VerifyConstraintResponse], error)
- func (a *ConnectAdapter) VerifyRequirement(ctx context.Context, req *connect.Request[pb.VerifyRequirementRequest]) (*connect.Response[pb.VerifyRequirementResponse], error)
- func (a *ConnectAdapter) VerifySatisfaction(ctx context.Context, req *connect.Request[pb.VerifySatisfactionRequest]) (*connect.Response[pb.VerifySatisfactionResponse], error)
- type GraphBounds
- type InstanceGraph
- type QueryError
- type QueryErrorKind
- type Service
- func (s *Service) ApplyEdits(ctx context.Context, req *pb.ApplyEditsRequest) (*pb.ApplyEditsResponse, error)
- func (s *Service) Close()
- func (s *Service) Convert(ctx context.Context, req *pb.ConvertRequest) (*pb.ConvertResponse, error)
- func (s *Service) Evaluate(ctx context.Context, req *pb.EvaluateRequest) (*pb.EvaluateResponse, error)
- func (s *Service) EvaluateCalc(ctx context.Context, req *pb.EvaluateCalcRequest) (*pb.EvaluateCalcResponse, error)
- func (s *Service) ExecuteAction(ctx context.Context, req *pb.ExecuteActionRequest) (*pb.ExecuteActionResponse, error)
- func (s *Service) ExecuteState(ctx context.Context, req *pb.ExecuteStateRequest) (*pb.ExecuteStateResponse, error)
- func (s *Service) GetDiagnostics(ctx context.Context, req *pb.DiagnosticsRequest) (*pb.DiagnosticsResponse, error)
- func (s *Service) GetServerInfo(ctx context.Context, req *pb.ServerInfoRequest) (*pb.ServerInfoResponse, error)
- func (s *Service) GetSymbol(ctx context.Context, req *pb.GetSymbolRequest) (*pb.SymbolResponse, error)
- func (s *Service) Instantiate(ctx context.Context, req *pb.InstantiateRequest) (*pb.InstantiateResponse, error)
- func (s *Service) ParseFile(ctx context.Context, req *pb.ParseFileRequest) (*pb.ParseFileResponse, error)
- func (s *Service) ParseSources(ctx context.Context, req *pb.ParseSourcesRequest) (*pb.ParseSourcesResponse, error)
- func (s *Service) Prewarm()
- func (s *Service) Query(ctx context.Context, req *pb.QueryRequest) (*pb.QueryResponse, error)
- func (s *Service) RenderDocument(ctx context.Context, req *pb.RenderDocumentRequest) (*pb.RenderDocumentResponse, error)
- func (s *Service) RunDocumentQuery(ctx context.Context, req *pb.RunDocumentQueryRequest) (*pb.RunDocumentQueryResponse, error)
- func (s *Service) VerifyConstraint(ctx context.Context, req *pb.VerifyConstraintRequest) (*pb.VerifyConstraintResponse, error)
- func (s *Service) VerifyRequirement(ctx context.Context, req *pb.VerifyRequirementRequest) (*pb.VerifyRequirementResponse, error)
- func (s *Service) VerifySatisfaction(ctx context.Context, req *pb.VerifySatisfactionRequest) (*pb.VerifySatisfactionResponse, error)
- type SymbolContext
Constants ¶
const ( QueryPropID = corequery.PropertyID QueryPropType = corequery.PropertyType QueryPropName = corequery.PropertyName QueryPropDeclaredName = corequery.PropertyDeclaredName QueryPropQualifiedName = corequery.PropertyQualifiedName QueryPropOwner = corequery.PropertyOwner QueryPropIsAbstract = corequery.PropertyIsAbstract QueryPropElementType = corequery.PropertyElementType QueryPropMultiplicityLower = corequery.PropertyMultiplicityLower QueryPropMultiplicityUpper = corequery.PropertyMultiplicityUpper )
Query property names, as the SysML v2 API & Services standard's clients write them. docs/reference/api.md documents what each one reports.
const CapabilityApplyEdits = "apply_edits"
CapabilityApplyEdits names the capability of the ApplyEdits RPC, which edits a parsed model's own source, preserving everything the edit did not touch.
const CapabilityAuthoring = "authoring"
CapabilityAuthoring names add-member and delete source authoring operations.
const CapabilityComplexValues = "complex_values"
CapabilityComplexValues names the capability of carrying a complex number as Value.complex, rather than reporting it as an unsupported null.
const CapabilityConvert = "convert"
CapabilityConvert names the capability of the Convert RPC, which writes a model back out as SysML notation or RDF Turtle. The RDF direction is experimental, which the response says per conversion.
const CapabilityDocumentQuery = "document_query"
CapabilityDocumentQuery names the capability of the RunDocumentQuery RPC, which runs a named document query and answers with typed rows.
const CapabilityEnumValues = "enum_values"
CapabilityEnumValues names the capability of carrying an enumeration literal as Value.enum_literal, rather than reporting it as an unsupported null.
const CapabilityEvaluateSubject = "evaluate_subject"
CapabilityEvaluateSubject names the capability of evaluating an expression against an instantiated subject.
const CapabilityFeatureValues = "feature_values"
CapabilityFeatureValues names the capability of populating Instance.feature_values, which replaced the pre-0.1.0 Instance.slots.
const CapabilityInlineLanguage = "inline_language"
CapabilityInlineLanguage names explicit language selection for inline content.
const CapabilityOSLCQuery = "oslc_query"
CapabilityOSLCQuery names the capability of evaluating OSLC Query text.
const CapabilityParseSources = "parse_sources"
CapabilityParseSources names the ParseSources RPC, which parses several documents as one model so a name one declares resolves in another.
const CapabilityQuery = "query"
CapabilityQuery names the capability of the Query RPC, which evaluates a SysML v2 API & Services Query over a parsed model.
const CapabilityRenderDocument = "render_document"
CapabilityRenderDocument names the capability of the RenderDocument RPC, which renders a named document to Markdown.
const CapabilityStrictConformance = "strict_conformance"
CapabilityStrictConformance names ParseFileRequest.strict_conformance, which asks whether the source is conforming SysML v2.
const CapabilitySymbolAttributes = "symbol_attributes"
CapabilitySymbolAttributes names the capability of populating SymbolInfo.attributes, rather than always reporting none.
const CapabilityTypeFacts = "type_facts"
CapabilityTypeFacts names the capability of populating SymbolInfo.type_info, .multiplicity and .specializations, which typed code generation requires.
const CapabilityUnsetValue = "unset_value"
CapabilityUnsetValue names the capability of reporting a valueless feature of a value type as Value.unset, rather than as the empty object it materializes.
const CapabilityVerification = "verification"
CapabilityVerification names the capability of the verification RPCs, which answer the questions the REPL's %constraint, %requirement, %satisfy and %calc answer.
const DefaultIndexPrewarm = 4
DefaultIndexPrewarm is the value IndexPrewarmEnvVar takes when unset: any positive value prewarms, since one library index now serves every model.
const IndexPrewarmEnvVar = "OPENSYSML_GRPC_INDEX_POOL"
IndexPrewarmEnvVar names the variable saying whether the service builds the standard library index before the requests that need it. Zero disables prewarming, so the first request builds it. The legacy SYSML_GRPC_INDEX_POOL name remains accepted; the OPENSYSML_ name wins when both are set.
Variables ¶
var ( // ErrQuantityNeedsIndex reports a quantity converted from the wire without // the model's symbols, which its base units can only be resolved against. ErrQuantityNeedsIndex = errors.New("a quantity needs the model's symbols to be converted from the wire") // ErrUnknownBaseUnit reports a base unit the model does not declare, so no // unit can be rebuilt from the reduction naming it. ErrUnknownBaseUnit = errors.New("unknown base unit") // ErrNotAMeasurementUnit reports a reduction naming a symbol that is not a // measurement unit, which nothing is measured in. ErrNotAMeasurementUnit = errors.New("not a measurement unit") // ErrUnitScaleUnusable reports a unit reduction whose scale is zero or // undefined, which no magnitude can be converted through. ErrUnitScaleUnusable = errors.New("unit scale is not a usable ratio") // ErrUnitNotReduced reports a named unit sent without its reduction, over // which alone commensurability is decided. ErrUnitNotReduced = errors.New("unit carries no reduction to base units") // ErrUnitTextMismatch reports a unit whose text names units that do not // reduce to the unit_term sent with it, so the two describe different units. ErrUnitTextMismatch = errors.New("unit as written does not reduce to its unit_term") // ErrUnsetNotAccepted reports the unset arm arriving as an input. It reports // that a feature value holds no value, which is something to read, not to supply. ErrUnsetNotAccepted = errors.New("unset is not a value a caller can supply") )
Functions ¶
func Capabilities ¶
func Capabilities() []string
Capabilities returns the capability names this build of the service reports.
func ComplexToProto ¶ added in v0.5.0
func ComplexToProto(z complex128) *pb.Complex
ComplexToProto marshals a complex number as its rectangular parts.
func DiagnosticToProto ¶
func DiagnosticToProto(diag passes.Diagnostic, sf *source.SourceFile) *pb.Diagnostic
DiagnosticToProto converts a passes.Diagnostic to protobuf.
func InstanceGraphToProto ¶
func InstanceGraphToProto(rt *runtime.Context, inst *runtime.Instance, idx *symbols.Index) (*pb.Instance, []*pb.Instance)
InstanceGraphToProto converts inst and every instance reachable from it. The root is returned first; runtime instances live only for the duration of a request, so the whole reachable graph is serialized while the context is alive.
Expansion stops at a child whose type is already on the path, at maxGraphDepth and at maxGraphInstances: reading a composite feature value materializes the object it holds, so a self-referential part would otherwise instantiate forever. An unexpanded child stays a bare instance id.
func InstanceToProto ¶
InstanceToProto converts runtime.Instance to protobuf Instance. Feature values are read through Instance.GetFeatureValue, so a derived default is evaluated against the instance rather than reported as unmaterialized. Features are read in name order, because reading one materializes the object it holds, so map order would decide the ids those objects are given.
func ParserDiagnosticToProto ¶
func ParserDiagnosticToProto(diag parser.Diagnostic, sf *source.SourceFile) *pb.Diagnostic
ParserDiagnosticToProto converts a parser.Diagnostic to protobuf.
func ProtoToComplex ¶ added in v0.5.0
func ProtoToComplex(pc *pb.Complex) complex128
ProtoToComplex is the complex number a Complex message carries; an empty message is zero, as every proto3 default is.
func ProtoToQuantity ¶
func ProtoToQuantity(pq *pb.Quantity, idx *symbols.Index, sem *semantics.Model) (runtime.Value, error)
ProtoToQuantity rebuilds a quantity from the wire: the magnitude as sent, in the unit as written — read as the product of the named units it composes, so an operation over it cancels and merges them — over the base units idx resolves its reduction to.
func ProtoToValueIn ¶
ProtoToValueIn converts a protobuf Value to a runtime.Value in the model idx and sem describe, resolving a quantity's base units against them. Inverse of ValueToProto.
func QuantityToProto ¶
QuantityToProto marshals a quantity: the magnitude in the unit written, plus what that unit reduces to. Reports nil for a magnitude that is not a number.
func QueryPropertyNames ¶
func QueryPropertyNames() []string
QueryPropertyNames returns every queryable property name, sorted. It is what an unknown-property error lists, and what docs/reference/api.md's table documents.
func SymbolToProtoIn ¶
func SymbolToProtoIn(sym *symbols.Symbol, sc *SymbolContext) *pb.SymbolInfo
SymbolToProtoIn converts a Symbol to protobuf SymbolInfo in an existing conversion context.
func ValueCarriesComplex ¶ added in v0.5.0
ValueCarriesComplex reports whether a value, or any element of a sequence, is a Complex: the kind the complex_values capability governs.
func ValueToProto ¶
ValueToProto converts runtime.Value to protobuf Value. An enumeration literal is named by its declaration, which idx supplies the qualified name of.
func ValueToProtoIn ¶
ValueToProtoIn converts a value read from a live context, which is what tells an object holding no value from one with features: the former crosses as the unset arm, as every other surface reads it. rt may be nil for a value no context materialized.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is an LRU cache for parsed models keyed by content hash
func NewCache ¶
NewCache creates a cache with the specified max size. It returns an error if maxSize is not positive.
func (*Cache) Get ¶
func (c *Cache) Get(hash string) (*CachedModel, bool)
Get retrieves a model from cache, returns (model, true) on hit
func (*Cache) Put ¶
func (c *Cache) Put(hash string, model *CachedModel)
Put adds a model to cache, evicting LRU if at capacity
type CachedDocument ¶ added in v0.4.2
type CachedDocument struct {
Root *ast.RootNamespace
Source *source.SourceFile // For diagnostic line/col mapping
ParseDiags []parser.Diagnostic // Parser diagnostics
PassesDiags []passes.Diagnostic // Semantic pass diagnostics (name-resolution, type, constraint)
}
CachedDocument is one parsed document of a model.
type CachedModel ¶
type CachedModel struct {
// Documents are the model's documents, at least one, in the order the parse
// request named them. They share Index, so a name one declares resolves in
// another and an import between them is satisfied.
Documents []*CachedDocument
Index *symbols.Index // For symbol lookups by FQN
// contains filtered or unexported fields
}
CachedModel holds parsed model data with semantic analysis results
func (*CachedModel) DocumentRoots ¶ added in v0.4.2
func (m *CachedModel) DocumentRoots() []*symbols.Scope
DocumentRoots are the root scopes of the model's documents, in order, skipping any the index does not hold.
func (*CachedModel) Primary ¶ added in v0.4.2
func (m *CachedModel) Primary() *CachedDocument
Primary is the document a model is named by: the only one of a single-document model, and the first named of a multi-document one, whose root namespace is where a name with nothing else to resolve against is looked up.
func (*CachedModel) PrimaryRoot ¶ added in v0.4.2
func (m *CachedModel) PrimaryRoot() *symbols.Scope
PrimaryRoot is the root scope of the document the model is named by.
func (*CachedModel) RuntimeSemantics ¶ added in v0.5.0
func (m *CachedModel) RuntimeSemantics() (*runtimeSemantics, func())
RuntimeSemantics locks and returns the model's shared runtime resolver and semantic model, built on first use, with the function releasing them.
func (*CachedModel) SoleDocument ¶ added in v0.4.2
func (m *CachedModel) SoleDocument() (*CachedDocument, error)
SoleDocument is the model's one document, for an operation defined on a single document's own source — editing it, or writing it back out. A model of several documents is refused rather than answered about one of them.
func (*CachedModel) SymbolContext ¶
func (m *CachedModel) SymbolContext() *SymbolContext
SymbolContext returns the conversion context for this model, building it on first use. Name resolution and the semantic relations derived from it are memoized in it, so every symbol converted from one cached model shares one.
type ConnectAdapter ¶ added in v0.3.0
type ConnectAdapter struct {
// contains filtered or unexported fields
}
ConnectAdapter serves the same Service through the Connect handler signatures, so one implementation answers every protocol Connect speaks.
func NewConnectAdapter ¶ added in v0.3.0
func NewConnectAdapter(svc *Service) *ConnectAdapter
NewConnectAdapter wraps a Service as a Connect handler.
func (*ConnectAdapter) ApplyEdits ¶ added in v0.3.0
func (a *ConnectAdapter) ApplyEdits(ctx context.Context, req *connect.Request[pb.ApplyEditsRequest]) (*connect.Response[pb.ApplyEditsResponse], error)
ApplyEdits edits a parsed model's own source.
func (*ConnectAdapter) Convert ¶ added in v0.3.0
func (a *ConnectAdapter) Convert(ctx context.Context, req *connect.Request[pb.ConvertRequest]) (*connect.Response[pb.ConvertResponse], error)
Convert writes a model out as SysML notation or RDF Turtle.
func (*ConnectAdapter) Evaluate ¶ added in v0.3.0
func (a *ConnectAdapter) Evaluate(ctx context.Context, req *connect.Request[pb.EvaluateRequest]) (*connect.Response[pb.EvaluateResponse], error)
Evaluate evaluates an expression against a parsed model.
func (*ConnectAdapter) EvaluateCalc ¶ added in v0.3.0
func (a *ConnectAdapter) EvaluateCalc(ctx context.Context, req *connect.Request[pb.EvaluateCalcRequest]) (*connect.Response[pb.EvaluateCalcResponse], error)
EvaluateCalc evaluates a calculation with the arguments given.
func (*ConnectAdapter) ExecuteAction ¶ added in v0.3.0
func (a *ConnectAdapter) ExecuteAction(ctx context.Context, req *connect.Request[pb.ExecuteActionRequest]) (*connect.Response[pb.ExecuteActionResponse], error)
ExecuteAction runs an action to completion.
func (*ConnectAdapter) ExecuteState ¶ added in v0.3.0
func (a *ConnectAdapter) ExecuteState(ctx context.Context, req *connect.Request[pb.ExecuteStateRequest]) (*connect.Response[pb.ExecuteStateResponse], error)
ExecuteState runs a state machine over the events given.
func (*ConnectAdapter) GetDiagnostics ¶ added in v0.3.0
func (a *ConnectAdapter) GetDiagnostics(ctx context.Context, req *connect.Request[pb.DiagnosticsRequest]) (*connect.Response[pb.DiagnosticsResponse], error)
GetDiagnostics returns the diagnostics of a parsed model.
func (*ConnectAdapter) GetServerInfo ¶ added in v0.3.0
func (a *ConnectAdapter) GetServerInfo(ctx context.Context, req *connect.Request[pb.ServerInfoRequest]) (*connect.Response[pb.ServerInfoResponse], error)
GetServerInfo reports what this build of the service can do.
func (*ConnectAdapter) GetSymbol ¶ added in v0.3.0
func (a *ConnectAdapter) GetSymbol(ctx context.Context, req *connect.Request[pb.GetSymbolRequest]) (*connect.Response[pb.SymbolResponse], error)
GetSymbol returns symbol information by qualified name.
func (*ConnectAdapter) Instantiate ¶ added in v0.3.0
func (a *ConnectAdapter) Instantiate(ctx context.Context, req *connect.Request[pb.InstantiateRequest]) (*connect.Response[pb.InstantiateResponse], error)
Instantiate materializes an instance of a definition.
func (*ConnectAdapter) ParseFile ¶ added in v0.3.0
func (a *ConnectAdapter) ParseFile(ctx context.Context, req *connect.Request[pb.ParseFileRequest]) (*connect.Response[pb.ParseFileResponse], error)
ParseFile parses a model and returns its hash.
func (*ConnectAdapter) ParseSources ¶ added in v0.4.2
func (a *ConnectAdapter) ParseSources(ctx context.Context, req *connect.Request[pb.ParseSourcesRequest]) (*connect.Response[pb.ParseSourcesResponse], error)
ParseSources parses several documents as one model.
func (*ConnectAdapter) Query ¶ added in v0.3.0
func (a *ConnectAdapter) Query(ctx context.Context, req *connect.Request[pb.QueryRequest]) (*connect.Response[pb.QueryResponse], error)
Query evaluates a SysML v2 API & Services Query over a parsed model.
func (*ConnectAdapter) RenderDocument ¶ added in v0.4.2
func (a *ConnectAdapter) RenderDocument(ctx context.Context, req *connect.Request[pb.RenderDocumentRequest]) (*connect.Response[pb.RenderDocumentResponse], error)
RenderDocument renders a named document to Markdown.
func (*ConnectAdapter) RunDocumentQuery ¶ added in v0.4.2
func (a *ConnectAdapter) RunDocumentQuery(ctx context.Context, req *connect.Request[pb.RunDocumentQueryRequest]) (*connect.Response[pb.RunDocumentQueryResponse], error)
RunDocumentQuery runs a named document query and answers with typed rows.
func (*ConnectAdapter) VerifyConstraint ¶ added in v0.3.0
func (a *ConnectAdapter) VerifyConstraint(ctx context.Context, req *connect.Request[pb.VerifyConstraintRequest]) (*connect.Response[pb.VerifyConstraintResponse], error)
VerifyConstraint evaluates a constraint and returns its verdict.
func (*ConnectAdapter) VerifyRequirement ¶ added in v0.3.0
func (a *ConnectAdapter) VerifyRequirement(ctx context.Context, req *connect.Request[pb.VerifyRequirementRequest]) (*connect.Response[pb.VerifyRequirementResponse], error)
VerifyRequirement evaluates a requirement and returns its verdict.
func (*ConnectAdapter) VerifySatisfaction ¶ added in v0.3.0
func (a *ConnectAdapter) VerifySatisfaction(ctx context.Context, req *connect.Request[pb.VerifySatisfactionRequest]) (*connect.Response[pb.VerifySatisfactionResponse], error)
VerifySatisfaction evaluates satisfaction relationships in a model.
type GraphBounds ¶ added in v0.5.0
GraphBounds is how far InstanceGraphToProtoWithin expands an object graph: nested objects to Depth, and Instances objects in all.
func DefaultGraphBounds ¶ added in v0.5.0
func DefaultGraphBounds() GraphBounds
DefaultGraphBounds are the bounds the service serializes an instance graph under.
type InstanceGraph ¶ added in v0.5.0
type InstanceGraph struct {
Root *pb.Instance
All []*pb.Instance // the root first
// Truncated reports that the instance bound cut the graph short.
Truncated bool
// Errors are the typed failures behind every FeatureValue.Error in All.
Errors []error
}
InstanceGraph is an object graph serialized by InstanceGraphToProtoWithin.
func InstanceGraphToProtoWithin ¶ added in v0.5.0
func InstanceGraphToProtoWithin(rt *runtime.Context, inst *runtime.Instance, idx *symbols.Index, bounds GraphBounds) InstanceGraph
InstanceGraphToProtoWithin is InstanceGraphToProto under the given bounds; the type cycle guard applies whatever the bounds.
type QueryError ¶
type QueryError struct {
Kind QueryErrorKind
Message string
}
QueryError is a query the service refuses to evaluate. It reports itself as INVALID_ARGUMENT, since every kind is a fault in the query, not in the model.
func (*QueryError) Error ¶
func (e *QueryError) Error() string
type QueryErrorKind ¶
type QueryErrorKind int
QueryErrorKind classifies why a query could not be evaluated. Every kind fails the call: answering with no elements would read as "nothing matched".
const ( // QueryErrUnknownProperty is a property no queryable property names. QueryErrUnknownProperty QueryErrorKind = iota + 1 // QueryErrMalformedConstraint is a constraint with no form, no operator or // no operand. QueryErrMalformedConstraint // QueryErrUnorderedProperty is > or < on a property that is not ordered. QueryErrUnorderedProperty // QueryErrUnparsableValue is an operand the operator cannot compare. QueryErrUnparsableValue // QueryErrUnknownScope is a scope naming an element the model does not have. QueryErrUnknownScope )
type Service ¶
type Service struct {
pb.UnimplementedSysMLServiceServer
// contains filtered or unexported fields
}
Service implements SysMLServiceServer
func NewService ¶
NewService creates a gRPC service with specified cache size, reporting version as its build version. It returns an error if cacheSize is not positive, if a budget variable holds anything but a positive integer, or if the prewarm setting is not a non-negative integer. It does not load the standard library: call Prewarm to have that happen in the background, ahead of the requests that need it.
func NewServiceWithUnavailableCapabilitiesForTesting ¶ added in v0.3.0
func NewServiceWithUnavailableCapabilitiesForTesting(cacheSize int, version string, unavailable []string) (*Service, error)
NewServiceWithUnavailableCapabilitiesForTesting creates a service that deliberately lacks named capabilities for conformance testing.
func (*Service) ApplyEdits ¶
func (s *Service) ApplyEdits(ctx context.Context, req *pb.ApplyEditsRequest) (*pb.ApplyEditsResponse, error)
ApplyEdits edits the source a model was parsed from and returns the edited notation, so a client can change a model and write it back with its comments and layout intact. Argument faults fail the call; an edit the engine refuses is reported in the response's error, failure kind and diagnostics.
func (*Service) Close ¶
func (s *Service) Close()
Close waits for a background library build in flight and releases the service's reference to the shared index. The service still answers afterwards, building the library on the request that needs it.
func (*Service) Convert ¶
func (s *Service) Convert(ctx context.Context, req *pb.ConvertRequest) (*pb.ConvertResponse, error)
Convert writes a model in another representation, so a client can save a model it read rather than only inspect it. Argument faults fail the call; a model the converter refuses is reported in the response's error and diagnostics.
func (*Service) Evaluate ¶
func (s *Service) Evaluate(ctx context.Context, req *pb.EvaluateRequest) (*pb.EvaluateResponse, error)
Evaluate evaluates a SysML expression in the context of a parsed model
func (*Service) EvaluateCalc ¶
func (s *Service) EvaluateCalc(ctx context.Context, req *pb.EvaluateCalcRequest) (*pb.EvaluateCalcResponse, error)
EvaluateCalc invokes a calculation, as the REPL's %calc does: a calc usage named with no arguments is evaluated from its own members and reports every output feature it computes (SysML 7.17); anything else is invoked with the arguments given, bound positionally.
func (*Service) ExecuteAction ¶
func (s *Service) ExecuteAction(ctx context.Context, req *pb.ExecuteActionRequest) (*pb.ExecuteActionResponse, error)
ExecuteAction executes an action definition
func (*Service) ExecuteState ¶
func (s *Service) ExecuteState(ctx context.Context, req *pb.ExecuteStateRequest) (*pb.ExecuteStateResponse, error)
ExecuteState executes a state machine
func (*Service) GetDiagnostics ¶
func (s *Service) GetDiagnostics(ctx context.Context, req *pb.DiagnosticsRequest) (*pb.DiagnosticsResponse, error)
GetDiagnostics retrieves all diagnostics for a parsed model (parser + semantic passes)
func (*Service) GetServerInfo ¶
func (s *Service) GetServerInfo(ctx context.Context, req *pb.ServerInfoRequest) (*pb.ServerInfoResponse, error)
GetServerInfo reports the service's build version and capabilities. A service too old to have this RPC fails the call with UNIMPLEMENTED, which is itself the answer that it predates every capability.
func (*Service) GetSymbol ¶
func (s *Service) GetSymbol(ctx context.Context, req *pb.GetSymbolRequest) (*pb.SymbolResponse, error)
GetSymbol retrieves symbol information by FQN
func (*Service) Instantiate ¶
func (s *Service) Instantiate(ctx context.Context, req *pb.InstantiateRequest) (*pb.InstantiateResponse, error)
Instantiate creates a runtime instance of a part/usage
func (*Service) ParseFile ¶
func (s *Service) ParseFile(ctx context.Context, req *pb.ParseFileRequest) (*pb.ParseFileResponse, error)
ParseFile parses a SysML file and caches the result
func (*Service) ParseSources ¶ added in v0.4.2
func (s *Service) ParseSources(ctx context.Context, req *pb.ParseSourcesRequest) (*pb.ParseSourcesResponse, error)
ParseSources parses several documents as one model, so a name one document declares resolves in another.
func (*Service) Prewarm ¶
func (s *Service) Prewarm()
Prewarm starts building the service's standard library index in the background, so the first model to arrive is not the one that pays for the library. It returns immediately and is safe to call more than once.
func (*Service) Query ¶
func (s *Service) Query(ctx context.Context, req *pb.QueryRequest) (*pb.QueryResponse, error)
Query evaluates a SysML v2 API & Services Query against a parsed model.
func (*Service) RenderDocument ¶ added in v0.4.2
func (s *Service) RenderDocument(ctx context.Context, req *pb.RenderDocumentRequest) (*pb.RenderDocumentResponse, error)
RenderDocument renders a named document to Markdown, as -render-document does.
func (*Service) RunDocumentQuery ¶ added in v0.4.2
func (s *Service) RunDocumentQuery(ctx context.Context, req *pb.RunDocumentQueryRequest) (*pb.RunDocumentQueryResponse, error)
RunDocumentQuery runs a named document query with parameter bindings, the answer %run-query gives, as typed rows rather than formatted lines.
func (*Service) VerifyConstraint ¶
func (s *Service) VerifyConstraint(ctx context.Context, req *pb.VerifyConstraintRequest) (*pb.VerifyConstraintResponse, error)
VerifyConstraint evaluates a constraint definition or usage, as the REPL's %constraint does.
func (*Service) VerifyRequirement ¶
func (s *Service) VerifyRequirement(ctx context.Context, req *pb.VerifyRequirementRequest) (*pb.VerifyRequirementResponse, error)
VerifyRequirement evaluates a requirement definition or usage, as the REPL's %requirement does.
func (*Service) VerifySatisfaction ¶
func (s *Service) VerifySatisfaction(ctx context.Context, req *pb.VerifySatisfactionRequest) (*pb.VerifySatisfactionResponse, error)
VerifySatisfaction evaluates the satisfaction assertions a model states, as the REPL's %satisfy does: every one, or, given a symbol, the ones that element states — or that element itself when it is a named satisfy assertion.
type SymbolContext ¶
type SymbolContext struct {
Index *symbols.Index
Resolver *resolve.Resolver
Semantics *semantics.Model
// contains filtered or unexported fields
}
SymbolContext holds what converting a symbol to proto needs besides the symbol: its index, and the resolver and semantic model that answer what its declared names refer to. Their memoization is why it is shared per model.
The resolver and semantic model memoize into plain maps, so a shared context must be used by one goroutine at a time; Lock serializes concurrent conversions of the same model.
func NewSymbolContext ¶
func NewSymbolContext(idx *symbols.Index) *SymbolContext
NewSymbolContext builds a conversion context over a symbol index.
func (*SymbolContext) Lock ¶
func (sc *SymbolContext) Lock() func()
Lock takes exclusive use of the context's resolver and semantic model, and returns the function releasing it.