Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsboyko2014-04-17 13:12:24 +0000
committersboyko2014-04-17 13:12:24 +0000
commitbf75f18afb17ba8bb0c4b1865bdc3807afbb5637 (patch)
tree6ddb01a46b4fb969f361e4a2d95bab80d3902bed
parentd8844eef4ff56c7a8bcbe9ed0f4bedd6d4d38d27 (diff)
downloadorg.eclipse.qvto-bf75f18afb17ba8bb0c4b1865bdc3807afbb5637.tar.gz
org.eclipse.qvto-bf75f18afb17ba8bb0c4b1865bdc3807afbb5637.tar.xz
org.eclipse.qvto-bf75f18afb17ba8bb0c4b1865bdc3807afbb5637.zip
[391289] - The QVTo builder is not cancellable
[431082] - Progress monitoring for TransformationExecutor [422269] - ExecutionContext does not provide an interface to set config properties
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml.debug.core/src/org/eclipse/m2m/qvt/oml/debug/core/vm/QVTODebugEvaluator.java9
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/QvtCompilerFacade.java7
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/QvtReconcilingStrategy.java13
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/completion/QvtCompletionCompiler.java8
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/completion/QvtCompletionVisitorCS.java7
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml.project/src/org/eclipse/m2m/internal/qvt/oml/project/builder/QVTOBuilder.java67
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/launch/QvtLaunchConfigurationDelegate.java27
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/launch/QvtLaunchConfigurationDelegateBase.java2
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/project/QvtCompilerFacade.java5
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/InternalTransformationExecutor.java81
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/TransformationRunner.java452
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/ast/parser/QvtOperationalVisitorCS.java26
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/compiler/CompilerUtils.java19
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/compiler/QVTOCompiler.java86
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/evaluator/EvaluationUtil.java4
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/evaluator/QvtOperationalEvaluationVisitorImpl.java4
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/library/Context.java34
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/ExecutionContext.java17
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/ExecutionContextImpl.java53
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/TransformationExecutor.java23
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/util/EvaluationMonitor.java40
-rw-r--r--plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/util/IContext.java13
-rw-r--r--tests/org.eclipse.m2m.tests.qvt.oml/src/org/eclipse/m2m/tests/qvt/oml/bbox/AnnotatedJavaLibrary.java5
-rw-r--r--tests/org.eclipse.m2m.tests.qvt.oml/src/org/eclipse/m2m/tests/qvt/oml/callapi/InvocationTest.java29
24 files changed, 585 insertions, 446 deletions
diff --git a/plugins/org.eclipse.m2m.qvt.oml.debug.core/src/org/eclipse/m2m/qvt/oml/debug/core/vm/QVTODebugEvaluator.java b/plugins/org.eclipse.m2m.qvt.oml.debug.core/src/org/eclipse/m2m/qvt/oml/debug/core/vm/QVTODebugEvaluator.java
index a2d7e7ea5..300657154 100644
--- a/plugins/org.eclipse.m2m.qvt.oml.debug.core/src/org/eclipse/m2m/qvt/oml/debug/core/vm/QVTODebugEvaluator.java
+++ b/plugins/org.eclipse.m2m.qvt.oml.debug.core/src/org/eclipse/m2m/qvt/oml/debug/core/vm/QVTODebugEvaluator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009,2012 R.Dvorak and others.
+ * Copyright (c) 2009,2014 R.Dvorak and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,7 +7,7 @@
*
* Contributors:
* Radek Dvorak - initial API and implementation
- * Christopher Gerking - bug 394498
+ * Christopher Gerking - bugs 394498, 431082
*******************************************************************************/
package org.eclipse.m2m.qvt.oml.debug.core.vm;
@@ -25,8 +25,6 @@ import org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalEnv;
import org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalEvaluationEnv;
import org.eclipse.m2m.internal.qvt.oml.compiler.CompiledUnit;
import org.eclipse.m2m.internal.qvt.oml.evaluator.InternalEvaluator;
-import org.eclipse.m2m.internal.qvt.oml.evaluator.ModelInstance;
-import org.eclipse.m2m.internal.qvt.oml.evaluator.ModuleInstance;
import org.eclipse.m2m.internal.qvt.oml.evaluator.QvtGenericVisitorDecorator;
import org.eclipse.m2m.internal.qvt.oml.evaluator.QvtInterruptedExecutionException;
import org.eclipse.m2m.internal.qvt.oml.evaluator.QvtOperationalEvaluationVisitor;
@@ -46,7 +44,6 @@ import org.eclipse.m2m.qvt.oml.debug.core.vm.protocol.VMSuspendEvent;
import org.eclipse.m2m.qvt.oml.debug.core.vm.protocol.VMSuspendRequest;
import org.eclipse.m2m.qvt.oml.debug.core.vm.protocol.VMTerminateRequest;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.AssignExp;
-import org.eclipse.m2m.qvt.oml.util.IContext;
import org.eclipse.ocl.expressions.LoopExp;
import org.eclipse.ocl.expressions.OCLExpression;
import org.eclipse.ocl.expressions.Variable;
@@ -493,7 +490,7 @@ public final class QVTODebugEvaluator extends QvtOperationalEvaluationVisitorImp
@Override
protected Object genericPreVisitAST(ASTNode visited) {
- if (getContext().getMonitor() != null && getContext().getMonitor().isCanceled()) {
+ if (getContext().getProgressMonitor() != null && getContext().getProgressMonitor().isCanceled()) {
throwQVTException(new QvtInterruptedExecutionException());
}
return preElementVisit(visited);
diff --git a/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/QvtCompilerFacade.java b/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/QvtCompilerFacade.java
index 645ede2ca..338879bf0 100644
--- a/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/QvtCompilerFacade.java
+++ b/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/QvtCompilerFacade.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Borland Software Corporation and others.
+ * Copyright (c) 2007, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bug 431082
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.editor.ui;
@@ -56,7 +57,7 @@ public class QvtCompilerFacade {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
- monitor.beginTask(Messages.QvtCompilerFacade_compilingDoc , 4);
+ monitor.beginTask(Messages.QvtCompilerFacade_compilingDoc, 4);
CompiledUnit result = null;
try {
@@ -73,7 +74,7 @@ public class QvtCompilerFacade {
final UnitProxy inMemoryUnit = new InMemoryUnitProxy(unit.getNamespace(), unit.getName(), unit.getURI(), contents, unitResolver);
QVTOCompiler compiler = CompilerUtils.createCompiler();
- result = compiler.compile(inMemoryUnit, options, new BasicMonitor.EclipseSubProgress(monitor, 2));
+ result = compiler.compile(inMemoryUnit, options, CompilerUtils.createMonitor(BasicMonitor.toMonitor(monitor), 3));
if (result != null) {
documentProvider.setMappingModule(result);
diff --git a/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/QvtReconcilingStrategy.java b/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/QvtReconcilingStrategy.java
index 58ee25ef3..16a63ca85 100644
--- a/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/QvtReconcilingStrategy.java
+++ b/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/QvtReconcilingStrategy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Borland Software Corporation and others.
+ * Copyright (c) 2007, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,11 +8,13 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bug 391289
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.editor.ui;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
@@ -69,7 +71,7 @@ public class QvtReconcilingStrategy implements IReconcilingStrategy, IReconcilin
CompiledUnit compilationResult = null;
try {
myReconcilingListener.aboutToBeReconciled();
- compilationResult = getCompiler(editingInQvtSourceContainer);
+ compilationResult = getCompilationResult(editingInQvtSourceContainer);
}
catch (Exception ex) {
handleError(ex);
@@ -78,7 +80,7 @@ public class QvtReconcilingStrategy implements IReconcilingStrategy, IReconcilin
}
}
- private CompiledUnit getCompiler(boolean editingInQvtSourceContainer) {
+ private CompiledUnit getCompilationResult(boolean editingInQvtSourceContainer) {
CompiledUnit compilationResult;
QvtCompilerOptions options = new QvtCompilerOptions();
options.setShowAnnotations(editingInQvtSourceContainer);
@@ -90,6 +92,11 @@ public class QvtReconcilingStrategy implements IReconcilingStrategy, IReconcilin
}
private void handleError(Exception ex) {
+
+ if (ex instanceof OperationCanceledException) {
+ return;
+ }
+
if (myLoggedCompilationExceptionsCount < MAX_LOGGED_COMPILATION_EXCEPTIONS) {
myLoggedCompilationExceptionsCount ++;
Activator.log(ex);
diff --git a/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/completion/QvtCompletionCompiler.java b/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/completion/QvtCompletionCompiler.java
index f49d79798..489f97817 100644
--- a/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/completion/QvtCompletionCompiler.java
+++ b/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/completion/QvtCompletionCompiler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Borland Software Corporation and others.
+ * Copyright (c) 2008, 2014 Borland Software Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bug 391289
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.editor.ui.completion;
@@ -19,6 +20,7 @@ import java.util.Map;
import lpg.runtime.IPrsStream;
import lpg.runtime.IToken;
+import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalEnv;
@@ -113,8 +115,8 @@ public class QvtCompletionCompiler extends QVTOCompiler {
}
@Override
- protected QvtOperationalVisitorCS createAnalyzer(AbstractQVTParser parser, QvtCompilerOptions options) {
- return new QvtCompletionVisitorCS(parser, options) {
+ protected QvtOperationalVisitorCS createAnalyzer(AbstractQVTParser parser, QvtCompilerOptions options, Monitor monitor) {
+ return new QvtCompletionVisitorCS(parser, options, monitor) {
@Override
protected void setEnv(QvtOperationalEnv env) {
super.setEnv(env);
diff --git a/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/completion/QvtCompletionVisitorCS.java b/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/completion/QvtCompletionVisitorCS.java
index cb87120ba..7e60c3ba9 100644
--- a/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/completion/QvtCompletionVisitorCS.java
+++ b/plugins/org.eclipse.m2m.qvt.oml.editor.ui/src/org/eclipse/m2m/internal/qvt/oml/editor/ui/completion/QvtCompletionVisitorCS.java
@@ -11,6 +11,7 @@
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.editor.ui.completion;
+import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.m2m.internal.qvt.oml.ast.binding.ASTBindingHelper;
@@ -34,10 +35,8 @@ import org.eclipse.ocl.ecore.EcoreEnvironment;
public class QvtCompletionVisitorCS extends QvtOperationalVisitorCS {
private QvtOperationalEnv myEnv;
- public QvtCompletionVisitorCS(
- AbstractQVTParser parser,
- QvtCompilerOptions options) {
- super(parser, options);
+ public QvtCompletionVisitorCS(AbstractQVTParser parser, QvtCompilerOptions options, Monitor monitor) {
+ super(parser, options, monitor);
myEnv = (QvtOperationalEnv) parser.getEnvironment();
}
diff --git a/plugins/org.eclipse.m2m.qvt.oml.project/src/org/eclipse/m2m/internal/qvt/oml/project/builder/QVTOBuilder.java b/plugins/org.eclipse.m2m.qvt.oml.project/src/org/eclipse/m2m/internal/qvt/oml/project/builder/QVTOBuilder.java
index 8815a2390..854df3296 100644
--- a/plugins/org.eclipse.m2m.qvt.oml.project/src/org/eclipse/m2m/internal/qvt/oml/project/builder/QVTOBuilder.java
+++ b/plugins/org.eclipse.m2m.qvt.oml.project/src/org/eclipse/m2m/internal/qvt/oml/project/builder/QVTOBuilder.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bugs 391289, 431082
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.project.builder;
@@ -35,6 +36,9 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.ProgressMonitorWrapper;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.emf.common.util.BasicMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
@@ -82,27 +86,32 @@ public class QVTOBuilder extends IncrementalProjectBuilder {
@Override
protected IProject[] build(int kind, Map<String,String> args, IProgressMonitor monitor) throws CoreException {
- if(monitor == null) {
- monitor = new NullProgressMonitor();
- }
-
- monitor.beginTask(getProject().getFullPath().toString(), 1);
+
+ monitor = new ProgressMonitorWrapper(monitor == null ? new NullProgressMonitor() : monitor) {
+ @Override
+ public boolean isCanceled() {
+ return super.isCanceled() || isInterrupted();
+ }
+ };
- if (kind == IncrementalProjectBuilder.FULL_BUILD) {
- fullBuild(monitor);
- } else {
- incrementalBuild(monitor);
- }
-
+ try {
+ monitor.setTaskName("Build " + getProject().getFullPath().toString()); //$NON-NLS-1$
+
+ if (kind == IncrementalProjectBuilder.FULL_BUILD) {
+ fullBuild(monitor);
+ } else {
+ incrementalBuild(monitor);
+ }
+ } finally {
+ monitor.done();
+ }
+
fireBuildEvent();
-
- monitor.worked(1);
-
+
IProject[] projectDependencies = getConfig().getProjectDependencies(true);
-
- monitor.done();
- return projectDependencies;
+ return projectDependencies;
+
}
private void fullBuild(IProgressMonitor monitor) throws CoreException {
@@ -112,6 +121,8 @@ public class QVTOBuilder extends IncrementalProjectBuilder {
@Override
protected void clean(final IProgressMonitor monitor) throws CoreException {
+ monitor.setTaskName("Clean " + getProject().getFullPath().toString()); //$NON-NLS-1$
+
getProject().accept(new IResourceProxyVisitor() {
public boolean visit(IResourceProxy proxy) throws CoreException {
if (proxy.getType() == IResource.FILE) {
@@ -124,6 +135,8 @@ public class QVTOBuilder extends IncrementalProjectBuilder {
}
}, IContainer.INCLUDE_TEAM_PRIVATE_MEMBERS);
+
+ monitor.done();
}
private void incrementalBuild(IProgressMonitor monitor) throws CoreException {
@@ -201,8 +214,9 @@ public class QVTOBuilder extends IncrementalProjectBuilder {
private void rebuildAll(IProgressMonitor monitor) throws CoreException {
- IFile[] files = collectFiles();
- monitor.worked(1);
+ SubMonitor progress = SubMonitor.convert(monitor, "Rebuild all", 10); //$NON-NLS-1$
+
+ IFile[] files = collectFiles(progress.newChild(1, SubMonitor.SUPPRESS_NONE));
CompiledUnit[] units;
try {
@@ -220,7 +234,7 @@ public class QVTOBuilder extends IncrementalProjectBuilder {
List<UnitProxy> allUnits = ResolverUtils.findAllUnits(resolver);
units = compiler.compile(allUnits.toArray(new UnitProxy[allUnits.size()]),
- options, new BasicMonitor.EclipseSubProgress(monitor, 1));
+ options, CompilerUtils.createMonitor(BasicMonitor.toMonitor(progress.newChild(8, SubMonitor.SUPPRESS_NONE)), 8));
if(shouldSaveXMI()) {
ResourceSet metamodelResourceSet = compiler.getResourceSet();
@@ -228,7 +242,7 @@ public class QVTOBuilder extends IncrementalProjectBuilder {
ExeXMISerializer.saveUnitXMI(units, registry != null ? registry : EPackage.Registry.INSTANCE);
}
}
- catch(OperationCanceledException e) {
+ catch (OperationCanceledException e) {
throw e;
}
catch (Exception e) {
@@ -236,8 +250,8 @@ public class QVTOBuilder extends IncrementalProjectBuilder {
}
for (int i = 0; i < units.length; i++) {
- if(monitor.isCanceled()) {
- throw new OperationCanceledException();
+ if(monitor.isCanceled()) {
+ CompilerUtils.throwOperationCanceled();
}
CompiledUnit nextUnit = units[i];
@@ -251,6 +265,8 @@ public class QVTOBuilder extends IncrementalProjectBuilder {
createQvtMarker(sourceFile, nextMessage);
}
}
+
+ progress.worked(1);
}
private void createQvtMarker(IFile curFile, QvtMessage e) {
@@ -279,9 +295,10 @@ public class QVTOBuilder extends IncrementalProjectBuilder {
return myConfig;
}
- private IFile[] collectFiles() throws CoreException {
+ private IFile[] collectFiles(IProgressMonitor monitor) throws CoreException {
+
final ArrayList<IFile> result = new ArrayList<IFile>();
- getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ getProject().refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 1));
IContainer srcContainer = null;
try {
diff --git a/plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/launch/QvtLaunchConfigurationDelegate.java b/plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/launch/QvtLaunchConfigurationDelegate.java
index cdb77707c..88b3b5506 100644
--- a/plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/launch/QvtLaunchConfigurationDelegate.java
+++ b/plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/launch/QvtLaunchConfigurationDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Borland Software Corporation and others.
+ * Copyright (c) 2007, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bug 431082
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.runtime.launch;
@@ -28,7 +29,6 @@ import org.eclipse.m2m.internal.qvt.oml.library.Context;
import org.eclipse.m2m.internal.qvt.oml.runtime.QvtRuntimePlugin;
import org.eclipse.m2m.internal.qvt.oml.runtime.project.QvtInterpretedTransformation;
import org.eclipse.m2m.internal.qvt.oml.runtime.project.QvtTransformation;
-import org.eclipse.m2m.qvt.oml.util.EvaluationMonitor;
import org.eclipse.m2m.qvt.oml.util.WriterLog;
public class QvtLaunchConfigurationDelegate extends QvtLaunchConfigurationDelegateBase {
@@ -42,12 +42,11 @@ public class QvtLaunchConfigurationDelegate extends QvtLaunchConfigurationDelega
}
// FIXME - do refactoring of this area
- public void launch(final ILaunchConfiguration configuration, String mode, final ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ public void launch(final ILaunchConfiguration configuration, String mode, final ILaunch launch, final IProgressMonitor monitor) throws CoreException {
try {
final QvtTransformation qvtTransformation = new QvtInterpretedTransformation(getQvtModule(configuration));
- final EvaluationMonitor execMonitor = createMonitor();
-
+
final StreamsProxy streamsProxy = new StreamsProxy();
ShallowProcess.IRunnable r = new ShallowProcess.IRunnable() {
@@ -60,7 +59,7 @@ public class QvtLaunchConfigurationDelegate extends QvtLaunchConfigurationDelega
Context context = QvtLaunchUtil.createContext(configuration);
context.setLog(new WriterLog(streamsProxy.getOutputWriter()));
- context.setMonitor(execMonitor);
+ context.setProgressMonitor(monitor);
QvtLaunchConfigurationDelegateBase.doLaunch(qvtTransformation, configuration, context);
@@ -74,7 +73,7 @@ public class QvtLaunchConfigurationDelegate extends QvtLaunchConfigurationDelega
boolean isTerminated = false;
@Override
public void terminate() throws DebugException {
- execMonitor.cancel();
+ monitor.setCanceled(true);
isTerminated = true;
super.terminate();
}
@@ -129,20 +128,6 @@ public class QvtLaunchConfigurationDelegate extends QvtLaunchConfigurationDelega
throw new CoreException(org.eclipse.m2m.internal.qvt.oml.runtime.util.MiscUtil.makeErrorStatus(e));
}
}
-
- private EvaluationMonitor createMonitor() {
- return new EvaluationMonitor() {
- boolean fIsCanceled = false;
-
- public void cancel() {
- fIsCanceled = true;
- }
-
- public boolean isCanceled() {
- return fIsCanceled;
- }
- };
- }
// FIXME - do we need such an annoying generic check ?
diff --git a/plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/launch/QvtLaunchConfigurationDelegateBase.java b/plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/launch/QvtLaunchConfigurationDelegateBase.java
index ff34fc1b6..74b7ba6eb 100644
--- a/plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/launch/QvtLaunchConfigurationDelegateBase.java
+++ b/plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/launch/QvtLaunchConfigurationDelegateBase.java
@@ -198,7 +198,7 @@ public abstract class QvtLaunchConfigurationDelegateBase extends LaunchConfigura
Iterator<ModelExtentContents> itrExtent = out.getExtents().iterator();
for (TargetUriData outUriData : targetData) {
if (!itrExtent.hasNext()) {
- throw new MdaException("Imcomplete transformation results"); //$NON-NLS-1$
+ throw new MdaException("Incomplete transformation results"); //$NON-NLS-1$
}
saveTransformationResult(itrExtent.next(), outUriData, resSet);
}
diff --git a/plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/project/QvtCompilerFacade.java b/plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/project/QvtCompilerFacade.java
index 19e1a8f2d..1fb90cf98 100644
--- a/plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/project/QvtCompilerFacade.java
+++ b/plugins/org.eclipse.m2m.qvt.oml.runtime/src/org/eclipse/m2m/internal/qvt/oml/runtime/project/QvtCompilerFacade.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Borland Software Corporation and others.
+ * Copyright (c) 2007, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bug 431082
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.runtime.project;
@@ -79,7 +80,7 @@ public class QvtCompilerFacade {
final QVTOCompiler compiler = CompilerUtils.createCompiler();
final CompiledUnit module = compiler.compile(sourceUnit, compilerOptions,
- new BasicMonitor.EclipseSubProgress(monitor, 0));
+ BasicMonitor.toMonitor(monitor));
return new CompilationResult() {
public CompiledUnit getCompiledModule() {
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/InternalTransformationExecutor.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/InternalTransformationExecutor.java
index cda8a0606..8e192faba 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/InternalTransformationExecutor.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/InternalTransformationExecutor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 R.Dvorak and others.
+ * Copyright (c) 2009, 2014 R.Dvorak and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,13 +7,18 @@
*
* Contributors:
* Radek Dvorak - initial API and implementation
+ * Christopher Gerking - bug 431082
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.BasicMonitor;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
@@ -123,11 +128,16 @@ public class InternalTransformationExecutor {
*
* @return the diagnostic indicating possible problems of the load action
*/
- public Diagnostic loadTransformation() {
- if (fLoadDiagnostic == null) {
- doLoad();
+ public Diagnostic loadTransformation(IProgressMonitor monitor) {
+ try {
+ if (fLoadDiagnostic == null) {
+ doLoad(monitor);
+ }
+ return fLoadDiagnostic;
+ }
+ finally {
+ monitor.done();
}
- return fLoadDiagnostic;
}
/**
@@ -141,7 +151,7 @@ public class InternalTransformationExecutor {
* @return compiled unit or <code>null</code> if it failed to be obtained
*/
public CompiledUnit getUnit() {
- loadTransformation();
+ loadTransformation(new NullProgressMonitor());
return fCompiledUnit;
}
@@ -160,30 +170,40 @@ public class InternalTransformationExecutor {
* if the context or any of the model parameters is
* <code>null</code>
*/
- public ExecutionDiagnostic execute(ExecutionContext executionContext,
- ModelExtent... modelParameters) {
+ public ExecutionDiagnostic execute(ExecutionContext executionContext, ModelExtent... modelParameters) {
// Java API check for nulls etc.
if (executionContext == null) {
throw new IllegalArgumentException();
}
- checkLegalModelParams(modelParameters);
-
- // ensure transformation unit is loaded
- loadTransformation();
-
- // check if we have successfully loaded the transformation unit
- if (!isSuccess(fLoadDiagnostic)) {
- return fLoadDiagnostic;
- }
-
- try {
- return doExecute(modelParameters,
- createInternalContext(executionContext));
- } catch (QvtRuntimeException e) {
- Log logger = executionContext.getLog();
- logger.log(EvaluationMessages.TerminatingExecution);
-
- return createExecutionFailure(e);
+
+ IProgressMonitor monitor = executionContext.getProgressMonitor();
+
+ try {
+ SubMonitor progress = SubMonitor.convert(monitor, "Execute " + getURI().toString(), 2); //$NON-NLS-1$
+
+ checkLegalModelParams(modelParameters);
+
+ // ensure transformation unit is loaded
+ loadTransformation(progress.newChild(1));
+
+ // check if we have successfully loaded the transformation unit
+ if (!isSuccess(fLoadDiagnostic)) {
+ return fLoadDiagnostic;
+ }
+
+ try {
+ return doExecute(modelParameters,
+ createInternalContext(executionContext, progress.newChild(1)));
+ } catch (QvtRuntimeException e) {
+ Log logger = executionContext.getLog();
+ logger.log(EvaluationMessages.TerminatingExecution);
+
+ return createExecutionFailure(e);
+ }
+ } finally {
+ if (monitor != null) {
+ monitor.done();
+ }
}
}
@@ -237,7 +257,7 @@ public class InternalTransformationExecutor {
// nothing interesting here
}
- private void doLoad() {
+ private void doLoad(IProgressMonitor monitor) {
fLoadDiagnostic = ExecutionDiagnosticImpl.OK_INSTANCE;
UnitProxy unit = UnitResolverFactory.Registry.INSTANCE.getUnit(fURI);
@@ -250,7 +270,7 @@ public class InternalTransformationExecutor {
QVTOCompiler compiler = createCompiler();
try {
- fCompiledUnit = compiler.compile(unit, null, null);
+ fCompiledUnit = compiler.compile(unit, null, BasicMonitor.toMonitor(monitor));
fCompilationRs = compiler.getResourceSet();
// fCompilerKernel = compiler.getKernel();
@@ -442,11 +462,10 @@ public class InternalTransformationExecutor {
|| severity == Diagnostic.INFO;
}
- private static IContext createInternalContext(
- ExecutionContext executionContext) {
+ private static IContext createInternalContext(ExecutionContext executionContext, IProgressMonitor monitor) {
Context ctx = new Context();
ctx.setLog(executionContext.getLog());
- ctx.setMonitor(executionContext.getMonitor());
+ ctx.setProgressMonitor(monitor);
for (String key : executionContext.getConfigPropertyNames()) {
Object value = executionContext.getConfigProperty(key);
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/TransformationRunner.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/TransformationRunner.java
index 6b5b46e7d..15441ce75 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/TransformationRunner.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/TransformationRunner.java
@@ -1,226 +1,228 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2013 R.Dvorak and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Radek Dvorak - initial API and implementation
- *******************************************************************************/
-package org.eclipse.m2m.internal.qvt.oml;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.util.BasicDiagnostic;
-import org.eclipse.emf.common.util.Diagnostic;
-import org.eclipse.emf.common.util.DiagnosticException;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EPackage.Registry;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-import org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalEnvFactory;
-import org.eclipse.m2m.internal.qvt.oml.expressions.OperationalTransformation;
-import org.eclipse.m2m.internal.qvt.oml.trace.Trace;
-import org.eclipse.m2m.qvt.oml.ExecutionContext;
-import org.eclipse.m2m.qvt.oml.ExecutionDiagnostic;
-import org.eclipse.m2m.qvt.oml.ModelExtent;
-
-public class TransformationRunner {
-
- protected static class Executor extends InternalTransformationExecutor {
-
- Trace fTraces;
-
- public Executor(URI uri, Registry registry) {
- super(uri, registry);
- }
-
- public Executor(URI uri) {
- super(uri);
- }
-
- @Override
- protected void handleExecutionTraces(Trace traces) {
- super.handleExecutionTraces(traces);
- fTraces = traces;
- }
-
- }
-
- private final URI fTransformationURI;
- private final Executor fExecutor;
- private final List<URI> fModelParamURIs;
- private URI fTraceFileURI;
-
- private BasicDiagnostic fDiagnostic;
- private List<ModelExtent> fModelParams;
- private ModelExtentHelper fExtentHelper;
-
-
- public TransformationRunner(URI transformationURI,
- EPackage.Registry packageRegistry,
- List<URI> modelParamURIs) {
-
- if (transformationURI == null || modelParamURIs == null
- || modelParamURIs.contains(null)) {
- throw new IllegalArgumentException();
- }
-
- fExecutor = new Executor(transformationURI, packageRegistry);
- fTransformationURI = transformationURI;
- fModelParamURIs = modelParamURIs;
- }
-
- protected InternalTransformationExecutor getExecutor() {
- return fExecutor;
- };
-
- public URI getTransformationURI() {
- return fTransformationURI;
- }
-
- public void setTraceFile(URI traceFileURI) {
- fTraceFileURI = traceFileURI;
- }
-
- public URI getTraceFileURI() {
- return fTraceFileURI;
- }
-
- public Diagnostic initialize() {
- if(fDiagnostic != null) {
- return fDiagnostic;
- }
-
- fDiagnostic = QvtPlugin.createDiagnostic("Transformation runner initiliaze");
-
- Diagnostic loadDiagnostic = fExecutor.loadTransformation();
- if(!QvtPlugin.isSuccess(loadDiagnostic)) {
- fDiagnostic.add(loadDiagnostic);
- }
-
- handleLoadTransformation(loadDiagnostic);
-
- OperationalTransformation transformation = fExecutor.getTransformation();
- if(transformation == null) {
- return fDiagnostic;
- }
-
- // Note: initialized here already loaded transformation is required
- fExtentHelper = new ModelExtentHelper(transformation, fModelParamURIs, fExecutor.getResourceSet());
-
- Diagnostic extentsDiagnostic = Diagnostic.OK_INSTANCE;
- try {
- fModelParams = fExtentHelper.loadExtents();
- } catch (DiagnosticException e) {
- extentsDiagnostic = e.getDiagnostic();
- }
-
- handleLoadExtents(extentsDiagnostic);
- if(!QvtPlugin.isSuccess(extentsDiagnostic)) {
- fDiagnostic.add(extentsDiagnostic);
- }
-
- // FIXME -
- // add validation for configuration properties and param count
- // into the internal executor
-
- // TODO - collect WARN, INFO diagnostics?
- return fDiagnostic;
- }
-
- protected QvtOperationalEnvFactory getEnvFactory() {
- return new QvtOperationalEnvFactory();
- }
-
- protected void handleLoadTransformation(Diagnostic diagnostic) {
- // do nothing
- }
-
- protected void handleLoadExtents(Diagnostic diagnostic) {
- // do nothing
- }
-
- protected void handleExecution(ExecutionDiagnostic execDiagnostic) {
- // do nothing
- }
-
- protected void handleSaveExtents(Diagnostic diagnostic) {
- // do nothing
- }
-
-
- public Diagnostic execute(ExecutionContext context) {
- Diagnostic diagnostic = initialize();
-
- if(!isSuccess(diagnostic)) {
- return diagnostic;
- }
-
- fExecutor.setEnvironmentFactory(getEnvFactory());
- try {
- ModelExtent[] params = fModelParams.toArray(new ModelExtent[fModelParams.size()]);
-
- ExecutionDiagnostic execDiagnostic = fExecutor.execute(context, params);
- handleExecution(execDiagnostic);
-
- Trace traces = fExecutor.fTraces;
- fExecutor.fTraces = null;
-
- if(!isSuccess(execDiagnostic)) {
- // skip saving any output
- return execDiagnostic;
- }
-
- // can continue and save output
- Diagnostic saveExtentsDiagnostic = fExtentHelper.saveExtents();
- handleSaveExtents(saveExtentsDiagnostic);
-
- if(!isSuccess(saveExtentsDiagnostic)) {
- return saveExtentsDiagnostic;
- }
-
- Diagnostic saveTracesDiagnostic = saveTraces(traces);
- if(!isSuccess(saveTracesDiagnostic)) {
- return saveTracesDiagnostic;
- }
-
- return execDiagnostic;
- } finally {
- fExecutor.cleanup();
- }
- }
-
- private Diagnostic saveTraces(Trace trace) {
- if(fTraceFileURI != null) {
- Resource resource = new ResourceSetImpl().createResource(fTraceFileURI);
- resource.getContents().add(trace);
- try {
- Map<String, String> options = new HashMap<String, String>();
- options.put(XMLResource.OPTION_PROCESS_DANGLING_HREF, XMLResource.OPTION_PROCESS_DANGLING_HREF_DISCARD);
- resource.save(options);
- } catch (IOException e) {
- String message = NLS.bind("Failed to save trace model uri={0}", fTraceFileURI);
- return new BasicDiagnostic(Diagnostic.ERROR, QvtPlugin.ID, 0,
- message, new Object[] { e });
- }
- }
-
- return Diagnostic.OK_INSTANCE;
- }
-
- /**
- * Successfully finished execution, no errors and user interruption
- */
- private static boolean isSuccess(Diagnostic diagnostic) {
- int severity = diagnostic.getSeverity();
- return severity != Diagnostic.ERROR && severity != Diagnostic.CANCEL;
- }
-
+/*******************************************************************************
+ * Copyright (c) 2009, 2014 R.Dvorak and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Radek Dvorak - initial API and implementation
+ * Christopher Gerking - bug 431082
+ *******************************************************************************/
+package org.eclipse.m2m.internal.qvt.oml;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.BasicDiagnostic;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.DiagnosticException;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Registry;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+import org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalEnvFactory;
+import org.eclipse.m2m.internal.qvt.oml.expressions.OperationalTransformation;
+import org.eclipse.m2m.internal.qvt.oml.trace.Trace;
+import org.eclipse.m2m.qvt.oml.ExecutionContext;
+import org.eclipse.m2m.qvt.oml.ExecutionDiagnostic;
+import org.eclipse.m2m.qvt.oml.ModelExtent;
+
+public class TransformationRunner {
+
+ protected static class Executor extends InternalTransformationExecutor {
+
+ Trace fTraces;
+
+ public Executor(URI uri, Registry registry) {
+ super(uri, registry);
+ }
+
+ public Executor(URI uri) {
+ super(uri);
+ }
+
+ @Override
+ protected void handleExecutionTraces(Trace traces) {
+ super.handleExecutionTraces(traces);
+ fTraces = traces;
+ }
+
+ }
+
+ private final URI fTransformationURI;
+ private final Executor fExecutor;
+ private final List<URI> fModelParamURIs;
+ private URI fTraceFileURI;
+
+ private BasicDiagnostic fDiagnostic;
+ private List<ModelExtent> fModelParams;
+ private ModelExtentHelper fExtentHelper;
+
+
+ public TransformationRunner(URI transformationURI,
+ EPackage.Registry packageRegistry,
+ List<URI> modelParamURIs) {
+
+ if (transformationURI == null || modelParamURIs == null
+ || modelParamURIs.contains(null)) {
+ throw new IllegalArgumentException();
+ }
+
+ fExecutor = new Executor(transformationURI, packageRegistry);
+ fTransformationURI = transformationURI;
+ fModelParamURIs = modelParamURIs;
+ }
+
+ protected InternalTransformationExecutor getExecutor() {
+ return fExecutor;
+ };
+
+ public URI getTransformationURI() {
+ return fTransformationURI;
+ }
+
+ public void setTraceFile(URI traceFileURI) {
+ fTraceFileURI = traceFileURI;
+ }
+
+ public URI getTraceFileURI() {
+ return fTraceFileURI;
+ }
+
+ public Diagnostic initialize() {
+ if(fDiagnostic != null) {
+ return fDiagnostic;
+ }
+
+ fDiagnostic = QvtPlugin.createDiagnostic("Transformation runner initialize"); //$NON-NLS-1$
+
+ Diagnostic loadDiagnostic = fExecutor.loadTransformation(new NullProgressMonitor());
+ if(!QvtPlugin.isSuccess(loadDiagnostic)) {
+ fDiagnostic.add(loadDiagnostic);
+ }
+
+ handleLoadTransformation(loadDiagnostic);
+
+ OperationalTransformation transformation = fExecutor.getTransformation();
+ if(transformation == null) {
+ return fDiagnostic;
+ }
+
+ // Note: initialized here already loaded transformation is required
+ fExtentHelper = new ModelExtentHelper(transformation, fModelParamURIs, fExecutor.getResourceSet());
+
+ Diagnostic extentsDiagnostic = Diagnostic.OK_INSTANCE;
+ try {
+ fModelParams = fExtentHelper.loadExtents();
+ } catch (DiagnosticException e) {
+ extentsDiagnostic = e.getDiagnostic();
+ }
+
+ handleLoadExtents(extentsDiagnostic);
+ if(!QvtPlugin.isSuccess(extentsDiagnostic)) {
+ fDiagnostic.add(extentsDiagnostic);
+ }
+
+ // FIXME -
+ // add validation for configuration properties and param count
+ // into the internal executor
+
+ // TODO - collect WARN, INFO diagnostics?
+ return fDiagnostic;
+ }
+
+ protected QvtOperationalEnvFactory getEnvFactory() {
+ return new QvtOperationalEnvFactory();
+ }
+
+ protected void handleLoadTransformation(Diagnostic diagnostic) {
+ // do nothing
+ }
+
+ protected void handleLoadExtents(Diagnostic diagnostic) {
+ // do nothing
+ }
+
+ protected void handleExecution(ExecutionDiagnostic execDiagnostic) {
+ // do nothing
+ }
+
+ protected void handleSaveExtents(Diagnostic diagnostic) {
+ // do nothing
+ }
+
+
+ public Diagnostic execute(ExecutionContext context) {
+ Diagnostic diagnostic = initialize();
+
+ if(!isSuccess(diagnostic)) {
+ return diagnostic;
+ }
+
+ fExecutor.setEnvironmentFactory(getEnvFactory());
+ try {
+ ModelExtent[] params = fModelParams.toArray(new ModelExtent[fModelParams.size()]);
+
+ ExecutionDiagnostic execDiagnostic = fExecutor.execute(context, params);
+ handleExecution(execDiagnostic);
+
+ Trace traces = fExecutor.fTraces;
+ fExecutor.fTraces = null;
+
+ if(!isSuccess(execDiagnostic)) {
+ // skip saving any output
+ return execDiagnostic;
+ }
+
+ // can continue and save output
+ Diagnostic saveExtentsDiagnostic = fExtentHelper.saveExtents();
+ handleSaveExtents(saveExtentsDiagnostic);
+
+ if(!isSuccess(saveExtentsDiagnostic)) {
+ return saveExtentsDiagnostic;
+ }
+
+ Diagnostic saveTracesDiagnostic = saveTraces(traces);
+ if(!isSuccess(saveTracesDiagnostic)) {
+ return saveTracesDiagnostic;
+ }
+
+ return execDiagnostic;
+ } finally {
+ fExecutor.cleanup();
+ }
+ }
+
+ private Diagnostic saveTraces(Trace trace) {
+ if(fTraceFileURI != null) {
+ Resource resource = new ResourceSetImpl().createResource(fTraceFileURI);
+ resource.getContents().add(trace);
+ try {
+ Map<String, String> options = new HashMap<String, String>();
+ options.put(XMLResource.OPTION_PROCESS_DANGLING_HREF, XMLResource.OPTION_PROCESS_DANGLING_HREF_DISCARD);
+ resource.save(options);
+ } catch (IOException e) {
+ String message = NLS.bind("Failed to save trace model uri={0}", fTraceFileURI);
+ return new BasicDiagnostic(Diagnostic.ERROR, QvtPlugin.ID, 0,
+ message, new Object[] { e });
+ }
+ }
+
+ return Diagnostic.OK_INSTANCE;
+ }
+
+ /**
+ * Successfully finished execution, no errors and user interruption
+ */
+ private static boolean isSuccess(Diagnostic diagnostic) {
+ int severity = diagnostic.getSeverity();
+ return severity != Diagnostic.ERROR && severity != Diagnostic.CANCEL;
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/ast/parser/QvtOperationalVisitorCS.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/ast/parser/QvtOperationalVisitorCS.java
index 8a92cca2a..83fb69802 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/ast/parser/QvtOperationalVisitorCS.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/ast/parser/QvtOperationalVisitorCS.java
@@ -7,7 +7,7 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
- * Christopher Gerking - bugs 302594, 310991, 289982, 427237, 425634
+ * Christopher Gerking - bugs 302594, 310991, 289982, 391289, 425634, 427237
* Alex Paperno - bugs 272869, 268636, 404647, 414363, 414363, 401521,
* 419299, 414619, 403440, 415024, 420970, 413391,
* 424584, 424869
@@ -29,9 +29,11 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.emf.common.util.BasicEMap;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.EMap;
+import org.eclipse.emf.common.util.Monitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EAttribute;
@@ -60,6 +62,7 @@ import org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalModuleEnv;
import org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalStdLibrary;
import org.eclipse.m2m.internal.qvt.oml.blackbox.BlackboxRegistry;
import org.eclipse.m2m.internal.qvt.oml.compiler.CompilerMessages;
+import org.eclipse.m2m.internal.qvt.oml.compiler.CompilerUtils;
import org.eclipse.m2m.internal.qvt.oml.compiler.QvtCompilerOptions;
import org.eclipse.m2m.internal.qvt.oml.compiler.UnitProxy;
import org.eclipse.m2m.internal.qvt.oml.cst.AssertExpCS;
@@ -262,16 +265,24 @@ public class QvtOperationalVisitorCS
*/
private List<ResolveExp> myLateResolveExps;
+ private final Monitor myMonitor;
+
public QvtOperationalVisitorCS(
OCLLexer lexStream,
Environment<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> environment, QvtCompilerOptions options) {
super(new OCLParser(lexStream));
myCompilerOptions = options;
+ myMonitor = CompilerUtils.createNullMonitor();
}
public QvtOperationalVisitorCS(AbstractQVTParser parser, QvtCompilerOptions options) {
+ this(parser, options, CompilerUtils.createNullMonitor());
+ }
+
+ public QvtOperationalVisitorCS(AbstractQVTParser parser, QvtCompilerOptions options, Monitor monitor) {
super(parser);
myCompilerOptions = options;
+ myMonitor = monitor;
}
public QvtCompilerOptions getCompilerOptions() {
@@ -665,6 +676,11 @@ public class QvtOperationalVisitorCS
Environment<EPackage, EClassifier, EOperation, EStructuralFeature,
EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction,
Constraint, EClass, EObject> env) {
+
+ if (isAborted()) {
+ CompilerUtils.throwOperationCanceled();
+ }
+
try {
if (oclExpressionCS instanceof BlockExpCS) {
return visitBlockExpCS((BlockExpCS) oclExpressionCS, env);
@@ -774,6 +790,9 @@ public class QvtOperationalVisitorCS
QvtPlugin.error(ex);
QvtOperationalUtil.reportError(env, ValidationMessages.QvtOperationalVisitorCS_oclParseNPE, oclExpressionCS);
}
+ catch (OperationCanceledException ex) {
+ throw ex;
+ }
catch (RuntimeException ex) {
//QvtPlugin.log(ex);
QvtOperationalUtil.reportError(env, ValidationMessages.QvtOperationalVisitorCS_oclParseNPE, oclExpressionCS);
@@ -5791,4 +5810,9 @@ public class QvtOperationalVisitorCS
}
return null;
}
+
+ private boolean isAborted() {
+ return myMonitor.isCanceled();
+ }
+
}
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/compiler/CompilerUtils.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/compiler/CompilerUtils.java
index 74d5f655f..494c58852 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/compiler/CompilerUtils.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/compiler/CompilerUtils.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 Borland Software Corporation and others.
+ * Copyright (c) 2009, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,14 +8,15 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bug 391289
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.compiler;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.common.util.BasicMonitor;
@@ -78,7 +79,7 @@ public class CompilerUtils {
return unitDiagnostic;
}
- static Monitor createMonitor(Monitor monitor, int ticks) {
+ public static Monitor createMonitor(Monitor monitor, int ticks) {
if (EMFPlugin.IS_ECLIPSE_RUNNING) {
return Eclipse.createMonitor(monitor, ticks);
}
@@ -86,7 +87,7 @@ public class CompilerUtils {
return monitor;
}
- static void throwOperationCanceled() throws RuntimeException {
+ public static void throwOperationCanceled() throws RuntimeException {
if(EMFPlugin.IS_ECLIPSE_RUNNING) {
Eclipse.throwOperationCanceled();
} else {
@@ -94,7 +95,7 @@ public class CompilerUtils {
}
}
- static Monitor createNullMonitor() {
+ public static Monitor createNullMonitor() {
return new BasicMonitor();
}
@@ -118,7 +119,7 @@ public class CompilerUtils {
}
public static QVTOCompiler createCompiler() {
- // FIXME - eliminate eclipse dependency here, the call should be should be responsible
+ // FIXME - eliminate eclipse dependency here, the call should be responsible
// for setting this up, as different domains have different requirements,
// like editor, builders etc.
if(EMFPlugin.IS_ECLIPSE_RUNNING && EMFPlugin.IS_RESOURCES_BUNDLE_AVAILABLE) {
@@ -135,11 +136,7 @@ public class CompilerUtils {
}
static Monitor createMonitor(Monitor monitor, int ticks) {
- if (monitor instanceof IProgressMonitor) {
- return new BasicMonitor.EclipseSubProgress((IProgressMonitor) monitor, ticks);
- } else {
- return new BasicMonitor.EclipseSubProgress(BasicMonitor.toIProgressMonitor(monitor), ticks);
- }
+ return new BasicMonitor.EclipseSubProgress(BasicMonitor.toIProgressMonitor(monitor), ticks, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
}
static void throwOperationCanceled() throws RuntimeException {
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/compiler/QVTOCompiler.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/compiler/QVTOCompiler.java
index 67f8e7ac3..9b0823f79 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/compiler/QVTOCompiler.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/compiler/QVTOCompiler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2013 Borland Software Corporation and others.
+ * Copyright (c) 2009, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -9,6 +9,7 @@
* Contributors:
* Borland Software Corporation - initial API and implementation
* Alex Paperno - bugs 416584
+ * Christopher Gerking - bugs 391289, 431082
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.compiler;
@@ -199,19 +200,15 @@ public class QVTOCompiler {
CompiledUnit[] result = new CompiledUnit[sources.length];
try {
- monitor.beginTask("", sources.length); //$NON-NLS-1$
+ monitor.beginTask("Compile sources", sources.length); //$NON-NLS-1$
int i = 0;
for (UnitProxy nextSource : sources) {
- if(monitor.isCanceled()) {
+ if(isAborted(monitor)) {
CompilerUtils.throwOperationCanceled();
}
- monitor.setTaskName(nextSource.getURI().toString());
-
- result[i++] = compileSingleFile(nextSource, options, monitor);
-
- monitor.worked(1);
+ result[i++] = compileSingleFile(nextSource, options, CompilerUtils.createMonitor(monitor, 1));
}
} finally {
fDependencyWalkPath.clear();
@@ -224,20 +221,7 @@ public class QVTOCompiler {
}
public CompiledUnit compile(UnitProxy source, QvtCompilerOptions options, Monitor monitor) throws MdaException {
- if(monitor == null) {
- monitor = CompilerUtils.createNullMonitor();
- }
-
- if(options == null) {
- options = getDefaultOptions();
- }
-
- try {
- return compileSingleFile(source, options, monitor);
- } finally {
- fDependencyWalkPath.clear();
- afterCompileCleanup();
- }
+ return compile(new UnitProxy[] { source }, options, monitor)[0];
}
protected CSTParseResult parse(UnitProxy source, QvtCompilerOptions options) throws ParserException {
@@ -291,13 +275,15 @@ public class QVTOCompiler {
return getContentReader(unit);
}
- protected CSTAnalysisResult analyze(CSTParseResult parseResult, UnitProxy unit, ExternalUnitElementsProvider externalUnitElementsProvider, QvtCompilerOptions options) {
+ private CSTAnalysisResult analyze(CSTParseResult parseResult, UnitProxy unit,
+ ExternalUnitElementsProvider externalUnitElementsProvider, QvtCompilerOptions options, Monitor monitor) {
+
QvtOperationalFileEnv env = parseResult.env;
env.setQvtCompilerOptions(options);
CSTAnalysisResult result = new CSTAnalysisResult();
try {
- QvtOperationalVisitorCS visitor = createAnalyzer(parseResult.parser, options);
+ QvtOperationalVisitorCS visitor = createAnalyzer(parseResult.parser, options, monitor);
UnitCS unitCS = parseResult.unitCS;
if(unitCS != null && !unitCS.getModules().isEmpty()) {
result.moduleEnvs = visitor.visitUnitCS(unitCS, unit, env, externalUnitElementsProvider, getResourceSet());
@@ -320,8 +306,8 @@ public class QVTOCompiler {
return result;
}
- protected QvtOperationalVisitorCS createAnalyzer(AbstractQVTParser parser, QvtCompilerOptions options) {
- return new QvtOperationalVisitorCS(parser, options);
+ protected QvtOperationalVisitorCS createAnalyzer(AbstractQVTParser parser, QvtCompilerOptions options, Monitor monitor) {
+ return new QvtOperationalVisitorCS(parser, options, monitor);
}
protected void afterCompileCleanup() {
@@ -351,17 +337,18 @@ public class QVTOCompiler {
}
private CompiledUnit doCompile(final UnitProxy source, QvtCompilerOptions options, Monitor monitor) throws ParserException, IOException {
- if(fSource2Compiled.containsKey(source.getURI())) {
- return fSource2Compiled.get(source.getURI());
- }
-
- monitor = CompilerUtils.createMonitor(monitor, 1); //new SubProgressMonitor(monitor, 1);
- monitor.beginTask(source.getURI().toString(), 3);
-
- List<CompiledUnit> compiledImports = null;
- DependencyPathElement dependencyElement = new DependencyPathElement(source);
try {
- fDependencyWalkPath.push(dependencyElement);
+ monitor.beginTask('\'' + source.getURI().toString() + '\'', 3);
+ monitor.subTask(""); //$NON-NLS-1$
+
+ List<CompiledUnit> compiledImports = null;
+ DependencyPathElement dependencyElement = new DependencyPathElement(source);
+
+ fDependencyWalkPath.push(dependencyElement);
+
+ if(fSource2Compiled.containsKey(source.getURI())) {
+ return fSource2Compiled.get(source.getURI());
+ }
if(fUseCompiledXMI) {
CompiledUnit binXMIUnit = getCompiledExeXMIUnit(source);
@@ -375,7 +362,6 @@ public class QVTOCompiler {
CompiledUnit loadBlackboxUnit = loadBlackboxUnit(source);
fSource2Compiled.put(source.getURI(), loadBlackboxUnit);
- monitor.worked(1);
return loadBlackboxUnit;
}
@@ -390,6 +376,9 @@ public class QVTOCompiler {
UnitResolverImpl unitResolver = new UnitResolverImpl(source);
List<ImportCS> allUnitImportsCS = parseResult.getImports();
+ Monitor importsMonitor = CompilerUtils.createMonitor(monitor, 1);
+ importsMonitor.beginTask("Process imports", allUnitImportsCS.size()); //$NON-NLS-1$
+
for (ImportCS nextImportCS : allUnitImportsCS) {
String importQNameStr = getQualifiedName(nextImportCS);
if(importQNameStr == null || importQNameStr.length() == 0) {
@@ -419,13 +408,15 @@ public class QVTOCompiler {
continue;
}
- compiledImport = doCompile(importedUnit, options, monitor);
+ compiledImport = doCompile(importedUnit, options, CompilerUtils.createMonitor(importsMonitor, 1));
} else {
// report that unit was not resolved
String notFoundMessage = NLS.bind(CompilerMessages.importedCompilationUnitNotFound,
QvtOperationalParserUtil.getStringRepresentation(nextImportCS.getPathNameCS(), NAMESPACE_SEP));
env.reportError(notFoundMessage, nextImportCS.getPathNameCS());
+
+ importsMonitor.worked(1);
}
if(compiledImport != null) {
@@ -453,14 +444,17 @@ public class QVTOCompiler {
} // end of imports processing
// announce CST and imports done
- monitor.worked(1);
-
+ importsMonitor.done();
+ monitor.subTask(""); //$NON-NLS-1$
+
// perform CST analysis
- CSTAnalysisResult analysisResult = analyze(parseResult, source, unitResolver, options);
+ CSTAnalysisResult analysisResult = analyze(parseResult, source, unitResolver, options, monitor);
if(options.isSourceLineNumbersEnabled()) {
addSourceLineNumberInfo(parseResult.parser, analysisResult, source);
}
+ monitor.worked(1);
+
// load black-box implementation bindings
//AST2BlackboxImplBinder.ensureImplementationBinding(source, analysisResult.modules);
@@ -482,13 +476,12 @@ public class QVTOCompiler {
// TODO - better to use this one as unit resolver
fSource2Compiled.put(source.getURI(), result);
- monitor.worked(1);
return result;
} finally {
- fDependencyWalkPath.pop();
+ fDependencyWalkPath.pop();
- monitor.done();
+ monitor.done();
}
}
@@ -775,4 +768,9 @@ public class QVTOCompiler {
}
};
}
+
+ private boolean isAborted(Monitor monitor) {
+ return monitor.isCanceled();
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/evaluator/EvaluationUtil.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/evaluator/EvaluationUtil.java
index 894436e5f..a57f52a6b 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/evaluator/EvaluationUtil.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/evaluator/EvaluationUtil.java
@@ -8,7 +8,7 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
- * Christopher Gerking - bugs 388801, 358709, 427237
+ * Christopher Gerking - bugs 388801, 358709, 427237, 431082
* Alex Paperno - bug 419299
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.evaluator;
@@ -206,7 +206,7 @@ public class EvaluationUtil {
};
nestedContext.setLog(parentContext.getLog());
- nestedContext.setMonitor(parentContext.getMonitor());
+ nestedContext.setProgressMonitor(parentContext.getProgressMonitor());
nestedContext.getSessionData().setValue(AGGREGATING_ROOT_ENV, evalEnv);
return nestedContext;
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/evaluator/QvtOperationalEvaluationVisitorImpl.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/evaluator/QvtOperationalEvaluationVisitorImpl.java
index ca37c8fe8..8d93ea0fe 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/evaluator/QvtOperationalEvaluationVisitorImpl.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/evaluator/QvtOperationalEvaluationVisitorImpl.java
@@ -29,6 +29,7 @@ import java.util.List;
import java.util.ListIterator;
import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
@@ -138,7 +139,6 @@ import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.UnpackExp;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.VariableInitExp;
import org.eclipse.m2m.qvt.oml.ecore.ImperativeOCL.WhileExp;
import org.eclipse.m2m.qvt.oml.util.Dictionary;
-import org.eclipse.m2m.qvt.oml.util.EvaluationMonitor;
import org.eclipse.m2m.qvt.oml.util.IContext;
import org.eclipse.m2m.qvt.oml.util.Log;
import org.eclipse.m2m.qvt.oml.util.MutableList;
@@ -2492,7 +2492,7 @@ implements QvtOperationalEvaluationVisitor, InternalEvaluator, DeferredAssignmen
}
protected InternalEvaluator createInterruptibleVisitor() {
- final EvaluationMonitor monitor = getContext().getMonitor();
+ final IProgressMonitor monitor = getContext().getProgressMonitor();
class InterruptVisitor extends QvtGenericVisitorDecorator.Any {
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/library/Context.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/library/Context.java
index 3321c500b..ee267010e 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/library/Context.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/library/Context.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Borland Software Corporation and others.
+ * Copyright (c) 2007, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bug 431082
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.library;
@@ -15,6 +16,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.m2m.qvt.oml.util.EvaluationMonitor;
import org.eclipse.m2m.qvt.oml.util.IContext;
import org.eclipse.m2m.qvt.oml.util.ISessionData;
@@ -23,18 +26,19 @@ import org.eclipse.m2m.qvt.oml.util.Log;
/**
* @noextend
*/
+@SuppressWarnings("deprecation")
public class Context implements IContext {
private final Map<String, Object> myConfiguration;
private SessionDataImpl myData;
private Log myLog;
- private EvaluationMonitor myMonitor;
+ private IProgressMonitor myMonitor;
public Context() {
myConfiguration = new HashMap<String, Object>();
myLog = Log.NULL_LOG;
- myMonitor = new DefaultMonitor();
+ myMonitor = new NullProgressMonitor();
myData = new SessionDataImpl();
}
@@ -46,7 +50,7 @@ public class Context implements IContext {
return new SessionDataImpl(myData);
}
- public void setMonitor(EvaluationMonitor monitor) {
+ public void setProgressMonitor(IProgressMonitor monitor) {
if(monitor == null) {
throw new IllegalArgumentException("Non-null monitor required"); //$NON-NLS-1$
}
@@ -54,10 +58,17 @@ public class Context implements IContext {
this.myMonitor = monitor;
}
- public EvaluationMonitor getMonitor() {
+ public IProgressMonitor getProgressMonitor() {
return myMonitor;
}
+ /**
+ * @deprecated Use getProgressMonitor() method
+ */
+ public EvaluationMonitor getMonitor() {
+ return EvaluationMonitor.EvaluationMonitorWrapper.convert(myMonitor);
+ }
+
public void setLog(Log log) {
if(log == null) {
throw new IllegalArgumentException("Non-null logger required"); //$NON-NLS-1$
@@ -92,19 +103,6 @@ public class Context implements IContext {
}
- private static class DefaultMonitor implements EvaluationMonitor {
-
- private boolean myIsCancelled;
-
- public void cancel() {
- myIsCancelled = true;
- }
-
- public boolean isCanceled() {
- return myIsCancelled;
- }
- }
-
private static class SessionDataImpl implements ISessionData {
private HashMap<Object, Object> fData;
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/ExecutionContext.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/ExecutionContext.java
index b899fcba1..9cd3c8b02 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/ExecutionContext.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/ExecutionContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Borland Software Corporation and others.
+ * Copyright (c) 2009, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,11 +8,13 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bugs 422269, 431082
*******************************************************************************/
package org.eclipse.m2m.qvt.oml;
import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.m2m.qvt.oml.util.EvaluationMonitor;
import org.eclipse.m2m.qvt.oml.util.Log;
@@ -24,6 +26,7 @@ import org.eclipse.m2m.qvt.oml.util.Log;
*
* @noimplement This interface is not intended to be implemented by clients.
*/
+@SuppressWarnings("deprecation")
public interface ExecutionContext {
/**
@@ -63,6 +66,18 @@ public interface ExecutionContext {
* request.
*
* @return the monitor implementation, never <code>null</code>
+ * @deprecated Use getProgressMonitor() method
*/
EvaluationMonitor getMonitor();
+
+ /**
+ * Gets the evaluation monitor assigned to this context. The execution
+ * engine will query the monitor the check for the user interruption
+ * request.
+ *
+ * @return the monitor implementation, never <code>null</code>
+ * @since 3.4
+ */
+ IProgressMonitor getProgressMonitor();
+
}
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/ExecutionContextImpl.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/ExecutionContextImpl.java
index f8fb64a34..de90cebd1 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/ExecutionContextImpl.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/ExecutionContextImpl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Borland Software Corporation and others.
+ * Copyright (c) 2009, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bugs 422269, 431082
*******************************************************************************/
package org.eclipse.m2m.qvt.oml;
@@ -16,6 +17,8 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.m2m.qvt.oml.util.EvaluationMonitor;
import org.eclipse.m2m.qvt.oml.util.Log;
@@ -27,12 +30,12 @@ import org.eclipse.m2m.qvt.oml.util.Log;
* @noextend This class is not intended to be subclassed by clients.
* @see TransformationExecutor
*/
+@SuppressWarnings("deprecation")
public final class ExecutionContextImpl implements ExecutionContext {
- private Map<String, Object> fConfigProperties = new HashMap<String, Object>(
- 5);
+ private Map<String, Object> fConfigProperties = new HashMap<String, Object>(5);
- private EvaluationMonitor fMonitor;
+ private IProgressMonitor fMonitor;
private Log fLog;
@@ -41,15 +44,14 @@ public final class ExecutionContextImpl implements ExecutionContext {
*/
public ExecutionContextImpl() {
fLog = Log.NULL_LOG;
- fMonitor = ExecutionContextImpl.createDefaultMonitor();
+ fMonitor = createDefaultMonitor();
}
/*
* (non-Javadoc)
*
* @see
- * org.eclipse.m2m.qvt.oml.ExecutionContext#getConfigProperty(java.lang.
- * String)
+ * org.eclipse.m2m.qvt.oml.ExecutionContext#getConfigProperty(java.lang.String)
*/
public Object getConfigProperty(String name) {
if (name == null) {
@@ -113,6 +115,13 @@ public final class ExecutionContextImpl implements ExecutionContext {
* @see org.eclipse.m2m.qvt.oml.ExecutionContext#getMonitor()
*/
public EvaluationMonitor getMonitor() {
+ return EvaluationMonitor.EvaluationMonitorWrapper.convert(fMonitor);
+ }
+
+ /**
+ * @since 3.4
+ */
+ public IProgressMonitor getProgressMonitor() {
return fMonitor;
}
@@ -121,26 +130,32 @@ public final class ExecutionContextImpl implements ExecutionContext {
*
* @param monitor
* the monitor implementation, never <code>null</code>
+ * @deprecated
*/
public void setMonitor(EvaluationMonitor monitor) {
if (monitor == null) {
throw new IllegalArgumentException("null monitor"); //$NON-NLS-1$
}
- fMonitor = monitor;
+ setProgressMonitor(EvaluationMonitor.EvaluationMonitorWrapper.convert(monitor));
}
- private static EvaluationMonitor createDefaultMonitor() {
- return new EvaluationMonitor() {
- boolean myIsCancelled;
-
- public void cancel() {
- myIsCancelled = true;
- }
+ /**
+ * Set evaluation monitor to this context
+ *
+ * @param monitor
+ * the monitor implementation, never <code>null</code>
+ * @since 3.4
+ */
+ public void setProgressMonitor(IProgressMonitor monitor) {
+ if (monitor == null) {
+ throw new IllegalArgumentException("null monitor"); //$NON-NLS-1$
+ }
- public boolean isCanceled() {
- return myIsCancelled;
- }
- };
+ fMonitor = monitor;
+ }
+
+ private static IProgressMonitor createDefaultMonitor() {
+ return new NullProgressMonitor();
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/TransformationExecutor.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/TransformationExecutor.java
index 721745135..92147fbad 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/TransformationExecutor.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/TransformationExecutor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Borland Software Corporation and others.
+ * Copyright (c) 2009, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,9 +8,12 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bug 431082
*******************************************************************************/
package org.eclipse.m2m.qvt.oml;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage;
@@ -65,7 +68,23 @@ public final class TransformationExecutor {
* @return the diagnostic indicating possible problems of the load action
*/
public Diagnostic loadTransformation() {
- return fExector.loadTransformation();
+ return loadTransformation(new NullProgressMonitor());
+ }
+
+ /**
+ * Attempts to load the transformation referred by this executor and checks
+ * if it is valid for execution.
+ * <p>
+ * <b>Remark:</b></br> Only the first performs the actual transformation
+ * loading, subsequent calls to this method will return the existing
+ * diagnostic.
+ *
+ * @since 3.4
+ * @param the monitor indicating load progress and cancellation
+ * @return the diagnostic indicating possible problems of the load action
+ */
+ public Diagnostic loadTransformation(IProgressMonitor monitor) {
+ return fExector.loadTransformation(monitor);
}
/**
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/util/EvaluationMonitor.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/util/EvaluationMonitor.java
index 9a63ed024..7a1481540 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/util/EvaluationMonitor.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/util/EvaluationMonitor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2009 Borland Software Corporation and others.
+ * Copyright (c) 2007, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,11 +8,17 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bug 431082
*******************************************************************************/
package org.eclipse.m2m.qvt.oml.util;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.ProgressMonitorWrapper;
+
/**
* @since 2.0
+ * @deprecated Use IProgressMonitor instance instead
*/
public interface EvaluationMonitor {
/**
@@ -25,4 +31,36 @@ public interface EvaluationMonitor {
* canceled by calling {@link #cancel()}.
*/
boolean isCanceled();
+
+
+ /**
+ * The purpose of this class is to support wrapping of the IProgressMonitor interface to
+ * deprecated <code>EvaluationMonitor</code> interface for API compatibility reason.
+ *
+ * @since 3.4
+ */
+ class EvaluationMonitorWrapper extends ProgressMonitorWrapper implements EvaluationMonitor {
+
+ private EvaluationMonitorWrapper(IProgressMonitor monitor) {
+ super(monitor);
+ }
+
+ public void cancel() {
+ setCanceled(true);
+ }
+
+ public static EvaluationMonitor convert(IProgressMonitor monitor) {
+ return new EvaluationMonitorWrapper(monitor);
+ }
+
+ public static IProgressMonitor convert(final EvaluationMonitor monitor) {
+ return new NullProgressMonitor() {
+ @Override
+ public boolean isCanceled() {
+ return monitor.isCanceled();
+ }
+ };
+ }
+ }
+
}
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/util/IContext.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/util/IContext.java
index 4841061e1..254e7dbbf 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/util/IContext.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/qvt/oml/util/IContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Borland Software Corporation and others.
+ * Copyright (c) 2007, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,11 +8,14 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bug 431082
*******************************************************************************/
package org.eclipse.m2m.qvt.oml.util;
import java.util.Map;
+import org.eclipse.core.runtime.IProgressMonitor;
+
/**
* @noimplement
@@ -34,11 +37,17 @@ public interface IContext {
/**
* Retrieve the monitor associated with this context.
* <p>
- * It can be used to interrupt execution from another thread then the
+ * It can be used to interrupt execution from another thread than the
* execution thread.
*
* @return the monitor object, never <code>null</code>
+ * @since 3.4
*/
+ IProgressMonitor getProgressMonitor();
+
+ /**
+ * @deprecated Use getProgressMonitor() method
+ */
EvaluationMonitor getMonitor();
Map<String, Object> getConfigProperties();
diff --git a/tests/org.eclipse.m2m.tests.qvt.oml/src/org/eclipse/m2m/tests/qvt/oml/bbox/AnnotatedJavaLibrary.java b/tests/org.eclipse.m2m.tests.qvt.oml/src/org/eclipse/m2m/tests/qvt/oml/bbox/AnnotatedJavaLibrary.java
index 93bb96187..13decc926 100644
--- a/tests/org.eclipse.m2m.tests.qvt.oml/src/org/eclipse/m2m/tests/qvt/oml/bbox/AnnotatedJavaLibrary.java
+++ b/tests/org.eclipse.m2m.tests.qvt.oml/src/org/eclipse/m2m/tests/qvt/oml/bbox/AnnotatedJavaLibrary.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Borland Software Corporation and others.
+ * Copyright (c) 2008, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bug 431082
*******************************************************************************/
package org.eclipse.m2m.tests.qvt.oml.bbox;
@@ -384,9 +385,11 @@ public class AnnotatedJavaLibrary {
context.getLog().log(param);
}
+ @SuppressWarnings("deprecation")
@Operation (withExecutionContext=true)
public void cancelExecution(IContext context) {
context.getMonitor().cancel();
+ // context.getProgressMonitor().setCanceled(true);
}
@Operation (contextual=true, withExecutionContext=true)
diff --git a/tests/org.eclipse.m2m.tests.qvt.oml/src/org/eclipse/m2m/tests/qvt/oml/callapi/InvocationTest.java b/tests/org.eclipse.m2m.tests.qvt.oml/src/org/eclipse/m2m/tests/qvt/oml/callapi/InvocationTest.java
index e27d102be..9290f6a3e 100644
--- a/tests/org.eclipse.m2m.tests.qvt.oml/src/org/eclipse/m2m/tests/qvt/oml/callapi/InvocationTest.java
+++ b/tests/org.eclipse.m2m.tests.qvt.oml/src/org/eclipse/m2m/tests/qvt/oml/callapi/InvocationTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Borland Software Corporation and others.
+ * Copyright (c) 2009, 2014 Borland Software Corporation and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
+ * Christopher Gerking - bugs 422269, 431082
*******************************************************************************/
package org.eclipse.m2m.tests.qvt.oml.callapi;
@@ -20,6 +21,8 @@ import java.util.List;
import junit.framework.TestCase;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.util.Diagnostic;
import org.eclipse.emf.common.util.URI;
@@ -33,7 +36,6 @@ import org.eclipse.m2m.qvt.oml.ExecutionContextImpl;
import org.eclipse.m2m.qvt.oml.ExecutionDiagnostic;
import org.eclipse.m2m.qvt.oml.ModelExtent;
import org.eclipse.m2m.qvt.oml.TransformationExecutor;
-import org.eclipse.m2m.qvt.oml.util.EvaluationMonitor;
import org.eclipse.m2m.qvt.oml.util.Log;
import org.eclipse.m2m.qvt.oml.util.StringBufferLog;
import org.eclipse.m2m.tests.qvt.oml.util.TestUtil;
@@ -154,39 +156,30 @@ public class InvocationTest extends TestCase {
}
public void testInterruption() throws Exception {
- final EvaluationMonitor monitor = new EvaluationMonitor() {
- boolean canceled = false;
-
- public void cancel() {
- canceled = true;
- }
- public boolean isCanceled() {
- return canceled;
- }
- };
+ final IProgressMonitor monitor = new NullProgressMonitor();
Log log = new Log() {
public void log(int level, String message, Object param) {
- monitor.cancel();
+ monitor.setCanceled(true);
}
public void log(int level, String message) {
- monitor.cancel();
+ monitor.setCanceled(true);
}
public void log(String message, Object param) {
- monitor.cancel();
+ monitor.setCanceled(true);
}
public void log(String message) {
- monitor.cancel();
+ monitor.setCanceled(true);
}
};
- fContext.setMonitor(monitor);
+ fContext.setProgressMonitor(monitor);
fContext.setLog(log);
- final ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);
+ final ExecutionDiagnostic diagnostic = fExecutor.execute(fContext, fInput, fOutput);
assertEquals(Diagnostic.CANCEL, diagnostic.getSeverity());
assertEquals(ExecutionDiagnostic.USER_INTERRUPTED, diagnostic.getCode());
assertEquals(1, diagnostic.getStackTrace().size());

Back to the top