问题
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