Beispiel #1
0
  public void resolve(
      String identifier,
      EObject container,
      boolean resolveFuzzy,
      final IMecoreReferenceResolveResult<MType> result) {
    EObject root = EcoreUtil.getRootContainer(container);
    for (EClassifier eClassifier : EcorePackage.eINSTANCE.getEClassifiers()) {
      if (eClassifier instanceof EDataType) {
        if (checkClassifier(identifier, resolveFuzzy, result, eClassifier, "")) {
          return;
        }
      }
    }

    if (!result.wasResolved() || resolveFuzzy) {
      // search in imported packages
      if (root instanceof MPackage) {
        MPackage mPackage = (MPackage) root;
        for (MImport mImport : mPackage.getImports()) {
          EPackage ePackage = mImport.getImportedPackage();
          String prefix = mImport.getPrefix() + ".";
          if (searchInEPackage(identifier, prefix, ePackage, resolveFuzzy, result)) {
            return;
          }
        }
      }
      // search in Ecore package (imported by default)
      searchInEPackage(identifier, "", EcorePackage.eINSTANCE, resolveFuzzy, result);
    }
  }
Beispiel #2
0
 private boolean checkClassifier(
     String identifier,
     boolean resolveFuzzy,
     final IMecoreReferenceResolveResult<MType> result,
     EClassifier eClassifier,
     String prefix) {
   String name = prefix + eClassifier.getName();
   if (identifier.equals(name) || resolveFuzzy) {
     if (eClassifier instanceof EDataType) {
       result.addMapping(name, getMDataType((EDataType) eClassifier));
     } else if (eClassifier instanceof EClassifier) {
       result.addMapping(name, createMEcoreType((EClassifier) eClassifier));
     }
     if (!resolveFuzzy) {
       return true;
     }
   }
   return false;
 }