处理intellij中虚假未使用进口商品的最佳方法 [英] Best way to handle false unused imports in intellij
本文介绍了处理intellij中虚假未使用进口商品的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Intellij错误地将某些导入的Scala隐式标记为未使用. 有没有一种方法可以防止在为特定导入显式优化导入时删除这些导入,而不是阻止整个项目的优化导入?
Intellij falsely marked some import of Scala implicits as not being use. Is there a way to prevent it from deleting those import when optimized them explicitly for a specific import and not prevent optimized import for the entire project ?
推荐答案
恐怕没有,尤其是在使用akka
并从ActorSystem
导入隐式执行上下文时,我遇到了类似的问题.我建议定义值而不是导入.这样的例子之一是:
I'm afraid there isn't, I had similar issues especially when using akka
and importing the implicit execution context from an ActorSystem
in some cases. I recommend defining the value instead of importing. One such example would be:
// Avoid importing the execution context like this
class MyActor extends Actor {
import context.system.dispatcher
}
// Define it explicitly instead
class MyActor extends Actor {
implicit val ec = context.system.dispatcher
}
希望对您有帮助.
这篇关于处理intellij中虚假未使用进口商品的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文