protected Boolean createContentDescription(EObject object) {
   QualifiedName name = nameOf(object);
   if (name != null) {
     acceptor.accept(EObjectDescription.create(name, object));
   }
   return Boolean.TRUE;
 }
 protected void findIndexedReferences(
     Set<URI> targetURIs,
     IAcceptor<IReferenceDescription> acceptor,
     Predicate<IReferenceDescription> filter,
     IProgressMonitor monitor) {
   Set<URI> targetResourceURIs =
       newHashSet(
           transform(
               targetURIs,
               new Function<URI, URI>() {
                 public URI apply(URI from) {
                   return from.trimFragment();
                 }
               }));
   int numResources = Iterables.size(index.getAllResourceDescriptions());
   SubMonitor subMonitor =
       SubMonitor.convert(monitor, Messages.ReferenceQuery_monitor, numResources);
   for (IResourceDescription resourceDescription : index.getAllResourceDescriptions()) {
     if (subMonitor.isCanceled()) return;
     if (!targetResourceURIs.contains(resourceDescription.getURI())) {
       for (IReferenceDescription referenceDescription :
           resourceDescription.getReferenceDescriptions()) {
         if (targetURIs.contains(referenceDescription.getTargetEObjectUri())
             && (filter == null || filter.apply(referenceDescription))) {
           acceptor.accept(referenceDescription);
         }
       }
     }
     subMonitor.worked(1);
   }
 }
 public void infer(
     EObject xtendFile, IAcceptor<JvmDeclaredType> acceptor, boolean prelinkingPhase) {
   if (!(xtendFile instanceof XtendFile)) return;
   final XtendFile xtendFile2 = (XtendFile) xtendFile;
   XtendClass xtendClass = xtendFile2.getXtendClass();
   if (xtendClass == null) return;
   JvmGenericType inferredJvmType = transform(xtendClass, prelinkingPhase);
   acceptor.accept(inferredJvmType);
 }
 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);
         }
       }
     }
   }
 }
 @Override
 public Boolean caseContent(Content content) {
   EList<Tag> tags = content.getTags();
   Map<String, String> userData = newHashMapWithExpectedSize(1);
   List<String> tagData = newArrayListWithExpectedSize(tags.size());
   for (Tag tag : tags) {
     createContentDescription(tag);
     tagData.add(tag.getName());
   }
   userData.put(Descriptions.TAG_KEY, on(Descriptions.SEPARATOR).join(tagData));
   IEObjectDescription description = create(nameOf(content), content, userData);
   acceptor.accept(description);
   return Boolean.TRUE;
 }
 protected void addSectionToAppend(IAcceptor<ReplaceRegion> acceptor) {
   StringBuilder importDeclarationsToAppend = getImportDeclarationsToAppend();
   if (importDeclarationsToAppend.length() == 0) return;
   importRegion = regionUtil.addLeadingWhitespace(importRegion, resource);
   importRegion = regionUtil.addTrailingSingleWhitespace(importRegion, lineSeparator, resource);
   int insertOffset = importRegion.getOffset() + importRegion.getLength();
   if (insertOffset != 0 && originalImportDeclarations.isEmpty())
     importDeclarationsToAppend.insert(0, lineSeparator);
   importDeclarationsToAppend.append(lineSeparator);
   int insertLength = -importRegion.getLength();
   insertLength += regionUtil.addTrailingWhitespace(importRegion, resource).getLength();
   ReplaceRegion appendDeclarations =
       new ReplaceRegion(
           new TextRegion(insertOffset, insertLength), importDeclarationsToAppend.toString());
   acceptor.accept(appendDeclarations);
 }
 /** @since 2.0 */
 public void findIndexedReferences(
     IQueryData queryData,
     URI resourceURI,
     IAcceptor<IReferenceDescription> acceptor,
     IProgressMonitor progressMonitor) {
   IResourceDescription resourceDescription =
       index.getResourceDescription(resourceURI.trimFragment());
   if (resourceDescription != null) {
     for (IReferenceDescription referenceDescription :
         resourceDescription.getReferenceDescriptions()) {
       if (queryData.getTargetURIs().contains(referenceDescription.getTargetEObjectUri())
           && (queryData.getResultFilter() == null
               || queryData.getResultFilter().apply(referenceDescription))) {
         acceptor.accept(referenceDescription);
       }
     }
   }
 }
 @Override
 public boolean createEObjectDescriptions(
     EObject eObject, IAcceptor<IEObjectDescription> acceptor) {
   if (eObject instanceof EClass) {
     QualifiedName name = nameProvider.getFullyQualifiedName(eObject);
     if (name != null) {
       URI uri = eObject.eResource().getURI();
       EClass eClass = ecoreFactory.createEClass();
       proxyTool.installProxyURI(uri, eClass, name);
       acceptor.accept(EObjectDescription.create(name, eClass));
     }
     return false;
   } else if (eObject instanceof GenClass) {
     QualifiedName name = nameProvider.getFullyQualifiedName(eObject);
     if (name != null) {
       URI uri = eObject.eResource().getURI();
       GenClass genClass = genFactory.createGenClass();
       proxyTool.installProxyURI(uri, genClass, name);
       acceptor.accept(EObjectDescription.create(name, genClass));
     }
     return false;
   } else if (eObject instanceof GenDataType) {
     QualifiedName name = nameProvider.getFullyQualifiedName(eObject);
     if (name != null) {
       URI uri = eObject.eResource().getURI();
       GenDataType genDataType =
           eObject instanceof GenEnum
               ? genFactory.createGenEnum()
               : genFactory.createGenDataType();
       proxyTool.installProxyURI(uri, genDataType, name);
       acceptor.accept(EObjectDescription.create(name, genDataType));
     }
     return false;
   } else if (eObject instanceof JvmGenericType) {
     QualifiedName name = nameProvider.getFullyQualifiedName(eObject);
     if (name != null) {
       URI uri = eObject.eResource().getURI();
       JvmGenericType jvmGenericType = typesFactory.createJvmGenericType();
       proxyTool.installProxyURI(uri, jvmGenericType, name);
       acceptor.accept(EObjectDescription.create(name, jvmGenericType));
     }
     return false;
   } else if (eObject instanceof JvmEnumerationType) {
     QualifiedName name = nameProvider.getFullyQualifiedName(eObject);
     if (name != null) {
       URI uri = eObject.eResource().getURI();
       JvmEnumerationType jvmEnumerationType = typesFactory.createJvmEnumerationType();
       proxyTool.installProxyURI(uri, jvmEnumerationType, name);
       acceptor.accept(EObjectDescription.create(name, jvmEnumerationType));
     }
     return false;
   } else if (eObject instanceof XAnnotationDirective) {
     QualifiedName name = nameProvider.getFullyQualifiedName(eObject);
     if (name != null) {
       acceptor.accept(EObjectDescription.create(name, eObject));
     }
     return false;
   } else if (eObject instanceof EPackage) {
     QualifiedName name = nameProvider.getFullyQualifiedName(eObject);
     if (name != null) {
       URI uri = eObject.eResource().getURI();
       EPackage ePackage = ecoreFactory.createEPackage();
       proxyTool.installProxyURI(uri, ePackage, name);
       acceptor.accept(
           EObjectDescription.create(name, ePackage, Collections.singletonMap("nsURI", "true")));
     }
     return true;
   } else if (eObject instanceof XPackage
       || eObject instanceof GenModel
       || eObject instanceof GenPackage) {
     return true;
   } else {
     return false;
   }
 }