use of com.github.sevntu.checkstyle.module.DependencyInformationConsumer in project methods-distance by sevntu-checkstyle.
the class MainServlet method processDsm.
private void processDsm(URL sourceUrl, HttpServletResponse resp) throws CheckstyleException, IOException {
class DsmDependencyInformationConsumer implements DependencyInformationConsumer {
private Configuration configuration;
@Override
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
}
@Override
public void accept(String filePath, Dependencies dependencies) {
try {
final String javaSource = FileUtils.getFileContents(filePath);
final MethodOrder methodOrder = new MethodOrder(dependencies);
final String html = DependencyInfoMatrixSerializer.serialize(methodOrder, javaSource, configuration);
resp.setContentType("text/html");
resp.getWriter().append(html);
} catch (final IOException | CheckstyleException ex) {
throw new ResponseGenerationException(ex);
}
}
}
final Map<String, String> config = getCheckConfiguration();
final DsmDependencyInformationConsumer consumer = new DsmDependencyInformationConsumer();
final MethodCallDependencyCheckInvoker invoker = new MethodCallDependencyCheckInvoker(config, consumer);
consumer.setConfiguration(invoker.getConfiguration());
invoker.invoke(Collections.singletonList(downloadSource(sourceUrl)));
}
use of com.github.sevntu.checkstyle.module.DependencyInformationConsumer in project methods-distance by sevntu-checkstyle.
the class ReportCli method main.
public static void main(String... args) throws CheckstyleException {
final DependencyInformationConsumer consumer = new ViolationReporterDependencyInformationConsumer();
final ModuleFactory moduleFactory = new DependencyInformationConsumerInjector(consumer);
final DefaultConfiguration moduleConfig = new DefaultConfiguration(MethodCallDependencyCheckstyleModule.class.getCanonicalName());
moduleConfig.addAttribute("screenLinesCount", "50");
final TreeWalker tw = new TreeWalker();
tw.setModuleFactory(moduleFactory);
tw.finishLocalSetup();
tw.setupChild(moduleConfig);
final AuditListener listener = new DefaultLogger(System.out, false);
final Checker checker = new Checker();
checker.setModuleFactory(moduleFactory);
checker.addFileSetCheck(tw);
checker.addListener(listener);
final List<File> files = Collections.singletonList(new File(args[0]));
checker.process(files);
}
use of com.github.sevntu.checkstyle.module.DependencyInformationConsumer in project methods-distance by sevntu-checkstyle.
the class MainServlet method processDot.
private void processDot(URL sourceUrl, HttpServletResponse resp) throws CheckstyleException, IOException {
final DependencyInformationConsumer consumer = (filePath, dependencies) -> {
try {
final String dot = DependencyInfoGraphSerializer.serializeInfo(dependencies);
resp.setContentType("text/vnd.graphviz");
resp.getWriter().append(dot);
} catch (final IOException ex) {
throw new ResponseGenerationException(ex);
}
};
final Map<String, String> config = getCheckConfiguration();
final MethodCallDependencyCheckInvoker invoker = new MethodCallDependencyCheckInvoker(config, consumer);
invoker.invoke(Collections.singletonList(downloadSource(sourceUrl)));
}
Aggregations