reference constraint - index in parent

Hi,

I have a smart reference
and I want to limit the search scope for it.
The problem is that the limitation should depend on the index of the   
node in it's enclosingNode.

And I don't know how to get that index if it is a new node and referenceNode
is therefor null.

In other words: how would I go about finding out on which item the user's cursor is in the parent's child node cell list when the reference constraint code is called ?
Thanks
5 comments
Hi!

It's not possible now AFAIK. You can vote for: MPS-13803
0
I see,
I found a way to work around it for my case for now, but that would certainly be good to have.
I'll vote for it.
Thanks!
0
As for now when referenceNode is null, return all available targets for all positions. Immediately after creation the reference will be highlighted as "out of scope" (if it doesn't fit). That's how it works in baseLanguage.
0
What about node attribute, .index?

See Node_GetIndexInParentOperation - it gets node's index in parent's collection.
0
When you decided to add a new "smart reference" node into a list the node doesn't exist yet. MPS collects all possible targets for the link and uses custom link presentation query to show them in a completion menu.

In both "search scope" and "presentation" queries here referenceNode is not available during creation, but becomes available later when you edit existing node containing the reference.

link {accessor} 
  referent set handler:<none> 
  search scope: 
    (model, scope, referenceNode, linkTarget, enclosingNode, operationContext)->join(ISearchScope | sequence<node<InstanceMethodDeclaration>>) { 
      // search scope
    } 
  validator: 
    <default> 
  presentation : 
    (parameterNode, visible, smartReference, inEditor, model, scope, referenceNode, linkTarget, enclosingNode, operationContext)->string { 
      // default behavior is to get presentation of the target node
      parameterNode.getPresentation(); 
    } 
;
prettyPrint();
The former question was why there is no role & index parameters in these queries when referenceNode is null.
0

Please sign in to leave a comment.