mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 08:48:55 +00:00
[xtext][xtext] Made EClassifierInfos more robust (fixes failing test)
This commit is contained in:
parent
381b91666d
commit
a7e949390b
1 changed files with 18 additions and 1 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue