Esempio n. 1
0
  public void ensureRefreshedTypeHierarchy(final IRubyElement element, IRunnableContext context)
      throws InvocationTargetException, InterruptedException {
    if (element == null || !element.exists()) {
      freeHierarchy();
      return;
    }
    boolean hierachyCreationNeeded = (fHierarchy == null || !element.equals(fInputElement));

    if (hierachyCreationNeeded || fHierarchyRefreshNeeded) {

      IRunnableWithProgress op =
          new IRunnableWithProgress() {
            public void run(IProgressMonitor pm)
                throws InvocationTargetException, InterruptedException {
              try {
                doHierarchyRefresh(element, pm);
              } catch (RubyModelException e) {
                throw new InvocationTargetException(e);
              } catch (OperationCanceledException e) {
                throw new InterruptedException();
              }
            }
          };
      fHierarchyRefreshNeeded = true;
      context.run(true, true, op);
      fHierarchyRefreshNeeded = false;
    }
  }
 /* package */ void handleAffectedChildren(IRubyElementDelta delta, IRubyElement element)
     throws RubyModelException {
   IRubyElementDelta[] affectedChildren = delta.getAffectedChildren();
   if (affectedChildren.length > 1) {
     // a package fragment might become non empty refresh from the parent
     if (element instanceof ISourceFolder) {
       IRubyElement parent = (IRubyElement) internalGetParent(element);
       if (parent instanceof ISourceFolderRoot) {
         parent = (IRubyElement) internalGetParent(parent);
       }
       // 1GE8SI6: ITPJUI:WIN98 - Rename is not shown in Packages View
       // avoid posting a refresh to an unvisible parent
       if (element.equals(fInput)) {
         postRefresh(element, ORIGINAL, element);
       } else {
         postRefresh(parent, PARENT, element);
       }
       return;
     }
     // more than one child changed, refresh from here downwards
     if (element instanceof ISourceFolderRoot) {
       Object toRefresh = skipProjectSourceFolderRoot((ISourceFolderRoot) element);
       postRefresh(toRefresh, ORIGINAL, toRefresh);
     } else {
       postRefresh(element, ORIGINAL, element);
     }
     return;
   }
   processAffectedChildren(affectedChildren);
 }
Esempio n. 3
0
 public synchronized void doHierarchyRefresh(IRubyElement element, IProgressMonitor pm)
     throws RubyModelException {
   boolean hierachyCreationNeeded = (fHierarchy == null || !element.equals(fInputElement));
   // to ensure the order of the two listeners always remove / add listeners on operations
   // on type hierarchies
   if (fHierarchy != null) {
     fHierarchy.removeTypeHierarchyChangedListener(this);
     RubyCore.removeElementChangedListener(this);
   }
   if (hierachyCreationNeeded) {
     fHierarchy = createTypeHierarchy(element, pm);
     if (pm != null && pm.isCanceled()) {
       throw new OperationCanceledException();
     }
     fInputElement = element;
   } else {
     fHierarchy.refresh(pm);
   }
   if (fHierarchy != null) {
     fHierarchy.addTypeHierarchyChangedListener(this);
     RubyCore.addElementChangedListener(this);
     fHierarchyRefreshNeeded = false;
   }
 }