Loading de.ugoe.cs.swe.T3Q/src/de/ugoe/cs/swe/T3Q/TTCN3ResourceProvider.java +2 −2 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ public class TTCN3ResourceProvider { Injector injector = new TTCN3StandaloneSetup().createInjectorAndDoEMFRegistration(); injector.injectMembers(this); resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE); resourceSet.addLoadOption(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS, Boolean.TRUE); //resourceSet.addLoadOption(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS, Boolean.TRUE); for (String path : paths) { File file = new File(path); Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3.xtext +1 −1 Original line number Diff line number Diff line Loading @@ -895,7 +895,7 @@ SingleTemplateExpression: // TODO: test this! TemplateRefWithParList: template=[TemplateBody|QualifiedIdentifier] list=TemplateActualParList?; template=[BaseTemplate|QualifiedIdentifier] list=TemplateActualParList?; TemplateActualParList: {TemplateActualParList} LPAREN (actual+=TemplateInstanceActualPar (COMMA actual+=TemplateInstanceActualPar)* | Loading de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3RuntimeModule.java +11 −5 Original line number Diff line number Diff line Loading @@ -4,16 +4,22 @@ package de.ugoe.cs.swe; import org.eclipse.xtext.naming.IQualifiedNameProvider; import org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy; import de.ugoe.cs.swe.common.TTCN3DeclarativeQualifiedNameProvider; import de.ugoe.cs.swe.common.TTCN3ResourceDescriptionStrategy; /** * Use this class to register components to be used at runtime / without the Equinox extension registry. */ public class TTCN3RuntimeModule extends AbstractTTCN3RuntimeModule { @Override public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() { return TTCN3DeclarativeQualifiedNameProvider.class; } // @Override // public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() { // return TTCN3DeclarativeQualifiedNameProvider.class; // } // // public Class<? extends IDefaultResourceDescriptionStrategy> bindIDefaultResourceDescriptionStrategy() { // return TTCN3ResourceDescriptionStrategy.class; // } } de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/TTCN3ResourceDescriptionStrategy.xtend 0 → 100644 +54 −0 Original line number Diff line number Diff line package de.ugoe.cs.swe.common import org.eclipse.emf.ecore.EObject import org.eclipse.xtext.resource.IEObjectDescription import org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy import org.eclipse.xtext.util.IAcceptor import org.eclipse.xtext.naming.QualifiedName import org.apache.log4j.Logger import com.google.inject.Inject import org.eclipse.xtext.naming.IQualifiedNameProvider import org.eclipse.xtext.resource.EObjectDescription import java.util.List import de.ugoe.cs.swe.tTCN3.GroupDef import static extension org.eclipse.xtext.EcoreUtil2.* import java.util.Collections import de.ugoe.cs.swe.tTCN3.RefValue class TTCN3ResourceDescriptionStrategy extends DefaultResourceDescriptionStrategy { private final static Logger LOG = Logger.getLogger(DefaultResourceDescriptionStrategy); @Inject private IQualifiedNameProvider qualifiedNameProvider; override createEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) { if (getQualifiedNameProvider() == null) return false try { val QualifiedName qualifiedName = qualifiedNameProvider.getFullyQualifiedName(eObject) if (qualifiedName != null) { acceptor.accept(EObjectDescription.create(qualifiedName, eObject)) alternativeEObjectDescriptions(eObject, acceptor) } } catch (Exception exc) { LOG.error(exc.getMessage(), exc) } return true; } private def alternativeEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) { if (eObject instanceof RefValue) { val List<String> groupNames = newArrayList var GroupDef group = eObject.getContainerOfType(GroupDef) groupNames.add(eObject.name) while (group != null) { groupNames.add(group.name) group = group.eContainer.getContainerOfType(GroupDef) } Collections.reverse(groupNames) acceptor.accept(EObjectDescription.create(QualifiedName.create(groupNames), eObject)) } } } de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/TTCN3ScopeHelper.xtend +82 −32 Original line number Diff line number Diff line Loading @@ -59,6 +59,14 @@ import static org.eclipse.xtext.scoping.Scopes.* import de.ugoe.cs.swe.tTCN3.NestedTypeDef import de.ugoe.cs.swe.tTCN3.NestedRecordOfDef import de.ugoe.cs.swe.tTCN3.NestedSetOfDef import org.eclipse.emf.ecore.resource.Resource import de.ugoe.cs.swe.tTCN3.PortInstance import de.ugoe.cs.swe.tTCN3.ReferencedValue import de.ugoe.cs.swe.tTCN3.RefValueTail import de.ugoe.cs.swe.tTCN3.VarInstance import de.ugoe.cs.swe.tTCN3.FormalValuePar import de.ugoe.cs.swe.tTCN3.TimerVarInstance import de.ugoe.cs.swe.tTCN3.FormalTemplatePar class TTCN3ScopeHelper { Loading Loading @@ -339,7 +347,6 @@ class TTCN3ScopeHelper { def static void componentScopeValueRefs(ComponentDef component, ArrayList<EObject> list, boolean searchTimer, boolean searchVar) { if (searchVar) { for (ComponentDefList l : component.defs.filter[it.element.variable != null]) { if (l.element.variable.list != null) { Loading @@ -352,11 +359,18 @@ class TTCN3ScopeHelper { } } } if (searchVar) { for (ComponentDefList l : component.defs.filter[it.element.const != null]) { for (SingleConstDef v : l.element.const.defs.list) { list.add(v) } } for (ComponentDefList l : component.defs.filter[it.element.port != null]) { for (PortElement v : l.element.port.instances) { list.add(v) } } } if (searchTimer) { for (ComponentDefList l : component.defs.filter[it.element.timer != null]) { Loading @@ -383,6 +397,10 @@ class TTCN3ScopeHelper { list.addAll(originalType.body.defs) } else if (originalType instanceof UnionDefNamed) { list.addAll(originalType.body.defs) } else if (originalType instanceof ComponentDef) { val ArrayList<EObject> compList = newArrayList originalType.componentScopeValueRefs(compList, true, true) list.addAll(compList.map[it as RefValue]) } else if (originalType instanceof RecordOfDefNamed) { // should be impossible, ... or not? } else if (originalType instanceof SetOfDefNamed) { Loading @@ -391,28 +409,13 @@ class TTCN3ScopeHelper { return list } def static IScope templateFieldScope(TemplateDef template) { val type = findOriginalType(getReferencedType((template.base.type.ref))) val list = newArrayList def static Iterable<RefValueElement> templateFieldScope(TypeReference ref) { val ArrayList<RefValueElement> list = newArrayList if (type != null && typeof(RecordDefNamed).isAssignableFrom(type.class)) { list.addAll((type as RecordDefNamed).body.defs) } if (type != null && typeof(UnionDefNamed).isAssignableFrom(type.class)) { list.addAll((type as UnionDefNamed).body.defs) } if (type != null && typeof(SetDefNamed).isAssignableFrom(type.class)) { list.addAll((type as SetDefNamed).body.defs) } if (type != null && typeof(SignatureDef).isAssignableFrom(type.class)) { list.addAll((type as SignatureDef).paramList.params) } scopeFor(list) } if (ref == null) return list def static IScope templateFieldScope(InLineTemplate template) { val type = findOriginalType(getReferencedType((template.type.ref))) val list = newArrayList val type = findOriginalType(getReferencedType(ref)) if (type != null && typeof(RecordDefNamed).isAssignableFrom(type.class)) { list.addAll((type as RecordDefNamed).body.defs) Loading @@ -426,9 +429,10 @@ class TTCN3ScopeHelper { if (type != null && typeof(SignatureDef).isAssignableFrom(type.class)) { list.addAll((type as SignatureDef).paramList.params) } scopeFor(list) list } // TODO: consider nested types private def static ReferencedType findOriginalType(ReferencedType type) { if (type != null && typeof(SubTypeDefNamed).isAssignableFrom(type.class)) { Loading Loading @@ -510,4 +514,50 @@ class TTCN3ScopeHelper { return type; } def static RefValue getReferencedValue(ReferencedValue value) { if (value == null) return null val head = value.head if (head.tail == null && head.target instanceof RefValue) return head.target as RefValue else if (head.tail == null) return null var RefValueTail ref = head.tail while (ref.tail != null) { ref = ref.tail } if (ref.value instanceof RefValue) return ref.value as RefValue else return null } def static TypeReference findVariableType(RefValue variable) { var TypeReference ref = null if (variable == null) return ref // TODO: implement missing ref values if (variable instanceof SingleVarInstance) { val instance = variable.findDesiredParent(VarInstance) if (instance != null && instance.type != null && instance.type.ref != null) { ref = instance.type.ref } else if (instance.listType != null && instance.listType.ref != null) { ref = instance.listType.ref } } else if (variable instanceof FormalValuePar) { ref = variable.type.ref } else if (variable instanceof FormalTemplatePar) { ref = variable.type.ref } return ref } } Loading
de.ugoe.cs.swe.T3Q/src/de/ugoe/cs/swe/T3Q/TTCN3ResourceProvider.java +2 −2 Original line number Diff line number Diff line Loading @@ -61,7 +61,7 @@ public class TTCN3ResourceProvider { Injector injector = new TTCN3StandaloneSetup().createInjectorAndDoEMFRegistration(); injector.injectMembers(this); resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE); resourceSet.addLoadOption(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS, Boolean.TRUE); //resourceSet.addLoadOption(ResourceDescriptionsProvider.PERSISTED_DESCRIPTIONS, Boolean.TRUE); for (String path : paths) { File file = new File(path); Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3.xtext +1 −1 Original line number Diff line number Diff line Loading @@ -895,7 +895,7 @@ SingleTemplateExpression: // TODO: test this! TemplateRefWithParList: template=[TemplateBody|QualifiedIdentifier] list=TemplateActualParList?; template=[BaseTemplate|QualifiedIdentifier] list=TemplateActualParList?; TemplateActualParList: {TemplateActualParList} LPAREN (actual+=TemplateInstanceActualPar (COMMA actual+=TemplateInstanceActualPar)* | Loading
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/TTCN3RuntimeModule.java +11 −5 Original line number Diff line number Diff line Loading @@ -4,16 +4,22 @@ package de.ugoe.cs.swe; import org.eclipse.xtext.naming.IQualifiedNameProvider; import org.eclipse.xtext.resource.IDefaultResourceDescriptionStrategy; import de.ugoe.cs.swe.common.TTCN3DeclarativeQualifiedNameProvider; import de.ugoe.cs.swe.common.TTCN3ResourceDescriptionStrategy; /** * Use this class to register components to be used at runtime / without the Equinox extension registry. */ public class TTCN3RuntimeModule extends AbstractTTCN3RuntimeModule { @Override public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() { return TTCN3DeclarativeQualifiedNameProvider.class; } // @Override // public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() { // return TTCN3DeclarativeQualifiedNameProvider.class; // } // // public Class<? extends IDefaultResourceDescriptionStrategy> bindIDefaultResourceDescriptionStrategy() { // return TTCN3ResourceDescriptionStrategy.class; // } }
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/TTCN3ResourceDescriptionStrategy.xtend 0 → 100644 +54 −0 Original line number Diff line number Diff line package de.ugoe.cs.swe.common import org.eclipse.emf.ecore.EObject import org.eclipse.xtext.resource.IEObjectDescription import org.eclipse.xtext.resource.impl.DefaultResourceDescriptionStrategy import org.eclipse.xtext.util.IAcceptor import org.eclipse.xtext.naming.QualifiedName import org.apache.log4j.Logger import com.google.inject.Inject import org.eclipse.xtext.naming.IQualifiedNameProvider import org.eclipse.xtext.resource.EObjectDescription import java.util.List import de.ugoe.cs.swe.tTCN3.GroupDef import static extension org.eclipse.xtext.EcoreUtil2.* import java.util.Collections import de.ugoe.cs.swe.tTCN3.RefValue class TTCN3ResourceDescriptionStrategy extends DefaultResourceDescriptionStrategy { private final static Logger LOG = Logger.getLogger(DefaultResourceDescriptionStrategy); @Inject private IQualifiedNameProvider qualifiedNameProvider; override createEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) { if (getQualifiedNameProvider() == null) return false try { val QualifiedName qualifiedName = qualifiedNameProvider.getFullyQualifiedName(eObject) if (qualifiedName != null) { acceptor.accept(EObjectDescription.create(qualifiedName, eObject)) alternativeEObjectDescriptions(eObject, acceptor) } } catch (Exception exc) { LOG.error(exc.getMessage(), exc) } return true; } private def alternativeEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) { if (eObject instanceof RefValue) { val List<String> groupNames = newArrayList var GroupDef group = eObject.getContainerOfType(GroupDef) groupNames.add(eObject.name) while (group != null) { groupNames.add(group.name) group = group.eContainer.getContainerOfType(GroupDef) } Collections.reverse(groupNames) acceptor.accept(EObjectDescription.create(QualifiedName.create(groupNames), eObject)) } } }
de.ugoe.cs.swe.TTCN3/src/de/ugoe/cs/swe/common/TTCN3ScopeHelper.xtend +82 −32 Original line number Diff line number Diff line Loading @@ -59,6 +59,14 @@ import static org.eclipse.xtext.scoping.Scopes.* import de.ugoe.cs.swe.tTCN3.NestedTypeDef import de.ugoe.cs.swe.tTCN3.NestedRecordOfDef import de.ugoe.cs.swe.tTCN3.NestedSetOfDef import org.eclipse.emf.ecore.resource.Resource import de.ugoe.cs.swe.tTCN3.PortInstance import de.ugoe.cs.swe.tTCN3.ReferencedValue import de.ugoe.cs.swe.tTCN3.RefValueTail import de.ugoe.cs.swe.tTCN3.VarInstance import de.ugoe.cs.swe.tTCN3.FormalValuePar import de.ugoe.cs.swe.tTCN3.TimerVarInstance import de.ugoe.cs.swe.tTCN3.FormalTemplatePar class TTCN3ScopeHelper { Loading Loading @@ -339,7 +347,6 @@ class TTCN3ScopeHelper { def static void componentScopeValueRefs(ComponentDef component, ArrayList<EObject> list, boolean searchTimer, boolean searchVar) { if (searchVar) { for (ComponentDefList l : component.defs.filter[it.element.variable != null]) { if (l.element.variable.list != null) { Loading @@ -352,11 +359,18 @@ class TTCN3ScopeHelper { } } } if (searchVar) { for (ComponentDefList l : component.defs.filter[it.element.const != null]) { for (SingleConstDef v : l.element.const.defs.list) { list.add(v) } } for (ComponentDefList l : component.defs.filter[it.element.port != null]) { for (PortElement v : l.element.port.instances) { list.add(v) } } } if (searchTimer) { for (ComponentDefList l : component.defs.filter[it.element.timer != null]) { Loading @@ -383,6 +397,10 @@ class TTCN3ScopeHelper { list.addAll(originalType.body.defs) } else if (originalType instanceof UnionDefNamed) { list.addAll(originalType.body.defs) } else if (originalType instanceof ComponentDef) { val ArrayList<EObject> compList = newArrayList originalType.componentScopeValueRefs(compList, true, true) list.addAll(compList.map[it as RefValue]) } else if (originalType instanceof RecordOfDefNamed) { // should be impossible, ... or not? } else if (originalType instanceof SetOfDefNamed) { Loading @@ -391,28 +409,13 @@ class TTCN3ScopeHelper { return list } def static IScope templateFieldScope(TemplateDef template) { val type = findOriginalType(getReferencedType((template.base.type.ref))) val list = newArrayList def static Iterable<RefValueElement> templateFieldScope(TypeReference ref) { val ArrayList<RefValueElement> list = newArrayList if (type != null && typeof(RecordDefNamed).isAssignableFrom(type.class)) { list.addAll((type as RecordDefNamed).body.defs) } if (type != null && typeof(UnionDefNamed).isAssignableFrom(type.class)) { list.addAll((type as UnionDefNamed).body.defs) } if (type != null && typeof(SetDefNamed).isAssignableFrom(type.class)) { list.addAll((type as SetDefNamed).body.defs) } if (type != null && typeof(SignatureDef).isAssignableFrom(type.class)) { list.addAll((type as SignatureDef).paramList.params) } scopeFor(list) } if (ref == null) return list def static IScope templateFieldScope(InLineTemplate template) { val type = findOriginalType(getReferencedType((template.type.ref))) val list = newArrayList val type = findOriginalType(getReferencedType(ref)) if (type != null && typeof(RecordDefNamed).isAssignableFrom(type.class)) { list.addAll((type as RecordDefNamed).body.defs) Loading @@ -426,9 +429,10 @@ class TTCN3ScopeHelper { if (type != null && typeof(SignatureDef).isAssignableFrom(type.class)) { list.addAll((type as SignatureDef).paramList.params) } scopeFor(list) list } // TODO: consider nested types private def static ReferencedType findOriginalType(ReferencedType type) { if (type != null && typeof(SubTypeDefNamed).isAssignableFrom(type.class)) { Loading Loading @@ -510,4 +514,50 @@ class TTCN3ScopeHelper { return type; } def static RefValue getReferencedValue(ReferencedValue value) { if (value == null) return null val head = value.head if (head.tail == null && head.target instanceof RefValue) return head.target as RefValue else if (head.tail == null) return null var RefValueTail ref = head.tail while (ref.tail != null) { ref = ref.tail } if (ref.value instanceof RefValue) return ref.value as RefValue else return null } def static TypeReference findVariableType(RefValue variable) { var TypeReference ref = null if (variable == null) return ref // TODO: implement missing ref values if (variable instanceof SingleVarInstance) { val instance = variable.findDesiredParent(VarInstance) if (instance != null && instance.type != null && instance.type.ref != null) { ref = instance.type.ref } else if (instance.listType != null && instance.listType.ref != null) { ref = instance.listType.ref } } else if (variable instanceof FormalValuePar) { ref = variable.type.ref } else if (variable instanceof FormalTemplatePar) { ref = variable.type.ref } return ref } }