IntelliJ 不断从 akka 教程中删除 context.dispatcher 的导入
IntelliJ keeps removing the import of context.dispatcher from akka tutorial
我正在学习 akka-in-action 教程,在第 2 章中,有一个 class (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._
...
从未使用过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
但是,IntelliJ 一直将导入标记为 "unused" 并在 "optimize imports" 时将其删除,导致错误 value pipeTo is not a member of scala.concurrent.Future[Any]
.
有没有办法告诉 IntelliJ 此导入不是为了 "used",而只是为了提供上下文?
或者教程是否应该更新为不使用这样的 "unused import"?
进入设置-编辑器-通用-自动导入
并将包添加到 "Exclude from import and completion" 列表
您也可以禁用 "Optimize import on the fly",这样它就不会在没有您明确请求的情况下删除您的导入内容
这对我来说似乎是个问题 SCL-9326。 IntelliJ 15 对此有一个很好的修复:按 alt-enter(在 Mac 上)和 select "mark this import as always used in this project".
我正在学习 akka-in-action 教程,在第 2 章中,有一个 class (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._
...
从未使用过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
但是,IntelliJ 一直将导入标记为 "unused" 并在 "optimize imports" 时将其删除,导致错误 value pipeTo is not a member of scala.concurrent.Future[Any]
.
有没有办法告诉 IntelliJ 此导入不是为了 "used",而只是为了提供上下文?
或者教程是否应该更新为不使用这样的 "unused import"?
进入设置-编辑器-通用-自动导入
并将包添加到 "Exclude from import and completion" 列表
您也可以禁用 "Optimize import on the fly",这样它就不会在没有您明确请求的情况下删除您的导入内容
这对我来说似乎是个问题 SCL-9326。 IntelliJ 15 对此有一个很好的修复:按 alt-enter(在 Mac 上)和 select "mark this import as always used in this project".