while (elementsIterator.hasNext()) { Element element = elementsIterator.next(); switch (element.type()) { case OPEN_TAG: OpenTag ot = (OpenTag) element;
@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)); } } } } }
switch (element.type()) { case OPEN_TAG: OpenTag ot = (OpenTag) element;
@Override public void visit(Element node) { switch (node.type()) { case OPEN_TAG: OpenTag ot = (OpenTag) node;
@Override public List<CompletionItem> completeAttributes(CompletionContext context) { Element node = context.getCurrentNode(); if (node.type() != ElementType.OPEN_TAG) { return Collections.emptyList();
@Override public void computeSuggestions(HintsProvider.HintsManager manager, RuleContext context, List<Hint> hints, int caretOffset) { HtmlParserResult result = (HtmlParserResult) context.parserResult; Node root = result.root(SyntaxAnalyzerResult.FILTERED_CODE_NAMESPACE); Snapshot snapshot = result.getSnapshot(); int embeddedCaretOffset = snapshot.getEmbeddedOffset(caretOffset); Element found = ElementUtils.findByPhysicalRange(root, embeddedCaretOffset, false); if (found != null) { switch (found.type()) { case OPEN_TAG: case CLOSE_TAG: Named named = (Named) found; String elementName = named.name().toString(); Configuration conf = Configuration.get(snapshot.getSource().getFileObject()); if (conf.getTagsNames().contains(elementName)) { //custom element hints.add(new CustomElementHint(elementName, context, new OffsetRange(snapshot.getOriginalOffset(found.from()), snapshot.getOriginalOffset(found.to())))); } //TODO add check + fix for missing required attributes } } }