mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Make VcsDirtyScopeVfsListener a service, not a component
There is no need to be a component: no sense in listening VFS until ChangeListManager & VcsDirtyScopeManager are ready anyway. On the other hand, being a component makes impossible to depend on the VDSM as a parent component.
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
serviceImplementation="com.intellij.openapi.vcs.changes.ui.WolfChangesFileNameDecorator"/>
|
serviceImplementation="com.intellij.openapi.vcs.changes.ui.WolfChangesFileNameDecorator"/>
|
||||||
<projectService serviceInterface="com.intellij.openapi.vcs.CodeSmellDetector"
|
<projectService serviceInterface="com.intellij.openapi.vcs.CodeSmellDetector"
|
||||||
serviceImplementation="com.intellij.openapi.vcs.impl.CodeSmellDetectorImpl"/>
|
serviceImplementation="com.intellij.openapi.vcs.impl.CodeSmellDetectorImpl"/>
|
||||||
|
<projectService serviceImplementation="com.intellij.openapi.vcs.changes.VcsDirtyScopeVfsListener" />
|
||||||
|
|
||||||
<diff.merge.MergeTool implementation="com.intellij.openapi.vcs.changes.patch.tool.ApplyPatchMergeTool"/>
|
<diff.merge.MergeTool implementation="com.intellij.openapi.vcs.changes.patch.tool.ApplyPatchMergeTool"/>
|
||||||
<diff.DiffTool implementation="com.intellij.openapi.vcs.changes.patch.tool.ApplyPatchDiffTool"/>
|
<diff.DiffTool implementation="com.intellij.openapi.vcs.changes.patch.tool.ApplyPatchDiffTool"/>
|
||||||
|
|||||||
@@ -20,9 +20,6 @@
|
|||||||
<option name="workspace" value="true"/>
|
<option name="workspace" value="true"/>
|
||||||
<loadForDefaultProject/>
|
<loadForDefaultProject/>
|
||||||
</component>
|
</component>
|
||||||
<component>
|
|
||||||
<implementation-class>com.intellij.openapi.vcs.changes.VcsDirtyScopeVfsListener</implementation-class>
|
|
||||||
</component>
|
|
||||||
<!-- <component>
|
<!-- <component>
|
||||||
<implementation-class>com.intellij.openapi.vcs.changes.dbCommitted.HistoryCacheManager</implementation-class>
|
<implementation-class>com.intellij.openapi.vcs.changes.dbCommitted.HistoryCacheManager</implementation-class>
|
||||||
<option name="workspace" value="true"/>
|
<option name="workspace" value="true"/>
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
|||||||
};
|
};
|
||||||
private final ChangelistConflictTracker myConflictTracker;
|
private final ChangelistConflictTracker myConflictTracker;
|
||||||
private VcsDirtyScopeManager myDirtyScopeManager;
|
private VcsDirtyScopeManager myDirtyScopeManager;
|
||||||
private final VcsDirtyScopeVfsListener myVfsListener;
|
|
||||||
|
|
||||||
private boolean myModalNotificationsBlocked;
|
private boolean myModalNotificationsBlocked;
|
||||||
@NotNull private final Collection<LocalChangeList> myListsToBeDeleted = new HashSet<LocalChangeList>();
|
@NotNull private final Collection<LocalChangeList> myListsToBeDeleted = new HashSet<LocalChangeList>();
|
||||||
@@ -137,7 +136,6 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
|||||||
myFreezeName = new AtomicReference<String>(null);
|
myFreezeName = new AtomicReference<String>(null);
|
||||||
myAdditionalInfo = null;
|
myAdditionalInfo = null;
|
||||||
myChangesViewManager = myProject.isDefault() ? new DummyChangesView(myProject) : ChangesViewManager.getInstance(myProject);
|
myChangesViewManager = myProject.isDefault() ? new DummyChangesView(myProject) : ChangesViewManager.getInstance(myProject);
|
||||||
myVfsListener = VcsDirtyScopeVfsListener.getInstance(project);
|
|
||||||
myFileStatusManager = FileStatusManager.getInstance(myProject);
|
myFileStatusManager = FileStatusManager.getInstance(myProject);
|
||||||
myComposite = new FileHolderComposite(project);
|
myComposite = new FileHolderComposite(project);
|
||||||
myIgnoredIdeaLevel = new IgnoredFilesComponent(myProject, true);
|
myIgnoredIdeaLevel = new IgnoredFilesComponent(myProject, true);
|
||||||
@@ -1644,7 +1642,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
|||||||
|
|
||||||
@TestOnly
|
@TestOnly
|
||||||
public void waitUntilRefreshed() {
|
public void waitUntilRefreshed() {
|
||||||
myVfsListener.flushDirt();
|
VcsDirtyScopeVfsListener.getInstance(myProject).flushDirt();
|
||||||
myUpdater.waitUntilRefreshed();
|
myUpdater.waitUntilRefreshed();
|
||||||
waitUpdateAlarm();
|
waitUpdateAlarm();
|
||||||
}
|
}
|
||||||
@@ -1713,7 +1711,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
|||||||
updateImmediately();
|
updateImmediately();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
myVfsListener.flushDirt();
|
VcsDirtyScopeVfsListener.getInstance(myProject).flushDirt();
|
||||||
myUpdater.waitUntilRefreshed();
|
myUpdater.waitUntilRefreshed();
|
||||||
waitUpdateAlarm();
|
waitUpdateAlarm();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
+13
-32
@@ -15,9 +15,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.intellij.openapi.vcs.changes;
|
package com.intellij.openapi.vcs.changes;
|
||||||
|
|
||||||
|
import com.intellij.openapi.Disposable;
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.components.ProjectComponent;
|
import com.intellij.openapi.components.ServiceManager;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
|
import com.intellij.openapi.util.Disposer;
|
||||||
import com.intellij.openapi.vcs.ConstantZipperUpdater;
|
import com.intellij.openapi.vcs.ConstantZipperUpdater;
|
||||||
import com.intellij.openapi.vcs.FilePath;
|
import com.intellij.openapi.vcs.FilePath;
|
||||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||||
@@ -38,8 +40,7 @@ import java.util.List;
|
|||||||
/**
|
/**
|
||||||
* Listens to file system events and notifies VcsDirtyScopeManagers responsible for changed files to mark these files dirty.
|
* Listens to file system events and notifies VcsDirtyScopeManagers responsible for changed files to mark these files dirty.
|
||||||
*/
|
*/
|
||||||
public class VcsDirtyScopeVfsListener implements ProjectComponent, BulkFileListener {
|
public class VcsDirtyScopeVfsListener implements BulkFileListener, Disposable {
|
||||||
@NotNull private final Project myProject;
|
|
||||||
@NotNull private final ProjectLevelVcsManager myVcsManager;
|
@NotNull private final ProjectLevelVcsManager myVcsManager;
|
||||||
|
|
||||||
private boolean myForbid; // for tests only
|
private boolean myForbid; // for tests only
|
||||||
@@ -49,8 +50,9 @@ public class VcsDirtyScopeVfsListener implements ProjectComponent, BulkFileListe
|
|||||||
private final Object myLock;
|
private final Object myLock;
|
||||||
private final Runnable myDirtReporter;
|
private final Runnable myDirtReporter;
|
||||||
|
|
||||||
public VcsDirtyScopeVfsListener(@NotNull Project project, @NotNull ProjectLevelVcsManager vcsManager) {
|
public VcsDirtyScopeVfsListener(@NotNull Project project,
|
||||||
myProject = project;
|
@NotNull ProjectLevelVcsManager vcsManager,
|
||||||
|
@NotNull VcsDirtyScopeManager dirtyScopeManager) {
|
||||||
myVcsManager = vcsManager;
|
myVcsManager = vcsManager;
|
||||||
|
|
||||||
myLock = new Object();
|
myLock = new Object();
|
||||||
@@ -65,16 +67,19 @@ public class VcsDirtyScopeVfsListener implements ProjectComponent, BulkFileListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (FilesAndDirs filesAndDirs : list) {
|
for (FilesAndDirs filesAndDirs : list) {
|
||||||
dirtyScopeManager().filePathsDirty(filesAndDirs.dirtyFiles, filesAndDirs.dirtyDirs);
|
dirtyScopeManager.filePathsDirty(filesAndDirs.dirtyFiles, filesAndDirs.dirtyDirs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
myZipperUpdater = new ConstantZipperUpdater(300, Alarm.ThreadToUse.POOLED_THREAD, ApplicationManager.getApplication(),
|
myZipperUpdater = new ConstantZipperUpdater(300, Alarm.ThreadToUse.POOLED_THREAD, ApplicationManager.getApplication(),
|
||||||
myDirtReporter);
|
myDirtReporter);
|
||||||
|
|
||||||
|
Disposer.register(project, this);
|
||||||
|
project.getMessageBus().connect().subscribe(VirtualFileManager.VFS_CHANGES, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VcsDirtyScopeVfsListener getInstance(@NotNull Project project) {
|
public static VcsDirtyScopeVfsListener getInstance(@NotNull Project project) {
|
||||||
return project.getComponent(VcsDirtyScopeVfsListener.class);
|
return ServiceManager.getService(project, VcsDirtyScopeVfsListener.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setForbid(boolean forbid) {
|
public void setForbid(boolean forbid) {
|
||||||
@@ -87,31 +92,12 @@ public class VcsDirtyScopeVfsListener implements ProjectComponent, BulkFileListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
public void dispose() {
|
||||||
public String getComponentName() {
|
|
||||||
return VcsDirtyScopeVfsListener.class.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initComponent() {
|
|
||||||
myProject.getMessageBus().connect().subscribe(VirtualFileManager.VFS_CHANGES, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disposeComponent() {
|
|
||||||
synchronized (myLock) {
|
synchronized (myLock) {
|
||||||
myQueue.clear();
|
myQueue.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void projectOpened() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void projectClosed() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void before(@NotNull List<? extends VFileEvent> events) {
|
public void before(@NotNull List<? extends VFileEvent> events) {
|
||||||
if (myForbid || !myVcsManager.hasAnyMappings()) return;
|
if (myForbid || !myVcsManager.hasAnyMappings()) return;
|
||||||
@@ -167,11 +153,6 @@ public class VcsDirtyScopeVfsListener implements ProjectComponent, BulkFileListe
|
|||||||
markDirtyOnPooled(dirtyFilesAndDirs);
|
markDirtyOnPooled(dirtyFilesAndDirs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private VcsDirtyScopeManager dirtyScopeManager() {
|
|
||||||
return VcsDirtyScopeManager.getInstance(myProject);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void markDirtyOnPooled(@NotNull FilesAndDirs dirtyFilesAndDirs) {
|
private void markDirtyOnPooled(@NotNull FilesAndDirs dirtyFilesAndDirs) {
|
||||||
synchronized (myLock) {
|
synchronized (myLock) {
|
||||||
myQueue.add(dirtyFilesAndDirs);
|
myQueue.add(dirtyFilesAndDirs);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package com.intellij.vcs
|
package com.intellij.vcs
|
||||||
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
|
import com.intellij.openapi.components.service
|
||||||
import com.intellij.openapi.vcs.AbstractVcs
|
import com.intellij.openapi.vcs.AbstractVcs
|
||||||
import com.intellij.openapi.vcs.FilePath
|
import com.intellij.openapi.vcs.FilePath
|
||||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager
|
import com.intellij.openapi.vcs.ProjectLevelVcsManager
|
||||||
@@ -143,7 +144,7 @@ class VcsDirtyScopeManagerTest : VcsPlatformTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun disableVcsDirtyScopeVfsListener() {
|
private fun disableVcsDirtyScopeVfsListener() {
|
||||||
myProject.getComponent(VcsDirtyScopeVfsListener::class.java).setForbid(true)
|
myProject.service<VcsDirtyScopeVfsListener>().setForbid(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun disableChangeListManager() {
|
private fun disableChangeListManager() {
|
||||||
|
|||||||
Reference in New Issue
Block a user