Skip to content

Commit

Permalink
[FIR] Add KDoc to CallableId
Browse files Browse the repository at this point in the history
  • Loading branch information
marcopennekamp authored and Space Team committed Dec 3, 2024
1 parent a31b435 commit 40db9d4
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions core/compiler.common/src/org/jetbrains/kotlin/name/CallableId.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,41 @@

package org.jetbrains.kotlin.name

// NB: with className == null we are at top level
/**
* A callable ID identifies a Kotlin callable, such as a function or property. When [className] is `null`, the ID represents a top-level
* callable.
*
* In case of overloads, multiple callables may share the same [CallableId].
*
* #### Example
*
* ```kotlin
* package one.two
*
* fun foo() {
* fun loc() { }
* }
*
* class A {
* val bar: String = "bar"
*
* class B {
* fun nes() { }
* }
* }
*
* fun overloaded(value: Int) { }
* fun overloaded(value: String) { }
* ```
*
* Callable IDs for the callables above:
*
* - `foo`: `one/two/foo`
* - `loc`: `<local>/loc` (see [SpecialNames.LOCAL])
* - `bar`: `one/two/A.bar`
* - `nes`: `one/two/A.B.nes`
* - `overloaded`: `one/two/overloaded` for *both* `overloaded(value: Int)` and `overloaded(value: String)`
*/
class CallableId private constructor(
val packageName: FqName,
val className: FqName?,
Expand All @@ -23,8 +57,8 @@ class CallableId private constructor(
}

/**
* Return `true` if corresponding declaration is itself local or it is a member of local class
* Otherwise, returns `false`
* Returns `true` if the corresponding callable declaration is itself local, or if it is a member of a local class.
* Otherwise, returns `false`.
*/
val isLocal: Boolean
get() = packageName == PACKAGE_FQ_NAME_FOR_LOCAL || classId?.isLocal == true
Expand Down

0 comments on commit 40db9d4

Please sign in to comment.