[solved] Accessing types and their properties from another file (with same grammar) [message #1419928] |
Tue, 09 September 2014 04:59  |
Eclipse User |
|
|
|
Hi
I'm new to xtext and have a question. I have defined a grammar according to [an'T post link, just google xtext-and-dot-expressions] and modified it a little bit e.g. imports. My grammar now looks like this
grammar org.eclipse.xtext.example.domainmodel.Domainmodel with org.eclipse.xtext.xbase.Xbase
generate domainmodel "[interpreted as link]/example/Domainmodel"
DomainModel:
'package' packageName=QualifiedName
importSection=XImportSection?
elements+=Entity*
usages+=Usage*
;
Entity:
"entity" name=ValidID "{"
features+=Feature*
"}"
;
Feature:
Attribute | Reference
;
Attribute:
"attr" name=ValidID ":" type=DataType
;
enum DataType:
string | int
;
Reference:
"ref" name=ValidID ":" type=[Entity|QualifiedName]
;
Usage:
"use" ref=DotExpression
;
DotExpression returns Ref:
EntityRef ({DotExpression.ref=current} "." tail=[Feature])*
;
EntityRef returns Ref:
{EntityRef} entity=[Entity]
;
I have two files:
1) firstModel.dmodel
package myFirstPackage
entity myFirstEntity {
attr value : int
}
2) secondModel.dmodel
package mySecondPackage
import myFirstPackage.*
entity mySecondEntity {
attr myAttr : int
ref myRef : myFirstEntity
}
use mySecondEntity.myRef
The import works, but the "dot-operation" does not. I followed christian's example, implemented the ScopeProvider and modified the bindIScopeProvider method in AbstractDomainmodelRuntimeModule.java accordingly.
Do I have to change / implement something else?
[Updated on: Thu, 11 September 2014 07:22] by Moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.24524 seconds