What is search scope and node adapter?


Can anybody explain to me by giving an example what is a search scope (ISearchScope interface) and what is node adapter (INodeAdapter)?

1 comment
Comment actions Permalink


Search scopes (ISearchScope) are used, for example, when you need to complete a name of a local variable in MPS. What variables are visible at the place you are in? This is determined by a search scope. You can look at example in LocalVariableReference's constraints. But it's better to use sequence<node> in such cases as the result of a concept function, because it's simplier and makes no need to deal with internal MPS classes. Search scopes are needed in some cases for performance reasons.

INodeAdapter is an internal system for working with MPS nodes from java code. They are exactly adapters from universal non-typed SNodes from AST to an interface giving an ability to manipulate with concrete node type. When you write your code in MPS, you use smodel language for that purposes. So, you normally don't need these classes (implementing INodeAdapter) in your code.

Btw, there's quite simple way to look for examples - in your case, you can use the following actions:

1) select "search scope" block in concept's constraints

2) press ctrl-shift-S to go to the concept of this node (concept function)

3) search for its instances

In my opinion, the best examples to look at are in baseLanguage




Please sign in to leave a comment.