MPS 2022.2 Help

SModel Query language

smodel.query language

The jetbrains.mps.lang.smodel.query language enables the same type of queries that the MPS Console uses:

Console query

This language is allowed to be used inside with-statement, which constraints the scope, on which the queries are performed. The scope can be constrained to a project, module, model or a sequence of these. Additionally, it specifies whether the scope includes all models or only the read-only ones.

Smodelquery1

Operation parameters

The behavior of smodel.query operations can be slightly changed using operation parameters, which can be specified after the operation name. 

Smodelquery2

Possible parameters include:

scope - Each command operates in the scope specified in the surrounding with-statement. The scope parameter changes the operating scope for a single command.

exact- can be used in #instances operations to find instances of the concept specified, excluding instances of descendant concepts

Scope specification

Scope on which queries are performed can be specified explicitly for a single query using scope parameter. This option overrides scope derived from with statement.

The scope parameter can consist of a sequence of models or modules, or can be an arbitrary expression of type SearchScope.

Smodelquery3

When the scope parameter of a query is not specified, the query is performed on the scope constructed by the enclosing with statement. To avoid confusion, nested with statements are not supported. With statements can construct a scope from a model, a module, a sequence of those, from a project of from an existing SearchScope object.

Scope constructed by the with statement may, if desired, include only editable models so that all operations that change models can be safely performed within that scope.

Using smodel queries in the console plugin

Queries can be used in the console without the wrapping with statement. The default scope for queries in the console that do not specify it explicitly contains all editable models in the current project. Also, some additional options are available when specifying the scope explicitly.

Queries defined in the smodel.query language

#instances - fast search for instances of a specified concept

#usages - fast search for usages of a specified node

#modules - all modules in scope

#models - all models in scope

#nodes - all nodes in scope

#references - all references in scope

 

Last modified: 08 February 2022