[VISUALIZER] Forbid to walk inside type reference children in psi

This commit is contained in:
Ivan Kylchik
2021-02-15 14:05:30 +03:00
committed by TeamCityServer
parent cc7d82ab7b
commit 951d607445
5 changed files with 31 additions and 28 deletions
@@ -107,26 +107,29 @@ class PsiVisualizer(private val file: KtFile, analysisResult: AnalysisResult) :
}
override fun visitTypeReference(typeReference: KtTypeReference) {
if (typeReference.text.isNotEmpty()) {
val hasResolvedCall = with(object : KtVisitorVoid() {
var hasCall: Boolean = false
override fun visitKtElement(element: KtElement) {
if (!hasCall) {
hasCall = element.getResolvedCall(bindingContext) != null
element.acceptChildren(this)
}
}
}) {
typeReference.accept(this)
this.hasCall
}
if (!hasResolvedCall) {
val type = typeReference.getAbbreviatedTypeOrType(bindingContext)
addAnnotation(renderType(type), typeReference)
}
if (typeReference.text.isEmpty()) {
return super.visitTypeReference(typeReference)
}
val hasResolvedCall = with(object : KtVisitorVoid() {
var hasCall: Boolean = false
override fun visitKtElement(element: KtElement) {
if (!hasCall) {
element.getResolvedCall(bindingContext)?.let {
hasCall = true
element.accept(this@Renderer)
} ?: element.acceptChildren(this)
}
}
}) {
typeReference.accept(this)
this.hasCall
}
if (!hasResolvedCall) {
val type = typeReference.getAbbreviatedTypeOrType(bindingContext)
addAnnotation(renderType(type), typeReference)
}
super.visitTypeReference(typeReference)
}
override fun visitConstantExpression(expression: KtConstantExpression) {