IntelliJ不断从akka教程中删除context.dispatcher的导入

mir*_*lon 7 scala intellij-idea akka executioncontext

我正在关注akka-in-action教程,在第2章中,有一个类(https://github.com/RayRoestenburg/akka-in-action/blob/master/chapter2/src/main/scala/com/ goticks/RestInterface.scala):

trait RestApi extends HttpService with ActorLogging { actor: Actor =>
  import context.dispatcher
  import com.goticks.TicketProtocol._
  ...
Run Code Online (Sandbox Code Playgroud)

import context.dispatcher从未使用过,但它与评论定义:

  /**
   * Returns the dispatcher (MessageDispatcher) that is used for this Actor.
   * Importing this member will place an implicit ExecutionContext in scope.
   */
  implicit def dispatcher: ExecutionContextExecutor
Run Code Online (Sandbox Code Playgroud)

但是,IntelliJ会将导入标记为"未使用",并在"优化导入"时将其删除,从而导致错误value pipeTo is not a member of scala.concurrent.Future[Any].

有没有办法告诉IntelliJ这个导入不打算"使用",而只是简单地提供一个上下文?

或者是否应该更新教程以不使用这种"未使用的导入"?

Duf*_*ffJ 13

这对我来说就像问题SCL-9326.IntelliJ 15对此有一个很好的解决方法:按alt-enter(在Mac上)并选择"将此导入标记为此项目中始终使用的".