0

I often have to debug old legacy code in Eclipse which I cannot or should not change. The code is often very long spaghetti code with confusing variable names.

While I debug I normally find out how things work.

I would now like to make comments on variables, methods and lines which are only disabled while I debug the code but will not change the code file itself. I could even think of changing the name of a variable from XI to countRowsProcessed just in the debugger.

Is there any plugin or maybe IDE which can do such a thing?

2
  • do you mean on the fly you want to change the variable names? Commented Jan 19, 2015 at 14:43
  • Yes. But think more of "overlay" them with a better name maybe. Commented Jan 19, 2015 at 15:23

1 Answer 1

1

When Eclipse is debugging, it takes the current class file and "attaches" a source file to it, which is the source file you interact with.

I'm not sure how to do this, but you can probably make a copy of your source file, say sourceFile-wDebugComments.java and tell Eclipse to use that file for debugging purposes, rather than the original one. This way, it's not a problem to add comments, as long as you don't insert new lines in the source file.

As for renaming variables, I'm afraid vanilla Eclipse doesn't allow that. Anyway, you might just make a copy of your whole source tree, and then modify the source file you normally can't modify. In general "can't modify" is referred to the copy on the source trunk. You can always do what you want on your local copies. If you then want to keep the thing, you can store the diff from the original file as a .diff or .patch file, and re-apply it every time you need it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.