Commit 0b8cfbb0 authored by Daniel Honsel's avatar Daniel Honsel
Browse files

some cleanup

parent d7d039ea
Loading
Loading
Loading
Loading
+0 −23
Original line number Diff line number Diff line
@@ -144,29 +144,6 @@ class TTCN3ScopeHelper {
		}
	}

	//	def static void scopeComponentDef(RefValue variable, ComponentDef component, ArrayList<EObject> list) {
	//		for (ComponentDefList l : component.defs) {
	//			if (l.element.const != null) {
	//				val constDefList = l.element.const.defs as ConstList
	//				for (SingleConstDef d : constDefList.list) {
	//					if (d != variable) {
	//						list.add(d);
	//					}
	//				}
	//			}
	//			if (l.element.variable != null) {
	//				val varList = l.element.variable.list as VarList
	//				for (SingleVarInstance d : varList.variables) {
	//					if (d != variable) {
	//						list.add(d);
	//					}
	//				}
	//			}
	//		}
	//		for (ComponentDef e : component.extends) {
	//			scopeComponentDef(variable, e, list)
	//		}
	//	}
	def static void scopeTemplateOrValueFormalParList(TemplateOrValueFormalParList paramsList,
		ArrayList<EObject> list) {
		var RefValue value;
+9 −48
Original line number Diff line number Diff line
@@ -15,12 +15,13 @@ import de.ugoe.cs.swe.tTCN3.ModuleControlBody
import de.ugoe.cs.swe.tTCN3.ModuleControlPart
import de.ugoe.cs.swe.tTCN3.ModuleDefinition
import de.ugoe.cs.swe.tTCN3.ModuleDefinitionsList
import de.ugoe.cs.swe.tTCN3.ModuleParDef
import de.ugoe.cs.swe.tTCN3.PortElement
import de.ugoe.cs.swe.tTCN3.PortOrAny
import de.ugoe.cs.swe.tTCN3.RecordDefNamed
import de.ugoe.cs.swe.tTCN3.RecordOfDefNamed
import de.ugoe.cs.swe.tTCN3.RefValue
import de.ugoe.cs.swe.tTCN3.ReferencedType
import de.ugoe.cs.swe.tTCN3.ReferencedValue
import de.ugoe.cs.swe.tTCN3.SetDefNamed
import de.ugoe.cs.swe.tTCN3.SetOfDefNamed
import de.ugoe.cs.swe.tTCN3.SignatureDef
@@ -42,11 +43,16 @@ import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider
import static org.eclipse.xtext.scoping.Scopes.*

import static extension de.ugoe.cs.swe.common.TTCN3ScopeHelper.*
import de.ugoe.cs.swe.tTCN3.ReferencedValue
import de.ugoe.cs.swe.tTCN3.ModuleParDef

class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

	/**
	 * This solution do not compare the defined variable with the assigned variable.
	 * 
	 * To compare the assigned with the defined value, something like this:
	 * "def IScope scope_RefValue(RefValue variable, EReference ref)"
	 * must be implemented. First versions did not work.
	 */
	def IScope scope_ReferencedValue_ref(ReferencedValue value, EReference ref) {
		val list = newArrayList();
		var parent = value.eContainer
@@ -81,57 +87,12 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
			} else if (parent instanceof ModuleParDef) {
				parent.scopeModuleParDef(list)
			}
			
			parent = parent.eContainer
		}

		scopeFor(list)
	}

	/**
	 * This solution makes the comparison of the defined variable with the assigned variable possible.
	 * It works not well in the case of expressions in if conditions. The solution above works, 
	 * but does not compare the defined variable with the assigned one.
	 */
//	def IScope scope_RefValue(RefValue variable, EReference ref) {
//		val list = newArrayList();
//		var parent = variable.eContainer
//
//		while (parent != null) {
//
//			//			if (parent instanceof TTCN3Module) {
//			//				variable.scopeModuleVariable(list)
//			//			} else if (parent instanceof StatementBlock) {
//			//				variable.scopeStatementBlock(parent, list)
//			//			} else if (parent instanceof Initial) {
//			//				variable.scopeInitial(parent, list)
//			//			} else if (parent instanceof ForStatement) {
//			//				variable.scopeInitial(parent.init, list)
//			//			} else if (parent instanceof FunctionDef) {
//			//				if(parent.parameterList != null) variable.scopeFunctionParameterValue(parent.parameterList, list)
//			//			} else if (parent instanceof ModuleControlPart) {
//			//				variable.scopeModuleControlPart(parent, list)
//			//			} else if (parent instanceof ComponentDef) {
//			//				parent.componentScopeValueRefs(list, variable, false, true)
//			//			else if (parent instanceof TestcaseDef) {
//			//				val ComponentDef comp = parent.spec.runsOn.component
//			//				//variable.scopeTemplateOrValueFormalParList(parent.parList, list)
//			//				comp.componentScopeValueRefs(list, variable, false, true)
//			//			} //else if (parent instanceof AltstepDef) {
//			//				if(parent.params != null) {
//			//					 variable.scopeFunctionParameterValue(parent.params, list)
//			//				}
//			//				variable.scopeAltstepExtendedDefList(parent, list)
//			//				variable.scopeAltstepLocalDefList(parent.local, list)
//			//			} else if (parent instanceof GroupDef) {
//			//				variable.scopeModuleVariable(list)
//			//			}
//			parent = parent.eContainer
//		}
//
//		scopeFor(list)
//	}

	def IScope scope_ReferencedType(ReferencedType type, EReference ref) {
		val module = type.findDesiredParent(typeof(ModuleDefinitionsList)) as TTCN3Module
		val res = newArrayList