com.intellij.ide.structureView.StructureViewExtension Java Examples

The following examples show how to use com.intellij.ide.structureView.StructureViewExtension. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PsiTreeElementBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @return element base children merged with children provided by extensions
 */
@Nonnull
public static List<StructureViewTreeElement> mergeWithExtensions(@Nonnull PsiElement element, @Nonnull Collection<StructureViewTreeElement> baseChildren, boolean withCustomRegions) {
  List<StructureViewTreeElement> result = new ArrayList<>(withCustomRegions ? CustomRegionStructureUtil.groupByCustomRegions(element, baseChildren) : baseChildren);
  StructureViewFactoryEx structureViewFactory = StructureViewFactoryEx.getInstanceEx(element.getProject());
  Class<? extends PsiElement> aClass = element.getClass();
  for (StructureViewExtension extension : structureViewFactory.getAllExtensions(aClass)) {
    StructureViewTreeElement[] children = extension.getChildren(element);
    if (children != null) {
      ContainerUtil.addAll(result, children);
    }
    extension.filterChildren(result, children == null || children.length == 0 ? Collections.emptyList() : Arrays.asList(children));
  }
  return result;
}