mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-21 14:37:45 +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"/>
|
||||
<projectService serviceInterface="com.intellij.openapi.vcs.CodeSmellDetector"
|
||||
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.DiffTool implementation="com.intellij.openapi.vcs.changes.patch.tool.ApplyPatchDiffTool"/>
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
<option name="workspace" value="true"/>
|
||||
<loadForDefaultProject/>
|
||||
</component>
|
||||
<component>
|
||||
<implementation-class>com.intellij.openapi.vcs.changes.VcsDirtyScopeVfsListener</implementation-class>
|
||||
</component>
|
||||
<!-- <component>
|
||||
<implementation-class>com.intellij.openapi.vcs.changes.dbCommitted.HistoryCacheManager</implementation-class>
|
||||
<option name="workspace" value="true"/>
|
||||
|
||||
@@ -118,7 +118,6 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
};
|
||||
private final ChangelistConflictTracker myConflictTracker;
|
||||
private VcsDirtyScopeManager myDirtyScopeManager;
|
||||
private final VcsDirtyScopeVfsListener myVfsListener;
|
||||
|
||||
private boolean myModalNotificationsBlocked;
|
||||
@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);
|
||||
myAdditionalInfo = null;
|
||||
myChangesViewManager = myProject.isDefault() ? new DummyChangesView(myProject) : ChangesViewManager.getInstance(myProject);
|
||||
myVfsListener = VcsDirtyScopeVfsListener.getInstance(project);
|
||||
myFileStatusManager = FileStatusManager.getInstance(myProject);
|
||||
myComposite = new FileHolderComposite(project);
|
||||
myIgnoredIdeaLevel = new IgnoredFilesComponent(myProject, true);
|
||||
@@ -1644,7 +1642,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
|
||||
@TestOnly
|
||||
public void waitUntilRefreshed() {
|
||||
myVfsListener.flushDirt();
|
||||
VcsDirtyScopeVfsListener.getInstance(myProject).flushDirt();
|
||||
myUpdater.waitUntilRefreshed();
|
||||
waitUpdateAlarm();
|
||||
}
|
||||
@@ -1713,7 +1711,7 @@ public class ChangeListManagerImpl extends ChangeListManagerEx implements Projec
|
||||
updateImmediately();
|
||||
return true;
|
||||
}
|
||||
myVfsListener.flushDirt();
|
||||
VcsDirtyScopeVfsListener.getInstance(myProject).flushDirt();
|
||||
myUpdater.waitUntilRefreshed();
|
||||
waitUpdateAlarm();
|
||||
return true;
|
||||
|
||||
+13
-32
@@ -15,9 +15,11 @@
|
||||
*/
|
||||
package com.intellij.openapi.vcs.changes;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
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.util.Disposer;
|
||||
import com.intellij.openapi.vcs.ConstantZipperUpdater;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
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.
|
||||
*/
|
||||
public class VcsDirtyScopeVfsListener implements ProjectComponent, BulkFileListener {
|
||||
@NotNull private final Project myProject;
|
||||
public class VcsDirtyScopeVfsListener implements BulkFileListener, Disposable {
|
||||
@NotNull private final ProjectLevelVcsManager myVcsManager;
|
||||
|
||||
private boolean myForbid; // for tests only
|
||||
@@ -49,8 +50,9 @@ public class VcsDirtyScopeVfsListener implements ProjectComponent, BulkFileListe
|
||||
private final Object myLock;
|
||||
private final Runnable myDirtReporter;
|
||||
|
||||
public VcsDirtyScopeVfsListener(@NotNull Project project, @NotNull ProjectLevelVcsManager vcsManager) {
|
||||
myProject = project;
|
||||
public VcsDirtyScopeVfsListener(@NotNull Project project,
|
||||
@NotNull ProjectLevelVcsManager vcsManager,
|
||||
@NotNull VcsDirtyScopeManager dirtyScopeManager) {
|
||||
myVcsManager = vcsManager;
|
||||
|
||||
myLock = new Object();
|
||||
@@ -65,16 +67,19 @@ public class VcsDirtyScopeVfsListener implements ProjectComponent, BulkFileListe
|
||||
}
|
||||
|
||||
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(),
|
||||
myDirtReporter);
|
||||
|
||||
Disposer.register(project, this);
|
||||
project.getMessageBus().connect().subscribe(VirtualFileManager.VFS_CHANGES, this);
|
||||
}
|
||||
|
||||
public static VcsDirtyScopeVfsListener getInstance(@NotNull Project project) {
|
||||
return project.getComponent(VcsDirtyScopeVfsListener.class);
|
||||
return ServiceManager.getService(project, VcsDirtyScopeVfsListener.class);
|
||||
}
|
||||
|
||||
public void setForbid(boolean forbid) {
|
||||
@@ -87,31 +92,12 @@ public class VcsDirtyScopeVfsListener implements ProjectComponent, BulkFileListe
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getComponentName() {
|
||||
return VcsDirtyScopeVfsListener.class.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
myProject.getMessageBus().connect().subscribe(VirtualFileManager.VFS_CHANGES, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposeComponent() {
|
||||
public void dispose() {
|
||||
synchronized (myLock) {
|
||||
myQueue.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectOpened() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void projectClosed() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void before(@NotNull List<? extends VFileEvent> events) {
|
||||
if (myForbid || !myVcsManager.hasAnyMappings()) return;
|
||||
@@ -167,11 +153,6 @@ public class VcsDirtyScopeVfsListener implements ProjectComponent, BulkFileListe
|
||||
markDirtyOnPooled(dirtyFilesAndDirs);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private VcsDirtyScopeManager dirtyScopeManager() {
|
||||
return VcsDirtyScopeManager.getInstance(myProject);
|
||||
}
|
||||
|
||||
private void markDirtyOnPooled(@NotNull FilesAndDirs dirtyFilesAndDirs) {
|
||||
synchronized (myLock) {
|
||||
myQueue.add(dirtyFilesAndDirs);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.vcs
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.vcs.AbstractVcs
|
||||
import com.intellij.openapi.vcs.FilePath
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager
|
||||
@@ -143,7 +144,7 @@ class VcsDirtyScopeManagerTest : VcsPlatformTest() {
|
||||
}
|
||||
|
||||
private fun disableVcsDirtyScopeVfsListener() {
|
||||
myProject.getComponent(VcsDirtyScopeVfsListener::class.java).setForbid(true)
|
||||
myProject.service<VcsDirtyScopeVfsListener>().setForbid(true)
|
||||
}
|
||||
|
||||
private fun disableChangeListManager() {
|
||||
|
||||
Reference in New Issue
Block a user