コード例 #1
0
  private void parseVersionInContext(
      int linkageID,
      LinkageTask map,
      IIndexFileLocation ifl,
      final FileVersionTask versionTask,
      Object tu,
      LinkedHashSet<IIndexFile> safeGuard,
      IProgressMonitor monitor)
      throws CoreException, InterruptedException {
    final IIndexFragmentFile headerFile = versionTask.fIndexFile;

    final int safeguardSize = safeGuard.size();
    while (true) {
      // Look for a context and parse the file.
      IIndexFragmentFile ctxFile = findContextFile(linkageID, map, versionTask, safeGuard, monitor);
      if (ctxFile == null || ctxFile == headerFile) return;

      Object contextTu = fResolver.getInputFile(ctxFile.getLocation());
      if (contextTu == null) return;

      final IScannerInfo scannerInfo = getScannerInfo(linkageID, contextTu);
      final AbstractLanguage language = getLanguage(contextTu, linkageID);
      final FileContext ctx = new FileContext(ctxFile, headerFile);
      Set<IIndexFile> dependencies = null;
      boolean done = false;
      while (!done) {
        done = true;
        DependsOnOutdatedFileException d = parseFile(tu, language, ifl, scannerInfo, ctx, monitor);
        if (d != null) {
          // File was not parsed, because there is a dependency that needs to be
          // handled before.
          if (dependencies == null) dependencies = new HashSet<IIndexFile>();
          if (dependencies.add(d.fIndexFile)) {
            if (parseFile(
                    d.fTu,
                    language,
                    d.fIndexFile.getLocation(),
                    scannerInfo,
                    new FileContext(ctxFile, d.fIndexFile),
                    monitor)
                == null) done = false;
          }
        }
      }
      if (!ctx.fLostPragmaOnceSemantics) return;

      // Try the next context
      restoreSet(safeGuard, safeguardSize);
    }
  }
コード例 #2
0
  @Override
  public void clearFile(IIndexFragmentFile file) throws CoreException {
    assert file.getIndexFragment() == this;
    IIndexFileLocation location = file.getLocation();
    PDOMFile pdomFile = (PDOMFile) file;
    pdomFile.clear();
    IIndexInclude include = pdomFile.getParsedInContext();
    if (include != null) {
      PDOMFile includedBy = (PDOMFile) include.getIncludedBy();
      if (includedBy.getTimestamp() > 0)
        getIndexOfFilesWithUnresolvedIncludes().insert(includedBy.getRecord());
    }

    fEvent.fClearedFiles.add(location);
  }
コード例 #3
0
  private IIndexFragmentFile findContextFile(
      int linkageID,
      LinkageTask map,
      final FileVersionTask versionTask,
      LinkedHashSet<IIndexFile> safeGuard,
      IProgressMonitor monitor)
      throws CoreException, InterruptedException {
    IIndexFragmentFile ctxFile = versionTask.fIndexFile;
    while (true) {
      IIndexInclude ctxInclude = ctxFile.getParsedInContext();
      if (ctxInclude == null) return ctxFile;

      IIndexFragmentFile nextCtx = (IIndexFragmentFile) ctxInclude.getIncludedBy();
      if (nextCtx == null) return nextCtx;

      // Found a recursion.
      if (!safeGuard.add(nextCtx)) return null;

      final IIndexFileLocation ctxIfl = nextCtx.getLocation();
      LocationTask ctxTask = map.find(ctxIfl);
      if (ctxTask != null) {
        FileVersionTask ctxVersionTask = ctxTask.findVersion(nextCtx);
        if (ctxVersionTask != null && ctxVersionTask.fOutdated) {
          // Handle the context first.
          parseVersionInContext(
              linkageID, map, ctxIfl, ctxVersionTask, ctxTask.fTu, safeGuard, monitor);
          if (ctxVersionTask.fOutdated // This is unexpected.
              || !versionTask.fOutdated) // Our file was parsed.
          return null;

          // The file is no longer a context, look for a different one.
          nextCtx = ctxFile;
        }
      }
      ctxFile = nextCtx;
    }
  }