use of com.intellij.psi.scope.processor.FilterElementProcessor in project intellij-community by JetBrains.
the class Html5SectionsNodeProvider method provideNodes.
@NotNull
@Override
public Collection<Html5SectionTreeElement> provideNodes(@NotNull final TreeElement node) {
if (!(node instanceof HtmlFileTreeElement))
return Collections.emptyList();
final XmlFile xmlFile = ((HtmlFileTreeElement) node).getElement();
final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument();
if (document == null)
return Collections.emptyList();
final List<XmlTag> rootTags = new ArrayList<>();
document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document);
final Collection<Html5SectionTreeElement> result = new ArrayList<>();
for (XmlTag tag : rootTags) {
result.addAll(Html5SectionsProcessor.processAndGetRootSections(tag));
}
return result;
}
use of com.intellij.psi.scope.processor.FilterElementProcessor in project intellij-community by JetBrains.
the class HtmlFileTreeElement method getChildrenBase.
@Override
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
if (isHtml5SectionsMode()) {
// Html5SectionsNodeProvider will return its structure
return Collections.emptyList();
}
final XmlFile xmlFile = getElement();
final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument();
if (document == null) {
return Collections.emptyList();
}
final List<XmlTag> rootTags = new SmartList<>();
document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document);
if (rootTags.isEmpty()) {
return Collections.emptyList();
} else if (rootTags.size() == 1) {
final XmlTag rootTag = rootTags.get(0);
if ("html".equalsIgnoreCase(rootTag.getLocalName())) {
final XmlTag[] subTags = rootTag.getSubTags();
if (subTags.length == 1 && ("head".equalsIgnoreCase(subTags[0].getLocalName()) || "body".equalsIgnoreCase(subTags[0].getLocalName()))) {
return new HtmlTagTreeElement(subTags[0]).getChildrenBase();
}
return new HtmlTagTreeElement(rootTag).getChildrenBase();
}
return Collections.<StructureViewTreeElement>singletonList(new HtmlTagTreeElement(rootTag));
} else {
final Collection<StructureViewTreeElement> result = new ArrayList<>(rootTags.size());
for (XmlTag tag : rootTags) {
result.add(new HtmlTagTreeElement(tag));
}
return result;
}
}
use of com.intellij.psi.scope.processor.FilterElementProcessor in project intellij-community by JetBrains.
the class XmlElementDescriptorImpl method doCollectAttlistDeclarations.
private static XmlAttlistDecl[] doCollectAttlistDeclarations(XmlElement xmlElement) {
final List<XmlAttlistDecl> result = new ArrayList<>();
XmlUtil.processXmlElements(xmlElement, new FilterElementProcessor(new ClassFilter(XmlAttlistDecl.class), result), false, false, XmlUtil.getContainingFile(xmlElement));
return result.toArray(new XmlAttlistDecl[result.size()]);
}
use of com.intellij.psi.scope.processor.FilterElementProcessor in project intellij-community by JetBrains.
the class XmlNSDescriptorImpl method doBuildDeclarationMap.
// Read-only calculation
private CachedValue<Map<String, XmlElementDescriptor>> doBuildDeclarationMap() {
return CachedValuesManager.getManager(myElement.getProject()).createCachedValue(() -> {
final List<XmlElementDecl> result = new ArrayList<>();
myElement.processElements(new FilterElementProcessor(new ClassFilter(XmlElementDecl.class), result), getDeclaration());
final Map<String, XmlElementDescriptor> ret = new LinkedHashMap<>((int) (result.size() * 1.5));
Set<PsiFile> dependencies = new THashSet<>(1);
dependencies.add(myDescriptorFile);
for (final XmlElementDecl xmlElementDecl : result) {
final String name = xmlElementDecl.getName();
if (name != null) {
if (!ret.containsKey(name)) {
ret.put(name, new XmlElementDescriptorImpl(xmlElementDecl));
// if element descriptor was produced from entity reference use proper dependency
PsiElement dependingElement = xmlElementDecl.getUserData(XmlElement.DEPENDING_ELEMENT);
if (dependingElement != null) {
PsiFile dependingElementContainingFile = dependingElement.getContainingFile();
if (dependingElementContainingFile != null)
dependencies.add(dependingElementContainingFile);
}
}
}
}
return new CachedValueProvider.Result<>(ret, dependencies.toArray());
}, false);
}
use of com.intellij.psi.scope.processor.FilterElementProcessor in project intellij-community by JetBrains.
the class XmlEnumeratedTypeImpl method getEnumeratedValues.
@Override
public XmlElement[] getEnumeratedValues() {
final List<XmlElement> result = new ArrayList<>();
processElements(new FilterElementProcessor(new XmlTokenTypeFilter(XmlTokenType.XML_NAME), result), this);
return result.toArray(new XmlElement[result.size()]);
}
Aggregations