mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Don't suspend VcsDirtyScopeManager: prefer suspending the ChangeListManager
This commit is contained in:
+5
-47
@@ -91,24 +91,6 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void suspendMe() {
|
|
||||||
myLife.suspendMe();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reanimate() {
|
|
||||||
final Ref<Boolean> wasNotEmptyRef = new Ref<Boolean>();
|
|
||||||
myLife.releaseMe(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
wasNotEmptyRef.set(! myDirtBuilder.isEmpty());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (Boolean.TRUE.equals(wasNotEmptyRef.get())) {
|
|
||||||
myChangeListManager.scheduleUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void markEverythingDirty() {
|
public void markEverythingDirty() {
|
||||||
if ((! myProject.isOpen()) || myProject.isDisposed() || myVcsManager.getAllActiveVcss().length == 0) return;
|
if ((! myProject.isOpen()) || myProject.isDisposed() || myVcsManager.getAllActiveVcss().length == 0) return;
|
||||||
|
|
||||||
@@ -123,7 +105,7 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (lifeDrop.isDone() && !lifeDrop.isSuspened()) {
|
if (lifeDrop.isDone()) {
|
||||||
myChangeListManager.scheduleUpdate();
|
myChangeListManager.scheduleUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,7 +200,7 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr
|
|||||||
};
|
};
|
||||||
final LifeDrop lifeDrop = myLife.doIfAlive(runnable);
|
final LifeDrop lifeDrop = myLife.doIfAlive(runnable);
|
||||||
|
|
||||||
if (lifeDrop.isDone() && !lifeDrop.isSuspened() && Boolean.TRUE.equals(wasNotEmptyRef.get())) {
|
if (lifeDrop.isDone() && Boolean.TRUE.equals(wasNotEmptyRef.get())) {
|
||||||
myChangeListManager.scheduleUpdate();
|
myChangeListManager.scheduleUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -459,26 +441,19 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr
|
|||||||
|
|
||||||
private static class LifeDrop {
|
private static class LifeDrop {
|
||||||
private final boolean myDone;
|
private final boolean myDone;
|
||||||
private final boolean mySuspened;
|
|
||||||
|
|
||||||
private LifeDrop(boolean done, boolean suspened) {
|
private LifeDrop(boolean done) {
|
||||||
myDone = done;
|
myDone = done;
|
||||||
mySuspened = suspened;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDone() {
|
public boolean isDone() {
|
||||||
return myDone;
|
return myDone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSuspened() {
|
|
||||||
return mySuspened;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SynchronizedLife {
|
private static class SynchronizedLife {
|
||||||
private LifeStages myStage;
|
private LifeStages myStage;
|
||||||
private final Object myLock;
|
private final Object myLock;
|
||||||
private boolean mySuspended;
|
|
||||||
|
|
||||||
private SynchronizedLife() {
|
private SynchronizedLife() {
|
||||||
myStage = LifeStages.NOT_BORN;
|
myStage = LifeStages.NOT_BORN;
|
||||||
@@ -498,31 +473,14 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void suspendMe() {
|
|
||||||
synchronized (myLock) {
|
|
||||||
if (LifeStages.ALIVE.equals(myStage)) {
|
|
||||||
mySuspended = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void releaseMe(final Runnable runnable) {
|
|
||||||
synchronized (myLock) {
|
|
||||||
if (LifeStages.ALIVE.equals(myStage)) {
|
|
||||||
mySuspended = false;
|
|
||||||
runnable.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// allow work under inner lock: inner class, not wide scope
|
// allow work under inner lock: inner class, not wide scope
|
||||||
public LifeDrop doIfAlive(final Runnable runnable) {
|
public LifeDrop doIfAlive(final Runnable runnable) {
|
||||||
synchronized (myLock) {
|
synchronized (myLock) {
|
||||||
if (LifeStages.ALIVE.equals(myStage)) {
|
if (LifeStages.ALIVE.equals(myStage)) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
return new LifeDrop(true, mySuspended);
|
return new LifeDrop(true);
|
||||||
}
|
}
|
||||||
return new LifeDrop(false, mySuspended);
|
return new LifeDrop(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-6
@@ -34,10 +34,7 @@ import com.intellij.openapi.vcs.*;
|
|||||||
import com.intellij.openapi.vcs.actions.AbstractVcsAction;
|
import com.intellij.openapi.vcs.actions.AbstractVcsAction;
|
||||||
import com.intellij.openapi.vcs.actions.DescindingFilesFilter;
|
import com.intellij.openapi.vcs.actions.DescindingFilesFilter;
|
||||||
import com.intellij.openapi.vcs.actions.VcsContext;
|
import com.intellij.openapi.vcs.actions.VcsContext;
|
||||||
import com.intellij.openapi.vcs.changes.RemoteRevisionsCache;
|
import com.intellij.openapi.vcs.changes.*;
|
||||||
import com.intellij.openapi.vcs.changes.VcsAnnotationRefresher;
|
|
||||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManager;
|
|
||||||
import com.intellij.openapi.vcs.changes.VcsDirtyScopeManagerImpl;
|
|
||||||
import com.intellij.openapi.vcs.changes.committed.CommittedChangesCache;
|
import com.intellij.openapi.vcs.changes.committed.CommittedChangesCache;
|
||||||
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
|
import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
|
||||||
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
import com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier;
|
||||||
@@ -293,6 +290,7 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
|
|||||||
|
|
||||||
private final Project myProject;
|
private final Project myProject;
|
||||||
private final ProjectLevelVcsManagerEx myProjectLevelVcsManager;
|
private final ProjectLevelVcsManagerEx myProjectLevelVcsManager;
|
||||||
|
private final ChangeListManagerEx myChangeListManager;
|
||||||
private UpdatedFiles myUpdatedFiles;
|
private UpdatedFiles myUpdatedFiles;
|
||||||
private final FilePath[] myRoots;
|
private final FilePath[] myRoots;
|
||||||
private final Map<AbstractVcs, Collection<FilePath>> myVcsToVirtualFiles;
|
private final Map<AbstractVcs, Collection<FilePath>> myVcsToVirtualFiles;
|
||||||
@@ -313,6 +311,7 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
|
|||||||
myProject = project;
|
myProject = project;
|
||||||
myProjectLevelVcsManager = ProjectLevelVcsManagerEx.getInstanceEx(project);
|
myProjectLevelVcsManager = ProjectLevelVcsManagerEx.getInstanceEx(project);
|
||||||
myDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
|
myDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject);
|
||||||
|
myChangeListManager = (ChangeListManagerEx)ChangeListManager.getInstance(myProject);
|
||||||
myRoots = roots;
|
myRoots = roots;
|
||||||
myVcsToVirtualFiles = vcsToVirtualFiles;
|
myVcsToVirtualFiles = vcsToVirtualFiles;
|
||||||
|
|
||||||
@@ -335,14 +334,14 @@ public abstract class AbstractCommonUpdateAction extends AbstractVcsAction {
|
|||||||
private void suspendIfNeeded() {
|
private void suspendIfNeeded() {
|
||||||
if (! myActionInfo.canChangeFileStatus()) {
|
if (! myActionInfo.canChangeFileStatus()) {
|
||||||
// i.e. for update but not for integrate or status
|
// i.e. for update but not for integrate or status
|
||||||
((VcsDirtyScopeManagerImpl) myDirtyScopeManager).suspendMe();
|
myChangeListManager.freezeImmediately(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void releaseIfNeeded() {
|
private void releaseIfNeeded() {
|
||||||
if (! myActionInfo.canChangeFileStatus()) {
|
if (! myActionInfo.canChangeFileStatus()) {
|
||||||
// i.e. for update but not for integrate or status
|
// i.e. for update but not for integrate or status
|
||||||
((VcsDirtyScopeManagerImpl) myDirtyScopeManager).reanimate();
|
myChangeListManager.letGo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user