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: default avatarmakedonski <makedonski@informatik.uni-goettingen.de>
parent 9afc9731
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -77,9 +77,11 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
		if (reference.getEType().getInstanceClass() == GateInstance.class) {
			if (context instanceof GateReference) {
				GateReference gate = (GateReference) context;
				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) {
				TestDescription testDescription = getTestDescription((Element) context);
@@ -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())) {
						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 (targetGateName.startsWith(c.getEndPoint().get(1).getComponent().getName()) &&
								   targetGateName.endsWith(c.getEndPoint().get(1).getGate().getName())) {
						} 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));