java-decompiler / jd-gui

A standalone Java Decompiler GUI
GNU General Public License v3.0
13.72k stars 2.36k forks source link

Please advise how to map getBody text to line numberts in original source code #441

Open robbinmav opened 3 months ago

robbinmav commented 3 months ago

Hi. I am using the following code to retrieve the method code. private long checkMethodCode(String tempFname, List classMethodMemberList) { Iterator sampleMethodIter = classMethodMemberList.iterator(); long warnCnt = 0; StringBuffer messSB = new StringBuffer(""); while (sampleMethodIter.hasNext()) { MethodTree methodTreeObj = (MethodTree) sampleMethodIter.next(); String methodName = methodTreeObj.getName().toString(); String bodyText = methodTreeObj.getBody().toString();

this works fine but I am unable to map the bodyText to the line numbers for the same lines in the original source file. I appreciate that the lines are being reconstructed

I want to be able to read an exception's stack trace e.g. packageX.classY.methodZ(classY.java:234) and then display the block of lines around line 234. Currently I can't see how to map the getBody() output to the line numbers.

The line numbers get out of sync if the source code has comments in it because the JD library doesn't seem to account for them

I know that the JD-GUI can do this because it can show it in the front-end

Thanks

Boat2017 commented 3 months ago

现在是假期。已经收到您的来信,我会尽快回复。

StevenJack666 commented 3 months ago

这是来自QQ邮箱的假期自动回复邮件。您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

robbinmav commented 1 month ago

Hello. I would appreciate any advice on this because it is a real problem for me. It would be really helpful if I could resolve this problem