Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Domain model: member access
Domain model: member access [message #700425] Sat, 23 July 2011 11:57 Go to next message
amazuzu  is currently offline amazuzu Friend
Messages: 17
Registered: May 2011
Junior Member
Hi

I want to impl member access in domain model example (I mean xtext 1.0 example without xtend or xbase ).

Here what I change in grammar
AbstractElement:
        PackageDeclaration | Type | Import | MemberAccess;

MemberAccess:
	"memberaccess" entity=[Entity] "." attribute = [Attribute];



dsl looks following
datatype int

entity Foo{
	foo:int
}

memberaccess Foo.foo //Couldn't resolve reference to Attribute 'foo'


what i'm doing wrong?
Re: Domain model: member access [message #700428 is a reply to message #700425] Sat, 23 July 2011 12:02 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13615
Registered: July 2009
Senior Member
Hi,

Qualified names a built by the elements names and their parents names.
so the Attribute foo has the FQN Foo.foo.

so you have to change the grammar too

MemberAccess:
	 attribute = [Attribute|FQN];
FQN: ID ("." ID)*;


or change to local scoping for attibute by putting the attributes under their simple name into scope

	public IScope scope_MemberAccess_attribute(MemberAccess memberAccess, EReference ref) {
		return Scopes.scopeFor(Iterables.filter(memberAccess.getEntity().getFeatures(), Attribute.class));
	}


~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 23 July 2011 12:09]

Report message to a moderator

Previous Topic:Single Character compete versus INT and ID
Next Topic:[Xtext2] Extending XbaseCompiler
Goto Forum:
  


Current Time: Wed Sep 30 09:35:32 GMT 2020

Powered by FUDForum. Page generated in 0.01415 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top