mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Disabling Read/Write filter in FindUsages toolbar and dding description to Read/Write filter
REF #41920 GitOrigin-RevId: 1ea4ee25356d861fb4f6008f1c7b63714065da29
This commit is contained in:
committed by
intellij-monorepo-bot
parent
beb05d920c
commit
f3e72bf79d
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
|
||||
public class UsageFilteringRuleProviderImpl implements UsageFilteringRuleProvider {
|
||||
private final ReadWriteState myReadWriteState = new ReadWriteState();
|
||||
private boolean readWriteActionsEnabled = true;
|
||||
|
||||
@Override
|
||||
public UsageFilteringRule @NotNull [] getActiveRules(@NotNull Project project) {
|
||||
@@ -78,6 +79,10 @@ public class UsageFilteringRuleProviderImpl implements UsageFilteringRuleProvide
|
||||
}
|
||||
}
|
||||
|
||||
public void setReadWriteEnabled(boolean readWriteEnabled) {
|
||||
this.readWriteActionsEnabled = readWriteEnabled;
|
||||
}
|
||||
|
||||
private class ShowReadAccessUsagesAction extends ToggleAction implements DumbAware {
|
||||
private ShowReadAccessUsagesAction() {
|
||||
super(UsageViewBundle.messagePointer("action.show.read.access"),
|
||||
@@ -96,6 +101,13 @@ public class UsageFilteringRuleProviderImpl implements UsageFilteringRuleProvide
|
||||
if (project == null) return;
|
||||
project.getMessageBus().syncPublisher(RULES_CHANGED).run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
super.update(e);
|
||||
Presentation presentation = e.getPresentation();
|
||||
presentation.setEnabled(readWriteActionsEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
private class ShowWriteAccessUsagesAction extends ToggleAction implements DumbAware {
|
||||
@@ -116,5 +128,12 @@ public class UsageFilteringRuleProviderImpl implements UsageFilteringRuleProvide
|
||||
if (project == null) return;
|
||||
project.getMessageBus().syncPublisher(RULES_CHANGED).run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
super.update(e);
|
||||
Presentation presentation = e.getPresentation();
|
||||
presentation.setEnabled(readWriteActionsEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.usages.impl;
|
||||
|
||||
import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector;
|
||||
import com.intellij.concurrency.JobSchedulerImpl;
|
||||
import com.intellij.find.FindManager;
|
||||
import com.intellij.icons.AllIcons;
|
||||
@@ -666,6 +667,27 @@ public class UsageViewImpl implements UsageViewEx {
|
||||
return list.toArray(UsageFilteringRule.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
protected void adjustReadWriteUsageFilter(Collection<? extends Usage> usages) {
|
||||
boolean b = usages.stream().anyMatch(usage -> {
|
||||
if(usage instanceof PsiElementUsage){
|
||||
PsiElement element = ((PsiElementUsage) usage).getElement();
|
||||
ReadWriteAccessDetector detector = ReadWriteAccessDetector.findDetector(element);
|
||||
if(detector.isDeclarationWriteAccess(element) || detector.isDeclarationWriteAccess(element)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
for (UsageFilteringRuleProvider provider : UsageFilteringRuleProvider.EP_NAME.getExtensionList()) {
|
||||
if (provider instanceof UsageFilteringRuleProvider){
|
||||
((UsageFilteringRuleProviderImpl)provider) .setReadWriteEnabled(b);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected static UsageGroupingRule @NotNull [] getActiveGroupingRules(@NotNull final Project project, @NotNull UsageViewSettings usageViewSettings) {
|
||||
final List<UsageGroupingRuleProvider> providers = UsageGroupingRuleProvider.EP_NAME.getExtensionList();
|
||||
List<UsageGroupingRule> list = new ArrayList<>(providers.size());
|
||||
@@ -1207,6 +1229,7 @@ public class UsageViewImpl implements UsageViewEx {
|
||||
@NotNull
|
||||
@Override
|
||||
public CompletableFuture<?> appendUsagesInBulk(@NotNull Collection<? extends Usage> usages) {
|
||||
adjustReadWriteUsageFilter(usages);
|
||||
CompletableFuture<Object> result = new CompletableFuture<>();
|
||||
addUpdateRequest(() -> ReadAction.run(() -> {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user