Search in sources :

Example 1 with TypeAwareVisitorAdapter

use of org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter in project sonarqube by SonarSource.

the class FileMoveDetectionStep method getReportFilesByKey.

private static Map<String, Component> getReportFilesByKey(Component root) {
    final ImmutableMap.Builder<String, Component> builder = ImmutableMap.builder();
    new DepthTraversalTypeAwareCrawler(new TypeAwareVisitorAdapter(CrawlerDepthLimit.FILE, POST_ORDER) {

        @Override
        public void visitFile(Component file) {
            builder.put(file.getKey(), file);
        }
    }).visit(root);
    return builder.build();
}
Also used : DepthTraversalTypeAwareCrawler(org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler) TypeAwareVisitorAdapter(org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter) Component(org.sonar.server.computation.task.projectanalysis.component.Component) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 2 with TypeAwareVisitorAdapter

use of org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter in project sonarqube by SonarSource.

the class LoadDuplicationsFromReportStep method execute.

@Override
public void execute() {
    new DepthTraversalTypeAwareCrawler(new TypeAwareVisitorAdapter(CrawlerDepthLimit.FILE, POST_ORDER) {

        @Override
        public void visitFile(Component file) {
            CloseableIterator<ScannerReport.Duplication> duplications = batchReportReader.readComponentDuplications(file.getReportAttributes().getRef());
            try {
                int idGenerator = 1;
                while (duplications.hasNext()) {
                    loadDuplications(file, duplications.next(), idGenerator);
                    idGenerator++;
                }
            } finally {
                duplications.close();
            }
        }
    }).visit(treeRootHolder.getRoot());
}
Also used : Duplication(org.sonar.server.computation.task.projectanalysis.duplication.Duplication) DepthTraversalTypeAwareCrawler(org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler) TypeAwareVisitorAdapter(org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter) Component(org.sonar.server.computation.task.projectanalysis.component.Component)

Aggregations

Component (org.sonar.server.computation.task.projectanalysis.component.Component)2 DepthTraversalTypeAwareCrawler (org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)2 TypeAwareVisitorAdapter (org.sonar.server.computation.task.projectanalysis.component.TypeAwareVisitorAdapter)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Duplication (org.sonar.server.computation.task.projectanalysis.duplication.Duplication)1