Ejemplo n.º 1
0
  public void runWithIndex(
      IIndex parseIndex,
      IIndex searchScopeindex,
      IIndexLocationConverter converter,
      IProgressMonitor monitor)
      throws OperationCanceledException, CoreException, InterruptedException {
    fConverter = converter;

    if (fElement instanceof ICElement) {
      IBinding binding = null;
      parseIndex.acquireReadLock();
      try {
        binding = IndexQueries.elementToBinding(parseIndex, (ICElement) fElement, fPath);
        cElement = CElementForBinding(parseIndex, binding);
      } finally {
        parseIndex.releaseReadLock();
      }
      if (binding != null) {
        searchScopeindex.acquireReadLock();
        try {
          createMatches(searchScopeindex, binding);
        } finally {
          searchScopeindex.releaseReadLock();
        }
      }
    }
  }
Ejemplo n.º 2
0
  IStatus performNavigation(IProgressMonitor monitor) throws CoreException {
    fAction.clearStatusLine();

    assert fIndex == null;
    if (fIndex != null) return Status.CANCEL_STATUS;

    fMonitor = monitor;
    fIndex =
        CCorePlugin.getIndexManager()
            .getIndex(
                fTranslationUnit.getCProject(),
                IIndexManager.ADD_DEPENDENCIES | IIndexManager.ADD_DEPENDENT);

    try {
      fIndex.acquireReadLock();
    } catch (InterruptedException e) {
      return Status.CANCEL_STATUS;
    }

    try {
      return ASTProvider.getASTProvider()
          .runOnAST(fTranslationUnit, ASTProvider.WAIT_ACTIVE_ONLY, monitor, this);
    } finally {
      fIndex.releaseReadLock();
    }
  }
 @Override
 protected void tearDown() throws Exception {
   if (index != null) {
     index.releaseReadLock();
   }
   if (cproject != null) {
     cproject
         .getProject()
         .delete(
             IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
   }
 }
Ejemplo n.º 4
0
 @Override
 protected void processTranslationUnitUnlocked(ITranslationUnit tu) {
   try {
     index = CCorePlugin.getIndexManager().getIndex(tu.getCProject());
     // lock the index for read access
     index.acquireReadLock();
     try {
       // traverse the translation unit using the visitor pattern.
       this.file = tu.getFile();
       processUnit(tu);
     } finally {
       this.file = null;
       index.releaseReadLock();
     }
   } catch (CoreException e) {
     CodanCorePlugin.log(e);
   } catch (InterruptedException e) {
     // ignore
   }
 }