|
|
|
|
Re: scope problem [message #634684 is a reply to message #634680] |
Fri, 22 October 2010 17:58 |
|
Hello chuck,
using a grammar like this
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
classes+=Class*
funs+=Fun*
;
Class returns ecore::EClass: exClass|CP;
exClass :"eclass" name=ID ":" (exref=[ecore::EClass]);
CP :"class" name=ID;
Fun:
"def" name=ID
('(' (params+=(CP))? (',' params+=(CP))* ')') "{"
"}"
;
and a IQNP like this
public String qualifiedName(CP cp) {
return cp.getName();
}
works for me with the sample model
class a
eclass Name : X
eclass Name2 : Z
class b
def fun (class X){
}
Z comes from the external .ecore file
@Meinte: Xtext automatically adds all EClasses to the global scope using the plugins org.eclipse.xtext.ecore, org.eclipse.xtext.ui.ecore
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Fri, 22 October 2010 18:06] Report message to a moderator
|
|
|
|
|
|
|
Re: scope problem [message #739367 is a reply to message #739364] |
Mon, 17 October 2011 11:54 |
|
Hi,
if in Xtext the damn name of class if packagename.classname you of course have to change the grammar to exref=[ecore::EClass|FQN]. i thought by telling "... but I overrided the FQN... you would already have dones this or fixed it in the scopeprovider. changing your dsls QualifiedNameProvider does not help at all.
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Re: scope problem [message #749602 is a reply to message #739379] |
Tue, 25 October 2011 10:17 |
chuck Messages: 160 Registered: July 2010 |
Senior Member |
|
|
Hi Christian... I found a very simple example of my problem...maybe a workaround could solve it...
grammar:
Model:'package' Class=[ecore::EPackage]"{"
feature+=MyFeature*
"}"
;
MyFeature returns ecore::EStructuralFeature:{MyFeature} feature=[ecore::EStructuralFeature];
scope:
public IScope scope_MyFeature_feature(MyFeature f, EReference r) {
List union=new ArrayList();
EPackage p=EcorePackage.eINSTANCE;
EClass c= (EClass) p.getEClassifier("EPackage");
for (EStructuralFeature feature : c.getEAllAttributes()) {
union.add(feature);
}
for (EClass supertype : c.getESuperTypes()) {
for (EStructuralFeature feature : supertype.getEAllAttributes()) {
union.add(feature);
}
}
return Scopes.scopeFor(union);
}
model:
package p1{
ctrl+space //i don't receive code completion...
}
if i change the rule:
MyFeature returns ecore::EStructuralFeature:{MyFeature} 'feature' feature=[ecore::EStructuralFeature]; //added a simple string
i receive code completion...
so... i hope to be clear
(solved the other problem)
[Updated on: Thu, 27 October 2011 08:23] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.05803 seconds