Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 326755 - Xpand template bug in Xtext User Guide
Summary: Xpand template bug in Xtext User Guide
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: M3   Edit
Assignee: Jan Koehnlein CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-01 05:42 EDT by Philip May CLA
Modified: 2017-09-19 17:41 EDT (History)
4 users (show)

See Also:
sven.efftinge: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philip May CLA 2010-10-01 05:42:36 EDT
Build Identifier: M20100909-0800

Xtext User Guide has a Xpand template with a bug.
It is in this section:
http://www.eclipse.org/Xtext/documentation/1_0_0/xtext.html#getting-started-xpand

The template you suggest ist:
«IMPORT org::eclipse::xtext::example::domainmodel»
«EXTENSION templates::Extensions»

«DEFINE main FOR Entity-»
«FILE qualifiedName().replaceAll("\\.","/")+".java"-»
package «packageName()»;

public class «name» {
  «EXPAND property FOREACH features»
}
«ENDFILE»
«ENDDEFINE»

«DEFINE property FOR Feature»
  private «type.referenced.qualifiedName()» «name»;
  
  public void set«name.toFirstUpper()»(
       «type.referenced.qualifiedName()» «name») {
    this.«name» = «name»;
  } 
  public «type.referenced.qualifiedName()» get«name.toFirstUpper()»() {
    return «name»;
  } 
«ENDDEFINE»

but this template does not recognize the extends expression of the language.
That means that Speaker does not extend Person when you generate the code.

The teamplate should be modified to this:

«IMPORT org::eclipse::xtext::example::domainmodel»
«EXTENSION templates::Extensions»

«DEFINE main FOR Entity-»
«FILE qualifiedName().replaceAll("\\.","/")+".java"-»
package «packageName()»;

public class «name»«IF superType != null» extends «superType.name»«ENDIF» {
  «EXPAND property FOREACH features»
}
«ENDFILE»
«ENDDEFINE»

«DEFINE property FOR Feature»
  private «type.referenced.qualifiedName()» «name»;
  
  public void set«name.toFirstUpper()»(
       «type.referenced.qualifiedName()» «name») {
    this.«name» = «name»;
  } 
  public «type.referenced.qualifiedName()» get«name.toFirstUpper()»() {
    return «name»;
  } 
«ENDDEFINE»


Reproducible: Always

Steps to Reproduce:
1. Do the tutorial: http://www.eclipse.org/Xtext/documentation/1_0_0/xtext.html#getting-started-xpand
2. generate the java classes and look at the Speaker class
3. notice that it does not extend Person
Comment 1 Jan Koehnlein CLA 2010-10-07 10:20:26 EDT
Fixed in HEAD.
Comment 2 Karsten Thoms CLA 2017-09-19 17:29:56 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 17:41:20 EDT
Closing all bugs that were set to RESOLVED before Neon.0