Search in sources :

Example 1 with UsageGroupingRule

use of com.intellij.usages.rules.UsageGroupingRule in project intellij-community by JetBrains.

the class UsageNodeTreeBuilderTest method buildUsageTree.

private GroupNode buildUsageTree(int[] indices, UsageGroupingRule[] rules) {
    Usage[] usages = new Usage[indices.length];
    for (int i = 0; i < usages.length; i++) {
        usages[i] = createUsage(indices[i]);
    }
    UsageViewPresentation presentation = new UsageViewPresentation();
    presentation.setUsagesString("searching for mock usages");
    ExtensionsArea area = Extensions.getRootArea();
    ExtensionPoint<UsageGroupingRuleProvider> point = area.getExtensionPoint(UsageGroupingRuleProvider.EP_NAME);
    UsageGroupingRuleProvider provider = new UsageGroupingRuleProvider() {

        @NotNull
        @Override
        public UsageGroupingRule[] getActiveRules(Project project) {
            return rules;
        }

        @NotNull
        @Override
        public AnAction[] createGroupingActions(UsageView view) {
            return AnAction.EMPTY_ARRAY;
        }
    };
    point.registerExtension(provider);
    try {
        UsageViewImpl usageView = new UsageViewImpl(getProject(), presentation, UsageTarget.EMPTY_ARRAY, null);
        Disposer.register(getTestRootDisposable(), usageView);
        for (Usage usage : usages) {
            usageView.appendUsage(usage);
        }
        UIUtil.dispatchAllInvocationEvents();
        return usageView.getRoot();
    } finally {
        point.unregisterExtension(provider);
    }
}
Also used : ExtensionsArea(com.intellij.openapi.extensions.ExtensionsArea) Project(com.intellij.openapi.project.Project) UsageGroupingRule(com.intellij.usages.rules.UsageGroupingRule) AnAction(com.intellij.openapi.actionSystem.AnAction) ExtensionPoint(com.intellij.openapi.extensions.ExtensionPoint) UsageGroupingRuleProvider(com.intellij.usages.rules.UsageGroupingRuleProvider)

Example 2 with UsageGroupingRule

use of com.intellij.usages.rules.UsageGroupingRule in project intellij-community by JetBrains.

the class UsageNodeTreeBuilder method appendUsage.

UsageNode appendUsage(@NotNull Usage usage, @NotNull Consumer<Node> edtInsertedUnderQueue, boolean filterDuplicateLines) {
    if (!isVisible(usage))
        return null;
    final boolean dumb = DumbService.isDumb(myProject);
    GroupNode groupNode = myRoot;
    for (int i = 0; i < myGroupingRules.length; i++) {
        UsageGroupingRule rule = myGroupingRules[i];
        if (dumb && !DumbService.isDumbAware(rule))
            continue;
        UsageGroup group = rule instanceof UsageGroupingRuleEx ? ((UsageGroupingRuleEx) rule).groupUsage(usage, myTargets) : rule.groupUsage(usage);
        if (group != null) {
            groupNode = groupNode.addOrGetGroup(group, i, edtInsertedUnderQueue);
        }
    }
    return groupNode.addUsage(usage, edtInsertedUnderQueue, filterDuplicateLines);
}
Also used : UsageGroupingRule(com.intellij.usages.rules.UsageGroupingRule) UsageGroup(com.intellij.usages.UsageGroup) UsageGroupingRuleEx(com.intellij.usages.rules.UsageGroupingRuleEx)

Aggregations

UsageGroupingRule (com.intellij.usages.rules.UsageGroupingRule)2 AnAction (com.intellij.openapi.actionSystem.AnAction)1 ExtensionPoint (com.intellij.openapi.extensions.ExtensionPoint)1 ExtensionsArea (com.intellij.openapi.extensions.ExtensionsArea)1 Project (com.intellij.openapi.project.Project)1 UsageGroup (com.intellij.usages.UsageGroup)1 UsageGroupingRuleEx (com.intellij.usages.rules.UsageGroupingRuleEx)1 UsageGroupingRuleProvider (com.intellij.usages.rules.UsageGroupingRuleProvider)1