scala - 如何在任何代码点查看所有可用的隐式及其类型?
问题描述
Action
我正在处理 Scala Play 项目迁移,由于积累了许多隐式,因此在代码中的不同点(例如,在 Play Controller 中和委派之前)找出可用的隐式变量及其类型成为一项艰巨的任务到一个视图,即
@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 的 Ctrl++启用Shift隐式提示,但遗憾的是它只显示函数所需的隐式参数,而不是可用的隐式。例如,我想知道是否存在隐式可用及其类型,因为我正在处理 Play 混合 Java 和 Scala 项目,这可能会变成前者和后者的类型。Alt+lang: Lang
lang
play.i18n.Lang
play.api.i18n.Lang
解决方案
推荐阅读
- bash - 提交后如何 gitignore 来自 git 存储库的所有单个文件扩展名文件?
- java - Java - 在主要方法和绘图方法之间传递变量时遇到问题
- vb.net - 带变量的节点
- python - Python 如何将 collections.OrderedDict 转换为 dataFrame
- bash - 是否可以使用 bash sript 将数字的二进制表示形式写入文件?
- javascript - 如何在 Javascript 中从 JSON 中检索叶子子节点?
- shell - shell脚本中的多个条件不起作用
- django - 使用 python 3.7 版在生产环境中启动 django
- r - 通过 for-if 循环评估多个条件来生成虚拟变量
- javascript - 根据可用空间在 div 旁边排列文本