Ejemplo n.º 1
0
 @Override
 public List<EObject> getLinkedObjects(EObject context, EReference ref, INode node)
     throws IllegalNodeException {
   try {
     depth++;
     String text = getText(node);
     boolean traceLookup = BaseScopeProvider.LOOKUP.isActive();
     if ((text == null) || "".equals(text)) { // Avoid IQualifiedNameConverter IAE
       if (traceLookup) {
         BaseScopeProvider.LOOKUP.println("" + depth + " Lookup null");
       }
       return Collections.emptyList();
     }
     IScope scope = getScope(context, ref);
     if (traceLookup) {
       //				EObject target = ((ScopeView)scope).getTarget();
       //				String inString = target instanceof ElementCS ? ((ElementCS)target).getSignature() :
       // target.toString();
       //				BaseScopeProvider.LOOKUP.println("" + depth + " Lookup " + text + " in " + inString);
       BaseScopeProvider.LOOKUP.println("" + depth + " Lookup " + text);
     }
     if (scope == null) {
       return Collections.emptyList();
     }
     QualifiedName qualifiedName = QualifiedName.create(text);
     List<EObject> linkedObjects = lookUp(scope, qualifiedName);
     if ((linkedObjects.size() <= 0) && text.startsWith("_")) { // Deprecated compatibility
       linkedObjects = lookUp(scope, QualifiedName.create(text.substring(1)));
     }
     if (traceLookup) {
       BaseScopeProvider.LOOKUP.println("" + depth + " Lookup " + text + " failed");
     }
     List<Adapter> eAdapters = context.eAdapters();
     Adapter adapter = EcoreUtil.getAdapter(eAdapters, ExceptionAdapter.class);
     if (adapter != null) {
       eAdapters.remove(adapter);
     }
     if (linkedObjects.size() > 1) {
       if (DEBUG_RETRY.isActive()) {
         scope.getElements(qualifiedName);
       }
       AmbiguitiesAdapter.setAmbiguities(context, linkedObjects);
       return Collections.emptyList();
     }
     if (linkedObjects.size() <= 0) {
       if (DEBUG_RETRY.isActive()) {
         scope.getElements(qualifiedName);
       }
     }
     return linkedObjects;
   } catch (IllegalLibraryException e) {
     context.eAdapters().add(new ExceptionAdapter(e));
     return Collections.emptyList();
   } finally {
     depth--;
   }
 }
Ejemplo n.º 2
0
 protected List<EObject> lookUp(@NonNull IScope scope, QualifiedName qualifiedName) {
   @NonNull List<EObject> linkedObjects = new ArrayList<EObject>();
   for (IEObjectDescription eObjectDescription : scope.getElements(qualifiedName)) {
     EObject eObjectOrProxy = eObjectDescription.getEObjectOrProxy();
     linkedObjects.add(eObjectOrProxy);
     if (BaseScopeProvider.LOOKUP.isActive()) {
       BaseScopeProvider.LOOKUP.println(
           "" + depth + " Lookup " + qualifiedName + " => " + eObjectOrProxy);
     }
   }
   return linkedObjects;
 }