2014-07-18 31 views
1

每次嘗試訪問ScopeProvider中的上下文對象時,我都會得到「循環分辨率的延遲鏈接」錯誤,或者我的ScopeProvider將被完全忽略,默認範圍是用過的。Xtext ScopeProvider:訪問上下文對象導致錯誤

繼承人一個小例子語法:

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals 

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl" 

Model: 
    (greetings+=Greeting)* 
    (farewells+=Farewell)*; 

Greeting: 
    'Hello' name=ID '!'; 

Farewell: 
    'Bye' name=[Greeting] '.'; 

這是ScopeProvider:

class MyDslScopeProvider extends org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider { 

def scope_Farewell_name(Farewell context,EReference reference){ 
    System.out.println(context.name); 
    return IScope::NULLSCOPE 
} 
} 

有什麼錯誤的,我的做法?

爲什麼我要訪問上下文:

我試着去創造的GLSL着色語言的編輯器。生病需要一個結構構件和場選擇算子之間進行區分:實施例:

struct Test{ 
vec4 x; 
}; 

Test s; 
s.x.x=5.0; 

第一x是結構構件和所述第二一個是矢量的x座標。

回答

2

嗨xtext做索引和鏈接在不同的階段。因此您不能訪問名稱提供程序中的交叉引用。您可以使用NodeModelUtil.findNodesForFeature來檢索名稱提供商中的鏈接文本

相關問題