Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » (Xtext) 15 Minute Tutorial needs to be updated for version 2.2
(Xtext) 15 Minute Tutorial needs to be updated for version 2.2 [message #778796] Fri, 13 January 2012 16:12 Go to next message
David Wegener is currently offline David Wegener
Messages: 1299
Registered: July 2009
Senior Member
The existing 15 minute tutorial - extended for Xtext appears to still be at the 2.1 level. It includes references to the deprecated class org.eclipse.xtext.xtend2.lib.ResourceExtensions. From looking through other posts and searching the net, this appears to have been replaced by org.eclipse.xtext.xbase.lib.IteratorExtensions.

Using IteratorExtensions produces the error: Couldn't resolve reference to JvmType 'org.eclipse.xtext.xbase.lib.IteratorExtensions'.

This is in the first step of the tutorial and renders it useless for this release of Xtext.

http://www.eclipse.org/Xtext/documentation/2_1_0/040-first-code-generator.php
Re: (Xtext) 15 Minute Tutorial needs to be updated for version 2.2 [message #778810 is a reply to message #778796] Fri, 13 January 2012 17:02 Go to previous messageGo to next message
David Wegener is currently offline David Wegener
Messages: 1299
Registered: July 2009
Senior Member
After restarting Eclipse, the error for IteratorExtensions has gone away and the editor is now able to resolve the reference to it. I'm now able to continue with the tutorial by simply replacing the

import static extension org.eclipse.xtext.xtend2.lib.ResourceExtensions.*


with
import static extension org.eclipse.xtext.xbase.lib.IteratorExtensions.*
Re: (Xtext) 15 Minute Tutorial needs to be updated for version 2.2 [message #780333 is a reply to message #778796] Tue, 17 January 2012 11:08 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten Thoms
Messages: 353
Registered: July 2009
Location: Dortmund
Senior Member

Hi David,

please open a bug report. This would get lost in the forum otherwise.

Regards,
~Karsten


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: (Xtext) 15 Minute Tutorial needs to be updated for version 2.2 [message #833527 is a reply to message #778796] Sat, 31 March 2012 12:47 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing name
Messages: 1
Registered: March 2012
Junior Member
I had to do this, to work:

package com.diegogusava.generator

import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.xtext.generator.IGenerator
import org.eclipse.xtext.generator.IFileSystemAccess
import org.eclipse.xtext.naming.IQualifiedNameProvider
import com.google.inject.Inject
import com.diegogusava.myDsl.Entity
import com.diegogusava.myDsl.Feature

class MyDslGenerator implements IGenerator {
	
	@Inject extension IQualifiedNameProvider nameProvider 
	
	override doGenerate(Resource resource, IFileSystemAccess fsa) {
	
		for(e: resource.allContents.toList().filter(typeof(Entity))) {
			 fsa.generateFile(
                e.fullyQualifiedName.toString.replace(".", "/") + ".java",
                e.compile)
		}
	
	}
	
	def compile(Entity e) ''' 
        «IF e.eContainer != null»
            package «e.eContainer.fullyQualifiedName»;
        «ENDIF»
        
        public class «e.name» «IF e.superType != null
                        »extends «e.superType.fullyQualifiedName» «ENDIF»{
            «FOR f:e.features»
                «f.compile»
            «ENDFOR»
        }
    '''
    
    def compile(Feature f) '''
        private «f.type.fullyQualifiedName» «f.name»;
        
        public «f.type.fullyQualifiedName» get«f.name.toFirstUpper»() {
            return «f.name»;
        }
        
        public void set«f.name.toFirstUpper»(«f.type.fullyQualifiedName» «f.name») {
            this.«f.name» = «f.name»;
        }
    '''
	
}


Re: (Xtext) 15 Minute Tutorial needs to be updated for version 2.2 [message #873117 is a reply to message #833527] Thu, 17 May 2012 10:14 Go to previous message
Aran A is currently offline Aran A
Messages: 22
Registered: January 2011
Junior Member
Thanks, thanks a lot...
Previous Topic:java.lang.OutOfMemoryError: PermGen space
Next Topic:extension of the dsl files
Goto Forum:
  


Current Time: Mon Apr 21 03:11:31 EDT 2014

Powered by FUDForum. Page generated in 0.02383 seconds