"shaddow" errors [message #703358] |
Wed, 27 July 2011 13:42 |
Michal S Messages: 74 Registered: July 2011 |
Member |
|
|
Hello,
I am getting very strange behaviour of my Xtext generated application. I have defined my grammar, e.g.:
MyModel:
entities += Entity*;
Entity:
EntityA|EntityB|EntityC;
EntityA,..,EntityC are defined.
Objects of EntityA refer to objects of EntityB and EntityC.
Everything works perfect, while I have all objects of EntityA, EntityB, EntityC defined in single file. However, if I put the EntityA objects into file1.ext, EntityB objects into file2.ext and EntityC objects into file3.ext (all these files are in src folder of MyModel project), there are references errors. The errors disappear after re-save of these files. The strange is: there is still "shaddow" (gray color) error in front of refferencing lines and I can't get rid of it.
Note: Scoping of files works perfect, as the code completion allways gives me reasonable possibilities.
What could cause this problem? How could I solve it?
Thank you & Best regards,
Michal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: "shaddow" errors [message #703651 is a reply to message #703647] |
Wed, 27 July 2011 19:50 |
|
So together with http://kthoms.wordpress.com/2011/07/12/xtend-generating-from-multiple-input-models/
package org.xtext.example.mydsl;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.generator.IFileSystemAccess;
import com.google.inject.Inject;
import com.google.inject.Provider;
public class MyParserToXML implements IGenerator2 {
@Inject Provider<ResourceSet> rsp;
public void doGenerate(ResourceSet rs, IFileSystemAccess fsa) {
ResourceSet rs2 = rsp.get();
EcoreUtil2.clone(rs2,rs);
XMIResourceFactoryImpl resFactory = new XMIResourceFactoryImpl();
List<Resource> toSave = new ArrayList<Resource>();
for (Resource resource : rs2.getResources()) {
String [] splitted_path = ((String) resource.getURI().toPlatformString(true)).split("/");
String newpath = "";
for (int i = 1; i<splitted_path.length;i++){
if(i!=2){
newpath += "/";
newpath += splitted_path[i];
} else {
newpath += "/src-gen";
}
}
newpath = newpath.replace(".tcf", ".xmi");
URI xmiuri = URI.createFileURI(newpath);
XMIResource xmiresource = (XMIResource) resFactory.createResource(xmiuri);
try {
xmiresource.delete(new HashMap());
} catch (IOException e1) {
System.out.println("DELETE NOT SUCCESSFULL");
e1.printStackTrace();
}
xmiresource.getContents().addAll(resource.getContents());
toSave.add(xmiresource);
}
for (Resource xmiresource : toSave) {
try {
xmiresource.save(new HashMap());
} catch (IOException e) {
System.out.println("SAVE NOT MADE");
e.printStackTrace();
}
}
}
@Override
public void doGenerate(Resource input, IFileSystemAccess fsa) {
// TODO Auto-generated method stub
}
}
Works perfect for me
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05374 seconds