Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Jouault2015-03-27 07:04:15 +0000
committerFrédéric Jouault2015-03-27 07:04:15 +0000
commit56b3beb107c23781ead9a43d82bcc5f1acfa1e9f (patch)
treea657cd8485fcae3f05372ccdf434465ce07f9e28
parenta0d6648085e1d7ab478eabb1b5327bc368ad87bf (diff)
downloadorg.eclipse.atl.tcs-56b3beb107c23781ead9a43d82bcc5f1acfa1e9f.tar.gz
org.eclipse.atl.tcs-56b3beb107c23781ead9a43d82bcc5f1acfa1e9f.tar.xz
org.eclipse.atl.tcs-56b3beb107c23781ead9a43d82bcc5f1acfa1e9f.zip
added support for hyperlinks on multivalued properties
-rw-r--r--plugins/org.eclipse.gmt.tcs.metadata/src/org/eclipse/gmt/tcs/metadata/AbstractLanguage.java37
1 files changed, 31 insertions, 6 deletions
diff --git a/plugins/org.eclipse.gmt.tcs.metadata/src/org/eclipse/gmt/tcs/metadata/AbstractLanguage.java b/plugins/org.eclipse.gmt.tcs.metadata/src/org/eclipse/gmt/tcs/metadata/AbstractLanguage.java
index e89178f..c33d66a 100644
--- a/plugins/org.eclipse.gmt.tcs.metadata/src/org/eclipse/gmt/tcs/metadata/AbstractLanguage.java
+++ b/plugins/org.eclipse.gmt.tcs.metadata/src/org/eclipse/gmt/tcs/metadata/AbstractLanguage.java
@@ -48,6 +48,7 @@ import org.eclipse.m2m.atl.dsls.textsource.TextSource;
import org.eclipse.m2m.atl.engine.emfvm.StackFrame;
import org.eclipse.m2m.atl.engine.emfvm.VMException;
import org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher;
+import org.eclipse.m2m.atl.engine.emfvm.lib.ASMModule;
import org.eclipse.m2m.atl.engine.emfvm.lib.AbstractStackFrame;
import org.eclipse.m2m.atl.engine.emfvm.lib.ExecEnv;
import org.eclipse.m2m.atl.engine.emfvm.lib.LibExtension;
@@ -97,6 +98,7 @@ public abstract class AbstractLanguage implements Language {
Object ret = TCSInjection.inject(factory, model, metamodel, source, params, this.getJarURL());
final ExecEnv execEnv_[] = new ExecEnv[1];
+ final ASMModule asmModule_[] = new ASMModule[1];
if(problemModel != null) {
// TODO: only if no parsing error?
@@ -169,6 +171,7 @@ public abstract class AbstractLanguage implements Language {
final CompletionInformation ci = (CompletionInformation)params.get("completionInformation");
execEnv.registerOperation(String.class, new Operation(1, "offsetToComplete") {
public Object exec(AbstractStackFrame frame) {
+ asmModule_[0] = frame.getAsmModule();
if(ci != null) {
return Integer.valueOf(ci.getOffset());
} else {
@@ -183,11 +186,32 @@ public abstract class AbstractLanguage implements Language {
Object locals[] = frame.getLocalVars();
// TODO: generalize this
Object source = ((ASMEMFModel)model_).getASMModelElement((EObject)locals[1]);
- Object target = ((ASMEMFModel)model_).getASMModelElement((EObject)locals[3]);
- hyperlinks.put(
- ((ElementTrace)trace.get(source)).getPropertyLocation((String)locals[2]),
- locations.get(target)
- );
+ String propertyName = (String)locals[2];
+ int index = 0;
+ String regex = "^(.*)\\[([0-9]+)\\]$"; // TODO: pre-compile regex
+ if(propertyName.matches(regex)) {
+ index = Integer.parseInt(propertyName.replaceAll(regex, "$2")) - 1; // conversion from 1-based OCL to 0-based ATL
+ propertyName = propertyName.replaceAll(regex, "$1");
+ }
+ Object sourceLocation = ((ElementTrace)trace.get(source)).getPropertyLocation(propertyName);
+ if(sourceLocation instanceof List) {
+ sourceLocation = ((List)sourceLocation).get(index);
+ }
+ if(locals[3] instanceof EObject) {
+ Object target = ((ASMEMFModel)model_).getASMModelElement((EObject)locals[3]);
+ Object targetLocation = locations.get(target);
+ if(targetLocation == null) {
+ EObject eo = (EObject)locals[3];
+ targetLocation = eo.eResource().getURI().toString() + "#" + eo.eResource().getURIFragment(eo);
+ }
+ hyperlinks.put(
+ sourceLocation,
+ targetLocation
+ );
+ } else {
+ hyperlinks.put(sourceLocation, locals[3]);
+ }
+ // TODO: handle URI hyperlinks
return null;
}
});
@@ -221,6 +245,7 @@ public abstract class AbstractLanguage implements Language {
});
options.put("extensionObjects", extensionObjects);
+ options.put("allowInterModelReferences", Boolean.TRUE);
launcher.launch(ILauncher.RUN_MODE, null, options, new Object[] {this.getWFR()});
} catch(IOException ioe) {
throw new RuntimeException("could not run WFR transformation", ioe);
@@ -245,7 +270,7 @@ public abstract class AbstractLanguage implements Language {
ExecEnv execEnv = execEnv_[0];
Operation op = execEnv.getOperation(ame.eClass(), "getCompletionProposals");
if(op != null) {
- StackFrame stackFrame = new StackFrame(execEnv, null, op);
+ StackFrame stackFrame = new StackFrame(execEnv, asmModule_[0], op);
Object localVars[] = new Object[op.getMaxLocals()];
localVars[0] = ame;
localVars[1] = propertyName;

Back to the top