Autocomplete for not INamedConcept references

In my application I have a concept that has context-depended name (MyConcept_Behavior.getName(node<> contextNode)). How should I declare a reference concept (and its constraints) in a way to render referenced node's name properly?

I created a MyConceptReference extends Expression concept with reference to a MyConcept[1]. Then I created a MyConceptReference_Constraints node and reference constraint in it with reference scope like this:
return new SimpleScope(model.nodes<MyConcept>){     public string getReferenceText(node<> target){         ifInstanceOf (target is MyConcept mc){             return mc.getName(null);         }         return "Unknown node " + target/.getNodeId();     } }

No aliases were defined for both MyConcept and MyConceptReference. Still I don't see getName(null) invocation result in autocomplete list, but "MyConcept" label for every entry.

How should I use references like these?
0
3 comments
Also if I give MyConceptReference an alias and create it's Editor so that I could distinguish reference from referenced node name (say, with prefix and postifx constant cells, like [- $ %myConcept%->*R/O model access* $ -], in model design time when I point cursor at referenced node cell and press Ctrl+Space, I have the same result in completion list - "MyConcept" for every scope entry.
0
Avatar
Permanently deleted user
You could add a referent constraint (Contraints <<referent constraints>>) in the concept which holds the reference (MyConceptReference as I take it). There you choose the reference, maybe you also want to define your scope. Then - the important part - you create a 'presentation' (the last part in the referent contraint editor). Here e.g. I want to show the XPath for an XML element I choose as a reference:
(parameterNode, visible, smartReference, inEditor, model, exists, contextNode, contextRole, position, scope, referenceNode, linkTarget, enclosingNode, containingLink, operationContext)->string {
 return XmlPathHelper.pathFor(parameterNode)
;
}
Here I used a utility class XmlPathHelper to do the calculation.
0
Thanks, Jens! It works fine after I added presentation handler.
0

Please sign in to leave a comment.