org.sonar.api.batch.sensor.duplication
Interface DuplicationBuilder

All Known Implementing Classes:
DefaultDuplicationBuilder

@Beta
public interface DuplicationBuilder

Experimental, do not use.

This builder is used to declare duplications on files of the project. Usage:

 DuplicationBuilder builder = context.duplicationBuilder(inputFile);
   .originBlock(2, 10)
   .isDuplicatedBy(inputFile, 14, 22)
   .isDuplicatedBy(anotherInputFile, 3, 11)
   // Start another duplication
   .originBlock(45, 50)
   .isDuplicatedBy(yetAnotherInputFile, 10, 15);
   context.saveDuplications(inputFile, builder.build());
 

Since:
4.5

Method Summary
 List<DuplicationGroup> build()
          Call this method when you have declared all duplications of the file.
 DuplicationBuilder isDuplicatedBy(InputFile sameOrOtherFile, int startLine, int endLine)
          Declare duplicate block of the previously declared originBlock(int, int).
 DuplicationBuilder originBlock(int startLine, int endLine)
          Declare duplication origin block.
 

Method Detail

originBlock

DuplicationBuilder originBlock(int startLine,
                               int endLine)
Declare duplication origin block. Then call isDuplicatedBy(InputFile, int, int) to reference all duplicates of this block. Then call again originBlock(int, int) to declare another duplication.


isDuplicatedBy

DuplicationBuilder isDuplicatedBy(InputFile sameOrOtherFile,
                                  int startLine,
                                  int endLine)
Declare duplicate block of the previously declared originBlock(int, int).

Parameters:
sameOrOtherFile - duplicate can be in the same file or in another file.

build

List<DuplicationGroup> build()
Call this method when you have declared all duplications of the file.



Copyright © 2009–2015 SonarSource. All rights reserved.