Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDennis Wagelaar2017-06-06 16:46:42 -0400
committerDennis Wagelaar2017-06-06 16:46:42 -0400
commit9efad1f13f6623ee7f2f894e7aea2a5a4e638b07 (patch)
tree80544efee61308ce1d2735b58a139a5a3b7fee76
parent7f99115f417ca7c37d2efa658cbf35d8a27fe348 (diff)
downloadorg.eclipse.atl-9efad1f13f6623ee7f2f894e7aea2a5a4e638b07.tar.gz
org.eclipse.atl-9efad1f13f6623ee7f2f894e7aea2a5a4e638b07.tar.xz
org.eclipse.atl-9efad1f13f6623ee7f2f894e7aea2a5a4e638b07.zip
EMFTVM compatibility launcher.
-rw-r--r--plugins/org.eclipse.m2m.atl.core.ui/src/org/eclipse/m2m/atl/core/ui/launch/AtlLaunchConfigurationDelegate.java41
-rw-r--r--plugins/org.eclipse.m2m.atl.debug.core/src/org/eclipse/m2m/atl/debug/core/AtlDebugTarget.java1
-rw-r--r--plugins/org.eclipse.m2m.atl.emftvm.launcher/plugin.xml5
-rw-r--r--plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/launcher/compat/EMFTVMLauncher.java70
4 files changed, 76 insertions, 41 deletions
diff --git a/plugins/org.eclipse.m2m.atl.core.ui/src/org/eclipse/m2m/atl/core/ui/launch/AtlLaunchConfigurationDelegate.java b/plugins/org.eclipse.m2m.atl.core.ui/src/org/eclipse/m2m/atl/core/ui/launch/AtlLaunchConfigurationDelegate.java
index a8edc996..00a37e23 100644
--- a/plugins/org.eclipse.m2m.atl.core.ui/src/org/eclipse/m2m/atl/core/ui/launch/AtlLaunchConfigurationDelegate.java
+++ b/plugins/org.eclipse.m2m.atl.core.ui/src/org/eclipse/m2m/atl/core/ui/launch/AtlLaunchConfigurationDelegate.java
@@ -26,6 +26,7 @@ import java.util.logging.Level;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
@@ -72,7 +73,6 @@ public class AtlLaunchConfigurationDelegate extends LaunchConfigurationDelegate
* @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration,
* java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
*/
- @SuppressWarnings("unchecked")
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch,
IProgressMonitor monitor) throws CoreException {
@@ -95,19 +95,19 @@ public class AtlLaunchConfigurationDelegate extends LaunchConfigurationDelegate
String fileName = configuration.getAttribute(ATLLaunchConstants.ATL_FILE_NAME,
ATLLaunchConstants.NULL_PARAMETER);
Map<String, String> unsortedSourceModels = configuration.getAttribute(ATLLaunchConstants.INPUT,
- Collections.EMPTY_MAP);
+ Collections.<String, String> emptyMap());
Map<String, String> unsortedTargetModels = configuration.getAttribute(ATLLaunchConstants.OUTPUT,
- Collections.EMPTY_MAP);
+ Collections.<String, String> emptyMap());
Map<String, String> launchConfigModelPaths = configuration.getAttribute(ATLLaunchConstants.PATH,
- Collections.EMPTY_MAP);
+ Collections.<String, String> emptyMap());
Map<String, String> modelPaths = convertPaths(launchConfigModelPaths);
- Map<String, String> libs = configuration.getAttribute(ATLLaunchConstants.LIBS, Collections.EMPTY_MAP);
+ Map<String, String> libs = configuration.getAttribute(ATLLaunchConstants.LIBS, Collections.<String, String> emptyMap());
List<String> superimps = configuration.getAttribute(ATLLaunchConstants.SUPERIMPOSE,
- Collections.EMPTY_LIST);
- options.putAll(configuration.getAttribute(ATLLaunchConstants.OPTIONS, Collections.EMPTY_MAP));
+ Collections.<String> emptyList());
+ options.putAll(configuration.getAttribute(ATLLaunchConstants.OPTIONS, Collections.<String, String> emptyMap()));
Map<String, String> modelHandlers = configuration.getAttribute(ATLLaunchConstants.MODEL_HANDLER,
- Collections.EMPTY_MAP);
+ Collections.<String, String> emptyMap());
options.put(ATLLaunchConstants.OPTION_MODEL_HANDLER, modelHandlers);
if (LauncherService.getBooleanOption(options.get(AdvancedTab.OPTION_CLEAR), false)) {
@@ -133,7 +133,7 @@ public class AtlLaunchConfigurationDelegate extends LaunchConfigurationDelegate
}
// ATL modules
- IFile currentAtlFile = ResourcesPlugin.getWorkspace().getRoot().getFile(Path.fromOSString(fileName));
+ IFile currentAtlFile = ResourcesPlugin.getWorkspace().getRoot().getFile(getBytecodePath(fileName, launcher));
String currentExtension = currentAtlFile.getFileExtension().toLowerCase();
if (currentExtension.equals("atl")) { //$NON-NLS-1$
options.put(ATLLaunchConstants.OPTION_ATL_FILE_PATH, fileName);
@@ -153,7 +153,7 @@ public class AtlLaunchConfigurationDelegate extends LaunchConfigurationDelegate
for (int i = 1; i < modules.length; i++) {
String moduleFileName = superimps.get(i - 1);
IFile moduleFile = ResourcesPlugin.getWorkspace().getRoot().getFile(
- Path.fromOSString(moduleFileName));
+ getBytecodePath(moduleFileName, launcher));
if (!addLaunchedModule(moduleFile)) {
return;
}
@@ -179,14 +179,14 @@ public class AtlLaunchConfigurationDelegate extends LaunchConfigurationDelegate
Map<String, String> sourceModels = unsortedSourceModels;
List<String> orderedInput = configuration.getAttribute(ATLLaunchConstants.ORDERED_INPUT,
- Collections.EMPTY_LIST);
+ Collections.<String> emptyList());
if (!orderedInput.isEmpty()) {
sourceModels = sort(unsortedSourceModels, orderedInput);
}
Map<String, String> targetModels = unsortedTargetModels;
List<String> orderedOutput = configuration.getAttribute(ATLLaunchConstants.ORDERED_OUTPUT,
- Collections.EMPTY_LIST);
+ Collections.<String> emptyList());
if (!orderedOutput.isEmpty()) {
targetModels = sort(unsortedTargetModels, orderedOutput);
}
@@ -231,10 +231,10 @@ public class AtlLaunchConfigurationDelegate extends LaunchConfigurationDelegate
newTargetModels.remove(key);
}
- launchOrDebug(mode, monitor, launcher, Collections.EMPTY_MAP, sourceModels, newTargetModels,
+ launchOrDebug(mode, monitor, launcher, Collections.<String, String> emptyMap(), sourceModels, newTargetModels,
modelPaths, options, libraries, launch, modules);
} else {
- launchOrDebug(mode, monitor, launcher, sourceModels, Collections.EMPTY_MAP, targetModels,
+ launchOrDebug(mode, monitor, launcher, sourceModels, Collections.<String, String> emptyMap(), targetModels,
modelPaths, options, libraries, launch, modules);
}
@@ -242,12 +242,19 @@ public class AtlLaunchConfigurationDelegate extends LaunchConfigurationDelegate
// Set generated files as derived
for (String targetModel : targetModels.keySet()) {
String path = launchConfigModelPaths.get(targetModel);
- setDerived(path);
+ setDerived(path, monitor);
}
}
}
+ private IPath getBytecodePath(String fileName, final ILauncher launcher) {
+ if (launcher != null && launcher.getClass().getSimpleName().startsWith("EMFTVM")) { //$NON-NLS-1$
+ fileName = fileName.replaceAll("\\.(atl|asm)$", ".emftvm"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return Path.fromOSString(fileName);
+ }
+
private static Object launchOrDebug(final String mode, final IProgressMonitor monitor,
final ILauncher launcher, final Map<String, String> sourceModels,
final Map<String, String> sourceTargetModels, final Map<String, String> targetModels,
@@ -424,12 +431,12 @@ public class AtlLaunchConfigurationDelegate extends LaunchConfigurationDelegate
return "platform:/resource" + path; //$NON-NLS-1$
}
- private void setDerived(String filePath) {
+ private void setDerived(String filePath, IProgressMonitor monitor) {
if (Platform.isRunning()) {
try {
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath));
if (file.exists()) {
- file.setDerived(true);
+ file.setDerived(true, monitor);
}
} catch (IllegalStateException e) {
ATLLogger.log(Level.SEVERE, e.getLocalizedMessage(), e);
diff --git a/plugins/org.eclipse.m2m.atl.debug.core/src/org/eclipse/m2m/atl/debug/core/AtlDebugTarget.java b/plugins/org.eclipse.m2m.atl.debug.core/src/org/eclipse/m2m/atl/debug/core/AtlDebugTarget.java
index c9151963..624d6e1b 100644
--- a/plugins/org.eclipse.m2m.atl.debug.core/src/org/eclipse/m2m/atl/debug/core/AtlDebugTarget.java
+++ b/plugins/org.eclipse.m2m.atl.debug.core/src/org/eclipse/m2m/atl/debug/core/AtlDebugTarget.java
@@ -153,7 +153,6 @@ public class AtlDebugTarget extends AtlDebugElement implements IDebugTarget {
public AtlDebugTarget(ILaunch launch) {
super(null);
DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this);
- // DebugPlugin.getDefault().addDebugEventListener(this);
try {
disassemblyMode = Boolean.valueOf(
diff --git a/plugins/org.eclipse.m2m.atl.emftvm.launcher/plugin.xml b/plugins/org.eclipse.m2m.atl.emftvm.launcher/plugin.xml
index 93d5bd61..ec65a5a3 100644
--- a/plugins/org.eclipse.m2m.atl.emftvm.launcher/plugin.xml
+++ b/plugins/org.eclipse.m2m.atl.emftvm.launcher/plugin.xml
@@ -57,6 +57,11 @@
mode="debug"
name="disassemblyMode">
</option>
+ <option
+ description="Stop in main"
+ mode="debug"
+ name="stopInMain">
+ </option>
</launcher>
</extension>
diff --git a/plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/launcher/compat/EMFTVMLauncher.java b/plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/launcher/compat/EMFTVMLauncher.java
index c2532934..0f8d8c96 100644
--- a/plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/launcher/compat/EMFTVMLauncher.java
+++ b/plugins/org.eclipse.m2m.atl.emftvm/src/org/eclipse/m2m/atl/emftvm/launcher/compat/EMFTVMLauncher.java
@@ -25,11 +25,13 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.m2m.atl.common.ATLLogger;
+import org.eclipse.m2m.atl.core.ATLCoreException;
import org.eclipse.m2m.atl.core.IModel;
-import org.eclipse.m2m.atl.core.IReferenceModel;
+import org.eclipse.m2m.atl.core.emf.EMFInjector;
import org.eclipse.m2m.atl.core.emf.EMFModel;
import org.eclipse.m2m.atl.core.emf.EMFReferenceModel;
import org.eclipse.m2m.atl.core.launch.ILauncher;
+import org.eclipse.m2m.atl.core.service.CoreService;
import org.eclipse.m2m.atl.core.service.LauncherService;
import org.eclipse.m2m.atl.emftvm.EmftvmFactory;
import org.eclipse.m2m.atl.emftvm.ExecEnv;
@@ -39,6 +41,7 @@ import org.eclipse.m2m.atl.emftvm.Model;
import org.eclipse.m2m.atl.emftvm.Module;
import org.eclipse.m2m.atl.emftvm.util.DefaultModuleResolver;
import org.eclipse.m2m.atl.emftvm.util.EMFTVMUtil;
+import org.eclipse.m2m.atl.emftvm.util.LazyCollections;
import org.eclipse.m2m.atl.emftvm.util.ModuleNotFoundException;
import org.eclipse.m2m.atl.emftvm.util.ModuleResolver;
import org.eclipse.m2m.atl.emftvm.util.TimingData;
@@ -70,6 +73,8 @@ public class EMFTVMLauncher implements ILauncher {
protected ExecEnv execEnv;
+ protected ResourceSet outputResourceSet;
+
protected TimingData timingData;
/**
@@ -88,16 +93,36 @@ public class EMFTVMLauncher implements ILauncher {
* the model name
* @param referenceModelName
* the model reference model name
+ * @return the EMFTVM {@link Model}
*/
- protected void addModel(IModel model, String name, String referenceModelName) {
+ protected Model addModel(IModel model, String name, String referenceModelName) {
+ final Model emftvmModel;
if (models.containsKey(name)) {
ATLLogger.warning(Messages.getString("EMFTVMLauncher.MODEL_REGISTERED", name)); //$NON-NLS-1$
+ emftvmModel = null;
} else {
models.put(name, model);
+ final EMFModel emfModel = (EMFModel) model;
+ final Resource resource = emfModel.getResource();
+ if (resource == null) {
+ final EMFInjector emfInjector;
+ try {
+ emfInjector = (EMFInjector) CoreService.getInjector(MODEL_FACTORY_NAME);
+ } catch (ATLCoreException e) {
+ throw new VMException(null, e.getLocalizedMessage(), e);
+ }
+ emfInjector.inject(emfModel, outputResourceSet.createResource(URI.createURI(name + ".xmi"))); //$NON-NLS-1$
+ }
+ emftvmModel = EmftvmFactory.eINSTANCE.createModel();
+ emftvmModel.setResource(emfModel.getResource());
}
if (!models.containsKey(referenceModelName)) {
models.put(referenceModelName, model.getReferenceModel());
+ final Metamodel metamodel = EmftvmFactory.eINSTANCE.createMetamodel();
+ metamodel.setResource(((EMFReferenceModel) model.getReferenceModel()).getResource());
+ execEnv.registerMetaModel(referenceModelName, metamodel);
}
+ return emftvmModel;
}
/**
@@ -108,7 +133,10 @@ public class EMFTVMLauncher implements ILauncher {
*/
public void addInModel(IModel model, String name, String referenceModelName) {
model.setIsTarget(false);
- addModel(model, name, referenceModelName);
+ final Model emftvmModel = addModel(model, name, referenceModelName);
+ if (emftvmModel != null) {
+ execEnv.registerInputModel(name, emftvmModel);
+ }
}
/**
@@ -119,7 +147,10 @@ public class EMFTVMLauncher implements ILauncher {
*/
public void addInOutModel(IModel model, String name, String referenceModelName) {
model.setIsTarget(true);
- addModel(model, name, referenceModelName);
+ final Model emftvmModel = addModel(model, name, referenceModelName);
+ if (emftvmModel != null) {
+ execEnv.registerInOutModel(name, emftvmModel);
+ }
}
/**
@@ -130,7 +161,10 @@ public class EMFTVMLauncher implements ILauncher {
*/
public void addOutModel(IModel model, String name, String referenceModelName) {
model.setIsTarget(true);
- addModel(model, name, referenceModelName);
+ final Model emftvmModel = addModel(model, name, referenceModelName);
+ if (emftvmModel != null) {
+ execEnv.registerOutputModel(name, emftvmModel);
+ }
}
/**
@@ -158,6 +192,7 @@ public class EMFTVMLauncher implements ILauncher {
moduleResourceSet = new ResourceSetImpl();
moduleResolver = new DefaultModuleResolver(EMF_URI_PREFIX, moduleResourceSet);
execEnv = EmftvmFactory.eINSTANCE.createExecEnv();
+ outputResourceSet = new ResourceSetImpl();
timingData = new TimingData();
}
@@ -193,30 +228,19 @@ public class EMFTVMLauncher implements ILauncher {
getModuleFromObject(modules[i]);
}
- for (Map.Entry<String, IModel> entry : models.entrySet()) {
- String name = entry.getKey();
- IModel iModel = entry.getValue();
- if (iModel instanceof IReferenceModel) {
- Metamodel metamodel = EmftvmFactory.eINSTANCE.createMetamodel();
- metamodel.setResource(((EMFReferenceModel) iModel).getResource());
- execEnv.registerMetaModel(name, metamodel);
- } else {
- Model model = EmftvmFactory.eINSTANCE.createModel();
- model.setResource(((EMFModel) iModel).getResource());
- if (iModel.isTarget()) {
- model.setAllowInterModelReferences(
- LauncherService.getBooleanOption(options.get("allowInterModelReferences"), false)); //$NON-NLS-1$
- execEnv.registerOutputModel(name, model);
- } else {
- execEnv.registerInputModel(name, model);
- }
- }
+ for (Model model : LazyCollections.asLazySet(execEnv.getInoutModels().values())
+ .union(LazyCollections.asLazySet(execEnv.getOutputModels().values()))) {
+ model.setAllowInterModelReferences(
+ LauncherService.getBooleanOption(options.get("allowInterModelReferences"), false)); //$NON-NLS-1$
}
execEnv.setMonitor(tool);
execEnv.setJitDisabled(LauncherService.getBooleanOption(options.get("jitDisabled"), false)); //$NON-NLS-1$
+ timingData.finishLoading();
+
final Object result = execEnv.run(timingData);
+ timingData.finish();
if (LauncherService.getBooleanOption(options.get("printExecutionTime"), false)) { //$NON-NLS-1$
ATLLogger.info(timingData.toString());
}

Back to the top