Extending XFeatureCall scope

六眼飞鱼酱① 提交于 2020-01-06 06:41:07

问题


This has been puzzling me for a while... I have done research, tried lots of things but failed miserably. The time has come to ask here.

My grammar has this rule to define types:

MyTypeDeclaration returns XExpression:
    =>({MyTypeDeclaration} type=JvmTypeReference name=ValidID '(')
    (params+=FullJvmFormalParameter (',' params+=FullJvmFormalParameter)*)?
  ')' block=XBlockExpression
;

Of course, in the inferrer, I map it to a class (with a supertype MySupertype to differentiate from other Java classes)

    members += f.toClass(f.fullyQualifiedName) [
      superTypes += typeRef(MySupertype)
      ...

      members += f.toConstructor [
        for (p : f.params)
          parameters += p.toParameter(p.name, p.parameterType)
        body = f.block
      ]
      ...
    ]

What I need is to invoke this class as a function, e.g. using XFeatureCall. XFeatureCall::feature is a JvmIdentifiableElement and so is MyTypeDeclaration when mapped (in the compiler I will add a "new" prefix to call the class constructor). However, naturally, XFeatureClass does not include Java classes in its default scope.

So the question is, how to change this behavior? I need to include MyTypeDeclaration instances (or, more generally, Java classes with MySupertype as superclass) in XFeatureClass scope. I looked at the type computer, getLinkingCandidates and al but it looks too arcane for me.

I use version 2.15 as I need GWT...

Please help as I am really stuck at this point...

Thanks,

Martin

来源:https://stackoverflow.com/questions/56138876/extending-xfeaturecall-scope

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!