IntelliJ continues to remove context.dispatcher import from akka tutorial

I follow the akka-in-action tutorial, and chapter 2 has a 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 never used, but is defined with a comment:

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

However, IntelliJ continues to mark the import as "unused" and deletes it during "import optimization", causing a value pipeTo is not a member of scala.concurrent.Future[Any] error.

Is there a way to tell IntelliJ that this import is not intended to be used, but just to simply provide context?

Or should the tutorial be updated so as not to use such an β€œunused import"?

+5
source share
2 answers

This looks like an SCL-9326 issue to me. IntelliJ 15 has a good fix for this: press alt-enter (on Mac) and select "check this import as always used in this project."

+10
source

Go to settings - editor - general - auto import and add the package to the "Exclude from import and completion" list enter image description here

You can also disable "Optimize imports on the fly" so that it does not delete imports without your explicit request

+1
source

Source: https://habr.com/ru/post/1211421/


All Articles