[VISUALIZER] Forbid to render unary minus for integer literals
This commit is contained in:
committed by
TeamCityServer
parent
685f599c82
commit
dd8a7010f0
+4
@@ -297,6 +297,10 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
|
|||||||
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression) {
|
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression) {
|
||||||
expression.firstOfTypeWithRender<FirGetClassCall>()
|
expression.firstOfTypeWithRender<FirGetClassCall>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visitPrefixExpression(expression: KtPrefixExpression) {
|
||||||
|
expression.firstOfTypeWithRender<FirConstExpression<*>>(expression.baseExpression) ?: super.visitPrefixExpression(expression)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class FirRenderer : FirVisitor<Unit, StringBuilder>() {
|
inner class FirRenderer : FirVisitor<Unit, StringBuilder>() {
|
||||||
|
|||||||
+8
@@ -233,6 +233,14 @@ class PsiVisualizer(private val file: KtFile, analysisResult: AnalysisResult) :
|
|||||||
addAnnotation(descriptorRenderer.render(it.type.constructor.declarationDescriptor!!), expression)
|
addAnnotation(descriptorRenderer.render(it.type.constructor.declarationDescriptor!!), expression)
|
||||||
} ?: super.visitClassLiteralExpression(expression)
|
} ?: super.visitClassLiteralExpression(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visitPrefixExpression(expression: KtPrefixExpression) {
|
||||||
|
val opName = expression.operationReference.getReferencedName()
|
||||||
|
if (expression.baseExpression?.node?.elementType == KtNodeTypes.INTEGER_CONSTANT && opName == "-") {
|
||||||
|
return expression.baseExpression!!.accept(this)
|
||||||
|
}
|
||||||
|
super.visitPrefixExpression(expression)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class PsiDescriptorRenderer(
|
inner class PsiDescriptorRenderer(
|
||||||
|
|||||||
@@ -23,10 +23,9 @@ fun main() {
|
|||||||
val a = Vector(1, 2)
|
val a = Vector(1, 2)
|
||||||
// Vector
|
// Vector
|
||||||
// │ constructor Vector(Int, Int)
|
// │ constructor Vector(Int, Int)
|
||||||
// │ │ fun (Int).unaryMinus(): Int
|
// │ │ Int
|
||||||
// │ │ │Int
|
// │ │ │ Int
|
||||||
// │ │ ││ Int
|
// │ │ │ │
|
||||||
// │ │ ││ │
|
|
||||||
val b = Vector(-1, 10)
|
val b = Vector(-1, 10)
|
||||||
|
|
||||||
// fun io/println(Any?): Unit
|
// fun io/println(Any?): Unit
|
||||||
|
|||||||
Reference in New Issue
Block a user