Search in sources :

Example 16 with TagNode

use of org.sonar.plugins.web.node.TagNode in project sonar-web by SonarSource.

the class UnclosedTagCheck method endElement.

@Override
public void endElement(TagNode element) {
    if (!ignoreTag(element) && !nodes.isEmpty()) {
        TagNode previousNode = nodes.remove(0);
        if (!previousNode.getNodeName().equals(element.getNodeName())) {
            createViolation(previousNode.getStartLinePosition(), "The tag \"" + previousNode.getNodeName() + "\" has no corresponding closing tag.");
            List<TagNode> rollup = new ArrayList<>();
            for (TagNode node : nodes) {
                rollup.add(node);
                if (node.getNodeName().equals(element.getNodeName())) {
                    nodes.removeAll(rollup);
                    break;
                }
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) TagNode(org.sonar.plugins.web.node.TagNode)

Aggregations

TagNode (org.sonar.plugins.web.node.TagNode)16 Node (org.sonar.plugins.web.node.Node)13 CommentNode (org.sonar.plugins.web.node.CommentNode)11 DirectiveNode (org.sonar.plugins.web.node.DirectiveNode)11 TextNode (org.sonar.plugins.web.node.TextNode)11 Test (org.junit.Test)10 StringReader (java.io.StringReader)8 FileReader (java.io.FileReader)2 Attribute (org.sonar.plugins.web.node.Attribute)2 ArrayList (java.util.ArrayList)1 CodeReader (org.sonar.channel.CodeReader)1