[VISUALIZER] Change rendering of equals call
This commit is contained in:
committed by
TeamCityServer
parent
dd8a7010f0
commit
59416f447e
+2
-2
@@ -118,7 +118,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
|
||||
|
||||
override fun visitKtElement(element: KtElement) {
|
||||
when (element) {
|
||||
is KtClassInitializer, is KtSecondaryConstructor, is KtPrimaryConstructor, is KtSuperTypeCallEntry -> {
|
||||
is KtClassInitializer, is KtSecondaryConstructor, is KtPrimaryConstructor, is KtSuperTypeCallEntry, is KtDelegatedSuperTypeEntry -> {
|
||||
val valueParameters = element.getChildrenOfType<KtParameterList>()
|
||||
valueParameters.flatMap { it.parameters }.forEach { stack.addName(it.nameAsSafeName) }
|
||||
|
||||
@@ -593,7 +593,7 @@ class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
|
||||
}
|
||||
|
||||
override fun visitEqualityOperatorCall(equalityOperatorCall: FirEqualityOperatorCall, data: StringBuilder) {
|
||||
data.append("fun (Any).equals(Any?): Boolean")
|
||||
data.append("EQ operator call")
|
||||
}
|
||||
|
||||
override fun visitSafeCallExpression(safeCallExpression: FirSafeCallExpression, data: StringBuilder) {
|
||||
|
||||
+5
-1
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.compiler.visualizer.Annotator.annotate
|
||||
import org.jetbrains.kotlin.contracts.parsing.isEqualsDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -166,7 +167,10 @@ class PsiVisualizer(private val file: KtFile, analysisResult: AnalysisResult) :
|
||||
val typeArguments = resolvedCall.typeArguments
|
||||
.takeIf { it.isNotEmpty() }
|
||||
?.values?.joinToString(", ", "<", ">") { renderType(it) } ?: ""
|
||||
val annotation = descriptorRenderer.render(descriptor).replace(argumentsLabel, typeArguments)
|
||||
val annotation = when {
|
||||
descriptor.isEqualsDescriptor() -> "EQ operator call"
|
||||
else -> descriptorRenderer.render(descriptor).replace(argumentsLabel, typeArguments)
|
||||
}
|
||||
addAnnotation(annotation, renderOn, deleteDuplicate = false)
|
||||
|
||||
return resolvedCall
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ fun test1(s: String?) contract [returnsNotNull()] {
|
||||
// [ERROR: not resolved]
|
||||
// │ [ERROR: not resolved]
|
||||
// │ │ test1.s: String?
|
||||
// │ │ │ fun (Any).equals(Any?): Boolean
|
||||
// │ │ │ EQ operator call
|
||||
// │ │ │ │ Nothing?
|
||||
// │ │ │ │ │
|
||||
returns() implies (s != null)
|
||||
|
||||
@@ -21,7 +21,7 @@ enum class SomeEnum(val x: Some) {
|
||||
SECOND(O2) {
|
||||
// Boolean
|
||||
// │ SomeEnum.SECOND.check.y: Some
|
||||
// │ │ fun (Any).equals(Any?): Boolean
|
||||
// │ │ EQ operator call
|
||||
// │ │ │ object O2: Some
|
||||
// │ │ │ │
|
||||
override fun check(y: Some): Boolean = y == O2
|
||||
|
||||
@@ -16,7 +16,7 @@ annotation class Ann
|
||||
fun foo(arg: Int): Int {
|
||||
// constructor Ann()
|
||||
// │ foo.arg: Int
|
||||
// │ │ fun (Any).equals(Any?): Boolean
|
||||
// │ │ EQ operator call
|
||||
// Unit │ │ │ Int
|
||||
// │ │ │ │ │
|
||||
if (@Ann arg == 0) {
|
||||
@@ -28,7 +28,7 @@ fun foo(arg: Int): Int {
|
||||
// constructor Ann()
|
||||
// │ Unit
|
||||
// │ │ foo.arg: Int
|
||||
// │ │ │ fun (Any).equals(Any?): Boolean
|
||||
// │ │ │ EQ operator call
|
||||
// │ │ │ │ Int
|
||||
// │ │ │ │ │
|
||||
@Ann if (arg == 1) {
|
||||
|
||||
@@ -23,7 +23,7 @@ fun fooLabeled() {
|
||||
label@ for (i in 1..10) {
|
||||
// Unit
|
||||
// │ val fooLabeled.i: Int
|
||||
// │ │ fun (Any).equals(Any?): Boolean
|
||||
// │ │ EQ operator call
|
||||
// │ │ │ Int
|
||||
// │ │ │ │
|
||||
if (i == 5) continue@label
|
||||
|
||||
@@ -41,7 +41,7 @@ fun foo(): Int {
|
||||
// Unit
|
||||
// │ foo.<anonymous>.it: Tuple
|
||||
// │ │ val (Tuple).x: Int
|
||||
// │ │ │ fun (Any).equals(Any?): Boolean
|
||||
// │ │ │ EQ operator call
|
||||
// │ │ │ │ Int Int
|
||||
// │ │ │ │ │ │
|
||||
if (it.x == 0) return@foo 0
|
||||
@@ -59,7 +59,7 @@ fun bar(): Int {
|
||||
// Unit
|
||||
// │ bar.<anonymous>.it: Tuple
|
||||
// │ │ val (Tuple).x: Int
|
||||
// │ │ │ fun (Any).equals(Any?): Boolean
|
||||
// │ │ │ EQ operator call
|
||||
// │ │ │ │ Int Int
|
||||
// │ │ │ │ │ │
|
||||
if (it.x == 0) return@bar 0
|
||||
|
||||
@@ -23,7 +23,7 @@ fun test() {
|
||||
// Unit
|
||||
// │ fun (Boolean).not(): Boolean
|
||||
// │ │ var test.x: Int
|
||||
// │ │ │ fun (Any).equals(Any?): Boolean
|
||||
// │ │ │ EQ operator call
|
||||
// │ │ │ │ Int
|
||||
// │ │ │ │ │
|
||||
if (!(x == 0)) {
|
||||
|
||||
@@ -18,7 +18,7 @@ fun foo(limit: Int) {
|
||||
// │ │
|
||||
println(k)
|
||||
// var foo.k: Int
|
||||
// │ fun (Any).equals(Any?): Boolean
|
||||
// │ EQ operator call
|
||||
// │ │ Int
|
||||
// │ │ │
|
||||
while (k == 13) {
|
||||
|
||||
@@ -48,7 +48,7 @@ fun main() {
|
||||
println("a hash - ${a.hashCode()}")
|
||||
|
||||
// val main.a: Vector
|
||||
// │ fun (Vector).equals(Any?): Boolean
|
||||
// │ EQ operator call
|
||||
// fun io/println(Any?): Unit │ │ val main.b: Vector
|
||||
// │ │ │ │
|
||||
println("a is equal to b ${a.equals(b)}")
|
||||
|
||||
@@ -6,7 +6,7 @@ class A(val a: Int) {
|
||||
// │ │ │
|
||||
if (other !is A) return false
|
||||
// val (A).a: Int
|
||||
// │ fun (Any).equals(Any?): Boolean
|
||||
// │ EQ operator call
|
||||
// │ │ A.equals.other: Any?
|
||||
// │ │ │ val (A).a: Int
|
||||
// │ │ │ │
|
||||
@@ -22,7 +22,7 @@ open class B(val b: Int) {
|
||||
// │ │ │
|
||||
if (other !is B) return false
|
||||
// val (B).b: Int
|
||||
// │ fun (Any).equals(Any?): Boolean
|
||||
// │ EQ operator call
|
||||
// │ │ B.equals.other: Any?
|
||||
// │ │ │ val (B).b: Int
|
||||
// │ │ │ │
|
||||
@@ -36,19 +36,19 @@ open class B(val b: Int) {
|
||||
class C(c: Int): B(c) {}
|
||||
|
||||
// constructor A(Int)
|
||||
// │ fun (A).equals(Any?): Boolean
|
||||
// │ EQ operator call
|
||||
// │ │ constructor A(Int)
|
||||
// Boolean │ Int │ │ Int
|
||||
// │ │ │ │ │ │
|
||||
val areEqual = A(10) == A(11)
|
||||
// constructor C(Int)
|
||||
// │ fun (B).equals(Any?): Boolean
|
||||
// │ EQ operator call
|
||||
// │ │ constructor C(Int)
|
||||
// Boolean │ Int │ │ Int
|
||||
// │ │ │ │ │ │
|
||||
val areEqual2 = C(10) == C(11)
|
||||
// constructor A(Int)
|
||||
// │ fun (A).equals(Any?): Boolean
|
||||
// │ EQ operator call
|
||||
// │ │ constructor C(Int)
|
||||
// Boolean │ Int │ │ Int
|
||||
// │ │ │ │ │ │
|
||||
|
||||
Reference in New Issue
Block a user