vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Open class files in VSCode and add a debug breakpoint anywhere

Open ydmykr opened this issue 1 year ago • 8 comments

I'm trying to add a breakpoint in a class library. I must first open the target library class file (decompiled), and add a breakpoint later.

image

But it looks like I can view the class library only while debugging the java application. How can I goto specific library class file in vscode?

ydmykr avatar Jul 14 '22 07:07 ydmykr

You can use the top menus "Go -> Go to Symbol in Workspace..." (shortcut Ctrl + T) to search any class you want.

testforstephen avatar Jul 14 '22 08:07 testforstephen

@testforstephen Does it work for symbols outside the project? I'm trying to set a breakpoint on spring framework, which is a library imported from maven.

ydmykr avatar Jul 15 '22 02:07 ydmykr

yes, it searches for all classes including source files and library classes.

testforstephen avatar Jul 15 '22 02:07 testforstephen

@testforstephen It works for class names, not class methods, is that expected?

screen 2022-07-15 at 13 51 54

CaledoniaProject avatar Jul 15 '22 05:07 CaledoniaProject

Yes, it only searchs the classes by default, that's by design.

We have a setting java.symbols.includeSourceMethodDeclarations to control whether to include methods from source files during symbol search. This is off by default. However, it does not include the methods in the library due to performance considerations.

Usually, I use Ctrl + T to search the target class first, then using Ctrl + Shift + O to search method in current opened file.

testforstephen avatar Jul 15 '22 06:07 testforstephen

However, it does not include the methods in the library due to performance considerations.

Any chances to create a new setting for that?

CaledoniaProject avatar Jul 15 '22 07:07 CaledoniaProject

No plan yet. It's very slow to search methods from all libraries.

testforstephen avatar Jul 15 '22 07:07 testforstephen

I think with new parallel index search in jdt.core searching for methods should be fast. I have a eclipse implementation as a plugin just for this which is faster for larger workspaces as well. So may be having setting might be good to use as a circuit breaker for really slow workspaces.

gayanper avatar Jul 18 '22 19:07 gayanper