Skip to content

Commit 34a5d5f

Browse files
KON-601 Update KDoc for isInitialized property (#895)
1 parent 532fd1a commit 34a5d5f

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

lib/src/integrationTest/kotlin/com/lemonappdev/konsist/core/declaration/koproperty/KoPropertyDeclarationForKoInitializerProviderTest.kt

+22
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ class KoPropertyDeclarationForKoInitializerProviderTest {
3838
sut.isInitialized shouldBeEqualTo true
3939
}
4040

41+
@Test
42+
fun `property-with-delegate-is-initialized-in-block-body`() {
43+
// given
44+
val sut = getSnippetFile("property-with-delegate-is-initialized-in-block-body")
45+
.properties()
46+
.first()
47+
48+
// then
49+
sut.isInitialized shouldBeEqualTo true
50+
}
51+
52+
@Test
53+
fun `property-with-lateinit-modifier-is-not-initialized`() {
54+
// given
55+
val sut = getSnippetFile("property-with-lateinit-modifier-is-not-initialized")
56+
.properties()
57+
.first()
58+
59+
// then
60+
sut.isInitialized shouldBeEqualTo false
61+
}
62+
4163
@Test
4264
fun `property-inside-interface-is-not-initialized`() {
4365
// given
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
val sampleProperty: Int by lazy { 0 }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import com.lemonappdev.konsist.testdata.SampleClass
2+
3+
lateinit var sampleProperty: SampleClass

lib/src/main/kotlin/com/lemonappdev/konsist/api/provider/KoInitializerProvider.kt

+21-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,27 @@ package com.lemonappdev.konsist.api.provider
55
*/
66
interface KoInitializerProvider : KoBaseProvider {
77
/**
8-
* Determines whatever this declaration has been initialized.
8+
* Determines whatever this declaration has been initialized. Declaration that has been initialized has a body.
9+
* e.g.
10+
* ```kotlin
11+
* val name: String = "John Doe" // true
12+
* val name: String by lazy { "John Doe" } // true
13+
* lateinit var name: String // false
14+
*
15+
* fun greet() = "Hello, World!" // true
16+
* fun greet() { println("Hello, World!") } // true
17+
* fun greet(): String // false
18+
*
19+
* val speed: Int
20+
* get() = 100 // true
21+
* set(value) { field = value } // true
22+
*
23+
* val speed: Int = 0
24+
* private set // false
25+
*
26+
* val speed: Int = 0
27+
* get // false
28+
* ```
929
*/
1030
val isInitialized: Boolean
1131

0 commit comments

Comments
 (0)