XCore Generation Workflow [message #1077109] |
Thu, 01 August 2013 08:59 |
Igor Zapletnev Messages: 33 Registered: September 2012 |
Member |
|
|
I am trying to execute xcore generation workflow (as start point I am using this bug)
My root application for xcore generation. It just uses Mwe2Runner
public class GenXcoreApplication implements IApplication {
private String model;
private String output;
@Override
public Object start(IApplicationContext context) throws Exception {
Injector injector = new Mwe2StandaloneSetup()
.createInjectorAndDoEMFRegistration();
Mwe2Runner runner = injector.getInstance(Mwe2Runner.class);
runner.run(URI.createPlatformPluginURI(
"com.home.genxcore/src/xcoregen.mwe2", true),
new HashMap<String, String>());
return null;
}
It is workflow to execute
module com.home.genxcore.Xcoregen
Workflow {
component = org.eclipse.emf.mwe.utils.DirectoryCleaner {
directory = "model-gen"
}
component = com.home.genxcore.XcoreReader {
register = org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup {}
path = "/Users/zapletnev/Documents/src/xcoregen/xtest/model"
slot = "model"
}
component = org.eclipse.xtext.generator.GeneratorComponent {
register = org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup {}
slot = 'model'
outlet = {
path = "/Users/zapletnev/Documents/src/xcoregen/xtest/src-gen"
}
}
}
And newly created XCoreReader (it parses xcore files and sets them as a slots)
package com.home.genxcore;
// some imports here...
public class XcoreReader extends AbstractWorkflowComponent2 {
protected List<String> pathes = Lists.newArrayList();
public void addPath(String path) {
this.pathes.add(path);
}
public List<String> getPathes() {
return pathes;
}
private String slot;
public String getSlot() {
return slot;
}
public void setSlot(String slot) {
this.slot = slot;
}
@Override
protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor,
Issues issues) {
ResourceSet resourceSet = getResourceSet();
Multimap<String, URI> uris = getPathTraverser().resolvePathes(pathes,
new Predicate<URI>() {
@Override
public boolean apply(URI input) {
return input.fileExtension().equals("xcore");
}
});
List<Resource> resources = new ArrayList<Resource>();
for (URI uri : uris.values()) {
String path = uri.toFileString();
Resource r;
System.out.println(path);
try {
r = parse(new FileInputStream(path), uri, null, resourceSet);
resources.add(r);
} catch (FileNotFoundException e) {
issues.addError("problem beim lesen", e);
e.printStackTrace();
}
}
EcoreUtil.resolveAll(resourceSet);
for (Resource r : resources) {
for (Diagnostic x : r.getErrors()) {
issues.addError(x.getMessage(), x);
}
}
ctx.set(slot, resources);
}
private Resource parse(InputStream in, URI uriToUse, Map<?, ?> options,
ResourceSet resourceSet) {
XtextResource resource = (XtextResource) resourceSet
.createResource(uriToUse);
resourceSet.getResources().add(resource);
try {
resource.load(in, options);
return resource;
} catch (IOException e) {
throw new WrappedException(e);
}
}
protected PathTraverser getPathTraverser() {
return new PathTraverser();
}
protected ResourceSet getResourceSet() {
if (!injectors.isEmpty()) {
ResourceSet instance = injectors.get(0).getInstance(
ResourceSet.class);
return instance;
}
return new ResourceSetImpl();
}
private final List<Injector> injectors = Lists.newArrayList();
public void addRegister(ISetup setup) {
injectors.add(setup.createInjectorAndDoEMFRegistration());
}
protected List<Injector> getInjectors() {
return injectors;
}
}
Manifest file of my applicatin plug-in
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: com.home.genxcore;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.ecore;visibility:=reexport,
org.eclipse.ui,
org.eclipse.emf.mwe2.runtime,
org.eclipse.emf.mwe.utils;bundle-version="1.2.1",
org.eclipse.emf.mwe2.lib;bundle-version="2.3.0",
org.eclipse.emf.mwe.core;bundle-version="1.2.1",
org.eclipse.xtext;bundle-version="2.3.1",
org.eclipse.emf.ecore.xcore;bundle-version="1.0.2",
org.eclipse.emf.mwe2.launch;bundle-version="2.3.0",
org.eclipse.xtext.xbase;bundle-version="2.3.1",
org.eclipse.xtext.xbase.lib;bundle-version="2.3.1",
org.eclipse.emf.ecore.xcore.lib;visibility:=reexport,
com.google.guava,
org.eclipse.xtext.ecore;bundle-version="2.3.1"
Bundle-ActivationPolicy: lazy
And the main issue it is that I am getting following errors:
java.lang.IllegalStateException: [XtextLinkingDiagnostic: null:8 Couldn't resolve reference to JvmType 'com.home.genxcore.XcoreReader'., XtextLinkingDiagnostic: null:9 Couldn't resolve reference to JvmIdentifiableElement 'register'., XtextLinkingDiagnostic: null:9 Couldn't resolve reference to JvmType 'org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup'., XtextLinkingDiagnostic: null:10 Couldn't resolve reference to JvmIdentifiableElement 'path'., XtextLinkingDiagnostic: null:11 Couldn't resolve reference to JvmIdentifiableElement 'slot'., XtextLinkingDiagnostic: null:15 Couldn't resolve reference to JvmType 'org.eclipse.emf.ecore.xcore.XcoreStandaloneSetup'.]
Can anyone explain that I have missed?
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06746 seconds