Loading plugins/org.etsi.mts.tdl.common/src/org/etsi/mts/tdl/scoping/TDLScopeProvider.java +40 −7 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import org.etsi.mts.tdl.DataElementMapping; import org.etsi.mts.tdl.DataInstance; import org.etsi.mts.tdl.DataInstanceUse; import org.etsi.mts.tdl.DataType; import org.etsi.mts.tdl.CollectionDataType; import org.etsi.mts.tdl.CollectionDataInstance; import org.etsi.mts.tdl.DataUse; import org.etsi.mts.tdl.Element; import org.etsi.mts.tdl.ElementImport; Loading Loading @@ -126,10 +128,12 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { testDescription = ((TestDescriptionReference)context.eContainer()).getTestDescription(); } TestConfiguration configuration = testDescription.getTestConfiguration(); if (configuration!=null) { EList<ComponentInstance> components = configuration.getComponentInstance(); IScope scope = Scopes.scopeFor(components); return scope; } } } else if (reference.getEType().getInstanceClass() == GateReference.class) { //TODO: safety checks in case invalid configuration is specified //TODO: only suggest connected gates as targets? Loading Loading @@ -157,6 +161,8 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { if (oppositeNode != null) { String targetGateName = oppositeNode.getText() .replaceAll("(?s)where\\s+it\\s+is.+", "") .replaceAll("(?s)assigned\\s*.+", "") .replaceAll("(?s).+=\\s*", "") .replaceAll("(?s)with\\s*\\{.+", "") .trim(); String[] split = targetGateName.split("\\."); Loading Loading @@ -260,7 +266,9 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { .allMembers()); return scope; } } else if (context.eContainer().eContainer() instanceof ParameterBinding) { } else if (context.eContainer().eContainer() instanceof ParameterBinding && ((ParameterBinding)context.eContainer().eContainer()).getParameter().getDataType() instanceof StructuredDataType ) { IScope scope = Scopes.scopeFor(((StructuredDataType)((ParameterBinding)context.eContainer().eContainer()).getParameter().getDataType()).allMembers()); return scope; } Loading Loading @@ -299,6 +307,23 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { IScope scope = Scopes.scopeFor(((StructuredDataType)((MemberReference)targetContext).getMember().getDataType()).allMembers()); return scope; } } else if (((MemberReference)targetContext).getCollectionIndex()!=null) { if (targetContext.eContainer() instanceof DataInstanceUse) { DataInstanceUse dataInstanceUse = (DataInstanceUse)targetContext.eContainer(); if (dataInstanceUse.getDataType()!=null) { //TODO:? } else if (dataInstanceUse.getDataInstance()!=null) { //TODO: check type DataType itemType = ((CollectionDataType)dataInstanceUse.getDataInstance().getDataType()).getItemType(); if (itemType instanceof StructuredDataType) { IScope scope = Scopes.scopeFor(((StructuredDataType)itemType).allMembers()); return scope; } } } else { //TODO: handle other scenarios? } } } if (context.eContainer() instanceof DataInstanceUse) { Loading Loading @@ -326,6 +351,9 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { } } else { } } else if (context instanceof ValueAssignment) { IScope scope = Scopes.scopeFor(((ProcedureCall)context.eContainer().eContainer()).getSignature().getParameter()); return scope; } } else if (reference.getEType().getInstanceClass() == Variable.class) { if (context instanceof Assignment) { Loading @@ -335,7 +363,7 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { } } if (context instanceof VariableUse) { if (((VariableUse)context).getComponentInstance()!=null) { if (((VariableUse)context).getComponentInstance()!=null && ((VariableUse)context).getComponentInstance().getType()!=null) { IScope scope = Scopes.scopeFor(((VariableUse)context).getComponentInstance().getType().allVariables()); return scope; } Loading @@ -347,7 +375,7 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { } } } else if (reference.getEType().getInstanceClass() == Timer.class) { if (context instanceof TimerOperation) { if (context instanceof TimerOperation && ((TimerOperation)context).getComponentInstance().getType()!=null) { IScope scope = Scopes.scopeFor(((TimerOperation)context).getComponentInstance().getType().allTimers()); return scope; } Loading Loading @@ -414,7 +442,7 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { } } private EList<EObject> getScopedElementsOfType(EObject context, Class c) { protected EList<EObject> getScopedElementsOfType(EObject context, Class c) { EList<EObject> elements = new BasicEList<>(); Package p = getPackage(context); Loading @@ -422,6 +450,11 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { for (PackageableElement e : p.getPackagedElement()) { if (c.isInstance(e)) { elements.add(e); } else if (e instanceof EnumDataType) { //TODO: naive enum handling (also below for (SimpleDataInstance ev : ((EnumDataType) e).getValue()) { elements.add(ev); } } } Loading Loading
plugins/org.etsi.mts.tdl.common/src/org/etsi/mts/tdl/scoping/TDLScopeProvider.java +40 −7 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ import org.etsi.mts.tdl.DataElementMapping; import org.etsi.mts.tdl.DataInstance; import org.etsi.mts.tdl.DataInstanceUse; import org.etsi.mts.tdl.DataType; import org.etsi.mts.tdl.CollectionDataType; import org.etsi.mts.tdl.CollectionDataInstance; import org.etsi.mts.tdl.DataUse; import org.etsi.mts.tdl.Element; import org.etsi.mts.tdl.ElementImport; Loading Loading @@ -126,10 +128,12 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { testDescription = ((TestDescriptionReference)context.eContainer()).getTestDescription(); } TestConfiguration configuration = testDescription.getTestConfiguration(); if (configuration!=null) { EList<ComponentInstance> components = configuration.getComponentInstance(); IScope scope = Scopes.scopeFor(components); return scope; } } } else if (reference.getEType().getInstanceClass() == GateReference.class) { //TODO: safety checks in case invalid configuration is specified //TODO: only suggest connected gates as targets? Loading Loading @@ -157,6 +161,8 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { if (oppositeNode != null) { String targetGateName = oppositeNode.getText() .replaceAll("(?s)where\\s+it\\s+is.+", "") .replaceAll("(?s)assigned\\s*.+", "") .replaceAll("(?s).+=\\s*", "") .replaceAll("(?s)with\\s*\\{.+", "") .trim(); String[] split = targetGateName.split("\\."); Loading Loading @@ -260,7 +266,9 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { .allMembers()); return scope; } } else if (context.eContainer().eContainer() instanceof ParameterBinding) { } else if (context.eContainer().eContainer() instanceof ParameterBinding && ((ParameterBinding)context.eContainer().eContainer()).getParameter().getDataType() instanceof StructuredDataType ) { IScope scope = Scopes.scopeFor(((StructuredDataType)((ParameterBinding)context.eContainer().eContainer()).getParameter().getDataType()).allMembers()); return scope; } Loading Loading @@ -299,6 +307,23 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { IScope scope = Scopes.scopeFor(((StructuredDataType)((MemberReference)targetContext).getMember().getDataType()).allMembers()); return scope; } } else if (((MemberReference)targetContext).getCollectionIndex()!=null) { if (targetContext.eContainer() instanceof DataInstanceUse) { DataInstanceUse dataInstanceUse = (DataInstanceUse)targetContext.eContainer(); if (dataInstanceUse.getDataType()!=null) { //TODO:? } else if (dataInstanceUse.getDataInstance()!=null) { //TODO: check type DataType itemType = ((CollectionDataType)dataInstanceUse.getDataInstance().getDataType()).getItemType(); if (itemType instanceof StructuredDataType) { IScope scope = Scopes.scopeFor(((StructuredDataType)itemType).allMembers()); return scope; } } } else { //TODO: handle other scenarios? } } } if (context.eContainer() instanceof DataInstanceUse) { Loading Loading @@ -326,6 +351,9 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { } } else { } } else if (context instanceof ValueAssignment) { IScope scope = Scopes.scopeFor(((ProcedureCall)context.eContainer().eContainer()).getSignature().getParameter()); return scope; } } else if (reference.getEType().getInstanceClass() == Variable.class) { if (context instanceof Assignment) { Loading @@ -335,7 +363,7 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { } } if (context instanceof VariableUse) { if (((VariableUse)context).getComponentInstance()!=null) { if (((VariableUse)context).getComponentInstance()!=null && ((VariableUse)context).getComponentInstance().getType()!=null) { IScope scope = Scopes.scopeFor(((VariableUse)context).getComponentInstance().getType().allVariables()); return scope; } Loading @@ -347,7 +375,7 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { } } } else if (reference.getEType().getInstanceClass() == Timer.class) { if (context instanceof TimerOperation) { if (context instanceof TimerOperation && ((TimerOperation)context).getComponentInstance().getType()!=null) { IScope scope = Scopes.scopeFor(((TimerOperation)context).getComponentInstance().getType().allTimers()); return scope; } Loading Loading @@ -414,7 +442,7 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { } } private EList<EObject> getScopedElementsOfType(EObject context, Class c) { protected EList<EObject> getScopedElementsOfType(EObject context, Class c) { EList<EObject> elements = new BasicEList<>(); Package p = getPackage(context); Loading @@ -422,6 +450,11 @@ public class TDLScopeProvider extends AbstractDeclarativeScopeProvider { for (PackageableElement e : p.getPackagedElement()) { if (c.isInstance(e)) { elements.add(e); } else if (e instanceof EnumDataType) { //TODO: naive enum handling (also below for (SimpleDataInstance ev : ((EnumDataType) e).getValue()) { elements.add(ev); } } } Loading