Search in sources :

Example 6 with Timestamps

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());
            }
        }
    }
}
Also used : Timestamps(org.jetbrains.jps.incremental.storage.Timestamps)

Example 7 with Timestamps

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);
            }
        }
    }
}
Also used : Timestamps(org.jetbrains.jps.incremental.storage.Timestamps) BuildRootIndex(org.jetbrains.jps.builders.BuildRootIndex) File(java.io.File)

Aggregations

Timestamps (org.jetbrains.jps.incremental.storage.Timestamps)7 THashSet (gnu.trove.THashSet)3 File (java.io.File)3 ProjectDescriptor (org.jetbrains.jps.cmdline.ProjectDescriptor)3 BuildFSState (org.jetbrains.jps.incremental.fs.BuildFSState)2 HashSet (java.util.HashSet)1 TargetTypeBuildScope (org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope)1 BuildRootIndex (org.jetbrains.jps.builders.BuildRootIndex)1 BuildTargetChunk (org.jetbrains.jps.builders.impl.BuildTargetChunk)1 JavaModuleBuildTargetType (org.jetbrains.jps.builders.java.JavaModuleBuildTargetType)1 SourceToOutputMapping (org.jetbrains.jps.builders.storage.SourceToOutputMapping)1 BuildTargetConfiguration (org.jetbrains.jps.incremental.storage.BuildTargetConfiguration)1 ProjectTimestamps (org.jetbrains.jps.incremental.storage.ProjectTimestamps)1 JpsJavaClasspathKind (org.jetbrains.jps.model.java.JpsJavaClasspathKind)1 JpsModule (org.jetbrains.jps.model.module.JpsModule)1