Commit 8c802c39 authored by Daniel Honsel's avatar Daniel Honsel
Browse files

improved type references

parent 57757402
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -630,7 +630,7 @@ VarList:
	variables+=SingleVarInstance (COMMA variables+=SingleVarInstance)*;

ReferencedType:
	SubTypeDefNamed | RecordDefNamed | SetDefNamed | PortDef | ComponentDef | UnionDefNamed | EnumDefNamed;
	SubTypeDefNamed | RecordDefNamed | SetDefNamed | PortDef | ComponentDef | UnionDefNamed | EnumDefNamed | RecordOfDefNamed | SetOfDefNamed;

TypeDef:
	TYPEDEFKEYWORD body=TypeDefBody;
@@ -1043,8 +1043,7 @@ ReferencedValue:
	ref=[RefValue|IDENTIFIER] ext+=ExtendedFieldReference*;

RefValue:
	SingleConstDef | ModuleParameter | SingleVarInstance | RecordOfDefNamed | SetOfDefNamed | FormalValuePar |
	FormalTemplatePar;
	SingleConstDef | ModuleParameter | SingleVarInstance | FormalValuePar | FormalTemplatePar;

	// IDENTIFIER omitted
PredefinedValue:
+40 −0
Original line number Diff line number Diff line
@@ -30,6 +30,14 @@ 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.ReferencedType
import de.ugoe.cs.swe.tTCN3.StructuredTypeDef
import de.ugoe.cs.swe.tTCN3.SubTypeDef
import de.ugoe.cs.swe.tTCN3.SetDefNamed
import de.ugoe.cs.swe.tTCN3.UnionDefNamed
import de.ugoe.cs.swe.tTCN3.RecordOfDefNamed
import de.ugoe.cs.swe.tTCN3.SetOfDefNamed
import de.ugoe.cs.swe.tTCN3.EnumDefNamed

class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {

@@ -68,6 +76,38 @@ class TTCN3ScopeProvider extends AbstractDeclarativeScopeProvider {
		scopeFor(list)
	}

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

		for (ModuleDefinition d : module.defs.definitions.filter[it.def instanceof TypeDef]) {
			struct = (d.def as TypeDef).body.structured

			if (struct != null) {
				if (struct.record != null && struct.record instanceof RecordDefNamed) {
					res.add(struct.record)
				} else if (struct.union != null && struct.union instanceof UnionDefNamed) {
					res.add(struct.union)
				} else if (struct.set != null && struct.set instanceof SetDefNamed) {
					res.add(struct.set)
				} else if (struct.recordOf != null && struct.recordOf instanceof RecordOfDefNamed) {
					res.add(struct.recordOf)
				} else if (struct.setOf != null && struct.setOf instanceof SetOfDefNamed) {
					res.add(struct.setOf)
				} else if (struct.enumDef != null && struct.enumDef instanceof EnumDefNamed) {
					res.add(struct.enumDef)
				} else if (struct.port != null) {
					res.add(struct.port)
				} else if (struct.component != null) {
					res.add(struct.component)
				}
			}

		}
		scopeFor(res)
	}

	def IScope scope_ComponentDef_extends(ComponentDef component, EReference ref) {
		val container = component.findDesiredParent(typeof(ModuleDefinitionsList)) as ModuleDefinitionsList
		val inner = newArrayList