Beispiel #1
0
  private final void invalidate(
      IFileSpecification fileSpec,
      Collection<ICompilationUnit> compilationUnits,
      Map<ICompilerProject, Set<ICompilationUnit>> cusToUpdate) {
    mxmlDataManager.invalidate(fileSpec);
    // Tell the SWC manager the SWC file is invalid.
    getSWCManager().remove(new File(fileSpec.getPath()));

    if (compilationUnits.size() == 0) return;

    Set<ICompilationUnit> unitsToInvalidate = new HashSet<ICompilationUnit>();
    unitsToInvalidate.addAll(compilationUnits);
    Set<ICompilationUnit> unitsToClean =
        Sets.<ICompilationUnit>union(
            DependencyGraph.computeInvalidationSet(unitsToInvalidate),
            getCompilationUnitsDependingOnMissingDefinitions(unitsToInvalidate));

    notifyInvalidationListener(unitsToClean);

    // Do the actual invalidation
    Map<ICompilerProject, Set<File>> invalidatedSWCFiles =
        new HashMap<ICompilerProject, Set<File>>();
    for (ICompilationUnit compilationUnit : unitsToClean) {
      boolean clearCUFileScope = unitsToInvalidate.contains(compilationUnit);
      compilationUnit.clean(invalidatedSWCFiles, cusToUpdate, clearCUFileScope);
    }

    // invalidate any library files in the project
    for (Map.Entry<ICompilerProject, Set<File>> e : invalidatedSWCFiles.entrySet()) {
      if (e.getKey() instanceof IASProject)
        ((IASProject) e.getKey()).invalidateLibraries(e.getValue());
    }
  }
Beispiel #2
0
  /**
   * When an ISWC has changed in memory, invalidate any compilation units which depend on the units
   * which depend on the SWC
   *
   * @param unitsRemoved The collection of compilation units to be removed.
   * @param unitsAdded The collection compilation units to be added.
   */
  public void swcChanged(
      Collection<ICompilationUnit> unitsRemoved,
      Collection<ICompilationUnit> unitsAdded,
      Runnable runWhileIdle) {
    final Map<ICompilerProject, Set<ICompilationUnit>> cusToUpdate =
        new HashMap<ICompilerProject, Set<ICompilationUnit>>();
    final Set<ICompilationUnit> unitsRemoveSet = ImmutableSet.copyOf(unitsRemoved);
    startIdleState();
    try {
      // Find all the compilation units reference a definition with the same base
      // name as a definition defined by any of the compilation units in the SWC that is
      // changing.
      final Collection<ICompilationUnit> unitsDependingOnMissingDefinitions =
          getCompilationUnitsDependingOnMissingDefinitions(unitsAdded);

      // Compute the set of compilation units to invalidate by starting with the union of
      // the unitsDependingOnMissingDefinitions and the list of
      // compilation units we are removing.
      Set<ICompilationUnit> unitsToInvalidate =
          DependencyGraph.computeInvalidationSet(
              Iterables.concat(unitsRemoved, unitsDependingOnMissingDefinitions));
      notifyInvalidationListener(unitsToInvalidate);

      // Do the actual invalidation
      Map<ICompilerProject, Set<File>> invalidatedSWCFiles =
          new HashMap<ICompilerProject, Set<File>>();
      for (ICompilationUnit compilationUnit : unitsToInvalidate) {
        compilationUnit.clean(
            invalidatedSWCFiles, cusToUpdate, unitsRemoveSet.contains(compilationUnit));
      }

      runWhileIdle.run();
    } finally {
      endIdleState(cusToUpdate);
    }
  }