MCPcopy Create free account
hub / github.com/evernat/dead-code-detector / Result

Class Result

src/main/java/dcd/Result.java:42–442  ·  view source on GitHub ↗

Classe utilisée pour rassembler le contexte d'analyse et pour afficher les résultats. @author evernat

Source from the content-addressed store, hash-verified

40 * @author evernat
41 */
42class Result {
43 // ici, on utilise des Set, ordonnés ou non, car les contenus sont uniques et surtout
44 // car l'utilisation de (Linked)HashSet est ici légèrement plus rapide que ArrayList
45 // (Implementation Patterns p108 à 111)
46 private final Map<String, Set<String>> methodsByClassMap = new HashMap<>();
47 private final Map<String, Set<String>> fieldsByClassMap = new HashMap<>();
48 private final Map<String, String> superClassByClassMap = new HashMap<>();
49 private final Map<String, Set<String>> subClassListByClassMap = new HashMap<>();
50 private final Map<String, Set<String>> javaMethodListByClassMap = new HashMap<>();
51 private final Set<String> javaLangObjectMethods = getJavaMethods(
52 Type.getInternalName(Object.class));
53 private final Report report;
54
55 /**
56 * Implémentation de l'interface MethodVisitor d'ASM utilisée lors de l'analyse
57 * (parcours des appels de méthodes et d'attributs).
58 */
59 private class CallersMethodVisitor extends MethodVisitor {
60 CallersMethodVisitor() {
61 super(Opcodes.ASM4);
62 }
63
64 /** {@inheritDoc} */
65 @Override
66 public void visitMethodInsn(int opcode, String owner, String name, String desc,
67 boolean itf) {
68 // les classes java et javax ne sont pas auditées
69 if (!DcdHelper.isJavaClass(owner)) {
70 //log("\t" + owner + " " + name + " " + desc);
71 methodCalled(owner, name, desc);
72 }
73 }
74
75 private boolean isFieldRead(int opcode) {
76 return opcode == Opcodes.GETFIELD || opcode == Opcodes.GETSTATIC;
77 }
78
79 /** {@inheritDoc} */
80 @Override
81 public void visitFieldInsn(int opcode, String owner, String name, String desc) {
82 // les classes java et javax ne sont pas auditées
83 if (isFieldRead(opcode) && !DcdHelper.isJavaClass(owner)) {
84 //log("\t" + owner + " " + name + " " + desc);
85 fieldCalled(owner, name, desc);
86 }
87 }
88
89 /** {@inheritDoc} */
90 @Override
91 public AnnotationVisitor visitAnnotation(String arg0, boolean arg1) {
92 return null;
93 }
94
95 /** {@inheritDoc} */
96 @Override
97 public AnnotationVisitor visitAnnotationDefault() {
98 return null;
99 }

Callers

nothing calls this directly

Calls 1

getJavaMethodsMethod · 0.95

Tested by

no test coverage detected