use of org.sonar.ce.task.projectanalysis.duplication.Duplication in project sonarqube by SonarSource.
the class DuplicationLineReader method extractAllDuplicatedTextBlocks.
/**
* Duplicated blocks in the current file are either {@link Duplication#getOriginal()} or {@link Duplication#getDuplicates()}
* when the {@link Duplicate} is a {@link InnerDuplicate}.
* <p>
* The returned list is mutable on purpose because it will be sorted.
* </p>
*
* @see {@link #createIndexOfDuplicatedTextBlocks(Iterable)}
*/
private static List<TextBlock> extractAllDuplicatedTextBlocks(Iterable<Duplication> duplications) {
List<TextBlock> duplicatedBlock = new ArrayList<>(size(duplications));
for (Duplication duplication : duplications) {
duplicatedBlock.add(duplication.getOriginal());
Arrays.stream(duplication.getDuplicates()).filter(InnerDuplicate.class::isInstance).forEach(duplicate -> duplicatedBlock.add(duplicate.getTextBlock()));
}
return duplicatedBlock;
}
Aggregations