@Override public void visitFieldInsn(int opcode, String owner, String fieldName, String fieldDescription) { AsmClass targetClass = asmClassProvider.getClass(owner, DETAIL_LEVEL.NOTHING); AsmField targetField = targetClass.getFieldOrCreateIt(fieldName); method.addEdge(new AsmEdge(method, targetField, SourceCodeEdgeUsage.CALLS_FIELD, lineNumber)); emptyMethod = false; }
@Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (isNotCallToJavaArrayMethod(owner)) { AsmClass targetClass = asmClassProvider.getClass(owner, DETAIL_LEVEL.STRUCTURE); AsmMethod targetMethod = targetClass.getMethodOrCreateIt(name + desc); method.addEdge(new AsmEdge(method, targetMethod, SourceCodeEdgeUsage.CALLS_METHOD, lineNumber)); } emptyMethod = false; }
@Override public FieldVisitor visitField(int access, String fieldName, String description, String signature, Object value) { AsmField field = asmClass.getFieldOrCreateIt(fieldName); field.setAccessFlags(access); String[] internalNames = AsmSignature.extractInternalNames(description, signature); AsmClass[] asmClasses = internalNamesToAsmClasses(internalNames, DETAIL_LEVEL.NOTHING); field.addUsesOfClasses(asmClasses); return null; }
private static boolean isInheritedMethodSignature(AsmClass parent, String key) { if (parent.getSuperClass() != null && (parent.getSuperClass().getMethod(key) != null || isInheritedMethodSignature(parent.getSuperClass(), key))) { return true; } for (AsmClass interfaceClass : parent.getInterfaces()) { if (interfaceClass.getMethod(key) != null || isInheritedMethodSignature(interfaceClass, key)) { return true; } } return false; } }
AsmMethod getMethodOrCreateIt(String key) { AsmMethod method = getMethod(key); if (method != null) { return method; } method = new AsmMethod(this, key); method.setBodyLoaded(false); addMethod(method); return method; }
@Override public AsmClass getClass(String internalName, DETAIL_LEVEL level) { if (internalName == null) { // TODO Godin: I believe that we should throw IllegalArgumentException instead throw new IllegalStateException("You can try to load a class whose internalName = 'null'"); } AsmClass asmClass = getAsmClassFromCacheOrCreateIt(internalName); if (level.isGreaterThan(asmClass.getDetailLevel())) { decoracteAsmClassFromBytecode(asmClass, level); } return asmClass; }
@Override public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { if (isNotCallToJavaArrayMethod(owner)) { AsmClass targetClass = asmClassProvider.getClass(owner, DETAIL_LEVEL.STRUCTURE); AsmMethod targetMethod = targetClass.getMethodOrCreateIt(name + desc); method.addEdge(new AsmEdge(method, targetMethod, SourceCodeEdgeUsage.CALLS_METHOD, lineNumber)); } emptyMethod = false; }
@Override public FieldVisitor visitField(int access, String fieldName, String description, String signature, Object value) { AsmField field = asmClass.getFieldOrCreateIt(fieldName); field.setAccessFlags(access); String[] internalNames = AsmSignature.extractInternalNames(description, signature); AsmClass[] asmClasses = internalNamesToAsmClasses(internalNames, DETAIL_LEVEL.NOTHING); field.addUsesOfClasses(asmClasses); return null; }
@Override public void visitFieldInsn(int opcode, String owner, String fieldName, String fieldDescription) { AsmClass targetClass = asmClassProvider.getClass(owner, DETAIL_LEVEL.NOTHING); AsmField targetField = targetClass.getFieldOrCreateIt(fieldName); method.addEdge(new AsmEdge(method, targetField, SourceCodeEdgeUsage.CALLS_FIELD, lineNumber)); emptyMethod = false; }
AsmMethod getMethodOrCreateIt(String key) { AsmMethod method = getMethod(key); if (method != null) { return method; } method = new AsmMethod(this, key); method.setBodyLoaded(false); addMethod(method); return method; }
@Override public void visitTryCatchBlock(Label start, Label end, Label handler, String exception) { if (exception != null) { AsmClass exceptionClass = asmClassProvider.getClass(exception, DETAIL_LEVEL.NOTHING); method.addEdge(new AsmEdge(method, exceptionClass, SourceCodeEdgeUsage.USES, lineNumber)); } emptyMethod = false; }
@Override public void visitTryCatchBlock(Label start, Label end, Label handler, String exception) { if (exception != null) { AsmClass exceptionClass = asmClassProvider.getClass(exception, DETAIL_LEVEL.NOTHING); method.addEdge(new AsmEdge(method, exceptionClass, SourceCodeEdgeUsage.USES, lineNumber)); } emptyMethod = false; }
@Override public void visitLdcInsn(Object cst) { if (cst instanceof Type) { Type type = (Type) cst; AsmClass usedClass = asmClassProvider.getClass(type.getInternalName(), DETAIL_LEVEL.NOTHING); method.addEdge(new AsmEdge(method, usedClass, SourceCodeEdgeUsage.USES, lineNumber)); } emptyMethod = false; }