Commit 7f5c55e6 authored by Daniel Honsel's avatar Daniel Honsel
Browse files

updated scope provider according to ComponentElementDef changes

parent f6028b06
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ import org.eclipse.xtext.scoping.IScope

import static org.eclipse.xtext.scoping.Scopes.*
import de.ugoe.cs.swe.tTCN3.TypeReferenceTail
import de.ugoe.cs.swe.tTCN3.BaseTemplate

class TTCN3ScopeHelper {

@@ -296,20 +297,20 @@ class TTCN3ScopeHelper {

	def static void scopeAltstepExtendedDefList(AltstepDef altstep, ArrayList<EObject> list) {
		if (altstep.spec != null) {
			componentScopeValueRefs(altstep.spec.component, list, true, true)
			componentScopeValueRefs(altstep.spec.component, list, true, true, true)
		}
	}

	def static dispatch IScope scopeTimerSpec(FunctionDef function) {
		val list = newArrayList
		if (function.runsOn != null) {
			componentScopeValueRefs(function.runsOn.component, list, true, false)
			componentScopeValueRefs(function.runsOn.component, list, true, false, false)
		}
		if (function.mtc != null) {
			componentScopeValueRefs(function.mtc.component, list, true, false)
			componentScopeValueRefs(function.mtc.component, list, true, false, false)
		}
		if (function.system != null) {
			componentScopeValueRefs(function.system.component, list, true, false)
			componentScopeValueRefs(function.system.component, list, true, false, false)
		}
		scopeFor(list)
	}
@@ -317,16 +318,16 @@ class TTCN3ScopeHelper {
	def static dispatch IScope scopeTimerSpec(AltstepDef altstep) {
		val list = newArrayList
		if (altstep.spec != null) {
			componentScopeValueRefs(altstep.spec.component, list, true, false)
			componentScopeValueRefs(altstep.spec.component, list, true, false, false)
		}
		scopeFor(list)
	}

	def static dispatch IScope scopeTimerSpec(TestcaseDef testcase) {
		val list = newArrayList
		componentScopeValueRefs(testcase.spec.runsOn.component, list, true, false)
		componentScopeValueRefs(testcase.spec.runsOn.component, list, true, false, false)
		if (testcase.spec.systemSpec != null) {
			componentScopeValueRefs(testcase.spec.systemSpec.component, list, true, false)
			componentScopeValueRefs(testcase.spec.systemSpec.component, list, true, false, false)
		}
		scopeFor(list)
	}
@@ -351,7 +352,7 @@ class TTCN3ScopeHelper {
	}

	def static void componentScopeValueRefs(ComponentDef component, ArrayList<EObject> list, boolean searchTimer,
		boolean searchVar) {
		boolean searchVar, boolean searchTemplate) {

		for (ComponentDefList l : component.defs.filter[it.element.variable != null]) {
			if (l.element.variable.list != null) {
@@ -384,8 +385,13 @@ class TTCN3ScopeHelper {
				}
			}
		}
		if (searchTemplate) {
			for (ComponentDefList l : component.defs.filter[it.element.template != null]) {
				list.add(l.element.template.base)
			}			
		}		
		for (ComponentDef e : component.extends) {
			componentScopeValueRefs(e, list, searchTimer, searchVar)
			componentScopeValueRefs(e, list, searchTimer, searchVar, searchTemplate)
		}
	}
	
@@ -404,7 +410,7 @@ class TTCN3ScopeHelper {
			list.addAll(originalType.body.defs)
		} else if (originalType instanceof ComponentDef) {
			val ArrayList<EObject> compList = newArrayList
			originalType.componentScopeValueRefs(compList, true, true)
			originalType.componentScopeValueRefs(compList, true, true, true)
			list.addAll(compList.map[it as RefValue])
		} else if (originalType instanceof RecordOfDefNamed) {
			// should be impossible, ... or not?
+7 −7
Original line number Diff line number Diff line
@@ -262,7 +262,7 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
		while (parent != null) {
			if (parent instanceof AltstepDef) {
				if (parent.spec != null) {
					componentScopeValueRefs(parent.spec.component, list, true, false)
					componentScopeValueRefs(parent.spec.component, list, true, false, false)
				}
				if (parent.params != null) {
					list.addAll(parent.params.eAllOfType(FormalTimerPar))
@@ -276,13 +276,13 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
				}
			} else if (parent instanceof FunctionDef) {
				if (parent.runsOn != null) {
					componentScopeValueRefs(parent.runsOn.component, list, true, false)
					componentScopeValueRefs(parent.runsOn.component, list, true, false, false)
				}
				if (parent.mtc != null) {
					componentScopeValueRefs(parent.mtc.component, list, true, false)
					componentScopeValueRefs(parent.mtc.component, list, true, false, false)
				}
				if (parent.system != null) {
					componentScopeValueRefs(parent.system.component, list, true, false)
					componentScopeValueRefs(parent.system.component, list, true, false, false)
				}
				list.addAll(parent.functionLocalParameter)
			} else if (parent instanceof ComponentDef) {
@@ -572,19 +572,19 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
		} else if (value instanceof FunctionDef) {
			if(value.parameterList != null) value.parameterList.scopeFunctionParameterValue(list)
			if (value.runsOn != null) {
				value.runsOn.component.componentScopeValueRefs(list, false, true)
				value.runsOn.component.componentScopeValueRefs(list, false, true, true)
			}
			scopeFor(list, value.eContainer.scope_ReferencedValueHead(ref))
		} else if (value instanceof ModuleControlPart) {
			value.scopeModuleControlPart(list)
			scopeFor(list, value.eContainer.scope_ReferencedValueHead(ref))
		} else if (value instanceof ComponentDef) {
			value.componentScopeValueRefs(list, false, true)
			value.componentScopeValueRefs(list, false, true, true)
			scopeFor(list, value.eContainer.scope_ReferencedValueHead(ref))
		} else if (value instanceof TestcaseDef) {
			val ComponentDef comp = value.spec.runsOn.component
			value.parList.scopeTemplateOrValueFormalParList(list)
			comp.componentScopeValueRefs(list, false, true)
			comp.componentScopeValueRefs(list, false, true, true)
			scopeFor(list, value.eContainer.scope_ReferencedValueHead(ref))
		} else if (value instanceof AltstepDef) {
			if (value.params != null) {