Home » Modeling » TMF (Xtext) » Rules group in grammar for a right outline view ?
Rules group in grammar for a right outline view ? [message #759670] |
Tue, 29 November 2011 15:06 |
Federico Sellanes Messages: 71 Registered: November 2011 |
Member |
|
|
This is a part of my grammar :
Greeting :
'module' name=ID '{'
innerElements += ModuleInnerElements*
'}'
;
ModuleInnerElements:
Entities
// | Interceptors
;
Entities:
Entities+=EntityStatement*
;
EntityStatement:
'entity' name=ID '{'
attributes += attributeStatement ((',' attributes += attributeStatement)?)*
'}'
;
Ok, this grammar was made in this manner, because i want that the outline view can show me something like :
SomeModuleName
-------Entities
--------------EntitieName
--------------AnotherEntitieName
-------Interceptors
--------------InterceptorName
But actually I getting :
SomeModuleName
-------<unnamed>
--------------EntitieName
--------------AnotherEntitieName
The question is : How i can force to change from "<unnamed>" to "Entities"?. It is possible?
Thanks in advance, sorry for my poor english.
[Updated on: Tue, 29 November 2011 15:08] Report message to a moderator
|
|
| | | |
Re: Rules group in grammar for a right outline view ? [message #759745 is a reply to message #759693] |
Tue, 29 November 2011 20:06 |
Federico Sellanes Messages: 71 Registered: November 2011 |
Member |
|
|
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 20:26 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
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 18:52 |
Federico Sellanes Messages: 71 Registered: November 2011 |
Member |
|
|
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 18:35 |
Anakreontas Mentis Messages: 85 Registered: October 2014 |
Member |
|
|
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: Sat Apr 20 00:16:39 GMT 2024
Powered by FUDForum. Page generated in 0.03894 seconds
|