0

我正在 MPS 中编写 DSL 来定义事件生产者/消费者,如下所示:

on FooEventProducer
    then FooEventConsumer

在哪里:

class FooEventProducer implements Producer<FooEvent> {}
class FooEventConsumer implements Consumer<FooEvent> {}

我有一个包含ClassifierType参考的 On 概念。

如何限制ClassifierType对子类的引用Producer

4

1 回答 1

0

我建议您创建和使用您自己的 ClassifierType 子概念,它指定对“分类器”引用的约束,例如:

concepts constraints MyClassifierType { 
  can be child <none> 

  can be parent <none> 

  can be ancestor <none> 


  <<property constraints>> 

  link {classifier} 
    referent set handler:<none> 
    scope: 
      (exists, referenceNode, contextNode, containingLink, linkTarget, operationContext, enclosingNode, model, position, contextRole)->Scope { 

        sequence<node<Classifier>> candidates = model.nodesIncludingImported(Classifier).where({~it => it.getExtendedClassifierTypes().any({~clazz => clazz.classifier :eq: node/Runnable/; }); }); 
        new ListScope(candidates) { 
          public string getName(node<> child) { 
            child : INamedConcept.name; 
          } 
        }; 
      } 
    presentation : 
      <no presentation> 
  ; 

  default scope 
    <no default scope> 

}
于 2015-08-25T07:55:13.357 回答