[xtext][xtext] Made EClassifierInfos more robust (fixes failing test)

This commit is contained in:
Sebastian Zarnekow 2011-11-09 19:40:49 +01:00
parent 381b91666d
commit a7e949390b

View file

@ -15,9 +15,12 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.xtext.AbstractMetamodelDeclaration;
import org.eclipse.xtext.EcoreUtil2;
import org.eclipse.xtext.Grammar;
@ -188,7 +191,21 @@ public class EClassifierInfos {
public List<EClassInfo> getSuperTypeInfos(EClassInfo subTypeInfo) throws UnexpectedClassInfoException {
List<EClassInfo> result = new ArrayList<EClassInfo>();
for (EClass superType : subTypeInfo.getEClass().getESuperTypes()) {
List<EClass> superTypes = subTypeInfo.getEClass().getESuperTypes();
for (int i = 0; i < superTypes.size(); i++) {
EClass superType = superTypes.get(i);
if (superType.eIsProxy()) {
URI proxyURI = EcoreUtil.getURI(superType);
if (proxyURI.isPlatformResource()) {
String platformString = proxyURI.toPlatformString(true);
URI platformPluginURI = URI.createPlatformPluginURI(platformString, true).appendFragment(proxyURI.fragment());
EObject secondAttempt = subTypeInfo.getEClass().eResource().getResourceSet().getEObject(platformPluginURI, true);
if (secondAttempt instanceof EClass) {
superType = (EClass) secondAttempt;
superTypes.set(i, superType);
}
}
}
EClassifierInfo info = getInfoOrNull(superType);
if (info != null) {
if (info instanceof EClassInfo) {