fix: mark dependencies for recompilation when the whole class definition was commented (empty java file)

This commit is contained in:
Eugene Zhuravlev
2011-03-10 17:19:43 +01:00
parent 813db5263b
commit 5477197252
3 changed files with 8 additions and 17 deletions
@@ -1047,20 +1047,11 @@ public class CompileDriver {
final boolean hasUnprocessedTraverseRoots = context.getDependencyCache().hasUnprocessedTraverseRoots();
if (!isRebuild && (compiledSomethingForThisChunk || hasUnprocessedTraverseRoots)) {
final Set<VirtualFile> compiledWithSuccess;
final Set<VirtualFile> compiledWithErrors = CacheUtils.getFilesCompiledWithErrors(context);
if (compiledWithErrors.isEmpty()) {
compiledWithSuccess = sink.getCompiledSources();
}
else {
compiledWithSuccess = new HashSet<VirtualFile>();
compiledWithSuccess.addAll(sink.getCompiledSources());
compiledWithSuccess.removeAll(compiledWithErrors);
}
filesToRecompile.removeAll(compiledWithSuccess);
filesToRecompile.removeAll(sink.getCompiledSources());
filesToRecompile.addAll(compiledWithErrors);
dependentFiles = CacheUtils.findDependentFiles(context, compiledWithSuccess, dependencyFilter);
dependentFiles = CacheUtils.findDependentFiles(context, compiledWithErrors, dependencyFilter);
if (!processedModules.isEmpty()) {
for (Iterator<VirtualFile> it = dependentFiles.iterator(); it.hasNext();) {
final VirtualFile next = it.next();
@@ -130,7 +130,7 @@ public class CacheUtils {
public static Collection<VirtualFile> findDependentFiles(
final CompileContextEx context,
final Set<VirtualFile> succesfullyCompiledJavaFiles,
final Set<VirtualFile> compiledWithErrors,
final @Nullable Function<Pair<int[], Set<VirtualFile>>, Pair<int[], Set<VirtualFile>>> filter) throws CacheCorruptedException {
if (!CompilerConfiguration.MAKE_ENABLED) {
@@ -141,7 +141,7 @@ public class CacheUtils {
final DependencyCache dependencyCache = context.getDependencyCache();
final Pair<int[], Set<VirtualFile>> deps =
dependencyCache.findDependentClasses(context, context.getProject(), succesfullyCompiledJavaFiles);
dependencyCache.findDependentClasses(context, context.getProject(), compiledWithErrors);
final Pair<int[], Set<VirtualFile>> filteredDeps = filter != null? filter.fun(deps) : deps;
final Set<VirtualFile> dependentFiles = new HashSet<VirtualFile>();
@@ -390,14 +390,14 @@ public class DependencyCache {
/**
* @return qualified names of the classes that should be additionally recompiled
*/
public Pair<int[], Set<VirtualFile>> findDependentClasses(CompileContext context, Project project, Set<VirtualFile> successfullyCompiled)
public Pair<int[], Set<VirtualFile>> findDependentClasses(CompileContext context, Project project, Set<VirtualFile> compiledWithErrors)
throws CacheCorruptedException {
markDependencies(context, project, successfullyCompiled);
markDependencies(context, project, compiledWithErrors);
return new Pair<int[], Set<VirtualFile>>(myMarkedInfos.toArray(), Collections.unmodifiableSet(myMarkedFiles));
}
private void markDependencies(CompileContext context, Project project, final Set<VirtualFile> successfullyCompiled) throws CacheCorruptedException {
private void markDependencies(CompileContext context, Project project, final Set<VirtualFile> compiledWithErrors) throws CacheCorruptedException {
try {
if (LOG.isDebugEnabled()) {
LOG.debug("====================Marking dependent files=====================");
@@ -441,7 +441,7 @@ public class DependencyCache {
final boolean markAsRemovedSource = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
public Boolean compute() {
VirtualFile sourceFile = sourceFileFinder.findSourceFile(qualifiedName, sourceFileName);
return sourceFile == null || successfullyCompiled.contains(sourceFile) ? Boolean.TRUE : Boolean.FALSE;
return sourceFile == null || !compiledWithErrors.contains(sourceFile) ? Boolean.TRUE : Boolean.FALSE;
}
}).booleanValue();
if (markAsRemovedSource) {