Commit 238ea92c authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ scope provider improvements for TO and enums

parent ee4f4174
Loading
Loading
Loading
Loading
+37 −1
Original line number Diff line number Diff line
package org.etsi.mts.tdl.scoping;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
@@ -53,6 +54,7 @@ import org.etsi.mts.tdl.PackageableElement;
import org.etsi.mts.tdl.Parameter;
import org.etsi.mts.tdl.ParameterBinding;
import org.etsi.mts.tdl.ParameterMapping;
import org.etsi.mts.tdl.PredefinedFunctionCall;
import org.etsi.mts.tdl.ProcedureCall;
import org.etsi.mts.tdl.ProcedureSignature;
import org.etsi.mts.tdl.SimpleDataInstance;
@@ -73,8 +75,12 @@ import org.etsi.mts.tdl.tdlPackage;
import org.etsi.mts.tdl.extendedconfigurations.ComponentReference;
import org.etsi.mts.tdl.extendedconfigurations.ExtendedGateReference;
import org.etsi.mts.tdl.extendedconfigurations.TestConfigurationInstance;
import org.etsi.mts.tdl.structuredobjectives.Content;
import org.etsi.mts.tdl.structuredobjectives.ContentReference;
import org.etsi.mts.tdl.structuredobjectives.EntityReference;
import org.etsi.mts.tdl.structuredobjectives.EventSequence;
import org.etsi.mts.tdl.structuredobjectives.LiteralValue;
import org.etsi.mts.tdl.structuredobjectives.LiteralValueReference;
import org.etsi.mts.tdl.structuredobjectives.StructuredTestObjective;

import com.google.common.base.Function;
@@ -548,6 +554,12 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider {
			EList<EObject> elements = new BasicEList<>();
			elements.addAll(getScopedElementsOfType(context, MappableDataElement.class));
			elements.addAll(getContainerParameters((Element) context));
			//TODO: filter enums
//			if 
			DataType dataType = ((DataElementUse) context).resolveDataType();
			if (dataType instanceof EnumDataType) {
				elements.removeIf(e->(e instanceof SimpleDataInstance) && ((SimpleDataInstance)e).getDataType() != dataType);
			}
//			elements.addAll(getScopedElementsOfType(context, FormalParameter.class));
//			elements.addAll(getScopedElementsOfType(context, StructuredDataType.class));
			return Scopes.scopeFor(elements);
@@ -555,6 +567,14 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider {
			//EList<EObject> elements = ;
			//return Scopes.scopeFor(dataElement.eContents());
		}
		if (context instanceof DataElementMapping) {
			//TODO: handle qualified names?!
		}

		if (context instanceof PredefinedFunctionCall) {
			//TODO: handle qualified names?!
		}

		
		if (context instanceof ComponentReference && reference.getEType().getInstanceClass() == ComponentInstance.class) {
			TestConfigurationInstance configuration = ((ComponentReference) context).getConfiguration();
@@ -572,6 +592,22 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider {
				return scope;
			}
		}
		if (context instanceof LiteralValueReference) {
			//TODO: why unsupported operation?
//			StructuredTestObjective to = ((LiteralValue) context).getTestObjective();
			StructuredTestObjective to = EcoreUtil2.getContainerOfType(context, StructuredTestObjective.class);
			List<LiteralValue> values = EcoreUtil2.getAllContentsOfType(to, LiteralValue.class);
			IScope scope = Scopes.scopeFor(values);
			return scope;
		}
		if (context instanceof ContentReference) {
			//TODO: why unsupported operation?
//			StructuredTestObjective to = ((LiteralValue) context).getTestObjective();
			StructuredTestObjective to = EcoreUtil2.getContainerOfType(context, StructuredTestObjective.class);
			List<Content> values = EcoreUtil2.getAllContentsOfType(to, Content.class);
			IScope scope = Scopes.scopeFor(values);
			return scope;
		}
		return super.getScope(context, reference);
	}