@Override public void run() { try { int insertOffset = openTag.from() + "<".length() + openTag.name().length(); int documentInsertOffset = snapshot.getOriginalOffset(insertOffset); document.insertString(documentInsertOffset, insertText.toString(), null); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } }
@Override public String getDescription() { return Bundle.addAttributeToSource(Utils.attributes2String(attrs), openTag.name().toString()); }
/** * Returns some source node with the specified tag name. * * @param root root of the source tree to search. * @param tagName tag name of the desired source node. * @return source node with the specified tag name or {@code null} * if such node doesn't exist. */ private static org.netbeans.modules.html.editor.lib.api.elements.Node findElementByTagName(org.netbeans.modules.html.editor.lib.api.elements.Node root, String tagName) { org.netbeans.modules.html.editor.lib.api.elements.Node result = null; if (root instanceof OpenTag) { OpenTag tag = ((OpenTag)root); String name = tag.name().toString(); if (tagName.equalsIgnoreCase(name)) { result = root; } else { for (org.netbeans.modules.html.editor.lib.api.elements.Element element : root.children(ElementType.OPEN_TAG)) { result = findElementByTagName((org.netbeans.modules.html.editor.lib.api.elements.Node)element, tagName); if (result != null) { break; } } } } return result; }
private List<OpenTag> findValue(Collection<OpenTag> nodes, String tagName, List<OpenTag> foundNodes) { if (nodes == null) { return foundNodes; } for (OpenTag ot : nodes) { if(LexerUtils.equals(tagName, ot.name(), true, false)) { foundNodes.add(ot); } else { foundNodes = findValue(ot.children(OpenTag.class), tagName, foundNodes); } } return foundNodes; }
String sourceTagName = tag.name().toString(); if (!domNode.getNodeName().equalsIgnoreCase(sourceTagName)) { return false;
@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)); } } } } }
case OPEN_TAG: OpenTag ot = (OpenTag) node; String name = ot.name().toString(); Tag tagModel = conf.getTag(name);
List<CompletionItem> items = new ArrayList<>(); Configuration conf = Configuration.get(context.getResult().getSnapshot().getSource().getFileObject()); String tagName = ((OpenTag) node).name().toString(); Tag t = conf.getTag(tagName); if (t != null) {