1 回答
TA贡献1934条经验 获得超2个赞
在你的语法中你有
QName:
data=[Data|ID] '.' path=[Field|ID]
;
因此a.b将成为两个参考的范围。因此你要么必须在你的范围提供商中反映这一点
// TODO: context will be a qname. ask it for its data. ask that for its data and collect fields from there and then
// scope for path
EObjectDescription.create(
QualifiedName.create(field.name ),
field ))
例如
override getScope(EObject context, EReference reference) {
if (reference === MyDslPackage.Literals.QNAME__PATH) {
if (context instanceof QName) {
val result = newArrayList
for (field : context.data.type.fields) {
result.add(EObjectDescription.create(QualifiedName.create(field.name), field))
}
System.err.println(result)
return new SimpleScope(IScope.NULLSCOPE, result)
}
}
super.getScope(context, reference)
}
或者你有语法来反映你的范围
DataOrField: Data | Field;
QName: dataOrField=[DataOrField|FQN]
FQN: ID ("." ID)?;
添加回答
举报