mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
VCS: also take all dirt from Vcs dirty scope vfs listener when waiting for everything to be refreshed in tests
This commit is contained in:
@@ -112,6 +112,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
};
|
||||
private final ChangelistConflictTracker myConflictTracker;
|
||||
private VcsDirtyScopeManager myDirtyScopeManager;
|
||||
private VcsDirtyScopeVfsListener myVfsListener;
|
||||
|
||||
public static ChangeListManagerImpl getInstanceImpl(final Project project) {
|
||||
return (ChangeListManagerImpl)PeriodicalTasksCloser.getInstance().safeGetComponent(project, ChangeListManager.class);
|
||||
@@ -126,6 +127,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
myFreezeName = new AtomicReference<String>(null);
|
||||
myAdditionalInfo = null;
|
||||
myChangesViewManager = myProject.isDefault() ? new DummyChangesView(myProject) : ChangesViewManager.getInstance(myProject);
|
||||
myVfsListener = ApplicationManager.getApplication().getComponent(VcsDirtyScopeVfsListener.class);
|
||||
myFileStatusManager = FileStatusManager.getInstance(myProject);
|
||||
myComposite = new FileHolderComposite(project);
|
||||
myIgnoredIdeaLevel = new IgnoredFilesComponent(myProject, true);
|
||||
@@ -1336,6 +1338,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
* Can be called only from not AWT thread; to do smthg after ChangeListManager refresh, call invokeAfterUpdate
|
||||
*/
|
||||
public boolean ensureUpToDate(final boolean canBeCanceled) {
|
||||
myVfsListener.flushDirt();
|
||||
final EnsureUpToDateFromNonAWTThread worker = new EnsureUpToDateFromNonAWTThread(myProject);
|
||||
worker.execute();
|
||||
myUpdater.waitUntilRefreshed();
|
||||
|
||||
+36
-29
@@ -56,42 +56,45 @@ public class VcsDirtyScopeVfsListener implements ApplicationComponent, BulkFileL
|
||||
private final ConstantZipperUpdater myZipperUpdater;
|
||||
private final List<FileAndDirsCollector> myQueue;
|
||||
private final Object myLock;
|
||||
private final Runnable myDirtReporter;
|
||||
|
||||
public VcsDirtyScopeVfsListener() {
|
||||
myProjectLocator = ProjectLocator.getInstance();
|
||||
myMessageBusConnection = ApplicationManager.getApplication().getMessageBus().connect();
|
||||
myLock = new Object();
|
||||
myQueue = new ArrayList<FileAndDirsCollector>();
|
||||
myDirtReporter = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ArrayList<FileAndDirsCollector> list;
|
||||
synchronized (myLock) {
|
||||
list = new ArrayList<FileAndDirsCollector>(myQueue);
|
||||
myQueue.clear();
|
||||
}
|
||||
Map<VcsDirtyScopeManager, Pair<HashSet<FilePath>, HashSet<FilePath>>> map =
|
||||
new HashMap<VcsDirtyScopeManager, Pair<HashSet<FilePath>, HashSet<FilePath>>>();
|
||||
for (FileAndDirsCollector collector : list) {
|
||||
Map<VcsDirtyScopeManager, Pair<HashSet<FilePath>, HashSet<FilePath>>> pairMap =
|
||||
collector.map;
|
||||
for (Map.Entry<VcsDirtyScopeManager, Pair<HashSet<FilePath>, HashSet<FilePath>>> entry : pairMap
|
||||
.entrySet()) {
|
||||
final VcsDirtyScopeManager key = entry.getKey();
|
||||
Pair<HashSet<FilePath>, HashSet<FilePath>> existing = map.get(key);
|
||||
Pair<HashSet<FilePath>, HashSet<FilePath>> value = entry.getValue();
|
||||
if (existing != null) {
|
||||
existing.getFirst().addAll(value.getFirst());
|
||||
existing.getSecond().addAll(value.getSecond());
|
||||
}
|
||||
else {
|
||||
map.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
new FileAndDirsCollector().markDirty(map);
|
||||
}
|
||||
};
|
||||
myZipperUpdater = new ConstantZipperUpdater(300, Alarm.ThreadToUse.SHARED_THREAD, ApplicationManager.getApplication(),
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ArrayList<FileAndDirsCollector> list;
|
||||
synchronized (myLock) {
|
||||
list = new ArrayList<FileAndDirsCollector>(myQueue);
|
||||
myQueue.clear();
|
||||
}
|
||||
Map<VcsDirtyScopeManager, Pair<HashSet<FilePath>, HashSet<FilePath>>> map =
|
||||
new HashMap<VcsDirtyScopeManager, Pair<HashSet<FilePath>, HashSet<FilePath>>>();
|
||||
for (FileAndDirsCollector collector : list) {
|
||||
Map<VcsDirtyScopeManager, Pair<HashSet<FilePath>, HashSet<FilePath>>> pairMap =
|
||||
collector.map;
|
||||
for (Map.Entry<VcsDirtyScopeManager, Pair<HashSet<FilePath>, HashSet<FilePath>>> entry : pairMap
|
||||
.entrySet()) {
|
||||
final VcsDirtyScopeManager key = entry.getKey();
|
||||
Pair<HashSet<FilePath>, HashSet<FilePath>> existing = map.get(key);
|
||||
Pair<HashSet<FilePath>, HashSet<FilePath>> value = entry.getValue();
|
||||
if (existing != null) {
|
||||
existing.getFirst().addAll(value.getFirst());
|
||||
existing.getSecond().addAll(value.getSecond());
|
||||
} else {
|
||||
map.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
new FileAndDirsCollector().markDirty(map);
|
||||
}
|
||||
});
|
||||
myDirtReporter);
|
||||
}
|
||||
|
||||
public void setForbid(boolean forbid) {
|
||||
@@ -99,6 +102,10 @@ public class VcsDirtyScopeVfsListener implements ApplicationComponent, BulkFileL
|
||||
myForbid = forbid;
|
||||
}
|
||||
|
||||
public void flushDirt() {
|
||||
myDirtReporter.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
|
||||
Reference in New Issue
Block a user