/** * 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; }
Attribute sourceAttr = tag.getAttribute("id"); // NOI18N CharSequence seq = (sourceAttr == null) ? null : sourceAttr.unquotedValue(); String sourceID = (seq == null) ? null : seq.toString();
@Override public void visit(Element node) { switch (node.type()) { case OPEN_TAG: OpenTag ot = (OpenTag) node; String name = ot.name().toString(); Tag tagModel = conf.getTag(name); //check just the custom elements if (tagModel != null) { Collection<org.netbeans.modules.html.custom.conf.Attribute> toAdd = new ArrayList<>(); for(org.netbeans.modules.html.custom.conf.Attribute modelAttribute : tagModel.getAttributes()) { if(modelAttribute.isRequired()) { if(ot.getAttribute(modelAttribute.getName()) == null) { //missing required attribute toAdd.add(modelAttribute); } } } if(!toAdd.isEmpty()) { hints.add(new MissingRequiredAttributes(toAdd, ot, context, HtmlEditorUtils.getDocumentOffsetRange(node, snapshot), false)); } } } } }
@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); } } } } } } });
if (ot.getAttribute(aName) == null) { if (aName.startsWith(context.getPrefix())) { items.add(new CustomAttributeCompletionItem(a, context.getCCItemStartOffset())); if (ot.getAttribute(aName) == null) { if (aName.startsWith(context.getPrefix())) { items.add(new CustomAttributeCompletionItem(a, context.getCCItemStartOffset()));