Search in sources :

Example 6 with DepthTraversalTypeAwareCrawler

use of org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler in project sonarqube by SonarSource.

the class PersistEventsStep method execute.

@Override
public void execute(ComputationStep.Context context) {
    try (DbSession dbSession = dbClient.openSession(false)) {
        long analysisDate = analysisMetadataHolder.getAnalysisDate();
        new DepthTraversalTypeAwareCrawler(new PersistEventComponentVisitor(dbSession, analysisDate)).visit(treeRootHolder.getRoot());
        dbSession.commit();
    }
}
Also used : DbSession(org.sonar.db.DbSession) DepthTraversalTypeAwareCrawler(org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)

Example 7 with DepthTraversalTypeAwareCrawler

use of org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler in project sonarqube by SonarSource.

the class PersistMeasuresStep method execute.

@Override
public void execute(ComputationStep.Context context) {
    try (DbSession dbSession = dbClient.openSession(true)) {
        MeasureVisitor visitor = new MeasureVisitor(dbSession);
        new DepthTraversalTypeAwareCrawler(visitor).visit(treeRootHolder.getRoot());
        dbSession.commit();
        context.getStatistics().add("inserts", visitor.inserts);
    }
}
Also used : DbSession(org.sonar.db.DbSession) DepthTraversalTypeAwareCrawler(org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)

Example 8 with DepthTraversalTypeAwareCrawler

use of org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler in project sonarqube by SonarSource.

the class LoadDuplicationsFromReportStep method execute.

@Override
public void execute(ComputationStep.Context context) {
    DuplicationVisitor visitor = new DuplicationVisitor();
    new DepthTraversalTypeAwareCrawler(visitor).visit(treeRootHolder.getReportTreeRoot());
    context.getStatistics().add("duplications", visitor.count);
}
Also used : DepthTraversalTypeAwareCrawler(org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)

Example 9 with DepthTraversalTypeAwareCrawler

use of org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler in project sonarqube by SonarSource.

the class FileMoveDetectionStep method getReportFilesByUuid.

private static Map<String, Component> getReportFilesByUuid(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.getUuid(), file);
        }
    }).visit(root);
    return builder.build();
}
Also used : DepthTraversalTypeAwareCrawler(org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler) TypeAwareVisitorAdapter(org.sonar.ce.task.projectanalysis.component.TypeAwareVisitorAdapter) Component(org.sonar.ce.task.projectanalysis.component.Component) ImmutableMap(com.google.common.collect.ImmutableMap)

Aggregations

DepthTraversalTypeAwareCrawler (org.sonar.ce.task.projectanalysis.component.DepthTraversalTypeAwareCrawler)9 DbSession (org.sonar.db.DbSession)7 Component (org.sonar.ce.task.projectanalysis.component.Component)4 TypeAwareVisitorAdapter (org.sonar.ce.task.projectanalysis.component.TypeAwareVisitorAdapter)2 Joiner (com.google.common.base.Joiner)1 Preconditions.checkState (com.google.common.base.Preconditions.checkState)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 String.format (java.lang.String.format)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 DateUtils.formatDateTime (org.sonar.api.utils.DateUtils.formatDateTime)1 MessageException (org.sonar.api.utils.MessageException)1 AnalysisMetadataHolder (org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolder)1 ComponentVisitor (org.sonar.ce.task.projectanalysis.component.ComponentVisitor)1 CrawlerDepthLimit (org.sonar.ce.task.projectanalysis.component.CrawlerDepthLimit)1 TreeRootHolder (org.sonar.ce.task.projectanalysis.component.TreeRootHolder)1