mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
made AnnotationsPreloader a Service
GitOrigin-RevId: 893c1be5d3366bad1b283970eba990b25a8db016
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e558acfc91
commit
efcae1cd5f
@@ -1,8 +1,5 @@
|
||||
<idea-plugin>
|
||||
<project-components>
|
||||
<component>
|
||||
<implementation-class>com.intellij.openapi.vcs.annotate.AnnotationsPreloader</implementation-class>
|
||||
</component>
|
||||
<component>
|
||||
<implementation-class>com.intellij.openapi.vcs.impl.VcsDirectoryMappingStorage</implementation-class>
|
||||
</component>
|
||||
@@ -78,4 +75,9 @@
|
||||
key="ignore.codeInspection.duplicateEntry"
|
||||
level="WARNING"/>
|
||||
</extensions>
|
||||
|
||||
<projectListeners>
|
||||
<listener class="com.intellij.openapi.vcs.annotate.AnnotationsPreloader$AnnotationsPreloaderFileEditorManagerListener"
|
||||
topic="com.intellij.openapi.fileEditor.FileEditorManagerListener"/>
|
||||
</projectListeners>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package com.intellij.openapi.vcs.annotate;
|
||||
|
||||
import com.intellij.ide.PowerSaveMode;
|
||||
import com.intellij.openapi.components.Service;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
|
||||
@@ -21,7 +22,8 @@ import com.intellij.util.ui.update.Update;
|
||||
import com.intellij.vcs.CacheableAnnotationProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class AnnotationsPreloader {
|
||||
@Service
|
||||
public final class AnnotationsPreloader {
|
||||
private static final Logger LOG = Logger.getInstance(AnnotationsPreloader.class);
|
||||
|
||||
private final MergingUpdateQueue myUpdateQueue;
|
||||
@@ -30,17 +32,6 @@ public class AnnotationsPreloader {
|
||||
public AnnotationsPreloader(@NotNull Project project) {
|
||||
myProject = project;
|
||||
myUpdateQueue = new MergingUpdateQueue("Annotations preloader queue", 1000, true, null, project, null, false);
|
||||
|
||||
project.getMessageBus().connect().subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
|
||||
@Override
|
||||
public void selectionChanged(@NotNull FileEditorManagerEvent event) {
|
||||
if (!isEnabled()) return;
|
||||
VirtualFile file = event.getNewFile();
|
||||
if (file != null) {
|
||||
schedulePreloading(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean isEnabled() {
|
||||
@@ -86,4 +77,21 @@ public class AnnotationsPreloader {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class AnnotationsPreloaderFileEditorManagerListener implements FileEditorManagerListener {
|
||||
private final Project myProject;
|
||||
|
||||
public AnnotationsPreloaderFileEditorManagerListener(Project project) {
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectionChanged(@NotNull FileEditorManagerEvent event) {
|
||||
if (!isEnabled()) return;
|
||||
VirtualFile file = event.getNewFile();
|
||||
if (file != null) {
|
||||
myProject.getService(AnnotationsPreloader.class).schedulePreloading(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user