-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- `currentComposableInvalidationTracker` - Resolves #40 - `ComposableInvalidationListener` - `currentComposableName` - `currentComposableKeyName` - `registerListener`, `unregisterListener` - `callListeners` - `computeInvalidationReason` - Improved code structure - Rewrite some tests
- Loading branch information
Showing
54 changed files
with
1,505 additions
and
1,157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...lin/land/sungbin/composeinvestigator/compiler/test/source/logger/InvalidationProcessed.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Designed and developed by Ji Sungbin 2023. | ||
* | ||
* Licensed under the MIT. | ||
* Please see full license: https://github.com/jisungbin/ComposeInvestigator/blob/main/LICENSE | ||
*/ | ||
|
||
package land.sungbin.composeinvestigator.compiler.test.source.logger | ||
|
||
import androidx.compose.material.Button | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableIntStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
|
||
@Composable | ||
fun InvalidationProcessedParameterChangedRoot() { | ||
var count by remember { mutableIntStateOf(0) } | ||
Button(onClick = { count = 1 }) {} | ||
InvalidationProcessedParameterChangedChild(count) | ||
} | ||
|
||
@Composable | ||
private fun InvalidationProcessedParameterChangedChild(count: Int) { | ||
Text(text = "$count") | ||
} |
43 changes: 43 additions & 0 deletions
43
...otlin/land/sungbin/composeinvestigator/compiler/test/source/logger/InvalidationSkipped.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Designed and developed by Ji Sungbin 2023. | ||
* | ||
* Licensed under the MIT. | ||
* Please see full license: https://github.com/jisungbin/ComposeInvestigator/blob/main/LICENSE | ||
*/ | ||
|
||
package land.sungbin.composeinvestigator.compiler.test.source.logger | ||
|
||
import androidx.compose.material.Button | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.currentRecomposeScope | ||
import land.sungbin.composeinvestigator.runtime.ComposableName | ||
import land.sungbin.composeinvestigator.runtime.currentComposableInvalidationTracker | ||
|
||
@Composable | ||
fun InvalidationSkippedRoot() { | ||
val recomposeScope = currentRecomposeScope | ||
|
||
Button(onClick = { recomposeScope.invalidate() }) {} | ||
InvalidationSkippedChild() | ||
} | ||
|
||
@Composable | ||
private fun InvalidationSkippedChild() { | ||
Text(text = "Child") | ||
} | ||
|
||
@Composable | ||
fun InvalidationSkippedRoot_CustomName() { | ||
currentComposableInvalidationTracker.currentComposableName = ComposableName("InvalidationSkippedRoot_custom_name") | ||
val recomposeScope = currentRecomposeScope | ||
|
||
Button(onClick = { recomposeScope.invalidate() }) {} | ||
InvalidationSkippedChild_CustomName() | ||
} | ||
|
||
@Composable | ||
private fun InvalidationSkippedChild_CustomName() { | ||
currentComposableInvalidationTracker.currentComposableName = ComposableName("InvalidationSkippedChild_custom_name") | ||
Text(text = "Child") | ||
} |
23 changes: 23 additions & 0 deletions
23
...st/src/main/kotlin/land/sungbin/composeinvestigator/compiler/test/source/logger/logger.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Designed and developed by Ji Sungbin 2023. | ||
* | ||
* Licensed under the MIT. | ||
* Please see full license: https://github.com/jisungbin/ComposeInvestigator/blob/main/LICENSE | ||
*/ | ||
|
||
package land.sungbin.composeinvestigator.compiler.test.source.logger | ||
|
||
import land.sungbin.composeinvestigator.runtime.AffectedComposable | ||
import land.sungbin.composeinvestigator.runtime.ComposableInvalidationLogger | ||
import land.sungbin.composeinvestigator.runtime.ComposableInvalidationType | ||
|
||
val invalidationLog = mutableMapOf<AffectedComposable, MutableList<ComposableInvalidationType>>() | ||
|
||
fun findInvalidationLog(composableName: String): List<ComposableInvalidationType> = | ||
invalidationLog.filterKeys { composable -> composable.name == composableName }.values.flatten() | ||
|
||
@Suppress("unused") | ||
@ComposableInvalidationLogger | ||
fun invalidationLogger(composable: AffectedComposable, type: ComposableInvalidationType) { | ||
invalidationLog.getOrPut(composable, ::mutableListOf).add(type) | ||
} |
45 changes: 45 additions & 0 deletions
45
.../land/sungbin/composeinvestigator/compiler/test/source/table/callback/RegisterListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Designed and developed by Ji Sungbin 2023. | ||
* | ||
* Licensed under the MIT. | ||
* Please see full license: https://github.com/jisungbin/ComposeInvestigator/blob/main/LICENSE | ||
*/ | ||
|
||
package land.sungbin.composeinvestigator.compiler.test.source.table.callback | ||
|
||
import androidx.compose.material.Button | ||
import androidx.compose.material.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.currentRecomposeScope | ||
import land.sungbin.composeinvestigator.runtime.AffectedComposable | ||
import land.sungbin.composeinvestigator.runtime.ComposableInvalidationType | ||
import land.sungbin.composeinvestigator.runtime.currentComposableInvalidationTracker | ||
|
||
val invalidationListensViaManualRegister = mutableMapOf<AffectedComposable, MutableList<ComposableInvalidationType>>() | ||
|
||
fun findInvalidationListensViaManualRegister(composableName: String): List<ComposableInvalidationType> = | ||
invalidationListensViaManualRegister.filterKeys { composable -> composable.name == composableName }.values.flatten() | ||
|
||
@Composable | ||
fun RegisterListener_InvalidationSkippedRoot() { | ||
val recomposeScope = currentRecomposeScope | ||
val tracker = currentComposableInvalidationTracker | ||
|
||
tracker.registerListener(keyName = tracker.currentComposableKeyName) { composable, type -> | ||
invalidationListensViaManualRegister.getOrPut(composable, ::mutableListOf).add(type) | ||
} | ||
|
||
Button(onClick = { recomposeScope.invalidate() }) {} | ||
RegisterListener_InvalidationSkippedChild() | ||
} | ||
|
||
@Composable | ||
private fun RegisterListener_InvalidationSkippedChild() { | ||
val tracker = currentComposableInvalidationTracker | ||
|
||
tracker.registerListener(keyName = tracker.currentComposableKeyName) { composable, type -> | ||
invalidationListensViaManualRegister.getOrPut(composable, ::mutableListOf).add(type) | ||
} | ||
|
||
Text(text = "Child") | ||
} |
32 changes: 32 additions & 0 deletions
32
...mposeinvestigator/compiler/test/source/table/invalidationtracktablecall/TableCallFile1.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Designed and developed by Ji Sungbin 2023. | ||
* | ||
* Licensed under the MIT. | ||
* Please see full license: https://github.com/jisungbin/ComposeInvestigator/blob/main/LICENSE | ||
*/ | ||
|
||
package land.sungbin.composeinvestigator.compiler.test.source.table.invalidationtracktablecall | ||
|
||
import io.kotest.matchers.shouldBe | ||
import io.kotest.matchers.types.shouldBeSameInstanceAs | ||
import land.sungbin.composeinvestigator.runtime.ComposableName | ||
import land.sungbin.composeinvestigator.runtime.currentComposableInvalidationTracker | ||
import land.sungbin.composeinvestigator.runtime.getValue | ||
|
||
val table1 = currentComposableInvalidationTracker | ||
|
||
fun table1() { | ||
table1 shouldBeSameInstanceAs currentComposableInvalidationTracker | ||
} | ||
|
||
fun currentComposableName1() { | ||
val prevComposableName by table1.currentComposableName | ||
prevComposableName shouldBe "currentComposableName1" | ||
|
||
table1.currentComposableName = ComposableName("ChangedComposableName1") | ||
table1.currentComposableName.name shouldBe "ChangedComposableName1" | ||
} | ||
|
||
fun currentComposableKeyName1() { | ||
table1.currentComposableKeyName shouldBe "fun-currentComposableKeyName1()Unit/pkg-land.sungbin.composeinvestigator.compiler.test.source.table.invalidationtracktablecall/file-TableCallFile1.kt" | ||
} |
32 changes: 32 additions & 0 deletions
32
...mposeinvestigator/compiler/test/source/table/invalidationtracktablecall/TableCallFile2.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Designed and developed by Ji Sungbin 2023. | ||
* | ||
* Licensed under the MIT. | ||
* Please see full license: https://github.com/jisungbin/ComposeInvestigator/blob/main/LICENSE | ||
*/ | ||
|
||
package land.sungbin.composeinvestigator.compiler.test.source.table.invalidationtracktablecall | ||
|
||
import io.kotest.matchers.shouldBe | ||
import io.kotest.matchers.types.shouldBeSameInstanceAs | ||
import land.sungbin.composeinvestigator.runtime.ComposableName | ||
import land.sungbin.composeinvestigator.runtime.currentComposableInvalidationTracker | ||
import land.sungbin.composeinvestigator.runtime.getValue | ||
|
||
val table2 = currentComposableInvalidationTracker | ||
|
||
fun table2() { | ||
table2 shouldBeSameInstanceAs currentComposableInvalidationTracker | ||
} | ||
|
||
fun currentComposableName2() { | ||
val prevComposableName by table2.currentComposableName | ||
prevComposableName shouldBe "currentComposableName2" | ||
|
||
table2.currentComposableName = ComposableName("ChangedComposableName2") | ||
table2.currentComposableName.name shouldBe "ChangedComposableName2" | ||
} | ||
|
||
fun currentComposableKeyName2() { | ||
table2.currentComposableKeyName shouldBe "fun-currentComposableKeyName2()Unit/pkg-land.sungbin.composeinvestigator.compiler.test.source.table.invalidationtracktablecall/file-TableCallFile2.kt" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.