override fun toString()

in common/src/main/org/jetbrains/lincheck/descriptors/AccessLocation.kt [95:146]


    override fun toString(): String {
        val builder = StringBuilder()

        val locations = this.filterThisAccesses().locations
        for (i in locations.indices) {
            val location = locations[i]
            val nextLocation = locations.getOrNull(i + 1)

            when (location) {
                is LocalVariableAccessLocation -> {
                    with(builder) {
                        builder.append(location.variableName)
                        if (nextLocation is FieldAccessLocation) {
                            append(".")
                        }
                    }
                }
                is StaticFieldAccessLocation -> {
                    with(builder) {
                        append(location.fieldName)
                        if (nextLocation is FieldAccessLocation) {
                            append(".")
                        }
                    }
                }
                is ObjectFieldAccessLocation -> {
                    with(builder) {
                        append(location.fieldName)
                        if (nextLocation is FieldAccessLocation) {
                            append(".")
                        }
                    }
                }
                is ArrayElementByIndexAccessLocation -> {
                    with(builder) {
                        append('[')
                        append(location.index)
                        append(']')
                    }
                }
                is ArrayElementByNameAccessLocation -> {
                    with(builder) {
                        append('[')
                        append(location.indexAccessPath)
                        append(']')
                    }
                }
            }
        }

        return builder.toString()
    }