Eclipse JDT Programmatically Set/Create Breakpoint

一世执手 提交于 2019-12-13 07:25:59

问题


I would like to programmatically set/create a breakpoint in another file at an arbitrary line number in Eclipse. I would love to see a generic solution, but I guess I have to rely on the Eclipse JDT plugin for it. How can I do that? I tried something like:

JDIDebugModel.createLineBreakpoint(resource, typeName, lineNumber, -1, -1, 0, false, null);

But I have two problems with it:

  1. I have to include a whole lot of libraries to my build path to make it work, e.g. /usr/local/eclipse/plugins/org.eclipse.core.resources_3.9.0.v20140514-1307.jar. If I add them, they require other ones etc. I probably have to add all Eclipse plugins/libraries to make it work.
  2. How do I get a proper resource in order to give it to the method above? Giving a null value will most probably not work. But all implementations of IResource are internal...

I also thought about directly communicating with the JDI, but I could not get it going in combination with the Eclipse debugger (here is a great, but german resource for it).

If it is not possible from arbitrary code, would it be possible from within an Eclipse plugin? This would also be an option, though not preferable.

I could not find any solution for it and hope to get some help here. Thanks in advance!


回答1:


Most Eclipse plugins can only be run in the Eclipse environment because they rely on the Eclipse/OSGi plugin infrastructure being initialized properly.

Since JDIDebugModel.createLineBreakpoint requires an IResource object it can only be used in the Eclipse IDE (or an RCP based on the IDE) with a workspace.

So, yes, you can use this in a Eclipse plugin which would have to be installed in to Eclipse or an Eclipse RCP.



来源:https://stackoverflow.com/questions/25445884/eclipse-jdt-programmatically-set-create-breakpoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!