Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Using templates(Question on top level Model template)
Using templates [message #674290] Thu, 26 May 2011 12:44
Michel Simeon is currently offline Michel SimeonFriend
Messages: 130
Registered: December 2009
Senior Member
I have a grammar for a DSL I use for data entry, that is as follows:

Model :
(('Country Name' | 'Nom du pays') '=')? countryName = STRING ';'
(('Project Name' | 'Nom du projet') '=')? projectName = STRING ';'
....
....
(elements += (Entity))*
('fin' | 'end') 'model'
;

Entity:
Commodity | Plan | Script | Table | Herd ;

......
......

I have a full set of templates to assist in data entry, including one for the entire Model, with a list of the initial parameters (Headers), some comments, and the end of model key words; it is defined with Model as context. There is also one template for each entity type.

When I create an empty file, ctrl-space bar gives me the choice between the initial optional keywords, the countryName string, or the Headers template, as expected.

If I select the key words or the string entry it works fine.

If I select the Headers template, it does not work. If I type a space, for exemple, so that the file is no longer empty, then it will work and write the template into my file.

I find this odd for the end users. Does anybody know a workaroud ?

Thanks
MS

PS Just in case, here is the actual template:

<template name="-Headers in English" description="template for header data"
id="fr.msimeon.mads.mads.EnHeaderData"
context="fr.msimeon.mads.Mads.Model"
enabled="true">Country Name = '${countryName}' ;
Project Name = '${projectName}' ;
Data Set Name = '${dataSetName}' ;
Currency Name = '${currency}' ;
Exchange Rate = ${1} to the US Dollar ;
OCC = ${12} % ;
Project life = ${20} years ;
File specs : ??
// optional list of file specs for import : export
end ; ??
Results as ${resultAs:Enum('ResKW')} ;
//
// A model is made of declarations of type Commodity, Plan, Script or Table
// A script item can be a command (print, display, filespec or export), a variable declaration
// or an instruction (variable declaration or variable Reference = expression)
// where expression combines numbers, [series], varRef, commRef, functions using + - / * ^ or ()
//
// Use ctrl-space for content proposals
${cursor}
end model
</template>




Previous Topic:How to implement function calls
Next Topic:Internationalization of DSL ?
Goto Forum:
  


Current Time: Tue Apr 16 04:44:47 GMT 2024

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

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

Back to the top