How can i display only substring of a property?

Hi,

in order to remove the "set" from Setter-Methods, i created an attribute concept with a reference to the setter-Method (InstanceMethodDeclaration). In this attribute concept i used a constraint and changed the presentation there as follows:

link {methodDeclaration}
  referent set handler:<none>
  search scope:
    (model, scope, referenceNode, linkTarget, enclosingNode)->join(ISearchScope | sequence<node< >>) {
...
}
  validator:
    <default>
  presentation :
    (parameterNode, visible, smartReference, inEditor, model, scope, referenceNode, linkTarget, enclosingNode)->string {
      parameterNode.name.substring(3, 4).toLowerCase() + parameterNode.name.substring(4);
    }
;


However, this does only change the presentation in the code completion menu - but not in the final editor. i.e. i removed the "set" in the code completion menu, but after selecting a method, the "set" appears again in the editor ...


Any ideas,
Dan
4 comments
Comment actions Permalink
Hi Dan,

Are you extending the BaseLanguage? What is your setup?
I don't know what you want to do.

The way you need to go, is to define the visualization in the editor.
Or to override the property that is used in the editor for visualisation at the constraints.

E.G.
If you have a Reference concept (a concept with just one reference to the thing you want to reference e.g. the methoddeclaration) you can define the editor for that concept and use a "read only model access" to only show the substring.

I hope I could help.
0
Comment actions Permalink
Hi Michael,

thanks for your answer. Yes i m extending the BaseLanguage in order to set properties of java classes more easily. One should simply be able to use text = "test" instead of setText("test"). It does work perfectly, except that i can not remove the set in the editor.

For code completion i use the "presentation" hook in the concept constraints. Work s perfect. (code above) But after selection with code completion (e.g. "text"), the concept editor displays "setText" again.

Where can i define the "read only model access" in the editor? Is it the right solution for me?

Best,
Dan
0
Comment actions Permalink
Hi Dan,

the read only model access is available here:
MPS-REadonlyMA.gif


btw. I'm using MPS2.0 but should be availabe in 1.x too.

As far as I understand what you are trying to do, this is already possible in MPS.
When you use MPS's baselang's properties, you can use sth. like
Blub blub = new Blub(); 
blub.someString = "someString";
prettyPrint();
and generate is
blub.setSomeString("someString");
prettyPrint();

Why do you want to reinvent this?
0
Comment actions Permalink
Hi Michael,

i m going the opposite direction. I read some apache pivot ClassConcept from stubs and access their properties in a apache pivot editor, without displaying set/get for the accessors ...

From the that editor i generate xml files, but they are also without set/get when accessing properties ..

dan
0

Please sign in to leave a comment.