Prevent Eclipse setting breakpoint on Scala anonymous functions (lambdas)

 ̄綄美尐妖づ 提交于 2019-12-25 04:08:15

问题


Using Scala plugin for Eclipse version 2.1 milestone 2, in Eclipse Indigo, if I set a breakpoint on a line that contains an anonymous function, e.g.

myList.map((x: String) => foo(bar(x)))

"the" breakpoint will be hit not only when map is called, but also when the anonymous function is called (it's actually multiple breakpoints, but frustratingly, they only show up as one breakpoint in the breakpoint tab in Eclipse). I think this is a regression, because I seem to remember you used to get multiple breakpoints showing up in this kind of case.

How can I stop Eclipse from treating the anonymous function as part of the same breakpoint?


回答1:


Breakpoints are line-based, so just add newlines in such a way that it's still syntactically valid, but the lambdas you don't want to hit are now on separate lines. E.g.

myList.map(
  (x: String) => foo(bar(x)))

(In my case, I still see an apparently spurious double-hit on the line, but that seems to be a different issue - it's not hitting the lambdas any more.)



来源:https://stackoverflow.com/questions/12640018/prevent-eclipse-setting-breakpoint-on-scala-anonymous-functions-lambdas

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