| Summary: |
Typesystem EmfRegistryMetaModel#getNamedElementRec(ENamedElement[],String) does not resolve subpackages wich does not contain Eclassifiers. |
| Product: |
[Modeling] M2T
|
Reporter: |
Yannick DIDIERJEAN <yannick7777> |
| Component: |
Xpand | Assignee: |
Project Inbox <m2t.xpand-inbox> |
| Status: |
CLOSED
WONTFIX
|
QA Contact: |
|
| Severity: |
normal
|
|
|
| Priority: |
P3
|
CC: |
ali.akar82, idydieng, quoclan, r.sezestre, sebastian.zarnekow, stephaneberle9
|
| Version: |
unspecified | |
|
| Target Milestone: |
--- | |
|
| Hardware: |
PC | |
|
| OS: |
Windows XP | |
|
| Whiteboard: |
|
According to observed Emf packages generation mechanisms, the subpackages of one package wich does not contain any Eclassifier are not listed as child packages. This leads to a bug in the EmfRegistryMetaMoldel when using it with a model containing packages generated as previously described. While evaluating statement , the type system try to resolve Eclassifier for one element by retrieving all possible qualified names according imports listed in the script and by matching an existing EClassifier in the model.The problem appears in the method org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel.getNamedElementRec(ENamedElement[], String). this method use the provided name as qualified name that it will try to match with provided elements , in order to find the corresponding Eclassifier. If the considered element have a qualified name containing one or more package name that have been ignored by Emf generation , the whole process will stop and the element will be considered as not being part of the considered model.Nevertheless this element exist in the model and its qualified name is correct. To solve that problem , i propose a modified implementation of the method org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel.getNamedElementRec(ENamedElement[], String) in order to adapt its way of investigating packages and sub packages to the emf generation process policy. this is my proposal for implementation: private Set<ENamedElement> getNamedElementRec(final ENamedElement[] elements, final String name) { Set<ENamedElement> result = new HashSet<ENamedElement>(); final String[] frags = name.split(SyntaxConstants.NS_DELIM); final String firstFrag = frags[0]; for (final ENamedElement ele : elements) { final String eleName = getElementName(ele); if (eleName != null && eleName.equals(firstFrag)) { if (frags.length > 1) { final Collection<ENamedElement> children = EcoreUtil.getObjectsByType(ele.eContents(), EcorePackage.eINSTANCE.getENamedElement()); result.addAll(getNamedElementRec(children.toArray(new ENamedElement[children.size()]), name .substring(name.indexOf(SyntaxConstants.NS_DELIM) + SyntaxConstants.NS_DELIM.length()))); } else { result.add(ele); } } } if(result.isEmpty()) { //If the first fragment does not match this can be due to a non generated EPackage by EMF because it does not contain EClassifier, and so it is not listed in elements but child subpackages are in elements and should be analyzed before returning. if(frags.length>1) { result.addAll(getNamedElementRec(elements,name .substring(name.indexOf(SyntaxConstants.NS_DELIM) + SyntaxConstants.NS_DELIM.length()))); } } return result; } This implementation , let Typesystem resolve elements that are part of subpackages located in packages without Eclassifier. This solve the problem i found using Xtend with models having that particularity. If this bugfix can be optimised or place to another level of the application,do not hesitate to comment.