Current issues:
How to do Model to Model Mapping
This program contains two Xtext generated models (spad and euclid) and I don't know how to choose the best way to map between them (to convert a program in one model to a program in the other model)
(this design is explained more fully on this page under 'Application Design' section).
Should I translate files between these two models using either:
- ATL
- Operational QVT
- or should I use Xtext code generation (not sure if this is intended to generate java only?).
I'm not sure what the criteria is for choosing between these methods but this things may be significant:
- Mapping is not 1:1, for instance, declaration and definition is done in different parts of SPAD which needs to be merged together in Euclid.
- Ideally the mapping would be 2-way although SPAD->Euclid is the most important.
Does Not Yet Create 'source' Folders
The SPAD new project wizard has the option to initialise a file structure from SPAD source files. This creates two top level folders 'src' and 'src-gen'. These folders are created as ordinary local folders but the Xtext documentation says "Now simply create a new source folder src-gen in the that project and see how the compiler will pick up your sample Entities and generate Java code for them."
public IFolder createFolder(String name,IFolder parent) { IFolder folder = null; try { if (parent == null) { //String folderFullPath = project.getStringProperty(INewJavaClassDataModelProperties.SOURCE_FOLDER); //folder = project.getFolder(new Path(folderFullPath)); folder = project.getFolder(name); } else folder = parent.getFolder(name); if (!folder.exists()) { folder.create(false,true, null); } IPackageFragmentRoot srcRoot = project.getPackageFragmentRoot(folder); IClasspathEntry[] oldEntries = project.getRawClasspath(); IClasspathEntry[] newEntries = new IClasspathEntry[oldEntries.length + 1]; System.arraycopy(oldEntries, 0, newEntries, 0, oldEntries.length); newEntries[oldEntries.length] = JavaCore.newSourceEntry(srcRoot.getPath()); project.setRawClasspath(newEntries, null); } catch (CoreException e) { e.printStackTrace(); } return folder; }
import org.eclipse.jdt.core.IPackageFragmentRoot;