我正在进行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
。
答案 0 :(得分:4)