Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
robbinmav opened this issue Mar 9, 2024 · 3 comments

Comments

@robbinmav
Copy link

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
Copy link

Boat2017 commented Mar 9, 2024 via email

@StevenJack666
Copy link

StevenJack666 commented Mar 9, 2024 via email

@robbinmav
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants