Home » Modeling » TMF (Xtext) » Rules group in grammar for a right outline view ?
| | | |
Re: Rules group in grammar for a right outline view ? [message #759745 is a reply to message #759693] |
Tue, 29 November 2011 15:06   |
Eclipse User |
|
|
|
Honestly, the "influencing the outline structure" in the reference manual is not very helping me !
"The following simplied snippet
from Xtend2 illustrates how to use it:"
protected void createChildren(DocumentRootNode parentNode,
XtendFile xtendFile) {
// show a node for the attribute XtendFile.package
createEStructuralFeatureNode(parentNode,
xtendFile,
Xtend2Package.Literals.XTEND FILE PACKAGE,
getImageForPackage(),
xtendFile.getPackage(),
true);
// show a container node for the list reference XtendFile.imports
// the imports will be shown as individual child nodes automatically
createEStructuralFeatureNode(parentNode,
xtendFile,
Xtend2Package.Literals.XTEND FILE IMPORTS,
getImageForImportContainer(),
"import declarations",
false);
createEObjectNode(parentNode, xtendFile.getXtendClass());
}
I dont really acquainted with xtend :
createEStructuralFeatureNode(IOutlineNode, EObject, EStructuralFeature, Image, Text, isLeaf)
What is supossed i must have to put in the -> EStructuralFeature parameter
Somebody can give me a light ??
|
|
|
Re: Rules group in grammar for a right outline view ? [message #759752 is a reply to message #759745] |
Tue, 29 November 2011 15:26   |
Eclipse User |
|
|
|
Hi Federico,
the EStructuralFeature parameter actually is not strongly related to
Xtend. It's an EMF concept which is the technology that is used for the
abstract syntax tree / semantic model. You should consider studying it
as it is a powerful tool.
Look for something like <MyDsl>Package in the runtime plugin of your
language. It should contain an inner class Literals with a lot of
fields. Many of them are structural features and can be understood as
the descriptive data for the structure of your model.
The hello world language would yield something along those lines:
MyDslPackage.Literals.MODEL__GREETINGS
which is the list of greetings that is contained in a model and thereby
the description for myModel.getGreetings(): EList<Greeting>.
Hope that helps,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 29.11.11 21:06, schrieb Federico Sellanes:
> Honestly, the "influencing the outline structure" in the reference
> manual is not very helping me !
>
> "The following simplied snippet
> from Xtend2 illustrates how to use it:"
>
> protected void createChildren(DocumentRootNode parentNode,
> XtendFile xtendFile) {
>
> // show a node for the attribute XtendFile.package
>
> createEStructuralFeatureNode(parentNode,
> xtendFile,
> Xtend2Package.Literals.XTEND FILE PACKAGE,
> getImageForPackage(),
> xtendFile.getPackage(),
> true);
>
> // show a container node for the list reference XtendFile.imports
> // the imports will be shown as individual child nodes automatically
>
> createEStructuralFeatureNode(parentNode,
> xtendFile,
> Xtend2Package.Literals.XTEND FILE IMPORTS,
> getImageForImportContainer(),
> "import declarations",
> false);
> createEObjectNode(parentNode, xtendFile.getXtendClass());
> }
>
>
> I dont really acquainted with xtend :
>
> createEStructuralFeatureNode(IOutlineNode, EObject, EStructuralFeature,
> Image, Text, isLeaf)
>
> What is supossed i must have to put in the -> EStructuralFeature parameter
>
> Somebody can give me a light ??
|
|
|
Re: Rules group in grammar for a right outline view ? [message #759973 is a reply to message #759752] |
Wed, 30 November 2011 13:52   |
Eclipse User |
|
|
|
Thanks, you save my head, is working now. 
I have a little and noob grammar question now, i think is not need to make another post :
My code :
Greeting :
'module' name=ID '{'
innerElements += ModuleInnerElements*
'}'
;
ModuleInnerElements:
EntitieStatement
| InterceptorStatement
;
EntityStatement:
'entity' name=ID '{'
attributes += attributeStatement ((',' attributes += attributeStatement)?)*
'}'
;
InterceptorStatement:
'interceptor' name=ID '{'
//Not interesting things
'}'
In this case i cant have an interceptor and an entity with the same name
module {
entitie customer {
// Attributtes
}
interceptor customer {
// Not interesting things
}
}
i have an error, obviously, "Duplicate InnerElement", and i dont know the right way for acomplish this.
if i do this in this manner :
My code :
Greeting :
'module' name=ID '{'
Entities += EntityStatement*
Interceptors += InterceptorStatement*
'}'
;
EntityStatement:
'entity' name=ID '{'
attributes += attributeStatement ((',' attributes += attributeStatement)?)*
'}'
;
InterceptorStatement:
'interceptor' name=ID '{'
//Not interesting things
'}'
I avoid the "name" problem but, there is no the correct sintaxis because i cant make an interceptor and after and entity or an entity,interceptor,entity...
Thanks, in advance.
|
|
| | |
Re: Rules group in grammar for a right outline view ? [message #1694956 is a reply to message #759752] |
Sun, 10 May 2015 14:35   |
Eclipse User |
|
|
|
In my model I construct a class called View that contains among other objects a collection of Fields. These classes are derived from the parser. I need to group some of the collections of View. To this end, in the _createChildren(DocumentRootNode parentNode, View view) I create a node with createEStructuralFeatureNode(parentNode, view,...).
Although the node shows in the outline, the problem is how to populate it with the elements of the corresponding collection in View.
I tried:
protected def _createChildren(DocumentRootNode parentNode, FieldDeclaration field) {
for (FieldDeclaration f : (field.eContainer as View).dbFields) {
createNode(parentNode, f);
}
}
but it didn't work.
I think the documentation could be improved if all examples and code snippets refer to the same model (e.g. the State Machine example). Examples for the Outline refer to a language with classes and attributes, scoping begins with the state machines and then switches to MyScopingDsl. Finally, code snippets would be more informative if the documentation states the file that contains the snippet.
|
|
| |
Goto Forum:
Current Time: Tue Jul 22 11:43:29 EDT 2025
Powered by FUDForum. Page generated in 0.08099 seconds
|