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());
}
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();
}
Aggregations