/** * Returns the source node with the specified ID. * * @param root root of the source tree to search. * @param id ID of the desired source node. * @return source node with the specified ID or {@code null} * if such a node doesn't exist. */ private static org.netbeans.modules.html.editor.lib.api.elements.Node findElementByID(org.netbeans.modules.html.editor.lib.api.elements.Node root, String id) { org.netbeans.modules.html.editor.lib.api.elements.Node result = null; if (root instanceof OpenTag) { OpenTag tag = (OpenTag)root; Attribute attr = tag.getAttribute("id"); // NOI18N CharSequence seq = (attr == null) ? null : attr.unquotedValue(); String nodeId = (seq == null) ? null : seq.toString(); if (id.equals(nodeId)) { result = root; } else { for (org.netbeans.modules.html.editor.lib.api.elements.Element element : root.children(ElementType.OPEN_TAG)) { result = findElementByID((org.netbeans.modules.html.editor.lib.api.elements.Node)element, id); if (result != null) { break; } } } } return result; }
String domID = (domAttr == null) ? null : domAttr.getValue(); Attribute sourceAttr = tag.getAttribute("id"); // NOI18N CharSequence seq = (sourceAttr == null) ? null : sourceAttr.unquotedValue(); String sourceID = (seq == null) ? null : seq.toString(); if ((domID == null) != (sourceID == null)) { String name = attribute.name().toString().toUpperCase(); String domValue = attributes.get(name); CharSequence sourceSeq = attribute.unquotedValue(); String sourceValue = (sourceSeq == null) ? "" : sourceSeq.toString(); // NOI18N if (domValue == null || !domValue.equals(sourceValue)) {
@Override public void run(ResultIterator resultIterator) throws Exception { templateData = new LinkedHashSet<>(); Result result = resultIterator.getParserResult(0); if (result.getSnapshot().getMimeType().equals("text/html")) { HtmlParserResult htmlResult = (HtmlParserResult)result; String ns = null; if (htmlResult.getNamespaces().containsKey(DefaultLibraryInfo.FACELETS.getNamespace())) { ns = DefaultLibraryInfo.FACELETS.getNamespace(); } else if (htmlResult.getNamespaces().containsKey(DefaultLibraryInfo.FACELETS.getLegacyNamespace())) { ns = DefaultLibraryInfo.FACELETS.getLegacyNamespace(); } if (ns != null) { String faceletsPrefix = htmlResult.getNamespaces().get(ns); List<OpenTag> foundNodes = findValue(htmlResult.root(ns).children(OpenTag.class), faceletsPrefix + ":insert", new ArrayList<OpenTag>()); // NOI18N for (OpenTag node : foundNodes) { Attribute attr = node.getAttribute(VALUE_NAME); if (attr !=null) { String value = attr.unquotedValue().toString(); if (value != null && !"".equals(value)) { //NOI18N templateData.add(value); } } } } } } });