Problem with scopes

Hi, i have problem with scope. I must to filter references in projects becasue i have ref to all that i need and some no name references. I try with SimpleRoleScope and Filtering.

9 comments
Comment actions Permalink

Yes, you are on the right track. What exactly is the problem? Can you share your scope resolution code?

0
Comment actions Permalink

Exactly is probelm how to implements scopes for my project, i see explanation on jb site but when i code like there, mps is filtering all ref and i want only this no name to filter. I send you my implemetation .

0
Comment actions Permalink

You get the "no name" entries in the completion menu, because you have nodes with no name in the SystemModel.domainModel collection. To filter these out from the scope, add a FilteringScope around the Scope that you are currently creating and in the isExcluded() method test for "node.name.isEmpty()".

Vaclav

 

0
Comment actions Permalink

Thanks for your answers, I haven`t idea how to implements that. I send you my implementation and if you can to fix my errors.

link {stateRef}
referent set handler <none>
scope (referenceNode, contextNode, containmentLink, position, linkTarget)->Scope {
SimpleRoleScope.forNamedElements(referenceNode.ancestor<concept = SystemModel>, link/SystemModel : domainModel/);
FilteringScope myfilter = myfilter.isExcluded(referenceNode.name.isEmpty());
}
<no presentation (deprecated)>

0
Comment actions Permalink

Sorry for interrupiton, if you can to help me with this its very important to me that is my project for my studies and i dont have idea how to implement correct.

 

0
Comment actions Permalink

You need to create an anonymous subclass of FilteringScope and implement the isExcluded method in that anonymous subclass as Vaclav says.

0
Comment actions Permalink

Thanks for answer, i understand that but i dont know how to create this anonymous subclass, i send you my implementation and if i am on track told me where is my errors.

return new FilteringScope(SimpleRoleScope.forNamedElements(referenceNode.ancestor<concept = SystemModel>, link/SystemModel : domainModel/)) {
@Override
public boolean isExcluded(node<StateRef> refNode) {
refNode.name.isEmpty();
}
};

0
Comment actions Permalink

This looks almost correct to me, I would only do two small changes:

  • Use contextNode instead of referenceNode because in case of a smart reference the reference node might be null so it's best to avoid using it.
  • Add a '+' to the ancestor<...> operation so that it becomes ancestor<concept = SystemModel, +>.

What result do you get with this code?

0
Comment actions Permalink

Thanks for answer, result is that filter everything in scope. I trying to solve and if you have any idea how to solve i am glad to see that.

0

Please sign in to leave a comment.