mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
exctect Timestamps interface to abstract work with file state
This commit is contained in:
@@ -26,7 +26,7 @@ import org.jetbrains.jps.incremental.fs.RootDescriptor;
|
||||
import org.jetbrains.jps.incremental.messages.*;
|
||||
import org.jetbrains.jps.incremental.storage.BuildDataManager;
|
||||
import org.jetbrains.jps.incremental.storage.ProjectTimestamps;
|
||||
import org.jetbrains.jps.incremental.storage.TimestampStorage;
|
||||
import org.jetbrains.jps.incremental.storage.Timestamps;
|
||||
import org.jetbrains.jps.server.ProjectDescriptor;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -385,7 +385,7 @@ final class BuildSession implements Runnable, CanceledStatus {
|
||||
forcedModules = Collections.emptySet();
|
||||
}
|
||||
|
||||
final TimestampStorage tsStorage = pd.timestamps.getStorage();
|
||||
final Timestamps tsStorage = pd.timestamps.getStorage();
|
||||
|
||||
final Map<String, Set<File>> filesToCompile;
|
||||
if (!paths.isEmpty()) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.jetbrains.jps.incremental.messages.ProgressMessage;
|
||||
import org.jetbrains.jps.incremental.messages.UptoDateFilesSavedEvent;
|
||||
import org.jetbrains.jps.incremental.storage.BuildDataManager;
|
||||
import org.jetbrains.jps.incremental.storage.SourceToOutputMapping;
|
||||
import org.jetbrains.jps.incremental.storage.TimestampStorage;
|
||||
import org.jetbrains.jps.incremental.storage.Timestamps;
|
||||
import org.jetbrains.jps.server.ProjectDescriptor;
|
||||
|
||||
import java.io.File;
|
||||
@@ -39,7 +39,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
private volatile boolean myErrorsFound = false;
|
||||
private final long myCompilationStartStamp;
|
||||
private final ProjectDescriptor myProjectDescriptor;
|
||||
private final TimestampStorage myTsStorage;
|
||||
private final Timestamps myTimestamps;
|
||||
private final Map<String, String> myBuilderParams;
|
||||
private final CanceledStatus myCancelStatus;
|
||||
private float myDone = -1.0f;
|
||||
@@ -53,7 +53,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
Map<String, String> builderParams,
|
||||
CanceledStatus cancelStatus) throws ProjectBuildException {
|
||||
myProjectDescriptor = pd;
|
||||
myTsStorage = myProjectDescriptor.timestamps.getStorage();
|
||||
myTimestamps = myProjectDescriptor.timestamps.getStorage();
|
||||
myBuilderParams = Collections.unmodifiableMap(builderParams);
|
||||
myCancelStatus = cancelStatus;
|
||||
myCompilationStartStamp = System.currentTimeMillis();
|
||||
@@ -95,21 +95,21 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
public void markDirty(final File file) throws IOException {
|
||||
final RootDescriptor descriptor = getModuleAndRoot(file);
|
||||
if (descriptor != null) {
|
||||
myProjectDescriptor.fsState.markDirty(file, descriptor, myTsStorage);
|
||||
myProjectDescriptor.fsState.markDirty(file, descriptor, myTimestamps);
|
||||
}
|
||||
}
|
||||
|
||||
public void markDirtyIfNotDeleted(final File file) throws IOException {
|
||||
final RootDescriptor descriptor = getModuleAndRoot(file);
|
||||
if (descriptor != null) {
|
||||
myProjectDescriptor.fsState.markDirtyIfNotDeleted(file, descriptor, myTsStorage);
|
||||
myProjectDescriptor.fsState.markDirtyIfNotDeleted(file, descriptor, myTimestamps);
|
||||
}
|
||||
}
|
||||
|
||||
public void markDeleted(File file) throws IOException {
|
||||
final RootDescriptor descriptor = getModuleAndRoot(file);
|
||||
if (descriptor != null) {
|
||||
myProjectDescriptor.fsState.registerDeleted(descriptor.module, file, descriptor.isTestRoot, myTsStorage);
|
||||
myProjectDescriptor.fsState.registerDeleted(descriptor.module, file, descriptor.isTestRoot, myTimestamps);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
myProjectDescriptor.fsState.clearContextRoundData();
|
||||
final Set<Module> modules = chunk.getModules();
|
||||
for (Module module : modules) {
|
||||
markDirtyFiles(module, myTsStorage, true, isCompilingTests()? DirtyMarkScope.TESTS : DirtyMarkScope.PRODUCTION, null);
|
||||
markDirtyFiles(module, myTimestamps, true, isCompilingTests()? DirtyMarkScope.TESTS : DirtyMarkScope.PRODUCTION, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
}
|
||||
|
||||
for (Module module : dirtyModules) {
|
||||
markDirtyFiles(module, myTsStorage, true, isCompilingTests()? DirtyMarkScope.TESTS : DirtyMarkScope.BOTH, null);
|
||||
markDirtyFiles(module, myTimestamps, true, isCompilingTests()? DirtyMarkScope.TESTS : DirtyMarkScope.BOTH, null);
|
||||
}
|
||||
|
||||
if (isMake()) {
|
||||
@@ -254,7 +254,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
final List<RootDescriptor> roots = myProjectDescriptor.rootsIndex.getModuleRoots(module);
|
||||
for (RootDescriptor descriptor : roots) {
|
||||
if (compilingTests? descriptor.isTestRoot : !descriptor.isTestRoot) {
|
||||
marked |= myProjectDescriptor.fsState.markAllUpToDate(getScope(), descriptor, myTsStorage, myCompilationStartStamp);
|
||||
marked |= myProjectDescriptor.fsState.markAllUpToDate(getScope(), descriptor, myTimestamps, myCompilationStartStamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -272,8 +272,8 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
return myProjectDescriptor.dataManager;
|
||||
}
|
||||
|
||||
public TimestampStorage getTimestampStorage() {
|
||||
return myTsStorage;
|
||||
public Timestamps getTimestampStorage() {
|
||||
return myTimestamps;
|
||||
}
|
||||
|
||||
public void processMessage(BuildMessage msg) {
|
||||
@@ -299,7 +299,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
final void ensureFSStateInitialized(ModuleChunk chunk) throws IOException {
|
||||
for (Module module : chunk.getModules()) {
|
||||
if (isProjectRebuild()) {
|
||||
markDirtyFiles(module, myTsStorage, true, isCompilingTests() ? DirtyMarkScope.TESTS : DirtyMarkScope.PRODUCTION, null);
|
||||
markDirtyFiles(module, myTimestamps, true, isCompilingTests() ? DirtyMarkScope.TESTS : DirtyMarkScope.PRODUCTION, null);
|
||||
}
|
||||
else {
|
||||
if (isMake()) {
|
||||
@@ -310,7 +310,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
else {
|
||||
// forced compilation mode
|
||||
if (getScope().isRecompilationForced(module.getName())) {
|
||||
markDirtyFiles(module, myTsStorage, true, isCompilingTests() ? DirtyMarkScope.TESTS : DirtyMarkScope.PRODUCTION, null);
|
||||
markDirtyFiles(module, myTimestamps, true, isCompilingTests() ? DirtyMarkScope.TESTS : DirtyMarkScope.PRODUCTION, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -319,7 +319,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
|
||||
private void initModuleFSState(Module module) throws IOException {
|
||||
final HashSet<File> currentFiles = new HashSet<File>();
|
||||
markDirtyFiles(module, myTsStorage, false, isCompilingTests() ? DirtyMarkScope.TESTS : DirtyMarkScope.PRODUCTION, currentFiles);
|
||||
markDirtyFiles(module, myTimestamps, false, isCompilingTests() ? DirtyMarkScope.TESTS : DirtyMarkScope.PRODUCTION, currentFiles);
|
||||
|
||||
final SourceToOutputMapping sourceToOutputMap = getDataManager().getSourceToOutputMap(module.getName(), isCompilingTests());
|
||||
for (final Iterator<String> it = sourceToOutputMap.getKeysIterator(); it.hasNext();) {
|
||||
@@ -327,7 +327,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
// can check if the file exists
|
||||
final File file = new File(path);
|
||||
if (!currentFiles.contains(file)) {
|
||||
myProjectDescriptor.fsState.registerDeleted(module.getName(), file, isCompilingTests(), myTsStorage);
|
||||
myProjectDescriptor.fsState.registerDeleted(module.getName(), file, isCompilingTests(), myTimestamps);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,7 +373,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
PRODUCTION, TESTS, BOTH
|
||||
}
|
||||
|
||||
private void markDirtyFiles(Module module, final TimestampStorage tsStorage, final boolean forceMarkDirty, @NotNull final DirtyMarkScope scope, @Nullable final Set<File> currentFiles) throws IOException {
|
||||
private void markDirtyFiles(Module module, final Timestamps tsStorage, final boolean forceMarkDirty, @NotNull final DirtyMarkScope scope, @Nullable final Set<File> currentFiles) throws IOException {
|
||||
final Set<File> excludes = new HashSet<File>();
|
||||
for (String excludePath : module.getExcludes()) {
|
||||
excludes.add(new File(excludePath));
|
||||
@@ -402,7 +402,7 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
}
|
||||
}
|
||||
|
||||
private void traverseRecursively(final RootDescriptor rd, final File file, Set<File> excludes, @NotNull final TimestampStorage tsStorage, final boolean forceDirty, @Nullable Set<File> currentFiles) throws IOException {
|
||||
private void traverseRecursively(final RootDescriptor rd, final File file, Set<File> excludes, @NotNull final Timestamps tsStorage, final boolean forceDirty, @Nullable Set<File> currentFiles) throws IOException {
|
||||
final File[] children = file.listFiles();
|
||||
if (children != null) { // is directory
|
||||
if (children.length > 0 && !PathUtil.isUnder(excludes, file)) {
|
||||
@@ -419,8 +419,8 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler
|
||||
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 TimestampStorage _tsStorage = isProjectRebuild() ? null : tsStorage;
|
||||
myProjectDescriptor.fsState.markDirty(file, rd, _tsStorage);
|
||||
final Timestamps marker = isProjectRebuild() ? null : tsStorage;
|
||||
myProjectDescriptor.fsState.markDirty(file, rd, marker);
|
||||
}
|
||||
if (currentFiles != null) {
|
||||
currentFiles.add(file);
|
||||
|
||||
@@ -137,7 +137,7 @@ public class IncProjectBuilder {
|
||||
|
||||
private static void flushContext(CompileContext context) {
|
||||
if (context != null) {
|
||||
context.getTimestampStorage().force();
|
||||
context.getProjectDescriptor().timestamps.getStorage().force();
|
||||
context.getDataManager().flush(false);
|
||||
}
|
||||
final ExternalJavacDescriptor descriptor = ExternalJavacDescriptor.KEY.get(context);
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.incremental.CompileContext;
|
||||
import org.jetbrains.jps.incremental.CompileScope;
|
||||
import org.jetbrains.jps.incremental.FileProcessor;
|
||||
import org.jetbrains.jps.incremental.storage.TimestampStorage;
|
||||
import org.jetbrains.jps.incremental.storage.Timestamps;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -55,7 +55,7 @@ public class BuildFSState extends FSState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean markDirty(File file, final RootDescriptor rd, @Nullable TimestampStorage tsStorage) throws IOException {
|
||||
public boolean markDirty(File file, final RootDescriptor rd, @Nullable Timestamps tsStorage) throws IOException {
|
||||
final FilesDelta roundDelta = myCurrentRoundDelta;
|
||||
if (roundDelta != null) {
|
||||
if (myContextModules.contains(rd.module)) {
|
||||
@@ -66,7 +66,7 @@ public class BuildFSState extends FSState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean markDirtyIfNotDeleted(File file, final RootDescriptor rd, @Nullable TimestampStorage tsStorage) throws IOException {
|
||||
public boolean markDirtyIfNotDeleted(File file, final RootDescriptor rd, @Nullable Timestamps tsStorage) throws IOException {
|
||||
final boolean marked = super.markDirtyIfNotDeleted(file, rd, tsStorage);
|
||||
if (marked) {
|
||||
final FilesDelta roundDelta = myCurrentRoundDelta;
|
||||
@@ -135,7 +135,7 @@ public class BuildFSState extends FSState {
|
||||
/**
|
||||
* @return true if marked something, false otherwise
|
||||
*/
|
||||
public boolean markAllUpToDate(CompileScope scope, final RootDescriptor rd, final TimestampStorage tsStorage, final long compilationStartStamp) throws IOException {
|
||||
public boolean markAllUpToDate(CompileScope scope, final RootDescriptor rd, final Timestamps stamps, final long compilationStartStamp) throws IOException {
|
||||
boolean marked = false;
|
||||
final FilesDelta delta = getDelta(rd.module);
|
||||
final Set<File> files = delta.clearRecompile(rd.root, rd.isTestRoot);
|
||||
@@ -152,7 +152,7 @@ public class BuildFSState extends FSState {
|
||||
}
|
||||
else {
|
||||
marked = true;
|
||||
tsStorage.saveStamp(file, stamp);
|
||||
stamps.saveStamp(file, stamp);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -160,7 +160,7 @@ public class BuildFSState extends FSState {
|
||||
}
|
||||
}
|
||||
else {
|
||||
tsStorage.remove(file);
|
||||
stamps.removeStamp(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.jetbrains.jps.incremental.fs;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.incremental.storage.TimestampStorage;
|
||||
import org.jetbrains.jps.incremental.storage.Timestamps;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -23,27 +23,27 @@ public class FSState {
|
||||
getDelta(rd.module).clearRecompile(rd.root, rd.isTestRoot);
|
||||
}
|
||||
|
||||
public boolean markDirty(final File file, final RootDescriptor rd, final @Nullable TimestampStorage tsStorage) throws IOException {
|
||||
public boolean markDirty(final File file, final RootDescriptor rd, final @Nullable Timestamps marker) throws IOException {
|
||||
final FilesDelta mainDelta = getDelta(rd.module);
|
||||
final boolean marked = mainDelta.markRecompile(rd.root, rd.isTestRoot, file);
|
||||
if (marked && tsStorage != null) {
|
||||
tsStorage.markDirty(file);
|
||||
if (marked && marker != null) {
|
||||
marker.removeStamp(file);
|
||||
}
|
||||
return marked;
|
||||
}
|
||||
|
||||
public boolean markDirtyIfNotDeleted(final File file, final RootDescriptor rd, final @Nullable TimestampStorage tsStorage) throws IOException {
|
||||
public boolean markDirtyIfNotDeleted(final File file, final RootDescriptor rd, final @Nullable Timestamps marker) throws IOException {
|
||||
final boolean marked = getDelta(rd.module).markRecompileIfNotDeleted(rd.root, rd.isTestRoot, file);
|
||||
if (marked && tsStorage != null) {
|
||||
tsStorage.markDirty(file);
|
||||
if (marked && marker != null) {
|
||||
marker.removeStamp(file);
|
||||
}
|
||||
return marked;
|
||||
}
|
||||
|
||||
public void registerDeleted(final String moduleName, final File file, final boolean forTests, @Nullable TimestampStorage tsStorage) throws IOException {
|
||||
public void registerDeleted(final String moduleName, final File file, final boolean forTests, @Nullable Timestamps tsStorage) throws IOException {
|
||||
getDelta(moduleName).addDeleted(file, forTests);
|
||||
if (tsStorage != null) {
|
||||
tsStorage.remove(file);
|
||||
tsStorage.removeStamp(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,23 +13,25 @@ import java.io.IOException;
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 10/7/11
|
||||
*/
|
||||
public class TimestampStorage extends AbstractStateStorage<File, TimestampValidityState> {
|
||||
public class TimestampStorage extends AbstractStateStorage<File, TimestampValidityState> implements Timestamps {
|
||||
|
||||
public TimestampStorage(File storePath) throws IOException {
|
||||
super(storePath, new FileKeyDescriptor(), new StateExternalizer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getStamp(File file) throws IOException {
|
||||
final TimestampValidityState state = getState(file);
|
||||
return state != null? state.getTimestamp() : -1L;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveStamp(File file, long timestamp) throws IOException {
|
||||
update(file, new TimestampValidityState(timestamp));
|
||||
}
|
||||
|
||||
public void markDirty(File file) throws IOException {
|
||||
update(file, null);
|
||||
public void removeStamp(File file) throws IOException {
|
||||
remove(file);
|
||||
}
|
||||
|
||||
private static class FileKeyDescriptor implements KeyDescriptor<File> {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package org.jetbrains.jps.incremental.storage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
* Date: 4/24/12
|
||||
*/
|
||||
public interface Timestamps {
|
||||
|
||||
void saveStamp(File file, long timestamp) throws IOException;
|
||||
|
||||
void removeStamp(File file) throws IOException;
|
||||
|
||||
long getStamp(File file) throws IOException;
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jps.incremental.messages.BuildMessage;
|
||||
import org.jetbrains.jps.incremental.messages.CompilerMessage;
|
||||
import org.jetbrains.jps.incremental.storage.BuildDataManager;
|
||||
import org.jetbrains.jps.incremental.storage.ProjectTimestamps;
|
||||
import org.jetbrains.jps.incremental.storage.TimestampStorage;
|
||||
import org.jetbrains.jps.incremental.storage.Timestamps;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -252,7 +252,7 @@ class ServerState {
|
||||
forcedModules = Collections.emptySet();
|
||||
}
|
||||
|
||||
final TimestampStorage tsStorage = pd.timestamps.getStorage();
|
||||
final Timestamps marker = pd.timestamps.getStorage();
|
||||
|
||||
final Map<String, Set<File>> filesToCompile;
|
||||
if (!paths.isEmpty()) {
|
||||
@@ -268,7 +268,7 @@ class ServerState {
|
||||
}
|
||||
files.add(file);
|
||||
if (buildType == BuildType.FORCED_COMPILATION) {
|
||||
pd.fsState.markDirty(file, rd, tsStorage);
|
||||
pd.fsState.markDirty(file, rd, marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user