MPS 2020.1 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 queries are performed.

smodelquery1

 

The scope can be constrained to a project, module, model or a sequence of these.

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 single query using scope parameter This option overrides scope derived from with statement.

The scope parameter can consist of 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 include only editable models so that modifying operations can be safely performed within that scope.

smodelquery4

Using smodel queries in console plugin

Queries can be used in the console without the wrapping with statement. Default scope there for queries 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: 18 June 2020