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

Sky*_*ker 7 scala intellij-idea playframework

我正在进行Scala Play项目迁移,由于积累了很多隐式变量,要弄清楚代码中不同点处的可用隐式变量及其类型(例如在Play Controller的内部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))
        }
      }
    }
Run Code Online (Sandbox Code Playgroud)

我所知道的理念的 Ctrl + Shift+ Alt+ +,使隐含的暗示,但遗憾的是它只能显示一个功能,而不是现有的implicits所需的隐含参数。例如,lang: Lang当我在Play Play Java和Scala混合项目中工作时,我想知道是否存在隐式可用类型及其隐式类型,这对于前者和lang后者而言可能都是类型。play.i18n.Langplay.api.i18n.Lang

Krz*_*sik 5

您正在寻找的可能是ctrl+ shift+ P。您需要将鼠标悬停在需要隐式的位置,然后按该组合。它甚至显示您是否有冲突的隐式:

InteliJ隐式

另请检查该页面以获取更多使用隐式方法的提示。