Package org.sonar.duplications.token

Examples of org.sonar.duplications.token.Token


  private static Matcher<List<Token>> isNumericLiteral() {
    return isTokens(new Token("$NUMBER", 1, 0));
  }

  private static Matcher<List<Token>> isStringLiteral() {
    return isTokens(new Token("$CHARS", 1, 0));
  }
View Full Code Here


  public StatementChannelDisptacher(List<StatementChannel> channels) {
    this.channels = channels.toArray(new StatementChannel[channels.size()]);
  }

  public boolean consume(TokenQueue tokenQueue, List<Statement> statements) {
    Token nextToken = tokenQueue.peek();
    while (nextToken != null) {
      boolean channelConsumed = false;
      for (StatementChannel channel : channels) {
        if (channel.consume(tokenQueue, statements)) {
          channelConsumed = true;
View Full Code Here

    if (!tokenQueue.isNextTokenValue(lToken)) {
      return false;
    }
    int stack = 0;
    while (tokenQueue.peek() != null) {
      Token token = tokenQueue.poll();
      matchedTokenList.add(token);
      if (lToken.equals(token.getValue())) {
        stack++;
      } else if (rToken.equals(token.getValue())) {
        stack--;
      } else if (except.equals(token.getValue())) {
        return false;
      }
      if (stack == 0) {
        return true;
      }
View Full Code Here

  }

  @Override
  public boolean matchToken(TokenQueue tokenQueue, List<Token> matchedTokenList) {
    do {
      Token token = tokenQueue.poll();
      matchedTokenList.add(token);
      if (uptoMatchTokens.contains(token.getValue())) {
        return true;
      }
    } while (tokenQueue.peek() != null);
    return false;
  }
View Full Code Here

    if (!tokenQueue.isNextTokenValue(lToken)) {
      return false;
    }
    int stack = 0;
    while (tokenQueue.peek() != null) {
      Token token = tokenQueue.poll();
      if (lToken.equals(token.getValue())) {
        stack++;
      } else if (rToken.equals(token.getValue())) {
        stack--;
      }
      matchedTokenList.add(token);
      if (stack == 0) {
        return true;
View Full Code Here

    new Statement(new ArrayList<Token>());
  }

  @Test
  public void shouldCreateStatementFromListOfTokens() {
    Statement statement = new Statement(Arrays.asList(new Token("a", 1, 1), new Token("b", 2, 1)));
    assertThat(statement.getValue(), is("ab"));
    assertThat(statement.getStartLine(), is(1));
    assertThat(statement.getEndLine(), is(2));
  }
View Full Code Here

    verifyNoMoreInteractions(output);
  }

  @Test
  public void shouldCreateStatement() {
    Token token = new Token("a", 1, 1);
    TokenQueue tokenQueue = spy(new TokenQueue(Arrays.asList(token)));
    TokenMatcher matcher = spy(new AnyTokenMatcher());
    StatementChannel channel = StatementChannel.create(matcher);
    List<Statement> output = mock(List.class);
View Full Code Here

    verifyNoMoreInteractions(output);
  }

  @Test
  public void shouldNotCreateStatement() {
    TokenQueue tokenQueue = spy(new TokenQueue(Arrays.asList(new Token("a", 1, 1))));
    TokenMatcher matcher = spy(new AnyTokenMatcher());
    StatementChannel channel = StatementChannel.create(matcher);
    List<Statement> output = mock(List.class);

    assertThat(channel.consume(tokenQueue, output), is(true));
View Full Code Here

TOP

Related Classes of org.sonar.duplications.token.Token

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.