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

时间:2019-05-08 08:57:54

标签: scala intellij-idea playframework

我正在进行Scala Play项目迁移,由于积累了许多隐式变量,要弄清楚代码中不同点处可用的隐式变量及其类型(例如在Play Controller的{ {1}},然后再委派给某个视图,即

Action

我知道Idea's Ctrl + Shift + Alt + + 已启用隐式提示,但遗憾的是,它仅显示函数所需的隐式参数,而不显示可用的隐式参数。例如,当我在Play Play Java和Scala混合项目中工作时,我想知道是否有@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)) } } } 隐式可用及其类型,因此lang: Lang可能会变成{前者为{1}},后者为lang

1 个答案:

答案 0 :(得分:4)

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

InteliJ implicits

还请检查page以获得更多使用隐式操作的提示。