use of org.intellij.plugins.markdown.lang.psi.impl.MarkdownHeaderImpl in project intellij-plugins by JetBrains.
the class MarkdownStructureElement method getChildrenBase.
@NotNull
@Override
public Collection<StructureViewTreeElement> getChildrenBase() {
final List<StructureViewTreeElement> childrenElements = new ArrayList<>();
final PsiElement myElement = getElement();
if (myElement == null)
return childrenElements;
final PsiElement structureContainer = myElement instanceof MarkdownFile ? myElement.getFirstChild() : getParentOfType(myElement, TRANSPARENT_CONTAINERS);
if (structureContainer == null) {
return Collections.emptyList();
}
final MarkdownPsiElement currentHeader = myElement instanceof MarkdownHeaderImpl ? ((MarkdownHeaderImpl) myElement) : null;
processContainer(structureContainer, currentHeader, currentHeader, element -> childrenElements.add(new MarkdownStructureElement(element)));
return childrenElements;
}
use of org.intellij.plugins.markdown.lang.psi.impl.MarkdownHeaderImpl in project intellij-plugins by JetBrains.
the class MarkdownStructureElement method processContainer.
private static void processContainer(@NotNull PsiElement container, @Nullable PsiElement sameLevelRestriction, @Nullable MarkdownPsiElement from, @NotNull Consumer<? super PsiElement> resultConsumer) {
PsiElement nextSibling = from == null ? container.getFirstChild() : from.getNextSibling();
PsiElement maxContentLevel = null;
while (nextSibling != null) {
if (TRANSPARENT_CONTAINERS.contains(PsiUtilCore.getElementType(nextSibling)) && maxContentLevel == null) {
processContainer(nextSibling, null, null, resultConsumer);
} else if (nextSibling instanceof MarkdownHeaderImpl) {
if (sameLevelRestriction != null && isSameLevelOrHigher(nextSibling, sameLevelRestriction)) {
break;
}
if (maxContentLevel == null || isSameLevelOrHigher(nextSibling, maxContentLevel)) {
maxContentLevel = nextSibling;
final IElementType type = nextSibling.getNode().getElementType();
if (PRESENTABLE_TYPES.contains(type)) {
resultConsumer.consume(nextSibling);
}
}
}
nextSibling = nextSibling.getNextSibling();
}
}
Aggregations