All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlin.fir.signaturer.FirManglerUtil.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-RC
Show newest version
/*
 * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
 * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
 */

package org.jetbrains.kotlin.fir.signaturer

import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames

/**
 * The name that an IR node generated from this [FirCallableDeclaration] will have, e.g. `` for constructors,
 * `` and `` for property accessors, name as is for variables and simple functions,
 * and `` for anonymous functions.
 */
val FirCallableDeclaration.irName: Name
    get() = when (this) {
        is FirConstructor -> SpecialNames.INIT
        is FirSimpleFunction -> this.name
        is FirPropertyAccessor -> this.irName
        is FirVariable -> this.name
        is FirFunction -> SpecialNames.ANONYMOUS
    }

/**
 * The name that an IR node generated from this [FirPropertyAccessor] will have.
 *
 * If the corresponding property has name `foo`, this will return `` or ``.
 */
val FirPropertyAccessor.irName: Name
    get() {
        val prefix = when {
            isGetter -> " " error("unknown property accessor kind $this")
        }
        return Name.special(prefix + propertySymbol.fir.name + ">")
    }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy