Xtend Editor resolution problems with plain Maven project

47 views
Skip to first unread message

hauke.f...@googlemail.com

unread,
Sep 7, 2017, 1:59:42 PM9/7/17
to Xtend Programming Language
Hi, 

I'm trying to use Xtend in a Maven Plugin-Project with additional dependencies. I.e. I'm writing a maven plugin myself.
For example I added Ecore to the dependencies and want to process Ecore objects in Xtend.

However, the Xtend editor correctly compiles the Xtend file, while it seems to have problems 
resolving methods of the external dependencies in the editor only (see attached screenshot). See the example below: Methods from EMF Resource
or EObject cannot be resolved. At least that are messages displayed in the Eclipse editor; I 
added the respective texts as comments.

However, the Xtend builder seems to correctly build the file. The Problems view is empty. Even worse,
if I add real compile-errors like change the type of 

var EList<EObject> references = e.eCrossReferences()
to
EList<EReference>

I get no compilation error shown in the editor but in the problems view. Respectively the generated Java
file contains an error message:
throw new Error("Unresolved compilation problems:"
     
+ "\nType mismatch: cannot convert from EList<EObject> to EList<EReference>");


Like this it's almost impossible to work. Is there a problem of the Editor? Strangely the external
classes are correctly resolved in general and content assist shows some methods, but not all.

Any hint? I'm using Eclipse Oxygen official release.  

Added Maven Dependencies:
   
<!-- https://mvnrepository.com/artifact/org.eclipse.emf/org.eclipse.emf.ecore -->
 
<dependency>
     
<groupId>org.eclipse.emf</groupId>
     
<artifactId>org.eclipse.emf.ecore</artifactId>
     
<version>2.12.0</version>
 
</dependency>
 
<dependency>
     
<groupId>org.eclipse.emf</groupId>
     
<artifactId>org.eclipse.emf.common</artifactId>
     
<version>2.12.0</version>
 
</dependency>
 
<!-- https://mvnrepository.com/artifact/org.eclipse.xtend/xtend-maven-plugin -->
 
<dependency>
     
<groupId>org.eclipse.xtend</groupId>
     
<artifactId>xtend-maven-plugin</artifactId>
     
<version>2.12.0</version>
 
</dependency>

 

package test.XtendMavenTest


import java.util.List
import org.eclipse.emf.common.util.EList
import org.eclipse.emf.ecore.EAttribute
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.EReference


class XtendMavenTest {

 
 
def test(Resource r){
 val
List<EObject> es = r.getContents()  
 
// The method getContents() is undefined for the type Resource
 
 
for(EObject e: es){
 
var EList<EObject> children = e.eContents()
 
// The method eContents() is undefined for the type EObject
 
 
var EList<EAttribute> attributes = e.eClass.getEAttributes()
 
// The method getEAttributes() is undefined for the type EClass
 
 
var EList<EReference> references = e.eCrossReferences()
 
// The method eCrossReferences() is undefined for the type EObject
 
 e
.extensionTestMethod
 
//The method extensionTestMethod(EObject) from the type XtendMavenTest refers to the missing type Object
 
}
 
}
 
 
def extensionTestMethod(EObject o){
 o
.eContents()
 
// The method eContents() is undefined for the type EObject
 
}
 
 
}

Am I missing smth I have to setup for Xtend? The project has the Xtext nature.

Cheers
Hauke

Screenshot.png

Christian Dietrich

unread,
Sep 8, 2017, 2:31:43 AM9/8/17
to Xtend Programming Language
Hi,

i am not sure what you are doing but

plugin.deps != project deps

and i dont understand why you write your own maven plugin. in doubt you can use xtext maven plugin as descriobed here:
https://www.nikostotz.de/blog/combine-xcore-xtend-ecore-and-maven/

with the nomal xtend maven plugin i can reproduce this problem

but it works fine with

  <dependencies>

   <dependency>
     <groupId>org.eclipse.emf</groupId>
     <artifactId>org.eclipse.emf.ecore</artifactId>
     <version>2.12.0</version>
 </dependency>
 <dependency>
     <groupId>org.eclipse.emf</groupId>
     <artifactId>org.eclipse.emf.common</artifactId>
     <version>2.12.0</version>
 </dependency>
    <dependency>
      <groupId>org.eclipse.xtend</groupId>
      <artifactId>org.eclipse.xtend.lib</artifactId>
      <version>2.12.0</version>
    </dependency>
  </dependencies>

so it looks its a bad idea to add the plugin to the classpath of the stuff it compiles

Hauke Fuhrmann

unread,
Sep 8, 2017, 6:32:35 AM9/8/17
to Xtend Programming Language
Hi Christian,

thanks a lot for your answer. Yippie-Ya-Yeah, changing the dependency to only xtend-lib worked.

Just to clarify: I am not developing a plugin that compiles Xtend code to Java code or processes any kind of Xtext stuff. 
I'm writing a plugin that iterates some internal source files (.ecore in my case) and generates some XML code (SVG in my case).
I'm just using xtend as an implementation language for my plugin. 

During runtime only the generated Java code is used. For simplicity I generate the Java code once with the IDE and add that to our sourcecode-repository. So on a central build server Xtend is not relevant anymore except the xtend.lib.

The hint to add the xtend-maven-plugin to the dependencies I got from the TMF-Forum. I guess I made my use-case not clear enough there.

Cheers,
Hauke

Christian Dietrich

unread,
Sep 8, 2017, 1:05:55 PM9/8/17
to Xtend Programming Language
if you want to compile the xtend file in maven you need the maven plugin, but inside the plugins section

https://www.eclipse.org/xtend/download.html
Reply all
Reply to author
Forward
0 new messages