Commit 7b360ff1 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ scoping refinements

parent 8f6dc62a
......@@ -21,6 +21,7 @@ import org.etsi.mts.tdl.ComponentInstanceBinding;
import org.etsi.mts.tdl.Connection;
import org.etsi.mts.tdl.DataElementMapping;
import org.etsi.mts.tdl.DataInstanceUse;
import org.etsi.mts.tdl.DataType;
import org.etsi.mts.tdl.DataUse;
import org.etsi.mts.tdl.Element;
import org.etsi.mts.tdl.ElementImport;
......@@ -39,6 +40,8 @@ import org.etsi.mts.tdl.Parameter;
import org.etsi.mts.tdl.ParameterBinding;
import org.etsi.mts.tdl.ParameterMapping;
import org.etsi.mts.tdl.ProcedureCall;
import org.etsi.mts.tdl.SimpleDataInstance;
import org.etsi.mts.tdl.SimpleDataType;
import org.etsi.mts.tdl.StructuredDataInstance;
import org.etsi.mts.tdl.StructuredDataType;
import org.etsi.mts.tdl.Target;
......@@ -116,19 +119,21 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
if (context instanceof Message) {
//TODO: quick hack until a better solution is found
ICompositeNode oppositeNode = NodeModelUtils.findActualNodeFor(((Message) context).getTarget().get(0));
String targetGateName = oppositeNode.getText()
.replaceAll("(?s)where\\s+it\\s+is.+", "")
.replaceAll("(?s)with\\s*\\{.+", "")
.trim();
String[] split = targetGateName.split("\\.");
String gate = split[1];
String component = split[0];
if (component.equals(c.getEndPoint().get(0).getComponent().getName()) &&
gate.equals(c.getEndPoint().get(0).getGate().getName())) {
if (oppositeNode != null) {
String targetGateName = oppositeNode.getText()
.replaceAll("(?s)where\\s+it\\s+is.+", "")
.replaceAll("(?s)with\\s*\\{.+", "")
.trim();
String[] split = targetGateName.split("\\.");
String gate = split[1];
String component = split[0];
if (component.equals(c.getEndPoint().get(0).getComponent().getName()) &&
gate.equals(c.getEndPoint().get(0).getGate().getName())) {
elements.add(c.getEndPoint().get(1));
} else if (component.equals(c.getEndPoint().get(1).getComponent().getName()) &&
gate.equals(c.getEndPoint().get(1).getGate().getName())) {
elements.add(c.getEndPoint().get(0));
} else if (component.equals(c.getEndPoint().get(1).getComponent().getName()) &&
gate.equals(c.getEndPoint().get(1).getGate().getName())) {
elements.add(c.getEndPoint().get(0));
}
}
// GateReference opposite = ((Message) context).getTarget().get(0).getTargetGate();
......@@ -170,7 +175,7 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
}
} else if (Parameter.class.isAssignableFrom(reference.getEType().getInstanceClass())) {
if (context instanceof MemberAssignment) {
if (context.eContainer() instanceof StructuredDataInstance) {
if (context.eContainer() instanceof StructuredDataInstance && ((StructuredDataInstance)context.eContainer()).getDataType() instanceof StructuredDataType) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((StructuredDataInstance)context.eContainer()).getDataType()).allMembers());
return scope;
}
......@@ -189,12 +194,20 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
if (((DataInstanceUse)context.eContainer()).getDataInstance() instanceof StructuredDataInstance) {
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()).allMembers());
return scope;
} else if (((DataInstanceUse)context.eContainer()).getDataType() instanceof StructuredDataType) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((DataInstanceUse)context.eContainer()).getDataType()).allMembers());
return scope;
} else if (context.eContainer().eContainer() instanceof MemberAssignment) {
DataType dataType = ((MemberAssignment)context
.eContainer()
.eContainer())
.getMember()
.getDataType();
if (dataType!=null) {
IScope scope = Scopes.scopeFor(((StructuredDataType)dataType)
.allMembers());
return scope;
}
} else if (context.eContainer().eContainer() instanceof ParameterBinding) {
IScope scope = Scopes.scopeFor(((StructuredDataType)((ParameterBinding)context.eContainer().eContainer()).getParameter().getDataType()).allMembers());
return scope;
......@@ -279,8 +292,10 @@ public class TDLan2ScopeProvider extends AbstractDeclarativeScopeProvider {
}
}
} else if (reference.getEType().getInstanceClass() == Timer.class) {
IScope scope = Scopes.scopeFor(((TimerOperation)context).getComponentInstance().getType().allTimers());
return scope;
if (context instanceof TimerOperation) {
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);
......
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