Package org.sonar.channel

Examples of org.sonar.channel.CodeReader


    codeBuilder = new HtmlCodeBuilder();
  }

  @Test
  public void testRead() {
    assertTrue(tokenizer.consume(new CodeReader("CONSTANT"), codeBuilder));
    assertTrue(tokenizer.consume(new CodeReader("IS_CONSTANT "), codeBuilder));
    assertTrue(tokenizer.consume(new CodeReader("IS-CONSTANT "), codeBuilder));
    assertFalse(tokenizer.consume(new CodeReader("Class"), codeBuilder));
    assertFalse(tokenizer.consume(new CodeReader("_NOTACONSTANT"), codeBuilder));
    assertFalse(tokenizer.consume(new CodeReader("IS_not_a_constant"), codeBuilder));
    assertFalse(tokenizer.consume(new CodeReader("property"), codeBuilder));
    assertFalse(tokenizer.consume(new CodeReader(" "), codeBuilder));
  }
View Full Code Here


    assertFalse(tokenizer.consume(new CodeReader(" "), codeBuilder));
  }

  @Test
  public void upperCaseWordsStartingWithADotShoutNotBeHighlighted() {
    CodeReader reader = new CodeReader(".URL");
    reader.pop();
    assertFalse(tokenizer.consume(reader, codeBuilder));
  }
View Full Code Here

    assertFalse(tokenizer.consume(reader, codeBuilder));
  }

  @Test
  public void hasNextTokenWhenFirstCharacterIsNotAConstant() {
    CodeReader code = new CodeReader("sCONSTANT");
    code.pop();
    assertFalse(tokenizer.consume(code, codeBuilder));
  }
View Full Code Here

    assertFalse(tokenizer.consume(code, codeBuilder));
  }

  @Test
  public void nextToken() {
    assertTrue(tokenizer.consume(new CodeReader("IS_TRUE = 4;"), codeBuilder));
    assertEquals("<c>IS_TRUE</c>", codeBuilder.toString());
  }
View Full Code Here

      .addChannel(new BlackholeChannel())
      .build();
  }

  private String convert(String input) {
    CodeReader reader = new CodeReader(input);
    MarkdownOutput output = new MarkdownOutput();
    dispatcher.consume(reader, output);
    return output.toString();
  }
View Full Code Here

  }

  @Test
  public void testStandardComment() {
    MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("{[||", "");
    assertThat(tokenizer.hasNextToken(new CodeReader("{[|| And here is strange  multi-line comment"), new HtmlCodeBuilder())).isTrue();
    assertThat(tokenizer.hasNextToken(new CodeReader("// this is not a strange multi-line comment"), new HtmlCodeBuilder())).isFalse();
  }
View Full Code Here

    assertThat(tokenizer.hasNextToken(new CodeReader("// this is not a strange multi-line comment"), new HtmlCodeBuilder())).isFalse();
  }

  @Test
  public void testLongStartToken() {
    CodeReader reader = new CodeReader("/*** multi-line comment**/ private part");
    MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("/***", "**/");
    assertThat(tokenizer.consume(reader, codeBuilder)).isTrue();
    assertThat(codeBuilder.toString()).isEqualTo("/*** multi-line comment**/");
  }
View Full Code Here

    assertThat(codeBuilder.toString()).isEqualTo("/*** multi-line comment**/");
  }

  @Test
  public void testStartTokenEndTokenOverlapping() {
    CodeReader reader = new CodeReader("/*// multi-line comment*/ private part");
    MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("/*", "*/");
    assertThat(tokenizer.consume(reader, codeBuilder)).isTrue();
    assertThat(codeBuilder.toString()).isEqualTo("/*// multi-line comment*/");
  }
View Full Code Here

    assertThat(codeBuilder.toString()).isEqualTo("/*// multi-line comment*/");
  }

  @Test
  public void testMultilinesComment() {
    CodeReader reader = new CodeReader("/* multi-line comment\n*/ private part");
    MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("/*", "*/");
    assertThat(tokenizer.consume(reader, codeBuilder)).isTrue();
    assertThat(codeBuilder.toString()).isEqualTo("/* multi-line comment");
    reader.pop();
    assertThat(tokenizer.consume(reader, codeBuilder)).isTrue();
    assertThat(codeBuilder.toString()).isEqualTo("/* multi-line comment*/");
  }
View Full Code Here

  /**
   * SONAR-3531
   */
  @Test
  public void should_work_for_html_comments() {
    CodeReader reader = new CodeReader("<!-- multi-line comment\n--> private part");
    MultilinesDocTokenizer tokenizer = new MultiLineDocTokenizerImpl("<!--", "-->");
    assertThat(tokenizer.consume(reader, codeBuilder)).isTrue();
    assertThat(codeBuilder.toString()).isEqualTo("&lt;!-- multi-line comment");
    reader.pop();
    assertThat(tokenizer.consume(reader, codeBuilder)).isTrue();
    assertThat(codeBuilder.toString()).isEqualTo("&lt;!-- multi-line comment--&gt;");
  }
View Full Code Here

TOP

Related Classes of org.sonar.channel.CodeReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.