Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 345405

Summary: Syntax errors in generated JvmModelInferer
Product: [Modeling] TMF Reporter: Karsten Thoms <karsten.thoms>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: sven.efftinge
Version: 2.0.0Flags: sven.efftinge: indigo+
Target Milestone: RC1   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
Test project none

Description Karsten Thoms CLA 2011-05-11 07:56:38 EDT
Created attachment 195333 [details]
Test project

When introducing Xbase to a DSL and generate the DSL, the initially created JvmModelInferrer xtend class has syntax errors.

To reproduce import the attached project and run the workflow.

- import com.google.inject.Inject is missing
- instance name for injected associator is missing

==============================================
GENERATED:
==============================================
package org.xtext.example.mydsl.jvmmodel

import org.eclipse.xtext.xbase.jvmmodel.*
import org.eclipse.xtext.common.types.*
import org.eclipse.emf.ecore.EObject
import java.util.List
import com.google.inject.Inject

/**
 * <p>Infers a JVM model from the source model.</p>
 *
 * <p>The JVM model should contain all elements that would appear in the Java code
 * which is generated from the source model.
 * Other Xtend models link against the JVM model rather than the source model. The JVM
 * model elements should be associated with their source element by means of the
 * {@link IJvmModelAssociator}.</p>
 */
class MyDslJvmModelInferrer implements IJvmModelInferrer {

  @Inject IJvmModelAssociator jvmModelAssociator

     override List<? extends JvmDeclaredType> inferJvmModel(EObject sourceObject) {
       return newArrayList();
     }
}


==============================================
FIXED:
==============================================
package org.xtext.example.mydsl.jvmmodel
 
import org.eclipse.xtext.xbase.jvmmodel.*
import org.eclipse.xtext.common.types.*
import org.eclipse.emf.ecore.EObject
import java.util.List

/**
 * <p>Infers a JVM model from the source model.</p> 
 *
 * <p>The JVM model should contain all elements that would appear in the Java code 
 * which is generated from the source model. 
 * Other Xtend models link against the JVM model rather than the source model. The JVM
 * model elements should be associated with their source element by means of the
 * {@link IJvmModelAssociator}.</p>     
 */
class MyDslJvmModelInferrer implements IJvmModelInferrer {

	@Inject IJvmModelAssociator 

   	override List<? extends JvmDeclaredType> inferJvmModel(EObject sourceObject) {
   		return newArrayList();
   	}
}
Comment 1 Sven Efftinge CLA 2011-05-11 10:54:27 EDT
pushed to master
Comment 2 Karsten Thoms CLA 2011-05-12 02:30:44 EDT
works after update