Commit aa52bf35 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ updated scope resolution for inheritance

parent 8467a55d
......@@ -24,12 +24,12 @@ import org.etsi.mts.tdl.DataInstanceUse;
import org.etsi.mts.tdl.DataUse;
import org.etsi.mts.tdl.Element;
import org.etsi.mts.tdl.ElementImport;
import org.etsi.mts.tdl.Extension;
import org.etsi.mts.tdl.FormalParameterUse;
import org.etsi.mts.tdl.FunctionCall;
import org.etsi.mts.tdl.GateInstance;
import org.etsi.mts.tdl.GateReference;
import org.etsi.mts.tdl.LocalExpression;
import org.etsi.mts.tdl.Member;
import org.etsi.mts.tdl.MemberAssignment;
import org.etsi.mts.tdl.MemberReference;
import org.etsi.mts.tdl.Message;
......@@ -51,7 +51,6 @@ import org.etsi.mts.tdl.ValueAssignment;
import org.etsi.mts.tdl.Variable;
import org.etsi.mts.tdl.VariableUse;
import org.etsi.mts.tdl.tdlPackage;
import org.etsi.mts.tdl.impl.ComponentInstanceBindingImpl;
import com.google.common.base.Function;
import com.google.inject.Inject;
......@@ -78,7 +77,7 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
if (context instanceof GateReference) {
GateReference gate = (GateReference) context;
if (gate.getComponent().getType()!=null) {
IScope scope = Scopes.scopeFor(gate.getComponent().getType().getGateInstance());
IScope scope = Scopes.scopeFor(gate.getComponent().getType().allGates());
return scope;
}
}
......@@ -98,7 +97,7 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
} else if (context instanceof ComponentInstanceBinding) {
//assume actual
TestDescription testDescription = getTestDescription((Element) context);
if (reference.getFeatureID() == tdlPackage.eINSTANCE.COMPONENT_INSTANCE_BINDING__FORMAL_COMPONENT) {
if (reference.getFeatureID() == tdlPackage.COMPONENT_INSTANCE_BINDING__FORMAL_COMPONENT) {
testDescription = ((TestDescriptionReference)context.eContainer()).getTestDescription();
}
TestConfiguration configuration = testDescription.getTestConfiguration();
......@@ -139,7 +138,12 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
// elements.add(c.getEndPoint().get(0));
// }
} else if (context instanceof Target) {
GateReference opposite = ((Message) context.eContainer()).getSourceGate();
GateReference opposite = null;
if (context.eContainer() instanceof Message) {
opposite = ((Message) context.eContainer()).getSourceGate();
} else {
opposite = ((ProcedureCall) context.eContainer()).getSourceGate();
}
if (c.getEndPoint().get(0) == opposite) {
elements.add(c.getEndPoint().get(1));
} else if (c.getEndPoint().get(1) == opposite) {
......@@ -167,13 +171,13 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
} else if (Parameter.class.isAssignableFrom(reference.getEType().getInstanceClass())) {
if (context instanceof MemberAssignment) {
if (context.eContainer() instanceof StructuredDataInstance) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((StructuredDataInstance)context.eContainer()).getDataType()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((StructuredDataInstance)context.eContainer()).getDataType()).allMembers());
return scope;
}
} else if (context instanceof ParameterMapping) {
if (context.eContainer() instanceof DataElementMapping) {
if (((DataElementMapping)context.eContainer()).getMappableDataElement() instanceof StructuredDataType) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((DataElementMapping)context.eContainer()).getMappableDataElement()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((DataElementMapping)context.eContainer()).getMappableDataElement()).allMembers());
return scope;
} else if (((DataElementMapping)context.eContainer()).getMappableDataElement() instanceof Action) {
IScope scope = Scopes.scopeFor(((Action)((DataElementMapping)context.eContainer()).getMappableDataElement()).getFormalParameter());
......@@ -183,16 +187,16 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
} else if (context instanceof ParameterBinding) {
if (context.eContainer() instanceof DataInstanceUse) {
if (((DataInstanceUse)context.eContainer()).getDataInstance() instanceof StructuredDataInstance) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((StructuredDataInstance)((DataInstanceUse)context.eContainer()).getDataInstance()).getDataType()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((StructuredDataInstance)((DataInstanceUse)context.eContainer()).getDataInstance()).getDataType()).allMembers());
return scope;
} else if (context.eContainer().eContainer() instanceof MemberAssignment) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((MemberAssignment)context.eContainer().eContainer()).getMember().getDataType()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((MemberAssignment)context.eContainer().eContainer()).getMember().getDataType()).allMembers());
return scope;
} else if (((DataInstanceUse)context.eContainer()).getDataType() instanceof StructuredDataType) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((DataInstanceUse)context.eContainer()).getDataType()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((DataInstanceUse)context.eContainer()).getDataType()).allMembers());
return scope;
} else if (context.eContainer().eContainer() instanceof ParameterBinding) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((ParameterBinding)context.eContainer().eContainer()).getParameter().getDataType()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((ParameterBinding)context.eContainer().eContainer()).getParameter().getDataType()).allMembers());
return scope;
}
} else if (context.eContainer() instanceof FunctionCall) {
......@@ -211,10 +215,10 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
return scope;
// }
} else if (context.eContainer() instanceof FormalParameterUse) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((FormalParameterUse)context.eContainer()).getParameter().getDataType()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((FormalParameterUse)context.eContainer()).getParameter().getDataType()).allMembers());
return scope;
} else if (context.eContainer() instanceof VariableUse) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((VariableUse)context.eContainer()).getVariable().getDataType()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((VariableUse)context.eContainer()).getVariable().getDataType()).allMembers());
return scope;
} else if (context.eContainer() instanceof ProcedureCall) {
// if (((FunctionCall)context.eContainer()).getFunction().get instanceof StructuredDataInstance) {
......@@ -227,29 +231,29 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
EObject targetContext = ((DataUse)context.eContainer()).getReduction().get(((DataUse)context.eContainer()).getReduction().indexOf(context)-1);
if (((MemberReference)targetContext).getMember()!=null) {
if (((MemberReference)targetContext).getMember().getDataType() instanceof StructuredDataType) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((MemberReference)targetContext).getMember().getDataType()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((MemberReference)targetContext).getMember().getDataType()).allMembers());
return scope;
}
}
}
if (context.eContainer() instanceof DataInstanceUse) {
if (((DataInstanceUse)context.eContainer()).getDataInstance() instanceof StructuredDataInstance) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((StructuredDataInstance)((DataInstanceUse)context.eContainer()).getDataInstance()).getDataType()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((StructuredDataInstance)((DataInstanceUse)context.eContainer()).getDataInstance()).getDataType()).allMembers());
return scope;
}
} else if (context.eContainer() instanceof FunctionCall) {
if (((FunctionCall)context.eContainer()).getFunction().getReturnType() instanceof StructuredDataType) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((FunctionCall)context.eContainer()).getFunction().getReturnType()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((FunctionCall)context.eContainer()).getFunction().getReturnType()).allMembers());
return scope;
}
} else if (context.eContainer() instanceof FormalParameterUse) {
if (((FormalParameterUse)context.eContainer()).getParameter().getDataType() instanceof StructuredDataType) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((FormalParameterUse)context.eContainer()).getParameter().getDataType()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((FormalParameterUse)context.eContainer()).getParameter().getDataType()).allMembers());
return scope;
}
} else if (context.eContainer() instanceof VariableUse) {
if (((VariableUse)context.eContainer()).getVariable().getDataType() instanceof StructuredDataType) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((VariableUse)context.eContainer()).getVariable().getDataType()).getMember());
IScope scope = Scopes.scopeFor(((StructuredDataType)((VariableUse)context.eContainer()).getVariable().getDataType()).allMembers());
return scope;
}
} else {
......@@ -258,25 +262,28 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
} else if (reference.getEType().getInstanceClass() == Variable.class) {
if (context instanceof Assignment) {
if (((Assignment)context).getComponentInstance()!=null) {
IScope scope = Scopes.scopeFor(((Assignment)context).getComponentInstance().getType().getVariable());
IScope scope = Scopes.scopeFor(((Assignment)context).getComponentInstance().getType().allVariables());
return scope;
}
}
if (context instanceof VariableUse) {
if (((VariableUse)context).getComponentInstance()!=null) {
IScope scope = Scopes.scopeFor(((VariableUse)context).getComponentInstance().getType().getVariable());
IScope scope = Scopes.scopeFor(((VariableUse)context).getComponentInstance().getType().allVariables());
return scope;
}
}
else if (context instanceof ValueAssignment) {
if (((Target)context.eContainer()).getTargetGate().getComponent()!=null) {
IScope scope = Scopes.scopeFor(((Target)context.eContainer()).getTargetGate().getComponent().getType().getVariable());
IScope scope = Scopes.scopeFor(((Target)context.eContainer()).getTargetGate().getComponent().getType().allVariables());
return scope;
}
}
} else if (reference.getEType().getInstanceClass() == Timer.class) {
IScope scope = Scopes.scopeFor(((TimerOperation)context).getComponentInstance().getType().getTimer());
IScope scope = Scopes.scopeFor(((TimerOperation)context).getComponentInstance().getType().allTimers());
return scope;
} else if (context instanceof Extension) {
EList<EObject> elements = getScopedElementsOfType(context, ((Element)context.eContainer()).getClass());
return Scopes.scopeFor(elements);
} else {
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment