use of com.github.sevntu.checkstyle.ordering.MethodOrder in project methods-distance by sevntu-checkstyle.
the class MethodOrderTest method testOverrideSplit1.
@Test
public void testOverrideSplit1() throws Exception {
final MethodOrder ds = withDefaultConfigOrdering("InputDependenciesOverrideSplit1.java");
assertEquals(3, ds.getOverrideGroupSplitCases());
}
use of com.github.sevntu.checkstyle.ordering.MethodOrder in project methods-distance by sevntu-checkstyle.
the class MethodOrderTest method testTotalSumOfMethodDistances1.
@Test
public void testTotalSumOfMethodDistances1() throws Exception {
final MethodOrder ds = withDefaultConfigOrdering("InputDependenciesDistance1.java");
assertEquals(12, ds.getTotalSumOfMethodDistances());
}
use of com.github.sevntu.checkstyle.ordering.MethodOrder in project methods-distance by sevntu-checkstyle.
the class TopologicalMethodReorderer method methodDependenciesRelativeOrderOptimization.
private MethodOrder methodDependenciesRelativeOrderOptimization(MethodOrder methodOrder) {
MethodOrder currentMethodOrder = methodOrder;
for (final Method caller : currentMethodOrder.getMethods()) {
final List<Method> dependenciesInAppearanceOrder = currentMethodOrder.getMethodDependenciesInAppearanceOrder(caller);
if (dependenciesInAppearanceOrder.size() > 1) {
final List<Integer> dependenciesIndices = dependenciesInAppearanceOrder.stream().map(currentMethodOrder::getMethodIndex).sorted(Integer::compare).collect(Collectors.toList());
final List<Method> optimized = new ArrayList<>(currentMethodOrder.getMethods());
optimized.removeAll(dependenciesInAppearanceOrder);
for (int i = 0; i < dependenciesIndices.size(); ++i) {
optimized.add(dependenciesIndices.get(i), dependenciesInAppearanceOrder.get(i));
}
final MethodOrder optimizedMethodOrder = currentMethodOrder.reorder(optimized);
currentMethodOrder = getBestOrdering(currentMethodOrder, optimizedMethodOrder);
}
}
return currentMethodOrder;
}
Aggregations