Commit 292bf321 authored by Daniel Honsel's avatar Daniel Honsel
Browse files

fixed template references to signature parameters

parent bc9a3b66
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1048,8 +1048,7 @@ ReferencedValue:
	ref=[RefValue|IDENTIFIER] ext+=ExtendedFieldReference*;

RefValue:
	SingleConstDef | ModuleParameter | SingleVarInstance | FieldReference | FormalTemplatePar | SingleTempVarInstance |
	FormalValuePar;
	SingleConstDef | ModuleParameter | SingleVarInstance | FieldReference | FormalTemplatePar | SingleTempVarInstance;

	// IDENTIFIER omitted
PredefinedValue:
+16 −4
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ 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.FieldExpressionSpec

class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

@@ -145,16 +146,27 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

	def IScope scope_FieldSpec_ref(FieldSpec spec, EReference ref) {
		val template = spec.findDesiredParent(typeof(TemplateDef)) as TemplateDef
		val type = template.base.type
		val inner = newArrayList
		template.templateFieldScope(inner)
		scopeFor(inner)
	}

	def IScope scope_FieldExpressionSpec_fieldRef(FieldExpressionSpec field, EReference ref) {
		val template = field.findDesiredParent(typeof(TemplateDef)) as TemplateDef
		val inner = newArrayList
		template.templateFieldScope(inner)
		scopeFor(inner)
	}

	def private void templateFieldScope(TemplateDef template, ArrayList<EObject> list) {
		val type = template.base.type

		if (type != null && type.ref != null && typeof(RecordDefNamed).isAssignableFrom(type.ref.class)) {
			inner.addAll((type.ref as RecordDefNamed).body.defs)
			list.addAll((type.ref as RecordDefNamed).body.defs)
		}
		if (type != null && type.ref != null && typeof(SignatureDef).isAssignableFrom(type.ref.class)) {
			inner.addAll((type.ref as SignatureDef).paramList.params)
			list.addAll((type.ref as SignatureDef).paramList.params)
		}
		scopeFor(inner)
	}

	def IScope scope_TimerRefOrAny_ref(TimerRefOrAny variable, EReference ref) {