防止Eclipse设置断点在Scala匿名函数(lambdas) [英] Prevent Eclipse setting breakpoint on Scala anonymous functions (lambdas)

查看:285
本文介绍了防止Eclipse设置断点在Scala匿名函数(lambdas)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Eclipse版本2.1里程碑2使用Scala插件,在Eclipse Indigo中,如果我在包含匿名函数的行上设置了一个断点,例如

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

断点将不仅在映射被调用时被击中,而且当匿名函数被调用时(实际上是多个断点,但令人沮丧的是它们仅在Eclipse中的断点选项卡中显示为一个断点)。我认为这是一个回归,因为我似乎记得你曾经在这种情况下出现多个断点。



我如何阻止Eclipse处理匿名作为相同断点的一部分?

解决方案

断点是基于行的,所以只需添加换行符,它仍然是在语法上是有效的,但是你不想命中的羔羊现在是分开的。

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

(在我的情况下,我仍然看到一个明显的虚假双击,但似乎是一个不同的问题 - 它不会再次击中羔羊。)


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?

解决方案

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.)

这篇关于防止Eclipse设置断点在Scala匿名函数(lambdas)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆