Examples of ClonePart


Examples of org.sonar.duplications.index.ClonePart

      .setLines(index, index + LINES_PER_BLOCK)
      .build();
  }

  protected static ClonePart newClonePart(String resourceId, int unitStart, int cloneUnitLength) {
    return new ClonePart(resourceId, unitStart, unitStart, unitStart + cloneUnitLength + LINES_PER_BLOCK - 1);
  }
View Full Code Here

Examples of org.sonar.duplications.index.ClonePart

    Iterator<CloneGroup> clonesIterator = clones.iterator();

    CloneGroup clone = clonesIterator.next();
    assertThat(clone.getCloneUnitLength(), is(1));
    assertThat(clone.getCloneParts().size(), is(2));
    assertThat(clone.getOriginPart(), is(new ClonePart("a", 0, 0, 1)));
    assertThat(clone.getCloneParts(), hasItem(new ClonePart("a", 0, 0, 1)));
    assertThat(clone.getCloneParts(), hasItem(new ClonePart("a", 2, 0, 1)));
  }
View Full Code Here

Examples of org.sonar.duplications.index.ClonePart

    CloneGroup duplication = duplications.get(0);
    assertThat(duplication.getOriginPart().getResourceId()).isEqualTo(file.getAbsolutePath());
    assertThat(duplication.getCloneParts().size()).isEqualTo(2);
    assertThat(duplication.getLengthInUnits()).as("length in tokens").isEqualTo(157);

    ClonePart part = duplication.getCloneParts().get(0);
    assertThat(part.getResourceId()).isEqualTo(file.getAbsolutePath());
    assertThat(part.getStartLine()).isEqualTo(30);
    assertThat(part.getEndLine()).isEqualTo(44);
  }
View Full Code Here

Examples of org.sonar.duplications.index.ClonePart

    List<CloneGroup> duplications = detect(file1);
    assertThat(duplications.size()).isEqualTo(1);

    CloneGroup duplication = duplications.get(0);
    assertThat(duplication.getOriginPart().getResourceId()).isEqualTo(file1.getAbsolutePath());
    ClonePart part1 = new ClonePart(file1.getAbsolutePath(), 1, 18, 41);
    ClonePart part2 = new ClonePart(file2.getAbsolutePath(), 1, 18, 41);
    assertThat(duplication.getCloneParts()).containsOnly(part1, part2);
    assertThat(duplication.getLengthInUnits()).as("length in tokens").isEqualTo(115);
  }
View Full Code Here

Examples of org.sonar.duplications.index.ClonePart

  /**
   * Creates new part with specified resourceId and unitStart, and 0 for lineStart and lineEnd.
   */
  private ClonePart newClonePart(String resourceId, int unitStart) {
    return new ClonePart(resourceId, unitStart, 0, 0);
  }
View Full Code Here

Examples of org.sonar.duplications.index.ClonePart

  }

  private void reportClones(BlocksGroup beginGroup, BlocksGroup endGroup, int cloneLength) {
    List<Block[]> pairs = beginGroup.pairs(endGroup, cloneLength);

    ClonePart origin = null;
    List<ClonePart> parts = Lists.newArrayList();

    for (int i = 0; i < pairs.size(); i++) {
      Block[] pair = pairs.get(i);
      Block firstBlock = pair[0];
      Block lastBlock = pair[1];
      ClonePart part = new ClonePart(firstBlock.getResourceId(),
          firstBlock.getIndexInFile(),
          firstBlock.getStartLine(),
          lastBlock.getEndLine());

      if (originResourceId.equals(part.getResourceId())) {
        if (origin == null) {
          origin = part;
        } else if (part.getUnitStart() < origin.getUnitStart()) {
          origin = part;
        }
      }

      parts.add(part);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.