SourceDebugExtension support for #156

This commit is contained in:
Mumfrey committed 2016-12-29 17:59:54 +00:00
1 parent ec8184939a
commit 6971fa83d7
7 files changed
+339 -3

No files matched your search

@@ -860,4 +860,25 @@ public class ASMHelper {
return (field.access & flag) == flag;
}
/**
* Compute the largest line number found in the specified class
*
* @param classNode Class to inspect
* @param min minimum value to return
* @param pad amount to pad at the end of files
* @return computed max
*/
public static int getMaxLineNumber(ClassNode classNode, int min, int pad) {
int max = 0;
for (MethodNode method : classNode.methods) {
for (Iterator<AbstractInsnNode> iter = method.instructions.iterator(); iter.hasNext();) {
AbstractInsnNode insn = iter.next();
if (insn instanceof LineNumberNode) {
max = Math.max(max, ((LineNumberNode)insn).line);
}
}
}
return Math.max(min, max + pad);
}
}