use of org.jetbrains.jps.incremental.storage.Timestamps in project intellij-community by JetBrains.
the class BuildSession method applyFSEvent.
private static void applyFSEvent(ProjectDescriptor pd, @Nullable CmdlineRemoteProto.Message.ControllerMessage.FSEvent event, final boolean saveEventStamp) throws IOException {
if (event == null) {
return;
}
final Timestamps timestamps = pd.timestamps.getStorage();
boolean cacheCleared = false;
for (String deleted : event.getDeletedPathsList()) {
final File file = new File(deleted);
Collection<BuildRootDescriptor> descriptor = pd.getBuildRootIndex().findAllParentDescriptors(file, null, null);
if (!descriptor.isEmpty()) {
if (!cacheCleared) {
pd.getFSCache().clear();
cacheCleared = true;
}
if (LOG.isDebugEnabled()) {
LOG.debug("Applying deleted path from fs event: " + file.getPath());
}
for (BuildRootDescriptor rootDescriptor : descriptor) {
pd.fsState.registerDeleted(null, rootDescriptor.getTarget(), file, timestamps);
}
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping deleted path: " + file.getPath());
}
}
}
for (String changed : event.getChangedPathsList()) {
final File file = new File(changed);
Collection<BuildRootDescriptor> descriptors = pd.getBuildRootIndex().findAllParentDescriptors(file, null, null);
if (!descriptors.isEmpty()) {
if (LOG.isDebugEnabled()) {
LOG.debug("Applying dirty path from fs event: " + changed);
}
long fileStamp = -1L;
for (BuildRootDescriptor descriptor : descriptors) {
if (!descriptor.isGenerated()) {
// ignore generates sources as they are processed at the time of generation
if (fileStamp == -1L) {
// lazy init
fileStamp = FileSystemUtil.lastModified(file);
}
final long stamp = timestamps.getStamp(file, descriptor.getTarget());
if (stamp != fileStamp) {
if (!cacheCleared) {
pd.getFSCache().clear();
cacheCleared = true;
}
pd.fsState.markDirty(null, file, descriptor, timestamps, saveEventStamp);
} else {
if (LOG.isDebugEnabled()) {
LOG.debug(descriptor.getTarget() + ": Path considered up-to-date: " + changed + "; timestamp= " + stamp);
}
}
}
}
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Skipping dirty path: " + file.getPath());
}
}
}
}
use of org.jetbrains.jps.incremental.storage.Timestamps in project intellij-community by JetBrains.
the class FSOperations method traverseRecursively.
private static void traverseRecursively(CompileContext context, final BuildRootDescriptor rd, final CompilationRound round, final File file, @NotNull final Timestamps tsStorage, final boolean forceDirty, @Nullable Set<File> currentFiles, @Nullable FileFilter filter, @NotNull FSCache fsCache) throws IOException {
BuildRootIndex rootIndex = context.getProjectDescriptor().getBuildRootIndex();
final File[] children = fsCache.getChildren(file);
if (children != null) {
// is directory
if (children.length > 0 && rootIndex.isDirectoryAccepted(file, rd)) {
for (File child : children) {
traverseRecursively(context, rd, round, child, tsStorage, forceDirty, currentFiles, filter, fsCache);
}
}
} else {
// is file
if (rootIndex.isFileAccepted(file, rd) && (filter == null || filter.accept(file))) {
boolean markDirty = forceDirty;
if (!markDirty) {
markDirty = tsStorage.getStamp(file, rd.getTarget()) != FileSystemUtil.lastModified(file);
}
if (markDirty) {
// if it is full project rebuild, all storages are already completely cleared;
// so passing null because there is no need to access the storage to clear non-existing data
final Timestamps marker = context.isProjectRebuild() ? null : tsStorage;
context.getProjectDescriptor().fsState.markDirty(context, round, file, rd, marker, false);
}
if (currentFiles != null) {
currentFiles.add(file);
}
}
}
}
Aggregations