use of jadx.core.dex.visitors.JadxVisitor in project jadx by skylot.
the class JadxVisitorsOrderTest method check.
private static List<String> check(List<IDexTreeVisitor> passes) {
List<Class<?>> classList = new ArrayList<Class<?>>(passes.size());
for (IDexTreeVisitor pass : passes) {
classList.add(pass.getClass());
}
List<String> errors = new ArrayList<String>();
Set<String> names = new HashSet<String>();
for (int i = 0; i < passes.size(); i++) {
IDexTreeVisitor pass = passes.get(i);
JadxVisitor info = pass.getClass().getAnnotation(JadxVisitor.class);
if (info == null) {
LOG.warn("No JadxVisitor annotation for visitor: {}", pass.getClass().getName());
continue;
}
String passName = pass.getClass().getSimpleName();
if (!names.add(passName)) {
errors.add("Visitor name conflict: " + passName + ", class: " + pass.getClass().getName());
}
for (Class<? extends IDexTreeVisitor> cls : info.runBefore()) {
if (classList.indexOf(cls) < i) {
errors.add("Pass " + passName + " must be before " + cls.getSimpleName());
}
}
for (Class<? extends IDexTreeVisitor> cls : info.runAfter()) {
if (classList.indexOf(cls) > i) {
errors.add("Pass " + passName + " must be after " + cls.getSimpleName());
}
}
}
return errors;
}
Aggregations