Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Rules group in grammar for a right outline view ?
icon5.gif  Rules group in grammar for a right outline view ? [message #759670] Tue, 29 November 2011 15:06 Go to next message
Federico Sellanes is currently offline Federico SellanesFriend
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 #759679 is a reply to message #759670] Tue, 29 November 2011 15:21 Go to previous messageGo to next message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
Because the Entities type rule (i.e., it leads to an EClass) doesn't have a String-valued 'name' attribute, no qualified name is computed by the configured IQualifiedNameProvider implementation. It's probably best to customize the outline provider (explained in the Reference manual), rather than creating your own implementation (extending the configured class and/or DefaultDeclarativeQualifiedNameProvider) and returning 'Entities' as q-name for Entities instances since that would give name clashes.

Re: Rules group in grammar for a right outline view ? [message #759683 is a reply to message #759670] Tue, 29 November 2011 15:29 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Federico,

you should rather customize your outline and insert artifical feature
nodes instead of structuring your grammar in such a way. The grammar
will influence the model that is created by the parser. It's the model
that should be easy to navigate and everything else should be build
around it and not vice versa.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 29.11.11 16:06, schrieb Federico Sellanes:
> 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.
Re: Rules group in grammar for a right outline view ? [message #759693 is a reply to message #759683] Tue, 29 November 2011 16:26 Go to previous messageGo to next message
Federico Sellanes is currently offline Federico SellanesFriend
Messages: 71
Registered: November 2011
Member
I am in the right way now. Sincerely, and obviously, i didnt read all the reference manual, because i only working in the ide and not in the interpreter, i already have the interpreter.

Thanks.
Re: Rules group in grammar for a right outline view ? [message #759745 is a reply to message #759693] Tue, 29 November 2011 20:06 Go to previous messageGo to next message
Federico Sellanes is currently offline Federico SellanesFriend
Messages: 71
Registered: November 2011
Member
Honestly, the "influencing the outline structure" in the reference manual is not very helping me !

"The following simpli ed 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 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
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 simpli ed 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 Go to previous messageGo to next message
Federico Sellanes is currently offline Federico SellanesFriend
Messages: 71
Registered: November 2011
Member
Thanks, you save my head, is working now. Very Happy

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 #759995 is a reply to message #759973] Wed, 30 November 2011 20:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi

what about

(Entities += EntityStatement | Interceptors += InterceptorStatement)*


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Rules group in grammar for a right outline view ? [message #759997 is a reply to message #759995] Wed, 30 November 2011 20:36 Go to previous messageGo to next message
Federico Sellanes is currently offline Federico SellanesFriend
Messages: 71
Registered: November 2011
Member
Holy hint, working now Very Happy

Thanks Sebastian, Christian and Meinte for helping me !!
Re: Rules group in grammar for a right outline view ? [message #1694956 is a reply to message #759752] Sun, 10 May 2015 18:35 Go to previous messageGo to next message
Anakreontas Mentis is currently offline Anakreontas MentisFriend
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.
Re: Rules group in grammar for a right outline view ? [message #1694957 is a reply to message #1694956] Sun, 10 May 2015 18:48 Go to previous message
Anakreontas Mentis is currently offline Anakreontas MentisFriend
Messages: 85
Registered: October 2014
Member
Found the solution by chance! When one creates an EStructureFeatureNode, the node is populated automatically. Previously it did not work because I invoked the function with the isLeaf attribute set to true.
Previous Topic:Not linked Element appears as != null in Validation
Next Topic:Cannot generate artifacts using ANT
Goto Forum:
  


Current Time: Thu Apr 18 18:10:20 GMT 2024

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

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

Back to the top