Better tooltip for try

This commit is contained in:
Valentin Kipyatkov
2016-09-22 16:47:47 +03:00
parent f1946ae154
commit 75d56e4902
2 changed files with 20 additions and 2 deletions
@@ -290,7 +290,24 @@ class KotlinBreadcrumbsInfoProvider : BreadcrumbsInfoProvider() {
override fun accepts(element: KtBlockExpression) = element.parent is KtTryExpression
override fun elementInfo(element: KtBlockExpression) = "try"
override fun elementTooltip(element: KtBlockExpression) = "try"
override fun elementTooltip(element: KtBlockExpression): String {
return buildString {
val tryExpression = element.parent as KtTryExpression
append("try {$ellipsis}")
for (catchClause in tryExpression.catchClauses) {
append("\ncatch(")
append(catchClause.catchParameter?.typeReference?.text ?: "")
append(") {$ellipsis}")
}
if (tryExpression.finallyBlock != null) {
append("\nfinally {$ellipsis}")
}
}
}
}
private object CatchHandler : ElementHandler<KtCatchClause>(KtCatchClause::class) {
+2 -1
View File
@@ -5,6 +5,7 @@ Crumbs:
catch (RuntimeException)
Tooltips:
function <b><code>foo()</code></b>
try
try {…}
catch(Exception) {…}
finally
catch (RuntimeException)