case OPEN_TAG: OpenTag ot = (OpenTag) element; for (Iterator<Attribute> it = ot.attributes(new AttributeFilter() { @Override public boolean accepts(Attribute attribute) {
@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); } }
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; Attribute sourceAttr = tag.getAttribute("id"); // NOI18N CharSequence seq = (sourceAttr == null) ? null : sourceAttr.unquotedValue(); String sourceID = (seq == null) ? null : seq.toString(); attributes.put(attribute.getName().toUpperCase(), attribute.getValue()); for (Attribute attribute : tag.attributes()) { String name = attribute.name().toString().toUpperCase(); String domValue = attributes.get(name);
case OPEN_TAG: OpenTag ot = (OpenTag) node; String name = ot.name().toString(); Tag tagModel = conf.getTag(name); Collection<Attribute> tagAttrs = ot.attributes(); Collection<String> unknownAttributeNames = new ArrayList<>(); for (Attribute a : tagAttrs) { OffsetRange range = new OffsetRange(snapshot.getEmbeddedOffset(ot.from()), snapshot.getEmbeddedOffset(ot.to())); hints.add(new UnknownAttributes(unknownAttributeNames, tagModel.getName(), context, range, lineHint));
@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 String getDescription() { return Bundle.addAttributeToSource(Utils.attributes2String(attrs), openTag.name().toString()); }
/** * 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 namespacePrefix = openTag.namespacePrefix() == null ? null : openTag.namespacePrefix().toString(); Map<String, String> namespaces = htmlParserResult.getNamespaces(); String namespace = null; String tagName = openTag.unqualifiedName().toString(); LibraryComponent component = library.getComponent(tagName); if (component == null) {
case OPEN_TAG: OpenTag ot = (OpenTag) element; String name = ot.unqualifiedName().toString(); Collection<CustomAttribute> customAttributes = AngularCustomAttribute.getCustomAttributes(model.getPrevailingAttributeConvention()); for(CustomAttribute ca : customAttributes) {
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) { 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()));
/** * 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; }
@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); } } } } } } });