Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
Hi David,

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

Regards,
~Karsten
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
Eclipse UserFriend
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
Eclipse UserFriend
Thanks, thanks a lot...
Previous Topic:java.lang.OutOfMemoryError: PermGen space
Next Topic:Autocomplete import example
Goto Forum:
  


Current Time: Tue Jul 08 16:52:45 EDT 2025

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

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

Back to the top