Commit 44c8efd1 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ fix for further issues with nested record of and similar, #30

parent b1b10813
Loading
Loading
Loading
Loading
+33 −1
Original line number Diff line number Diff line
@@ -546,10 +546,42 @@ class TTCN3ScopeHelper {
			list.addAll(type.defs)
		} else if (type instanceof NestedSetDef) {
			list.addAll(type.defs)
		//DONE: this should be only for arrays -> handle separately
		} else if (type instanceof NestedRecordOfDef) {
			//TODO: handle? -> separate in exceptional cases
		} else if (type instanceof NestedSetOfDef) {
			//TODO: handle? -> separate in exceptional cases
		}
		return list 
	}

	def static Iterable<RefValueElement> nestedFields(EObject type) {
		var ArrayList<RefValueElement> list = newArrayList
		if (type instanceof NestedRecordOfDef) {
			if (type.nested !== null) {
				list.addAll(type.nested.nestedTypeFieldElements)
			} else if (type.type !== null && type.type.ref !== null) {
				list.addAll(type.type.ref.templateFieldScope)
			}
		} else if (type instanceof NestedSetOfDef) {
			if (type.nested !== null) {
				list.addAll(type.nested.nestedTypeFieldElements)
			} else if (type.type !== null && type.type.ref !== null) {
				list.addAll(type.type.ref.templateFieldScope)
			}
		} else if (type instanceof RecordOfDefNamed) {
			//handle?
		} else if (type instanceof SetOfDefNamed) {
			//handle?
		} else if (type instanceof SubTypeDefNamed) {
			if (type.type.ref !== null) {
				val original = type.type.ref.referencedOrNestedTypeWithTail
				list.addAll(original.nestedFields)
			}
		}
		
		return list
	}

	def static Iterable<RefValueElement> templateFieldScope(TypeReference ref) {
		val ArrayList<RefValueElement> list = newArrayList
+18 −0
Original line number Diff line number Diff line
@@ -92,6 +92,9 @@ import de.ugoe.cs.swe.tTCN3.ImportDef
import de.ugoe.cs.swe.tTCN3.ExtendedFieldOrTypeReference
import de.ugoe.cs.swe.tTCN3.ArrayOrMixedExpression
import de.ugoe.cs.swe.tTCN3.SubTypeDefNamed
import de.ugoe.cs.swe.tTCN3.NestedRecordOfDef
import de.ugoe.cs.swe.tTCN3.RecordOfDefNamed
import de.ugoe.cs.swe.tTCN3.NestedTypeDef

//TODO: switch to TTCN3LocalScopeProvider as base class?
class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
@@ -250,6 +253,15 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

		if (eField !== null) {
			list.addAll(eField.fieldRef.scopeFieldReferences)
			if (hasArrayAsParent) {
				val ref = eField.fieldRef
				if (ref instanceof StructFieldDef) {
					if (ref.nestedType !== null) {
						val type = ref.nestedType 
						list.addAll(type.nestedFields)
					}
				}
			}
		} else if (cField !== null) {
			list.addAll(cField.fieldRef.scopeFieldReferences)
 		} else if (sField !== null) {
@@ -275,6 +287,12 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
		} else if (template !== null) {
			if (template.base.type !== null && template.base.type.ref !== null) {
				list.addAll(template.base.type.ref.templateFieldScope)
				//TODO: this has to be more specific.. -> perhaps too specific now?
				if (hasArrayAsParent) {
					val type = getReferencedOrNestedTypeWithTail(template.base.type.ref)
					//TODO: repeats parts, need to integrate better 
					list.addAll(type.nestedFields) 
				}
			}
		} else if (variable !== null) {
			if (variable.type !== null && variable.type.ref !== null) {