Search in sources :

Example 1 with UsageGroupingRuleProvider

use of com.intellij.usages.rules.UsageGroupingRuleProvider 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)

Aggregations

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 UsageGroupingRule (com.intellij.usages.rules.UsageGroupingRule)1 UsageGroupingRuleProvider (com.intellij.usages.rules.UsageGroupingRuleProvider)1