@Override public XmlAttributeDecl[] getAttributeDecls() { final List<XmlAttributeDecl> result = new ArrayList<XmlAttributeDecl>(); processElements(new FilterElementProcessor(new ClassFilter(XmlAttributeDecl.class), result) { @Override public boolean execute(@NotNull final PsiElement element) { if (element instanceof XmlAttributeDecl) { if (element.getNextSibling() == null && element.getChildren().length == 1) { return true; } return super.execute(element); } return true; } }, this); return result.toArray(new XmlAttributeDecl[result.size()]); }
@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<XmlTag>(); document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document); final Collection<Html5SectionTreeElement> result = new ArrayList<Html5SectionTreeElement>(); for (XmlTag tag : rootTags) { result.addAll(Html5SectionsProcessor.processAndGetRootSections(tag)); } return result; }
private CachedValue<Map<String, XmlElementDescriptor>> doBuildDeclarationMap() { return CachedValuesManager.getManager(myElement.getProject()).createCachedValue(new CachedValueProvider<Map<String, XmlElementDescriptor>>() { public Result<Map<String, XmlElementDescriptor>> compute() { final List<XmlElementDecl> result = new ArrayList<XmlElementDecl>(); myElement.processElements(new FilterElementProcessor(new ClassFilter(XmlElementDecl.class), result), getDeclaration()); final Map<String, XmlElementDescriptor> ret = new LinkedHashMap<String, XmlElementDescriptor>((int)(result.size() * 1.5)); for (final XmlElementDecl xmlElementDecl : result) { final String name = xmlElementDecl.getName(); if (name != null) { if (!ret.containsKey(name)) { ret.put(name, new XmlElementDescriptorImpl(xmlElementDecl)); } } } return new Result<Map<String, XmlElementDescriptor>>(ret, myDescriptorFile); } }, false); }
@Override public Collection<Html5SectionTreeElement> provideNodes(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<XmlTag>(); document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document); final Collection<Html5SectionTreeElement> result = new ArrayList<Html5SectionTreeElement>(); for (XmlTag tag : rootTags) { result.addAll(Html5SectionsProcessor.processAndGetRootSections(tag)); } return result; }
public Collection<Html5SectionTreeElement> provideNodes(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<XmlTag>(); document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document); final Collection<Html5SectionTreeElement> result = new ArrayList<Html5SectionTreeElement>(); for (XmlTag tag : rootTags) { result.addAll(Html5SectionsProcessor.processAndGetRootSections(tag)); } return result; }
private CachedValue<Map<String, XmlElementDescriptor>> doBuildDeclarationMap() { return CachedValuesManager.getManager(myElement.getProject()).createCachedValue(new CachedValueProvider<Map<String, XmlElementDescriptor>>() { @Override public Result<Map<String, XmlElementDescriptor>> compute() { final List<XmlElementDecl> result = new ArrayList<XmlElementDecl>(); myElement.processElements(new FilterElementProcessor(new ClassFilter(XmlElementDecl.class), result), getDeclaration()); final Map<String, XmlElementDescriptor> ret = new LinkedHashMap<String, XmlElementDescriptor>((int)(result.size() * 1.5)); Set<PsiFile> dependencies = new THashSet<PsiFile>(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 Result<Map<String, XmlElementDescriptor>>(ret, dependencies.toArray()); } }, false); }
@Override @NotNull public Collection<StructureViewTreeElement> getChildrenBase() { if (isHtml5SectionsMode()) { return Collections.emptyList(); // Html5SectionsNodeProvider will return its structure } final XmlFile xmlFile = getElement(); final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument(); if (document == null) { return Collections.emptyList(); } final List<XmlTag> rootTags = new SmartList<XmlTag>(); 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<StructureViewTreeElement>(rootTags.size()); for (XmlTag tag : rootTags) { result.add(new HtmlTagTreeElement(tag)); } return result; } }
public XmlAttributeDecl[] getAttributeDecls() { final List<XmlAttributeDecl> result = new ArrayList<XmlAttributeDecl>(); processElements(new FilterElementProcessor(new ClassFilter(XmlAttributeDecl.class), result) { public boolean execute(@NotNull final PsiElement element) { if (element instanceof XmlAttributeDecl) { if (element.getNextSibling() == null && element.getChildren().length == 1) { return true; } return super.execute(element); } return true; } }, this); return result.toArray(new XmlAttributeDecl[result.size()]); }
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); }
@NotNull public Collection<StructureViewTreeElement> getChildrenBase() { if (isHtml5SectionsMode()) { return Collections.emptyList(); // Html5SectionsNodeProvider will return its structure } final XmlFile xmlFile = getElement(); final XmlDocument document = xmlFile == null ? null : xmlFile.getDocument(); if (document == null) return Collections.emptyList(); final List<XmlTag> rootTags = new ArrayList<XmlTag>(); document.processElements(new FilterElementProcessor(XmlTagFilter.INSTANCE, rootTags), document); if (rootTags.isEmpty()) return Collections.emptyList(); 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 Arrays.<StructureViewTreeElement>asList(new HtmlTagTreeElement(rootTag)); } else { final Collection<StructureViewTreeElement> result = new ArrayList<StructureViewTreeElement>(); for (XmlTag tag : rootTags) { result.add(new HtmlTagTreeElement(tag)); } return result; } }
private static XmlAttlistDecl[] doCollectAttlistDeclarations(XmlElement xmlElement) { final List<XmlAttlistDecl> result = new ArrayList<XmlAttlistDecl>(); XmlUtil.processXmlElements(xmlElement, new FilterElementProcessor(new ClassFilter(XmlAttlistDecl.class), result), false, false, XmlUtil.getContainingFile(xmlElement)); return result.toArray(new XmlAttlistDecl[result.size()]); }
@Override public XmlElement[] getEnumeratedValues() { final List<XmlElement> result = new ArrayList<XmlElement>(); processElements(new FilterElementProcessor(new XmlTokenTypeFilter(XmlTokenType.XML_NAME), result), this); return result.toArray(new XmlElement[result.size()]); }
public XmlElement[] getEnumeratedValues() { final List<XmlElement> result = new ArrayList<XmlElement>(); processElements(new FilterElementProcessor(new XmlTokenTypeFilter(XmlTokenType.XML_NAME), result), this); return result.toArray(new XmlElement[result.size()]); }
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()]); }