コード例 #1
0
    /**
     * Searches for element.
     *
     * @param unit Unit to search in.
     * @param delta Delta.
     * @return Found element.
     */
    protected ICElementDelta findElement(ICElement unit, ICElementDelta delta) {
      if (delta == null || unit == null) {
        return null;
      }

      final ICElement element = delta.getElement();

      if (unit.equals(element)) {
        if (isPossibleStructuralChange(delta)) {
          return delta;
        }
        return null;
      }

      if (element.getElementType() > ICElement.C_UNIT) {
        return null;
      }

      final ICElementDelta[] children = delta.getAffectedChildren();
      if (children == null || children.length == 0) {
        return null;
      }

      for (ICElementDelta element2 : children) {
        final ICElementDelta d = findElement(unit, element2);
        if (d != null) {
          return d;
        }
      }

      return null;
    }
コード例 #2
0
 /**
  * Determines is structural change.
  *
  * @param cuDelta Delta to check.
  * @return <b>true</b> if structural change.
  */
 private boolean isPossibleStructuralChange(ICElementDelta cuDelta) {
   boolean ret;
   if (cuDelta.getKind() != ICElementDelta.CHANGED) {
     ret = true; // add or remove
   } else {
     final int flags = cuDelta.getFlags();
     if ((flags & ICElementDelta.F_CHILDREN) != 0) {
       ret = true;
     } else {
       ret =
           (flags & (ICElementDelta.F_CONTENT | ICElementDelta.F_FINE_GRAINED))
               == ICElementDelta.F_CONTENT;
     }
   }
   return ret;
 }
コード例 #3
0
ファイル: DeltaAnalyzer.java プロジェクト: NVIDIA/cdt-nsight
  private void processDelta(ICElementDelta delta, Set<IResource> handled) throws CoreException {
    final int flags = delta.getFlags();

    final boolean hasChildren = (flags & ICElementDelta.F_CHILDREN) != 0;
    if (hasChildren) {
      for (ICElementDelta child : delta.getAffectedChildren()) {
        processDelta(child, handled);
      }
    }

    final ICElement element = delta.getElement();
    switch (element.getElementType()) {
      case ICElement.C_UNIT:
        ITranslationUnit tu = (ITranslationUnit) element;
        if (!tu.isWorkingCopy()) {
          handled.add(element.getResource());
          switch (delta.getKind()) {
            case ICElementDelta.CHANGED:
              if ((flags & ICElementDelta.F_CONTENT) != 0) {
                fChanged.add(tu);
              }
              break;
            case ICElementDelta.ADDED:
              fChanged.add(tu);
              break;
            case ICElementDelta.REMOVED:
              fRemoved.add(tu);
              break;
          }
        }
        break;
      case ICElement.C_CCONTAINER:
        ICContainer folder = (ICContainer) element;
        if (delta.getKind() == ICElementDelta.ADDED) {
          handled.add(element.getResource());
          collectSources(folder, fChanged);
        }
        break;
    }

    if (!sSuppressPotentialTUs) {
      // Always look at the children of the resource delta (bug 343538)
      final IResourceDelta[] rDeltas = delta.getResourceDeltas();
      processResourceDelta(rDeltas, element, handled);
    }
  }