use of jadx.core.utils.ErrorsCounter in project jadx by skylot.
the class SummaryNode method writeDecompilationSummary.
private void writeDecompilationSummary(StringEscapeUtils.Builder builder) {
builder.append("<h2>Decompilation</h2>");
JadxDecompiler jadx = mainWindow.getWrapper().getDecompiler();
List<ClassNode> classes = jadx.getRoot().getClasses(false);
int classesCount = classes.size();
long processedClasses = classes.stream().filter(c -> c.getState() == ProcessState.PROCESS_COMPLETE).count();
long generatedClasses = classes.stream().filter(c -> c.getState() == ProcessState.GENERATED_AND_UNLOADED).count();
builder.append("<ul>");
builder.append("<li>Top level classes: " + classesCount + "</li>");
builder.append("<li>At process stage: " + valueAndPercent(processedClasses, classesCount) + "</li>");
builder.append("<li>Code generated: " + valueAndPercent(generatedClasses, classesCount) + "</li>");
builder.append("</ul>");
ErrorsCounter counter = jadx.getRoot().getErrorsCounter();
Set<IAttributeNode> problemNodes = new HashSet<>();
problemNodes.addAll(counter.getErrorNodes());
problemNodes.addAll(counter.getWarnNodes());
long problemMethods = problemNodes.stream().filter(MethodNode.class::isInstance).count();
int methodsCount = classes.stream().mapToInt(cls -> cls.getMethods().size()).sum();
double methodSuccessRate = (methodsCount - problemMethods) * 100.0 / (double) methodsCount;
builder.append("<h3>Issues</h3>");
builder.append("<ul>");
builder.append("<li>Errors: " + counter.getErrorCount() + "</li>");
builder.append("<li>Warnings: " + counter.getWarnsCount() + "</li>");
builder.append("<li>Nodes with errors: " + counter.getErrorNodes().size() + "</li>");
builder.append("<li>Nodes with warnings: " + counter.getWarnNodes().size() + "</li>");
builder.append("<li>Total nodes with issues: " + problemNodes.size() + "</li>");
builder.append("<li>Methods with issues: " + problemMethods + "</li>");
builder.append("<li>Methods success rate: " + String.format("%.2f", methodSuccessRate) + "%</li>");
builder.append("</ul>");
}
Aggregations