Update a property of a referenced concept

Anybody knows how to update the value of a property of a referenced concept?

Thanks.
6 comments
Sure, myReference.theDeclaration.itsProperty = "value"
0
Thanks! I am a newer to MPS, so I still need more explanations on your answer: 1. Does myReference denote the referenced concept defined in another concept? If so, what does theDeclaration refer to? 2. where can I use it? TextGen, Action, or other aspects? Thanks again.
0
1.
myReference was meant to be a "reference" concept, such as VariableReference, for example, in BaseLanguage
theDeclaration would then be the actual reference that points to the declaration of some sort, e.g. VariableReference.variableDeclaration that points to VariableDeclaration instance

2.
the code is usable in all aspects, it simply navigates the model (AST)

I might well have misunderstood your original question. In that case please provide more details of what you need.

Cheers,

Vaclav
0
Thanks for your reply! In order to help you understand my issue, I paste some code here. I defined two concepts: Dim and Select as follows:

concept Dim extends Statement         
            implements INamedConcept   

  instance can be root: false
  alias: dim
  short description: <no short description>

  properties:
  state : string

==============================================
concept Select extends Statement
implements <none>     
     
  instance can be root: false
  alias: select
  short description: <no short description>

  properties:
  which : string

  references:
  dim : Dim[1]

===============================================

I created a TextGen for Select concept; and then, in the TextGen, I was trying to update the value of "state" property of the referenced "dim" with the latest value of "which" property. My code looks like this

text gen component for concept Select {
  (context, buffer, node)->void {
   
    node.dim.state = node.which;
     
  }
}


My question is when I was trying to generate java code in sandbox, the code in the TextGen always causes errors. So, in order to achieve the update feature, how should I do? Thanks
0
The thing is that the model is read-only in the text-gen phase to allow for various optimalizations and multi-threaded text generation. You are not allowed to change the properties here. Text-gen is meant to provide straight model-to-text conversion.

Instead, you should leverage the generator, which is intended for transforming the models before the final text generation.
0
Understand now. Really thanks.
0

Please sign in to leave a comment.