mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
clean info about removed sources only after they have been 'integrated'
This commit is contained in:
@@ -259,17 +259,6 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
}
|
||||
}
|
||||
|
||||
// clean mapping only after everything else is processed
|
||||
final Map<String, Collection<String>> map = Utils.CHUNK_PER_MODULE_REMOVED_SOURCES_KEY.get(this);
|
||||
if (map != null) {
|
||||
for (Map.Entry<String, Collection<String>> entry : map.entrySet()) {
|
||||
final SourceToOutputMapping mapping = dataManager.getSourceToOutputMap(entry.getKey(), isCompilingTests());
|
||||
for (String path : entry.getValue()) {
|
||||
mapping.remove(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (marked) {
|
||||
processMessage(UptoDateFilesSavedEvent.INSTANCE);
|
||||
}
|
||||
@@ -350,7 +339,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
}
|
||||
|
||||
public boolean hasRemovedSources() {
|
||||
final Set<String> removed = Utils.CHUNK_REMOVED_SOURCES_KEY.get(this);
|
||||
final Map<String, Collection<String>> removed = Utils.REMOVED_SOURCES_KEY.get(this);
|
||||
return removed != null && !removed.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -428,8 +428,29 @@ public class IncProjectBuilder {
|
||||
throw new ProjectBuildException(e);
|
||||
}
|
||||
finally {
|
||||
Utils.CHUNK_REMOVED_SOURCES_KEY.set(context, null);
|
||||
Utils.CHUNK_PER_MODULE_REMOVED_SOURCES_KEY.set(context, null);
|
||||
|
||||
try {
|
||||
// restore deleted paths that were not procesesd by 'integrate'
|
||||
final Map<String, Collection<String>> map = Utils.REMOVED_SOURCES_KEY.get(context);
|
||||
if (map != null) {
|
||||
final boolean forTests = context.isCompilingTests();
|
||||
for (Map.Entry<String, Collection<String>> entry : map.entrySet()) {
|
||||
final String moduleName = entry.getKey();
|
||||
final Collection<String> paths = entry.getValue();
|
||||
if (paths != null) {
|
||||
for (String path : paths) {
|
||||
myProjectDescriptor.fsState.registerDeleted(moduleName, new File(path), forTests, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new ProjectBuildException(e);
|
||||
}
|
||||
|
||||
Utils.REMOVED_SOURCES_KEY.set(context, null);
|
||||
|
||||
if (doneSomething && GENERATE_CLASSPATH_INDEX) {
|
||||
final boolean forTests = context.isCompilingTests();
|
||||
final Future<?> future = SharedThreadPool.INSTANCE.submit(new Runnable() {
|
||||
@@ -485,8 +506,7 @@ public class IncProjectBuilder {
|
||||
private void processDeletedPaths(CompileContext context, ModuleChunk chunk) throws ProjectBuildException {
|
||||
try {
|
||||
// cleanup outputs
|
||||
final Set<String> allChunkRemovedSources = new HashSet<String>();
|
||||
final Map<String, Collection<String>> perModuleRemovedSources = new HashMap<String, Collection<String>>();
|
||||
final Map<String, Collection<String>> removedSources = new HashMap<String, Collection<String>>();
|
||||
|
||||
for (Module module : chunk.getModules()) {
|
||||
final Collection<String> deletedPaths = myProjectDescriptor.fsState.getAndClearDeletedPaths(module.getName(),
|
||||
@@ -494,11 +514,9 @@ public class IncProjectBuilder {
|
||||
if (deletedPaths.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
allChunkRemovedSources.addAll(deletedPaths);
|
||||
perModuleRemovedSources.put(module.getName(), deletedPaths);
|
||||
removedSources.put(module.getName(), deletedPaths);
|
||||
|
||||
final SourceToOutputMapping sourceToOutputStorage =
|
||||
context.getDataManager().getSourceToOutputMap(module.getName(), context.isCompilingTests());
|
||||
final SourceToOutputMapping sourceToOutputStorage = context.getDataManager().getSourceToOutputMap(module.getName(), context.isCompilingTests());
|
||||
// actually delete outputs associated with removed paths
|
||||
for (String deletedSource : deletedPaths) {
|
||||
// deleting outputs corresponding to non-existing source
|
||||
@@ -539,26 +557,20 @@ public class IncProjectBuilder {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!allChunkRemovedSources.isEmpty()) {
|
||||
final Set<String> currentData = Utils.CHUNK_REMOVED_SOURCES_KEY.get(context);
|
||||
if (currentData != null) {
|
||||
allChunkRemovedSources.addAll(currentData);
|
||||
}
|
||||
Utils.CHUNK_REMOVED_SOURCES_KEY.set(context, allChunkRemovedSources);
|
||||
|
||||
final Map<String, Collection<String>> existing = Utils.CHUNK_PER_MODULE_REMOVED_SOURCES_KEY.get(context);
|
||||
if (!removedSources.isEmpty()) {
|
||||
final Map<String, Collection<String>> existing = Utils.REMOVED_SOURCES_KEY.get(context);
|
||||
if (existing != null) {
|
||||
for (Map.Entry<String, Collection<String>> entry : existing.entrySet()) {
|
||||
final Collection<String> paths = perModuleRemovedSources.get(entry.getKey());
|
||||
final Collection<String> paths = removedSources.get(entry.getKey());
|
||||
if (paths != null) {
|
||||
paths.addAll(entry.getValue());
|
||||
}
|
||||
else {
|
||||
perModuleRemovedSources.put(entry.getKey(), entry.getValue());
|
||||
removedSources.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
Utils.CHUNK_PER_MODULE_REMOVED_SOURCES_KEY.set(context, perModuleRemovedSources);
|
||||
Utils.REMOVED_SOURCES_KEY.set(context, removedSources);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.ProjectPaths;
|
||||
import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -65,7 +66,7 @@ public abstract class ModuleLevelBuilder extends Builder {
|
||||
try {
|
||||
boolean additionalPassRequired = false;
|
||||
|
||||
final Set<String> removedPaths = getRemovedPaths(context);
|
||||
final Set<String> removedPaths = getRemovedPaths(context, chunk);
|
||||
|
||||
final Mappings globalMappings = context.getDataManager().getMappings();
|
||||
|
||||
@@ -143,6 +144,9 @@ public abstract class ModuleLevelBuilder extends Builder {
|
||||
|
||||
globalMappings.integrate(delta, removedPaths);
|
||||
|
||||
// save to remove everything that has been integrated
|
||||
dropRemovedPaths(context, chunk);
|
||||
|
||||
return additionalPassRequired;
|
||||
}
|
||||
catch(RuntimeException e) {
|
||||
@@ -205,9 +209,34 @@ public abstract class ModuleLevelBuilder extends Builder {
|
||||
return allCompiledFiles;
|
||||
}
|
||||
|
||||
private static Set<String> getRemovedPaths(CompileContext context) {
|
||||
final Set<String> removed = Utils.CHUNK_REMOVED_SOURCES_KEY.get(context);
|
||||
return removed != null? removed : Collections.<String>emptySet();
|
||||
private static Set<String> getRemovedPaths(CompileContext context, ModuleChunk chunk) {
|
||||
final Map<String, Collection<String>> map = Utils.REMOVED_SOURCES_KEY.get(context);
|
||||
if (map == null) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
final Set<String> removed = new HashSet<String>();
|
||||
for (Module module : chunk.getModules()) {
|
||||
final Collection<String> modulePaths = map.get(module.getName());
|
||||
if (modulePaths != null) {
|
||||
removed.addAll(modulePaths);
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
private static void dropRemovedPaths(CompileContext context, ModuleChunk chunk) throws IOException {
|
||||
final Map<String, Collection<String>> map = Utils.REMOVED_SOURCES_KEY.get(context);
|
||||
if (map != null) {
|
||||
for (Module module : chunk.getModules()) {
|
||||
final Collection<String> paths = map.remove(module.getName());
|
||||
if (paths != null) {
|
||||
final SourceToOutputMapping storage = context.getDataManager().getSourceToOutputMap(module.getName(), context.isCompilingTests());
|
||||
for (String path : paths) {
|
||||
storage.remove(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class ModulesBasedFileFilter implements Mappings.DependentFilesFilter{
|
||||
|
||||
@@ -15,8 +15,7 @@ import java.util.*;
|
||||
* Date: 10/20/11
|
||||
*/
|
||||
public class Utils {
|
||||
public static final Key<Set<String>> CHUNK_REMOVED_SOURCES_KEY = Key.create("_chunk_removed_sources_");
|
||||
public static final Key<Map<String, Collection<String>>> CHUNK_PER_MODULE_REMOVED_SOURCES_KEY = Key.create("_chunk_per_maodule_removed_sources_");
|
||||
public static final Key<Map<String, Collection<String>>> REMOVED_SOURCES_KEY = Key.create("_removed_sources_");
|
||||
private static volatile File ourSystemRoot = new File(System.getProperty("user.home", ".jps-server"));
|
||||
|
||||
private Utils() {
|
||||
|
||||
Reference in New Issue
Block a user