如何在使用Lombok生成的IntelliJ IDEA中的setter方法中设置断点? [英] How to set a breakpoint in a setter method in IntelliJ IDEA that is generated with Lombok?
问题描述
在由 Lombok 生成的setter方法中, IntelliJ IDEA 中是否有设置断点的方法?
这对于某些调试场景非常有用,例如看看何时从Hibernate这样的框架中调用setter。实际上,生成的setter方法显示在IntelliJ IDEA(正在使用的Lombok插件)的结构视图中, 。但我还没有找到通过上下文菜单或类似的方法设置断点的方法。
在我的理解中,这样做是因为lombok以突变的代码没有自动生成的零件的行号的方式突变字节码。
这样做的目的是始终有你的源代码行匹配你的字节码。它们不匹配,当你将断点放在一行上但是执行没有停止或停止在其他地方(因为行号不匹配),你可能会陷入困境。
但是作为交换,Lombok失去了调试生成代码的能力(不能在没有行号的行上放置断点)。您必须依赖生成的代码正确的事实。
Is there a way in IntelliJ IDEA to set a breakpoint in a setter method that is generated by Lombok?
This would be very useful in certain debugging scenarios, e.g. to see when the setter is called from a framework like Hibernate.
In fact, the generated setter methods are displayed in the structure view of IntelliJ IDEA (Lombok plugin in use). But I've not found a way to set a breakpoint via the context menu or such.
In my understanding you can't do that because lombok is mutating your bytecode in a way that mutated code doesn't have line numbers for auto-generated parts.
This is done on purpose to always have your source code lines match your bytecode. It they doesn't match, you'll may get caught in a situation when you placing your breakpoints on a line but execution didn't stop or stops somewhere else (because of line numbers mismatching).
But in exchange Lombok loses the ability to debug generated code (you can't place breakpoint on a line without line number). You have to rely on a fact that generated code is correct.
这篇关于如何在使用Lombok生成的IntelliJ IDEA中的setter方法中设置断点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!