Ejemplo n.º 1
0
 /**
  * Process the given resource within the context of the given working set in order to record the
  * data and relationships found within the resource.
  *
  * @param resource the resource containing the elements defined in the compilation unit
  * @param libraryFile the library file defining the library containing the compilation unit to be
  *     indexed or <code>null</code> if the library is not on disk
  * @param compilationUnit the compilation unit being indexed
  * @param unit the compilation unit to be indexed
  */
 @Override
 public void indexResource(
     Resource resource, File libraryFile, CompilationUnit compilationUnit, DartUnit unit) {
   queue.enqueue(
       new IndexResourceOperation(
           indexStore, resource, libraryFile, compilationUnit, unit, performanceRecorder));
 }
Ejemplo n.º 2
0
 /**
  * Return <code>true</code> if there is an operation on the queue to clear the index. We can
  * effectively do so by deleting the index file from disk.
  *
  * @return <code>true</code> if there is an operation on the queue to clear the index
  */
 private boolean hasPendingClear() {
   for (IndexOperation operation : queue.getOperations()) {
     if (operation instanceof ClearIndexOperation) {
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 3
0
 /**
  * Remove all of the information from this index and re-initialize it to have information about
  * the bundled libraries.
  */
 public void clear() {
   queue.enqueue(
       new ClearIndexOperation(
           indexStore,
           new Runnable() {
             @Override
             public void run() {
               initializeBundledLibraries();
             }
           }));
 }
Ejemplo n.º 4
0
  private void notify(final NotifyCallback callback, final boolean isQuery) {
    queue.enqueue(
        new IndexOperation() {
          @Override
          public boolean isQuery() {
            return isQuery;
          }

          @Override
          public void performOperation() {
            callback.done();
          }

          @Override
          public boolean removeWhenResourceRemoved(Resource resource) {
            return false;
          }
        });
  }
Ejemplo n.º 5
0
 /**
  * Set whether the index should process query requests.
  *
  * @param processQueries <code>true</code> if the index should process incomming query requests or
  *     <code>false</code> if query requests should be queued but not processed until this method
  *     is called with a value of <code>true</code>.
  */
 public void setProcessQueries(boolean processQueries) {
   queue.setProcessQueries(processQueries);
 }
Ejemplo n.º 6
0
 /**
  * Remove from the index all of the information associated with elements or locations in the given
  * resource. This includes relationships between an element in the given resource and any other
  * locations, relationships between any other elements and a location within the given resource,
  * and any values of any attributes defined on elements in the given resource.
  *
  * <p>This method should be invoked when a resource is no longer part of the code base and when
  * the information about the resource is about to be re-generated.
  *
  * @param resource the resource being removed
  */
 @Override
 public void removeResource(Resource resource) {
   queue.enqueue(new RemoveResourceOperation(indexStore, resource));
 }
Ejemplo n.º 7
0
 /**
  * Asynchronously invoke the given callback with an array containing all of the locations of the
  * elements that have the given relationship with the given element. For example, if the element
  * represents a method and the relationship is the is-referenced-by relationship, then the
  * locations that will be passed into the callback will be all of the places where the method is
  * invoked.
  *
  * @param element the element that has the relationship with the locations to be returned
  * @param relationship the relationship between the given element and the locations to be returned
  * @param callback the callback that will be invoked when the locations are found
  */
 @Override
 public void getRelationships(
     Element element, Relationship relationship, RelationshipCallback callback) {
   queue.enqueue(new GetRelationshipsOperation(indexStore, element, relationship, callback));
 }
Ejemplo n.º 8
0
 /**
  * Asynchronously invoke the given callback with the value of the given attribute that is
  * associated with the given element, or <code>null</code> if there is no value for the attribute.
  *
  * @param element the element with which the attribute is associated
  * @param attribute the attribute whose value is to be returned
  * @param callback the callback that will be invoked when the attribute value is available
  */
 @Override
 public void getAttribute(Element element, Attribute attribute, AttributeCallback callback) {
   queue.enqueue(new GetAttributeOperation(indexStore, element, attribute, callback));
 }