Search in sources :

Example 1 with CommentNode

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

the class PageLexerTest method testComment.

@Test
public void testComment() {
    String fragment = "<!-- text --><p>aaa</p>";
    StringReader reader = new StringReader(fragment);
    PageLexer lexer = new PageLexer();
    List<Node> nodeList = lexer.parse(reader);
    assertEquals(4, nodeList.size());
    assertTrue(nodeList.get(0) instanceof CommentNode);
}
Also used : TagNode(org.sonar.plugins.web.node.TagNode) TextNode(org.sonar.plugins.web.node.TextNode) CommentNode(org.sonar.plugins.web.node.CommentNode) Node(org.sonar.plugins.web.node.Node) DirectiveNode(org.sonar.plugins.web.node.DirectiveNode) StringReader(java.io.StringReader) CommentNode(org.sonar.plugins.web.node.CommentNode) Test(org.junit.Test)

Example 2 with CommentNode

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

the class PageLexerTest method testNestedComment.

@Test
public void testNestedComment() {
    String fragment = "<!-- text <!--><p>This is not part of the comment</p>";
    StringReader reader = new StringReader(fragment);
    PageLexer lexer = new PageLexer();
    List<Node> nodeList = lexer.parse(reader);
    assertEquals(4, nodeList.size());
    assertTrue(nodeList.get(0) instanceof CommentNode);
    assertTrue(nodeList.get(1) instanceof TagNode);
    assertTrue(nodeList.get(2) instanceof TextNode);
    assertTrue(nodeList.get(3) instanceof TagNode);
}
Also used : TagNode(org.sonar.plugins.web.node.TagNode) TextNode(org.sonar.plugins.web.node.TextNode) CommentNode(org.sonar.plugins.web.node.CommentNode) Node(org.sonar.plugins.web.node.Node) DirectiveNode(org.sonar.plugins.web.node.DirectiveNode) StringReader(java.io.StringReader) CommentNode(org.sonar.plugins.web.node.CommentNode) TextNode(org.sonar.plugins.web.node.TextNode) TagNode(org.sonar.plugins.web.node.TagNode) Test(org.junit.Test)

Example 3 with CommentNode

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

the class CommentTokenizer method createNode.

@Override
Node createNode() {
    CommentNode node = new CommentNode();
    node.setHtml(html);
    return node;
}
Also used : CommentNode(org.sonar.plugins.web.node.CommentNode)

Aggregations

CommentNode (org.sonar.plugins.web.node.CommentNode)3 StringReader (java.io.StringReader)2 Test (org.junit.Test)2 DirectiveNode (org.sonar.plugins.web.node.DirectiveNode)2 Node (org.sonar.plugins.web.node.Node)2 TagNode (org.sonar.plugins.web.node.TagNode)2 TextNode (org.sonar.plugins.web.node.TextNode)2