Java Code Examples for com.intellij.psi.search.PsiElementProcessor#CollectElements

The following examples show how to use com.intellij.psi.search.PsiElementProcessor#CollectElements . 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: PsiTreeUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static <T extends PsiElement> Collection<T> findChildrenOfAnyType(@Nullable final PsiElement element, @Nonnull final Class<? extends T>... classes) {
  if (element == null) {
    return ContainerUtil.emptyList();
  }

  PsiElementProcessor.CollectElements<T> processor = new PsiElementProcessor.CollectElements<T>() {
    @Override
    public boolean execute(@Nonnull T each) {
      if (each == element) return true;
      if (instanceOf(each, classes)) {
        return super.execute(each);
      }
      return true;
    }
  };
  processElements(element, processor);
  return processor.getCollection();
}
 
Example 2
Source File: SyntheticFileSystemItem.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public PsiElement[] getChildren() {
  final PsiElementProcessor.CollectElements<PsiFileSystemItem> collector = new PsiElementProcessor.CollectElements<PsiFileSystemItem>();
  processChildren(collector);
  return collector.toArray(new PsiFileSystemItem[0]);
}