如何在任何代码点查看所有可用的隐式及其类型?

How to see all the implicits and their types available at any code point?

我正在进行 Scala Play 项目迁移,由于积累了许多隐式变量,因此在代码的不同点(例如,在 Play 中)找出可用的隐式变量及其类型成为一项艰巨的任务控制器的 Action 和委托给视图之前的权利,即

@Singleton
class Application @Inject() (implicit
                             val verifier: RecaptchaVerifier,
                             config: Configuration,
                             env: Environment,
                             mat: Materializer,
                             indexView: views.html.index,
                             restrictedView: views.html.restricted,
                             profileView: views.html.profile,
                             loginView: views.html.login,
                             restrictedForbidCookieView: views.html.restricted_forbid_cookie,
                             reloginView: views.html.relogin,
                             googleAuthenticationView: views.html.google_authentication,
                             signupView: views.html.signup,
                             widgetHelper: WidgetHelper,
                             webJarUtil: WebJarsUtil,
                             deadbolt: DeadboltActions,
                             auth: PlayAuthenticate,
                             userService: UserService,
                             authProvider: MyAuthProvider,
                             formContext: FormContext,
                             googleAuthService: GoogleAuthService,
                             recaptchaWidget: recaptcha.recaptchaWidget) extends InjectedController with I18nSupport {
  import scala.concurrent._
  import ExecutionContext.Implicits.global

  //-------------------------------------------------------------------
  // public
  //-------------------------------------------------------------------
  def index =
    TryCookieAuthAction { implicit jContext =>
      deadbolt.WithAuthRequest()() { implicit request =>
        Future {
          implicit val lang = request.acceptLanguages.head
          Ok(indexView(userService))
        }
      }
    }

我知道 Idea's Ctrl+Shift+Alt ++ 启用隐式提示但遗憾的是它只显示函数所需的隐式参数而不是可用的隐式。例如,我想知道是否有 lang: Lang 隐式可用及其类型,因为我正在处理 Play 混合 Java 和 Scala 项目,这个 lang 可以转向前者的类型为 play.i18n.Lang,后者的类型为 play.api.i18n.Lang

你要找的可能是ctrl + shift + P。您需要将鼠标悬停在需要隐式的位置上,然后按该组合键。它甚至会告诉你是否有冲突的暗示:

另请查看 page 以获得更多使用隐式的技巧。