eclipse update broke my xtext [message #831282] |
Wed, 28 March 2012 17:52 |
Mauro Condarelli Messages: 428 Registered: September 2009 |
Senior Member |
|
|
Hi,
I recently updated my eclipse installation and this completely broke my XText/XTend installation.
The error I get is:
0 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - [XtextLinkingDiagnostic: null:52 Couldn't resolve reference to JvmIdentifiableElement 'generateStub'.]
java.lang.IllegalStateException: [XtextLinkingDiagnostic: null:52 Couldn't resolve reference to JvmIdentifiableElement 'generateStub'.]
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:83)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:73)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:64)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:55)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
I tried to re-create the project from scratch and I discovered that creating a new XText project produces a slightly different structure, with a second .mwe2 file in the .generator package.
I tried porting to the new structure, but I face several issues I don't know how to solve.
First andforemost is my XXXXGenerator.xtend still fails badly (even after some editing) because it starts:
....
class SIDLGenerator implements IMultipleResourceGenerator {
@Inject extension IQualifiedNameProvider nameProvider
@Inject extension ISerializer serializer
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
for(e: resource.allContents.toIterable.filter(typeof(IFace))) {
if (e.has_option("local")) {
fsa.generateFile(e.fullyQualifiedName.toString.replace(".", "/") + ".h", e.local_header)
} else {
fsa.generateFile(e.fullyQualifiedName.toString.replace(".", "/") + ".h", e.header)
fsa.generateFile(e.fullyQualifiedName.toString.replace(".", "/") + "_stub.c", e.stub)
fsa.generateFile(e.fullyQualifiedName.toString.replace(".", "/") + "_skel.c", e.skel)
}
}
}
override void doGenerate(ResourceSet rs, IFileSystemAccess fsa) {
val Map<IFace, String> m = new HashMap<IFace, String>();
val Iterable<IFace> entities = rs.resources.map(r|r.allContents.toIterable.filter(typeof(IFace))).flatten
for (e : entities) {
if (e.has_option("device")) {
m.put(e, e.option("device").sval)
}
}
for (s : m.values) {
val Set<IFace> set = new HashSet<IFace>()
for (p : m.entrySet) {
if (p.value.equals(s)) {
set.add(p.key)
}
}
fsa.generateFile(s.replaceAll("\\W", "_")+".h", set.header(s))
fsa.generateFile("server_"+s.replaceAll("\\W", "_")+".c", set.server(s))
fsa.generateFile("client_"+s.replaceAll("\\W", "_")+".c", set.client(s))
}
}
.....
This fails essentially because resource.allContents does not have a toIterable method (I don't know if this is the only error as it hides anything beyond it).
Could someone be so kind to tell me what should I change either to make my old project work or to fix the new one?
Thanks in advance.
Mauro
|
|
|
|
|
|
|
|
Re: eclipse update broke my xtext [message #831901 is a reply to message #831317] |
Thu, 29 March 2012 13:59 |
Mauro Condarelli Messages: 428 Registered: September 2009 |
Senior Member |
|
|
On 28/03/2012 20:58, Christian Dietrich wrote:
> no this should not be a problem but why do you no simply update to the
> current version
> http://download.eclipse.org/modeling/tmf/xtext/updates/composite/releases/
Done.
Previously I just did a Help->Check for Updates.
Now I get the following notice for each and all the Xtext projects:
*ATTENTION*
It is recommended to use the ANTLR 3 parser generator (BSD licence - http://www.antlr.org/license.html).
Do you agree to download it (size 1MB) from 'http://download.itemis.com/antlr-generator-3.2.0.jar'? (type 'y' or 'n' and hit enter)y
Is it possible to instal that jar once and for all?
Now the system compiles and runs, but my code generator is not invoked when I save the resource.
I see no error. Neither on the primary eclipse instance (the eclipse where I'm running xtext) nor on target (the eclipse instance where I run my DSL editor).
I have a non-standard invocation because I want to generate code also for the whole bunch of DSLs and not only for the current one.
Did something change in that interface?
==================================================================
package com.softin.rpc;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.IGenerator;
public interface IMultipleResourceGenerator extends IGenerator {
/**
* @param input - the input for which to generate resources
* @param fsa - file system access to be used to generate files
*/
public void doGenerate(ResourceSet input, IFileSystemAccess fsa);
}
==================================================================
/*
* generated by Xtext
*/
package com.softin.rpc.generator
import com.google.inject.Inject
import com.softin.rpc.IMultipleResourceGenerator
import com.softin.rpc.sIDL.Arg
import com.softin.rpc.sIDL.CDef
import com.softin.rpc.sIDL.Def
import com.softin.rpc.sIDL.FDef
import com.softin.rpc.sIDL.IFace
import com.softin.rpc.sIDL.TBody
import com.softin.rpc.sIDL.TDef
import com.softin.rpc.sIDL.Type
import com.softin.rpc.sIDL.XType
import com.softin.rpc.sIDL.XsType
import java.util.HashMap
import java.util.HashSet
import java.util.Map
import java.util.Set
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.xtext.generator.IFileSystemAccess
import org.eclipse.xtext.naming.IQualifiedNameProvider
import org.eclipse.xtext.serializer.ISerializer
class SIDLGenerator implements IMultipleResourceGenerator {
@Inject extension IQualifiedNameProvider nameProvider
@Inject extension ISerializer serializer
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
for(e: resource.allContents.toIterable.filter(typeof(IFace))) {
if (e.has_option("local")) {
fsa.generateFile(e.fullyQualifiedName.toString.replace(".", "/") + ".h", e.local_header)
} else {
fsa.generateFile(e.fullyQualifiedName.toString.replace(".", "/") + ".h", e.header)
fsa.generateFile(e.fullyQualifiedName.toString.replace(".", "/") + "_stub.c", e.stub)
fsa.generateFile(e.fullyQualifiedName.toString.replace(".", "/") + "_skel.c", e.skel)
}
}
}
override void doGenerate(ResourceSet rs, IFileSystemAccess fsa) {
val Map<IFace, String> m = new HashMap<IFace, String>();
val Iterable<IFace> entities = rs.resources.map(r|r.allContents.toIterable.filter(typeof(IFace))).flatten
for (e : entities) {
if (e.has_option("device")) {
m.put(e, e.option("device").sval)
}
}
for (s : m.values) {
val Set<IFace> set = new HashSet<IFace>()
for (p : m.entrySet) {
if (p.value.equals(s)) {
set.add(p.key)
}
}
fsa.generateFile(s.replaceAll("\\W", "_")+".h", set.header(s))
fsa.generateFile("server_"+s.replaceAll("\\W", "_")+".c", set.server(s))
fsa.generateFile("client_"+s.replaceAll("\\W", "_")+".c", set.client(s))
}
}
def has_option(IFace f, String opt) {
if (f.options == null)
return false
for (o : f.options.options) {
if (o.name.equals(opt))
return true
}
return false
}
.... here continues the real generator, cut for brevity ...
==================================================================
What can I check, now?
TiA
Mauro
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04376 seconds