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);
}
}
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);
}
Aggregations