Commit bd676b8c authored by Daniel Honsel's avatar Daniel Honsel
Browse files

scoping

parent 621a483c
Loading
Loading
Loading
Loading
+22 −5
Original line number Diff line number Diff line
@@ -270,6 +270,9 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
			if (function.runsOn != null) {
				function.runsOn.component.componentScopePorts(list)
			}
			if (function.mtc != null) {
				function.mtc.component.componentScopePorts(list)
			}
		}

		// ports from parent testcase
@@ -302,7 +305,21 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
	}

	def IScope scope_PortRef_port(PortRef pRef, EReference ref) {
		pRef.scope_communicationPort

		//TODO: find type of ComponentRef
		val list = newArrayList
		if (pRef.component.ref != null) {
			val value = pRef.component.ref.variable.ref as Head;
			if (value != null && typeof(SingleVarInstance).isAssignableFrom(value.target.class)) {
				val variable = value.target.findDesiredParent(VarInstance)
				if (variable != null && variable.type != null && variable.type.ref != null) {
					list.addAll(variable.type.scopeReferencedFields)
				} else if (variable.listType != null && variable.listType.ref != null) {
					list.addAll(variable.listType.scopeReferencedFields)
				}
			}
		}
		scopeFor(list, pRef.scope_communicationPort)
	}

	def IScope scope_RefValueTail_value(RefValueTail it, EReference ref) {
@@ -365,10 +382,10 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

	private def Iterable<RefValueElement> directGroupElements(GroupDef it) {
		val List<RefValueElement> res = newArrayList
		if (it.list == null)
		if (list == null)
			return res

		for (ModuleDefinition g : it.list.definitions) {
		for (ModuleDefinition g : list.definitions) {
			val elt = g.def
			if (elt instanceof GroupDef) {
				res.add(elt)
@@ -388,11 +405,11 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
	private def Iterable<RefValue> directModulePrams(ModuleParDef it) {
		val list = newArrayList
		if (it.param != null) {
			for (ModuleParameter p : it.param.list.params) {
			for (ModuleParameter p : param.list.params) {
				list.add(p)
			}
		} else if (it.multitypeParam != null) {
			for (ModulePar p : it.multitypeParam.params) {
			for (ModulePar p : multitypeParam.params) {
				for (ModuleParameter pa : p.list.params) {
					list.add(pa)
				}