public void findLocalReferences(
     Set<? extends EObject> targets,
     IAcceptor<IReferenceDescription> acceptor,
     Predicate<IReferenceDescription> filter,
     IProgressMonitor monitor) {
   if (monitor != null && monitor.isCanceled()) return;
   if (targets != null && !targets.isEmpty()) {
     Set<Resource> targetResources = new HashSet<Resource>();
     for (EObject target : targets) {
       targetResources.add(target.eResource());
     }
     Map<EObject, Collection<Setting>> targetResourceInternalCrossRefs =
         CrossReferencer.find(targetResources);
     Map<EObject, URI> exportedElementsMap = null;
     SubMonitor subMonitor =
         SubMonitor.convert(monitor, Messages.ReferenceQuery_monitor, targets.size());
     for (EObject target : targets) {
       Collection<Setting> crossRefSettings = targetResourceInternalCrossRefs.get(target);
       if (crossRefSettings != null) {
         SubMonitor subSubMonitor = subMonitor.newChild(crossRefSettings.size());
         for (Setting crossRefSetting : crossRefSettings) {
           if (subSubMonitor.isCanceled()) return;
           EObject source = crossRefSetting.getEObject();
           if (crossRefSetting.getEStructuralFeature() instanceof EReference) {
             EReference reference = (EReference) crossRefSetting.getEStructuralFeature();
             int index = 0;
             if (reference.isMany()) {
               List<?> values = (List<?>) source.eGet(reference);
               for (int i = 0; i < values.size(); ++i) {
                 if (target == values.get(i)) {
                   index = i;
                   break;
                 }
               }
             }
             if (exportedElementsMap == null)
               exportedElementsMap = createExportedElementsMap(target.eResource());
             IReferenceDescription localReferenceDescription =
                 new DefaultReferenceDescription(
                     source,
                     target,
                     reference,
                     index,
                     findClosestExportedContainerURI(source, exportedElementsMap));
             if (filter == null || filter.apply(localReferenceDescription))
               acceptor.accept(localReferenceDescription);
           }
           subSubMonitor.worked(1);
         }
       }
     }
   }
 }
  /**
   * Returns a list that holds the opposite elements of the given reference for the given owner. The
   * opposite elements are those of type E that have the reference to owner.
   *
   * <p>The collection corresponding to opposite in the following picture is returned, for given
   * owner and reference.
   *
   * <pre>
   *    <b>opposite</b>            reference
   *  E ----------------------------- owner
   *  </pre>
   *
   * reference has to be a key of the map observedRefToOpposite.
   *
   * @param <E>
   * @param <E> The type of the elements in the collection.
   * @param dataClass The class of the elements in the collection.
   * @param owner The object whose list is retrieved.
   * @param reference The reference whose opposite reference is retrieved.
   * @return The opposite of reference for owner.
   */
  public <E> List<E> getOppositeList(
      Class<E> dataClass, InternalEObject owner, EReference reference) {
    EReference opposite = observedRefToOpposite.get(reference);
    if (opposite == null)
      throw new IllegalArgumentException(
          "This reference is not observed by this adapter: " + reference.toString());

    EObjectEList<E> result = new EObjectEList<E>(dataClass, owner, opposite.getFeatureID());

    for (Setting cur : getNonNavigableInverseReferences(owner, false)) {
      if (cur.getEStructuralFeature().equals(reference))
        result.add(dataClass.cast(cur.getEObject()));
    }

    return result;
  }