Custom expression
Hello,
I'm building a DSL in MPS for my bachelor thesis and need your help. I just started with MPS and got a lot of insight with the online documentation and also the two reference books on the jetbrains website. But I can't figure something out how to do it. To give you some insight, I want to build a language to support the JUnit framework in Java and generate testcode it in a simple manner.
It should look like this
<Class> Test
...
I'm now there were I select the java class, select the method according to this class and also the parameters, using typesystem, constrains. The tricky part where I'm stuck is the "where" part. What I want to do is to have the result of the method, or staticfields of the class and use it within a DotExpression or some other Expression.
My approach is that I have a "Field" concept where I use a reference to BaseMethodDeclaration and in the editor I can access the returnType. I also have a child Expression where I want to use my Type to use a comparison operator, or if it's a class a dot operator. I used constrains to have the right returnType of that particular method, but how can I manipulate this that in the editor stands: 'result' and I can make Expression on that? I'm just clueless, I couldn't find anything in the examples or anywhere online. Maybe you can give me some hint how to go about this. I appreciate any help you can give me.
Michael
I'm building a DSL in MPS for my bachelor thesis and need your help. I just started with MPS and got a lot of insight with the online documentation and also the two reference books on the jetbrains website. But I can't figure something out how to do it. To give you some insight, I want to build a language to support the JUnit framework in Java and generate testcode it in a simple manner.
It should look like this
<Class> Test
- methods-
...
I'm now there were I select the java class, select the method according to this class and also the parameters, using typesystem, constrains. The tricky part where I'm stuck is the "where" part. What I want to do is to have the result of the method, or staticfields of the class and use it within a DotExpression or some other Expression.
My approach is that I have a "Field" concept where I use a reference to BaseMethodDeclaration and in the editor I can access the returnType. I also have a child Expression where I want to use my Type to use a comparison operator, or if it's a class a dot operator. I used constrains to have the right returnType of that particular method, but how can I manipulate this that in the editor stands: 'result' and I can make Expression on that? I'm just clueless, I couldn't find anything in the examples or anywhere online. Maybe you can give me some hint how to go about this. I appreciate any help you can give me.
Michael
Please sign in to leave a comment.
if I understand the problem correctly, you need to define a "MethodResult" concept, such as:
with an editor holding a single constant "result" cell and a type-system rule:
This will give you the type checks needed as well as the desired DotExpression behaviour.
Vaclav
But if I select the MethodResult and want to use an Expression on it this happens:
http://i.imgur.com/TAHV06o.png
I tried several things but couldn't solve it. Thanks in advance for your help!