Commit 086dfc9c authored by Philip Makedonski's avatar Philip Makedonski
Browse files

*refined scope handling for gate references and gate instances



Change-Id: I4370128f81e156df864478361901c7c0c73a8ca1
Signed-off-by: Philip Makedonski's avatarmakedonski <makedonski@informatik.uni-goettingen.de>
parent 9afc9731
......@@ -77,8 +77,10 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
if (reference.getEType().getInstanceClass() == GateInstance.class) {
if (context instanceof GateReference) {
GateReference gate = (GateReference) context;
IScope scope = Scopes.scopeFor(gate.getComponent().getType().getGateInstance());
return scope;
if (gate.getComponent().getType()!=null) {
IScope scope = Scopes.scopeFor(gate.getComponent().getType().getGateInstance());
return scope;
}
}
} else if (reference.getEType().getInstanceClass() == ComponentInstance.class) {
if (context instanceof Behaviour || context instanceof Block || context instanceof LocalExpression || context instanceof VariableUse) {
......@@ -116,13 +118,17 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
//TODO: quick hack until a better solution is found
ICompositeNode oppositeNode = NodeModelUtils.findActualNodeFor(((Message) context).getTarget().get(0));
String targetGateName = oppositeNode.getText().replaceAll("where\\s+it\\s+is.+", "").trim();
if (targetGateName.startsWith(c.getEndPoint().get(0).getComponent().getName()) &&
targetGateName.endsWith(c.getEndPoint().get(0).getGate().getName())) {
elements.add(c.getEndPoint().get(1));
} else if (targetGateName.startsWith(c.getEndPoint().get(1).getComponent().getName()) &&
targetGateName.endsWith(c.getEndPoint().get(1).getGate().getName())) {
String[] split = targetGateName.split("\\.");
String gate = split[1];
String component = split[0];
if (component.equals(c.getEndPoint().get(0).getComponent().getName()) &&
gate.equals(c.getEndPoint().get(0).getGate().getName())) {
elements.add(c.getEndPoint().get(1));
} else if (component.equals(c.getEndPoint().get(1).getComponent().getName()) &&
gate.equals(c.getEndPoint().get(1).getGate().getName())) {
elements.add(c.getEndPoint().get(0));
}
// GateReference opposite = ((Message) context).getTarget().get(0).getTargetGate();
// if (c.getEndPoint().get(0) == opposite) {
// elements.add(c.getEndPoint().get(1));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment