Calculator tutorial --- MPS 3.0 breaking changes

I'm watching a video tutorial on constraints and type-system in Calculator language. It seems MPS 3.0 introduces some breaking changes so that scope resolution no longer works when coded in a way shown. Precisely you cannot access InputFields names in code completion. Please correct my statement and show me my mistake or provide me with the closest approach to program scope resolution to the shown one :)
TutorialCalculator.zip (128KB)
20 comments
So, that isn't a bug, right?
0
You'd better follow the textual tutorial in this part, since that one does things as they should be done - http://www.jetbrains.com/mps/docs/tutorial.html#Creating_a_scope_for_InputFieldReference
0
In brief, you should be referring to InputField instead of Calculator in the Constraint definition as well as in the getScope() method. These are the only two changes necessary to make your code work :)
0
Okay, and what does forNamedElements — does it return a scope with all nodes, implemented INamedConcept interface?
0
And when (in which version) this has changed? In the video tutorial it's all working :)
0
public Scope getScope(concept<> kind, node<> child)
  overrides ScopeProvider.getScope {
  if (kind.isSubConceptOf(InputField)) { return SimpleRoleScope.forNamedElements(this, link/Calculator : inputField/); }
  return null;
}
0
Can you please send me corrected version? I didn't succeed in doing what you are saying.
0
Yeah, that's clear. But what about "In brief, you should be referring to InputField instead of Calculator in the Constraint definition as well as in the getScope() method. These are the only two changes necessary to make YOUR code work :)"
0
Type "InputField" instead of "Calculator" in two places of your code - the constraint definition and the getScope() method
0
The emphasis is on YOUR code :)
0
I was thinking it was your code (TutorialCalculator.zip) that is attached to this forum entry.
0
Nope. That's bad advice. If you saw my code you understand that if i change Calculator to InputField then the inputField link will be invalid (i'm talking about getScope method — and it has only one mentioning of Calculator). Am i right? Still i was able to resolve my problem by changing InputFieldReference to InputField in expression kind.isSubConceptOf(InputFieldReference). Common sense is a great thing, after all! :)
0
Sooooooooooo my bad!!! I'm so sorry! Don't know what happened but the code in the .zip is working! And my not working code was with the described mistake :(
EDIT: No, it's not working. Just got confused with different windows in which projects with the same name are opened.
0
Exactly! But And in a video tutorial it's with that mistake. Perhaps it was permissible in previous versions of MPS to use smart references' concepts and their referents' concepts more interchangeably than now. Perhaps, Vaclav, it would be good idea to add some comments under video on JetBrains TV?
0
Okay, and what does forNamedElements — does it return a scope with all nodes, implemented INamedConcept interface?

Please, i'm begging you, Vaclav, answer that! :-)
EDIT: I also don't quite understand — the 'scope: search for InputField' fragment of InputFieldReference referent constraints means that some of the ancestors have to look for InputFields?
0
It just creates scope with all children of given node by given link.
0
Yes, it is. I downloaded it and checked that my code does not use forNamedElements and also that my 'bad advice' message is applicable.
0
Then why 'Named' in the name?
0
As I understood, Scope represents both data and it's text presentation. For INamedConcept node name could be guessed as the concept's name property value.

The only thing I don't understand so far is if it ever uses text presentation or not - I have problems with node presentations (in the near topic).
0
Ok, after looking to the code, i understood that my assumption was correct — it's all about INamedConcepts. And the code does almost exactly what Vaclav did by hands (in the tutorial) :)
0

Please sign in to leave a comment.