Search in sources :

Example 1 with DirectAcyclicGraph

use of org.sonar.api.utils.dag.DirectAcyclicGraph in project sonarqube by SonarSource.

the class ScannerExtensionDictionnary method sort.

public <T> Collection<T> sort(Collection<T> extensions) {
    DirectAcyclicGraph dag = new DirectAcyclicGraph();
    for (T extension : extensions) {
        dag.add(extension);
        for (Object dependency : getDependencies(extension)) {
            dag.add(extension, dependency);
        }
        for (Object generates : getDependents(extension)) {
            dag.add(generates, extension);
        }
        completePhaseDependencies(dag, extension);
    }
    List<?> sortedList = dag.sort();
    return (Collection<T>) sortedList.stream().filter(extensions::contains).collect(Collectors.toList());
}
Also used : DirectAcyclicGraph(org.sonar.api.utils.dag.DirectAcyclicGraph) Collection(java.util.Collection)

Example 2 with DirectAcyclicGraph

use of org.sonar.api.utils.dag.DirectAcyclicGraph in project sonarqube by SonarSource.

the class LoadMeasureComputersStep method sortComputers.

private static Iterable<MeasureComputerWrapper> sortComputers(List<MeasureComputerWrapper> wrappers) {
    Map<String, MeasureComputerWrapper> computersByOutputMetric = new HashMap<>();
    Map<String, MeasureComputerWrapper> computersByInputMetric = new HashMap<>();
    feedComputersByMetric(wrappers, computersByOutputMetric, computersByInputMetric);
    ToComputerByKey toComputerByOutputMetricKey = new ToComputerByKey(computersByOutputMetric);
    ToComputerByKey toComputerByInputMetricKey = new ToComputerByKey(computersByInputMetric);
    DirectAcyclicGraph dag = new DirectAcyclicGraph();
    for (MeasureComputerWrapper computer : wrappers) {
        dag.add(computer);
        for (MeasureComputerWrapper dependency : getDependencies(computer, toComputerByOutputMetricKey)) {
            dag.add(computer, dependency);
        }
        for (MeasureComputerWrapper generates : getDependents(computer, toComputerByInputMetricKey)) {
            dag.add(generates, computer);
        }
    }
    return dag.sort();
}
Also used : MeasureComputerWrapper(org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper) HashMap(java.util.HashMap) DirectAcyclicGraph(org.sonar.api.utils.dag.DirectAcyclicGraph)

Aggregations

DirectAcyclicGraph (org.sonar.api.utils.dag.DirectAcyclicGraph)2 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 MeasureComputerWrapper (org.sonar.server.computation.task.projectanalysis.api.measurecomputer.MeasureComputerWrapper)1