我有这个iscope方法:
IScope scope_Assignment(AssignmentOrFBCall a, EReference ref){
System.out.println(a.toString());
return IScope.NULLSCOPE;
}
但不会产生任何结果。用println和内容助手的输出中没有任何变化。因此,我认为它尚未执行,但是如果我尝试添加一个断点,它将被交叉。
那么,问题在哪里?
语法规则是:
AssignmentOrFBCall:
(((variable=[VariableDefinition]) |
((variableArray=[ArrayDefinition]'['index=ExpressionIndex']')('.'internalVariable=InternalRecursive)?) |
(variableStructOrFB=[VariableDefinition]'.')(internalVariable=InternalRecursive))
((':='expression=Expression)|('('(parameter=FBParameter | ')'))))
;
使用此范围提供商解决:
@Override
protected IScope createLocalVarScope(IScope parentScope,
LocalVariableScopeContext scopeContext) {
if (scopeContext != null && scopeContext.getContext() != null) {
EObject context = scopeContext.getContext();
if (context instanceof Program) {
Program program = (Program) context;
return Scopes.scopeFor(program.getDeclarations());
}
}
return super.createLocalVarScope(parentScope, scopeContext);
}