[472482] Enable resolution of workspace blackboxes through JDT
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 208c7b6..e8ea653 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2019 Borland Software Corporation and others.
+ * Copyright (c) 2008, 2020 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 v2.0
* which accompanies this distribution, and is available at
@@ -8,7 +8,7 @@
* Contributors:
* Borland Software Corporation - initial API and implementation
* Christopher Gerking - bugs 302594, 310991, 289982, 391289, 425634, 427237,
- * 433585, 433919, 438038, 536601
+ * 433585, 433919, 438038, 472482, 536601
* Alex Paperno - bugs 272869, 268636, 404647, 414363, 414363, 401521,
* 419299, 414619, 403440, 415024, 420970, 413391,
* 424584, 424869
@@ -5985,7 +5985,7 @@
return annotation;
}
- private static URI getSourceURI(QvtOperationalModuleEnv env) {
+ public static URI getSourceURI(QvtOperationalModuleEnv env) {
if(env instanceof QvtOperationalFileEnv) {
QvtOperationalFileEnv fileEnv = (QvtOperationalFileEnv) env;
return fileEnv.getFile();
diff --git a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/blackbox/BlackboxProvider.java b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/blackbox/BlackboxProvider.java
index c40df85..ba0598b 100644
--- a/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/blackbox/BlackboxProvider.java
+++ b/plugins/org.eclipse.m2m.qvt.oml/src/org/eclipse/m2m/internal/qvt/oml/blackbox/BlackboxProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2018 Borland Software Corporation and others.
+ * Copyright (c) 2007, 2020 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 v2.0
@@ -8,7 +8,7 @@
*
* Contributors:
* Borland Software Corporation - initial API and implementation
- * Christopher Gerking - bugs 289982, 326871, 427237
+ * Christopher Gerking - bugs 289982, 326871, 427237, 472482
*******************************************************************************/
package org.eclipse.m2m.internal.qvt.oml.blackbox;
@@ -18,12 +18,14 @@
import java.util.List;
import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EOperation;
import org.eclipse.m2m.internal.qvt.oml.NLS;
import org.eclipse.m2m.internal.qvt.oml.QvtPlugin;
import org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalEvaluationEnv;
import org.eclipse.m2m.internal.qvt.oml.ast.env.QvtOperationalModuleEnv;
+import org.eclipse.m2m.internal.qvt.oml.ast.parser.QvtOperationalVisitorCS;
import org.eclipse.m2m.internal.qvt.oml.ast.parser.ValidationMessages;
import org.eclipse.m2m.internal.qvt.oml.compiler.BlackboxUnitResolver;
import org.eclipse.m2m.internal.qvt.oml.evaluator.ModuleInstance;
@@ -113,9 +115,14 @@
}
+ private ResolutionContext getResolutionContext(QvtOperationalModuleEnv env) {
+ URI sourceURI = QvtOperationalVisitorCS.getSourceURI(env);
+ return sourceURI != null ? new ResolutionContextImpl(sourceURI) : GLOBAL_RESOLUTION_CONTEXT;
+ }
+
public Collection<CallHandler> getBlackboxCallHandler(ImperativeOperation operation, QvtOperationalModuleEnv env) {
Collection<CallHandler> result = Collections.emptyList();
- for (BlackboxUnitDescriptor d : getUnitDescriptors(GLOBAL_RESOLUTION_CONTEXT)) {
+ for (BlackboxUnitDescriptor d : getUnitDescriptors(getResolutionContext(env))) {
if (env.getImportedNativeLibs().isEmpty()) {
try {
d.load(new LoadContext(env.getEPackageRegistry()));
@@ -144,7 +151,7 @@
public Collection<CallHandler> getBlackboxCallHandler(OperationalTransformation transformation, QvtOperationalModuleEnv env) {
Collection<CallHandler> result = Collections.emptyList();
- for (BlackboxUnitDescriptor d : getUnitDescriptors(GLOBAL_RESOLUTION_CONTEXT)) {
+ for (BlackboxUnitDescriptor d : getUnitDescriptors(getResolutionContext(env))) {
if (env.getImportedNativeLibs().isEmpty()) {
try {
d.load(new LoadContext(env.getEPackageRegistry()));