use of com.github.sevntu.checkstyle.ordering.PenaltyCalculator in project methods-distance by sevntu-checkstyle.
the class DependencyInfoMatrixSerializer method serialize.
public static String serialize(MethodOrder methodOrder, String javaSource, Configuration config) throws CheckstyleException {
final VelocityEngine engine = new VelocityEngine();
engine.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
engine.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
engine.init();
final PenaltyCalculator calculator = getPenaltyCalculator();
final int screenLinesCount = Integer.parseInt(config.getAttribute("screenLinesCount"));
final VelocityContext context = new VelocityContext();
context.put("info", methodOrder);
context.put("javaScript", getJavaScript());
context.put("css", getStyles());
context.put("javaSource", javaSource);
context.put("calculator", calculator);
context.put("penaltyValue", calculator.getPenalty(methodOrder, screenLinesCount));
context.put("configuration", config);
final StringWriter writer = new StringWriter();
final Template template = engine.getTemplate("com/github/sevntu/checkstyle/dsm/matrix.vm");
template.merge(context, writer);
return writer.toString();
}
Aggregations