@Nullable protected <T> T findChildByClass(Class<T> aClass) { for (PsiElement cur = getFirstChild(); cur != null; cur = cur.getNextSibling()) { if (ReflectionCache.isInstance(cur, aClass)) return (T) cur; } return null; }
@NotNull protected <T> T[] findChildrenByClass(Class<T> aClass) { List<T> result = new ArrayList<T>(); for (PsiElement cur = getFirstChild(); cur != null; cur = cur.getNextSibling()) { if (ReflectionCache.isInstance(cur, aClass)) result.add((T) cur); } return result.toArray((T[]) Array.newInstance(aClass, result.size())); }