Commit 7b360ff1 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ scoping refinements

parent 8f6dc62a
Loading
Loading
Loading
Loading
+19 −4
Changes for plugins/org.etsi.mts.tdl.TDLan2/src/org/etsi/mts/tdl/scoping/TDLan2ScopeProvider.java: 19 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import org.etsi.mts.tdl.ComponentInstanceBinding;
import org.etsi.mts.tdl.Connection;
import org.etsi.mts.tdl.DataElementMapping;
import org.etsi.mts.tdl.DataInstanceUse;
import org.etsi.mts.tdl.DataType;
import org.etsi.mts.tdl.DataUse;
import org.etsi.mts.tdl.Element;
import org.etsi.mts.tdl.ElementImport;
@@ -39,6 +40,8 @@ import org.etsi.mts.tdl.Parameter;
import org.etsi.mts.tdl.ParameterBinding;
import org.etsi.mts.tdl.ParameterMapping;
import org.etsi.mts.tdl.ProcedureCall;
import org.etsi.mts.tdl.SimpleDataInstance;
import org.etsi.mts.tdl.SimpleDataType;
import org.etsi.mts.tdl.StructuredDataInstance;
import org.etsi.mts.tdl.StructuredDataType;
import org.etsi.mts.tdl.Target;
@@ -116,6 +119,7 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
					if (context instanceof Message) {
						//TODO: quick hack until a better solution is found
						ICompositeNode oppositeNode = NodeModelUtils.findActualNodeFor(((Message) context).getTarget().get(0));
						if (oppositeNode != null) {
							String targetGateName = oppositeNode.getText()
									.replaceAll("(?s)where\\s+it\\s+is.+", "")
									.replaceAll("(?s)with\\s*\\{.+", "")
@@ -130,6 +134,7 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
									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) {
@@ -170,7 +175,7 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
			}
		} else if (Parameter.class.isAssignableFrom(reference.getEType().getInstanceClass())) {
			if (context instanceof MemberAssignment) {
				if (context.eContainer() instanceof StructuredDataInstance) {
				if (context.eContainer() instanceof StructuredDataInstance && ((StructuredDataInstance)context.eContainer()).getDataType() instanceof StructuredDataType) {
					IScope scope = Scopes.scopeFor(((StructuredDataType)((StructuredDataInstance)context.eContainer()).getDataType()).allMembers());
					return scope;
				}
@@ -189,12 +194,20 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
					if (((DataInstanceUse)context.eContainer()).getDataInstance() instanceof StructuredDataInstance) {
						IScope scope = Scopes.scopeFor(((StructuredDataType)((StructuredDataInstance)((DataInstanceUse)context.eContainer()).getDataInstance()).getDataType()).allMembers());
						return scope;
					} else if (context.eContainer().eContainer() instanceof MemberAssignment) {
						IScope scope = Scopes.scopeFor(((StructuredDataType)((MemberAssignment)context.eContainer().eContainer()).getMember().getDataType()).allMembers());
						return scope;
					} else if (((DataInstanceUse)context.eContainer()).getDataType() instanceof StructuredDataType) {
						IScope scope = Scopes.scopeFor(((StructuredDataType)((DataInstanceUse)context.eContainer()).getDataType()).allMembers());
						return scope;
					} else if (context.eContainer().eContainer() instanceof MemberAssignment) {
						DataType dataType = ((MemberAssignment)context
								.eContainer()
								.eContainer())
								.getMember()
								.getDataType();
						if (dataType!=null) {
							IScope scope = Scopes.scopeFor(((StructuredDataType)dataType)
									.allMembers());
							return scope;
						}
					} else if (context.eContainer().eContainer() instanceof ParameterBinding) {
						IScope scope = Scopes.scopeFor(((StructuredDataType)((ParameterBinding)context.eContainer().eContainer()).getParameter().getDataType()).allMembers());
						return scope;
@@ -279,8 +292,10 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
				}
			}
		} else if (reference.getEType().getInstanceClass() == Timer.class) {
			if (context instanceof TimerOperation) {
				IScope scope = Scopes.scopeFor(((TimerOperation)context).getComponentInstance().getType().allTimers());
				return scope;
			}
		} else if (context instanceof Extension) {
			EList<EObject> elements = getScopedElementsOfType(context, ((Element)context.eContainer()).getClass());
			return Scopes.scopeFor(elements);