Ejemplo n.º 1
0
 /**
  * Register the given reconcile delta with the Dart Model Manager.
  *
  * @param workingCopy the working copy with which the delta is to be associated
  * @param delta the delta to be added
  */
 protected void addReconcileDelta(CompilationUnit workingCopy, DartElementDeltaImpl delta) {
   HashMap<CompilationUnit, DartElementDelta> reconcileDeltas =
       DartModelManager.getInstance().getDeltaProcessor().getReconcileDeltas();
   DartElementDeltaImpl previousDelta = (DartElementDeltaImpl) reconcileDeltas.get(workingCopy);
   if (previousDelta != null) {
     DartElementDelta[] children = delta.getAffectedChildren();
     for (int i = 0, length = children.length; i < length; i++) {
       DartElementDeltaImpl child = (DartElementDeltaImpl) children[i];
       previousDelta.insertDeltaTree(child.getElement(), child);
     }
     // note that the last delta's AST always takes precedence over the
     // existing delta's AST since it is the result of the last reconcile
     // operation
     if ((delta.getFlags() & DartElementDelta.F_AST_AFFECTED) != 0) {
       previousDelta.changedAST(delta.getCompilationUnitAST());
     }
   } else {
     reconcileDeltas.put(workingCopy, delta);
   }
 }
Ejemplo n.º 2
0
  /**
   * Run this operation and register any deltas created.
   *
   * @throws CoreException if the operation fails
   */
  @Override
  public void run(IProgressMonitor monitor) throws CoreException {
    DartCore.notYetImplemented();
    DartModelManager manager = DartModelManager.getInstance();
    IDeltaProcessor deltaProcessor = manager.getDeltaProcessor();
    int previousDeltaCount = deltaProcessor.getDartModelDeltas().size();
    try {
      progressMonitor = monitor;
      pushOperation(this);
      try {
        if (canModifyRoots()) {
          // // computes the root infos before executing the operation
          // // noop if already initialized
          // DartModelManager.getInstance().getDeltaState().initializeRoots(false);
        }

        executeOperation();
      } finally {
        if (isTopLevelOperation()) {
          runPostActions();
        }
      }
    } finally {
      try {
        // re-acquire delta processor as it can have been reset during
        // executeOperation()
        deltaProcessor = manager.getDeltaProcessor();

        // update DartModel using deltas that were recorded during this
        // operation
        for (int i = previousDeltaCount, size = deltaProcessor.getDartModelDeltas().size();
            i < size;
            i++) {
          deltaProcessor.updateDartModel(deltaProcessor.getDartModelDeltas().get(i));
        }

        // // close the parents of the created elements and reset their
        // // project's cache (in case we are in an IWorkspaceRunnable and the
        // // clients wants to use the created element's parent)
        // // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=83646
        // for (int i = 0, length = resultElements.length; i < length; i++)
        // {
        // DartElement element = resultElements[i];
        // Openable openable = (Openable) element.getOpenable();
        // if (!(openable instanceof CompilationUnit) || !((CompilationUnit)
        // openable).isWorkingCopy()) { // a working copy must remain a child of
        // its parent even after a move
        // ((DartElementImpl) openable.getParent()).close();
        // }
        // switch (element.getElementType()) {
        // case DartElement.PACKAGE_FRAGMENT_ROOT:
        // case DartElement.PACKAGE_FRAGMENT:
        // deltaProcessor.projectCachesToReset.add(element.getDartProject());
        // break;
        // }
        // }
        deltaProcessor.resetProjectCaches();

        // fire only iff:
        // - the operation is a top level operation
        // - the operation did produce some delta(s)
        // - but the operation has not modified any resource
        if (isTopLevelOperation()) {
          if ((deltaProcessor.getDartModelDeltas().size() > previousDeltaCount
                  || !deltaProcessor.getReconcileDeltas().isEmpty())
              && !hasModifiedResource()) {
            deltaProcessor.fire(null, DeltaProcessor.DEFAULT_CHANGE_EVENT);
          } // else deltas are fired while processing the resource delta
        }
      } finally {
        popOperation();
      }
    }
  }
Ejemplo n.º 3
0
 /** Register the given delta with the Dart Model Manager. */
 protected void addDelta(DartElementDelta delta) {
   DartModelManager.getInstance().getDeltaProcessor().registerDartModelDelta(delta);
 }
Ejemplo n.º 4
0
 /**
  * Return the Dart Model this operation is operating in.
  *
  * @return the Dart Model this operation is operating in
  */
 public DartModel getDartModel() {
   return DartModelManager.getInstance().getDartModel();
 }