Exemplo n.º 1
0
  public static Object getAdapterFromActualObject(IResource actualObject2, Class adapter) {
    if (IProject.class.equals(adapter)
        || IResource.class.equals(adapter)
        || IFolder.class.equals(adapter)
        || IContainer.class.equals(adapter)
        || IFile.class.equals(adapter)
        || ResourceMapping.class.equals(adapter)
        || IFileStore.class.equals(adapter)) {
      return actualObject2.getAdapter(adapter);
    }

    try {
      if (IWatchExpressionFactoryAdapter2.class.equals(adapter)) {
        return actualObject2.getAdapter(adapter);
      }
    } catch (Throwable e) {
      // Ignore (not available in eclipse 3.2)
    }

    if (IDeferredWorkbenchAdapter.class.equals(adapter)
        || IWorkbenchAdapter2.class.equals(adapter)
        || IWorkbenchAdapter.class.equals(adapter)) {
      return null;
    }
    synchronized (lock) {
      if (!logged.contains(adapter)) {
        logged.add(adapter);
        // Only log once per session.
        Log.logInfo("Did not expect adapter request: " + adapter);
      }
    }
    return null;
  }
Exemplo n.º 2
0
 /**
  * @param project the project we want to know about (if it is null, null is returned)
  * @return the python nature for a project (or null if it does not exist for the project)
  * @note: it's synchronized because more than 1 place could call getPythonNature at the same time
  *     and more than one nature ended up being created from project.getNature().
  */
 public static synchronized PythonNature getPythonNature(IProject project) {
   if (project != null && project.isOpen()) {
     try {
       IProjectNature n = project.getNature(PYTHON_NATURE_ID);
       if (n instanceof PythonNature) {
         return (PythonNature) n;
       }
     } catch (CoreException e) {
       Log.logInfo(e);
     }
   }
   return null;
 }
    /**
     * Keeps in a loop for 3 seconds or until the completions are found. If no completions are found
     * in that time, returns an empty array.
     */
    private ICompletionProposal[] waitForCommand() {
      int i = 300; // wait up to 3 seconds
      while (--i > 0 && receivedCompletions == null) {
        try {
          Thread.sleep(10); // 10 millis
        } catch (InterruptedException e) {
          // ignore
        }
      }

      ICompletionProposal[] temp = receivedCompletions;
      receivedCompletions = null;
      if (temp == null) {
        Log.logInfo("Timeout for waiting for debug completions elapsed (3 seconds).");
        return EMPTY_COMPLETION_PROPOSALS;
      }
      return temp;
    }
Exemplo n.º 4
0
 public IModulesManager[] getManagers(boolean referenced) {
   calls += 1;
   if (calls % 30 == 0) {
     long diff = System.currentTimeMillis() - creationTime;
     if (diff > ONE_MINUTE_IN_MILLIS) {
       String msg =
           String.format(
               "Warning: the cache related to project dependencies is the same for %.2f minutes.",
               (diff / ONE_MINUTE_IN_MILLIS));
       Log.logInfo(msg);
     }
   }
   if (referenced) {
     return this.referencedManagers;
   } else {
     return this.referredManagers;
   }
 }