mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
run only dumb-aware usage grouping rules in dumb mode (EA-65019 - INRE: FileBasedIndexImpl.handleDumbMode; IDEA-141160 Indexing prevents "Find in Path")
This commit is contained in:
@@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.actionSystem.DataSink;
|
||||
import com.intellij.openapi.actionSystem.TypeSafeDataProvider;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -40,7 +41,7 @@ import javax.swing.*;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class ClassGroupingRule implements UsageGroupingRule {
|
||||
public class ClassGroupingRule implements UsageGroupingRule, DumbAware {
|
||||
@Override
|
||||
public UsageGroup groupUsage(@NotNull Usage usage) {
|
||||
if (!(usage instanceof PsiElementUsage)) {
|
||||
|
||||
@@ -35,7 +35,6 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.util.ProgressWrapper;
|
||||
import com.intellij.openapi.progress.util.TooManyUsagesStatus;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.DumbServiceImpl;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -210,7 +209,7 @@ public class FindInProjectUtil {
|
||||
TooManyUsagesStatus tooManyUsagesStatus = TooManyUsagesStatus.getFrom(indicator);
|
||||
do {
|
||||
tooManyUsagesStatus.pauseProcessingIfTooManyUsages(); // wait for user out of read action
|
||||
found = DumbService.getInstance(psiFile.getProject()).runReadActionInSmartMode(new Computable<Integer>() {
|
||||
found = ApplicationManager.getApplication().runReadAction(new Computable<Integer>() {
|
||||
@Override
|
||||
@NotNull
|
||||
public Integer compute() {
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ public class UsageNodeTreeBuilderTest extends LightPlatformTestCase {
|
||||
UsageViewTreeModelBuilder model = new UsageViewTreeModelBuilder(new UsageViewPresentation(), UsageTarget.EMPTY_ARRAY);
|
||||
GroupNode rootNode = new GroupNode(null, 0, model);
|
||||
model.setRoot(rootNode);
|
||||
UsageNodeTreeBuilder usageNodeTreeBuilder = new UsageNodeTreeBuilder(UsageTarget.EMPTY_ARRAY, rules, UsageFilteringRule.EMPTY_ARRAY, rootNode);
|
||||
UsageNodeTreeBuilder usageNodeTreeBuilder = new UsageNodeTreeBuilder(UsageTarget.EMPTY_ARRAY, rules, UsageFilteringRule.EMPTY_ARRAY, rootNode, ourProject);
|
||||
for (Usage usage : usages) {
|
||||
usageNodeTreeBuilder.appendUsage(usage, new Consumer<Runnable>() {
|
||||
@Override
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.util.ProgressWrapper;
|
||||
import com.intellij.openapi.progress.util.TooManyUsagesStatus;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
@@ -288,7 +287,7 @@ class SearchForUsagesRunnable implements Runnable {
|
||||
final Usage firstUsage = myFirstUsage.get();
|
||||
if (firstUsage != null) {
|
||||
final UsageViewImpl finalUsageView = usageView;
|
||||
DumbService.getInstance(myProject).runReadActionInSmartMode(new Runnable() {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
finalUsageView.appendUsage(firstUsage);
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.usages.impl;
|
||||
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.usages.Usage;
|
||||
import com.intellij.usages.UsageGroup;
|
||||
import com.intellij.usages.UsageTarget;
|
||||
@@ -31,6 +33,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
class UsageNodeTreeBuilder {
|
||||
private final GroupNode myRoot;
|
||||
private final Project myProject;
|
||||
private final UsageTarget[] myTargets;
|
||||
private UsageGroupingRule[] myGroupingRules;
|
||||
private UsageFilteringRule[] myFilteringRules;
|
||||
@@ -38,11 +41,13 @@ class UsageNodeTreeBuilder {
|
||||
UsageNodeTreeBuilder(@NotNull UsageTarget[] targets,
|
||||
@NotNull UsageGroupingRule[] groupingRules,
|
||||
@NotNull UsageFilteringRule[] filteringRules,
|
||||
@NotNull GroupNode root) {
|
||||
@NotNull GroupNode root,
|
||||
@NotNull Project project) {
|
||||
myTargets = targets;
|
||||
myGroupingRules = groupingRules;
|
||||
myFilteringRules = filteringRules;
|
||||
myRoot = root;
|
||||
myProject = project;
|
||||
}
|
||||
|
||||
public void setGroupingRules(@NotNull UsageGroupingRule[] rules) {
|
||||
@@ -73,9 +78,13 @@ class UsageNodeTreeBuilder {
|
||||
UsageNode appendUsage(@NotNull Usage usage, @NotNull Consumer<Runnable> edtQueue) {
|
||||
if (!isVisible(usage)) return null;
|
||||
|
||||
final boolean dumb = DumbService.isDumb(myProject);
|
||||
|
||||
GroupNode lastGroupNode = myRoot;
|
||||
for (int i = 0; i < myGroupingRules.length; i++) {
|
||||
final UsageGroupingRule rule = myGroupingRules[i];
|
||||
if (dumb && !DumbService.isDumbAware(rule)) continue;
|
||||
|
||||
final UsageGroup group;
|
||||
if (rule instanceof UsageGroupingRuleEx) {
|
||||
group = ((UsageGroupingRuleEx) rule).groupUsage(usage, myTargets);
|
||||
|
||||
@@ -195,7 +195,7 @@ public class UsageViewImpl implements UsageView, UsageModelTracker.UsageModelTra
|
||||
|
||||
myModel = new UsageViewTreeModelBuilder(myPresentation, targets);
|
||||
myRoot = (GroupNode)myModel.getRoot();
|
||||
myBuilder = new UsageNodeTreeBuilder(myTargets, getActiveGroupingRules(project), getActiveFilteringRules(project), myRoot);
|
||||
myBuilder = new UsageNodeTreeBuilder(myTargets, getActiveGroupingRules(project), getActiveFilteringRules(project), myRoot, myProject);
|
||||
|
||||
final MessageBusConnection messageBusConnection = myProject.getMessageBus().connect(this);
|
||||
messageBusConnection.subscribe(UsageFilteringRuleProvider.RULES_CHANGED, new Runnable() {
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.actionSystem.DataSink;
|
||||
import com.intellij.openapi.actionSystem.TypeSafeDataProvider;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.openapi.vcs.FileStatusManager;
|
||||
@@ -43,7 +44,7 @@ import java.io.File;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class DirectoryGroupingRule implements UsageGroupingRule {
|
||||
public class DirectoryGroupingRule implements UsageGroupingRule, DumbAware {
|
||||
public static DirectoryGroupingRule getInstance(Project project) {
|
||||
return ServiceManager.getService(project, DirectoryGroupingRule.class);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.intellij.usages.impl.rules;
|
||||
import com.intellij.injected.editor.VirtualFileWindow;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Iconable;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
@@ -40,7 +41,7 @@ import javax.swing.*;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class FileGroupingRule implements UsageGroupingRule {
|
||||
public class FileGroupingRule implements UsageGroupingRule, DumbAware {
|
||||
private final Project myProject;
|
||||
|
||||
public FileGroupingRule(Project project) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.actionSystem.TypeSafeDataProvider;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleType;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.roots.OrderEntry;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
import com.intellij.usageView.UsageViewBundle;
|
||||
@@ -38,7 +39,7 @@ import javax.swing.*;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class ModuleGroupingRule implements UsageGroupingRule {
|
||||
public class ModuleGroupingRule implements UsageGroupingRule, DumbAware {
|
||||
@Override
|
||||
public UsageGroup groupUsage(@NotNull Usage usage) {
|
||||
if (usage instanceof UsageInModule) {
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package com.intellij.usages.impl.rules;
|
||||
|
||||
import com.intellij.openapi.roots.GeneratedSourcesFilter;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.GeneratedSourcesFilter;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usageView.UsageViewBundle;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.usages.impl.rules;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.vcs.FileStatus;
|
||||
@@ -35,7 +36,7 @@ import javax.swing.*;
|
||||
/**
|
||||
* @author max
|
||||
*/
|
||||
public class UsageScopeGroupingRule implements UsageGroupingRule {
|
||||
public class UsageScopeGroupingRule implements UsageGroupingRule, DumbAware {
|
||||
@Override
|
||||
public UsageGroup groupUsage(@NotNull Usage usage) {
|
||||
if (!(usage instanceof PsiElementUsage)) {
|
||||
|
||||
@@ -20,8 +20,17 @@ import com.intellij.usages.UsageGroup;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* A rule specifying how specific Usage View elements should be grouped.
|
||||
*
|
||||
* During indexing, only instances that implement {@link com.intellij.openapi.project.DumbAware} are executed.
|
||||
*/
|
||||
public interface UsageGroupingRule {
|
||||
UsageGroupingRule[] EMPTY_ARRAY = new UsageGroupingRule[0];
|
||||
|
||||
/**
|
||||
* @return a group a specific usage should be placed into, or null, if this rule doesn't apply to this kind of usages.
|
||||
*/
|
||||
@Nullable
|
||||
UsageGroup groupUsage(@NotNull Usage usage);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user