-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add ResourceContentHash annotation to generated resource accessors #5357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d506f5c
Add ResourceContentHash annotation to generated resource accessors.
pjBooms 3dec5d3
Generate ResourceContentHash annotation only when the respective syst…
pjBooms 227d3ba
Review fixes
pjBooms 81524ae
Use misc/CommonResources for testGeneratedAccessorsAnnotatedWithResou…
pjBooms 1892dba
Handle Windows in the test
pjBooms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...rces/library/src/commonMain/kotlin/org/jetbrains/compose/resources/ResourceContentHash.kt
This file contains hidden or 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,5 @@ | ||
| package org.jetbrains.compose.resources | ||
|
|
||
| @Suppress("unused") | ||
| @Retention(AnnotationRetention.BINARY) | ||
| annotation class ResourceContentHash(val hash: Int) | ||
This file contains hidden or 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 hidden or 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 hidden or 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
25 changes: 25 additions & 0 deletions
25
...MainResourceAccessors/app/group/resources_test/generated/resources/String0.androidMain.kt
This file contains hidden or 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,25 @@ | ||
| @file:OptIn(InternalResourceApi::class) | ||
|
|
||
| package app.group.resources_test.generated.resources | ||
|
|
||
| import kotlin.OptIn | ||
| import kotlin.String | ||
| import kotlin.collections.MutableMap | ||
| import org.jetbrains.compose.resources.InternalResourceApi | ||
| import org.jetbrains.compose.resources.ResourceContentHash | ||
| import org.jetbrains.compose.resources.ResourceItem | ||
| import org.jetbrains.compose.resources.StringResource | ||
|
|
||
| private const val MD: String = "composeResources/app.group.resources_test.generated.resources/" | ||
|
|
||
| @delegate:ResourceContentHash(50_967_853) | ||
| internal val Res.string.android_str: StringResource by lazy { | ||
| StringResource("string:android_str", "android_str", setOf( | ||
| ResourceItem(setOf(), "${MD}values/strings.androidMain.cvr", 10, 39), | ||
| )) | ||
| } | ||
|
|
||
| @InternalResourceApi | ||
| internal fun _collectAndroidMainString0Resources(map: MutableMap<String, StringResource>) { | ||
| map.put("android_str", Res.string.android_str) | ||
| } |
42 changes: 42 additions & 0 deletions
42
...sourceCollectors/app/group/resources_test/generated/resources/ActualResourceCollectors.kt
This file contains hidden or 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,42 @@ | ||
| @file:OptIn(org.jetbrains.compose.resources.InternalResourceApi::class) | ||
|
|
||
| package app.group.resources_test.generated.resources | ||
|
|
||
| import kotlin.OptIn | ||
| import kotlin.String | ||
| import kotlin.collections.Map | ||
| import org.jetbrains.compose.resources.DrawableResource | ||
| import org.jetbrains.compose.resources.FontResource | ||
| import org.jetbrains.compose.resources.PluralStringResource | ||
| import org.jetbrains.compose.resources.StringArrayResource | ||
| import org.jetbrains.compose.resources.StringResource | ||
|
|
||
| internal actual val Res.allDrawableResources: Map<String, DrawableResource> by lazy { | ||
| val map = mutableMapOf<String, DrawableResource>() | ||
| _collectCommonMainDrawable0Resources(map) | ||
| return@lazy map | ||
| } | ||
|
|
||
| internal actual val Res.allStringResources: Map<String, StringResource> by lazy { | ||
| val map = mutableMapOf<String, StringResource>() | ||
| _collectAndroidMainString0Resources(map) | ||
| _collectCommonMainString0Resources(map) | ||
| return@lazy map | ||
| } | ||
|
|
||
| internal actual val Res.allStringArrayResources: Map<String, StringArrayResource> by lazy { | ||
| val map = mutableMapOf<String, StringArrayResource>() | ||
| return@lazy map | ||
| } | ||
|
|
||
| internal actual val Res.allPluralStringResources: Map<String, PluralStringResource> by lazy { | ||
| val map = mutableMapOf<String, PluralStringResource>() | ||
| _collectCommonMainPlurals0Resources(map) | ||
| return@lazy map | ||
| } | ||
|
|
||
| internal actual val Res.allFontResources: Map<String, FontResource> by lazy { | ||
| val map = mutableMapOf<String, FontResource>() | ||
| _collectCommonMainFont0Resources(map) | ||
| return@lazy map | ||
| } |
64 changes: 64 additions & 0 deletions
64
...ainResourceAccessors/app/group/resources_test/generated/resources/Drawable0.commonMain.kt
This file contains hidden or 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,64 @@ | ||
| @file:OptIn(InternalResourceApi::class) | ||
|
|
||
| package app.group.resources_test.generated.resources | ||
|
|
||
| import kotlin.OptIn | ||
| import kotlin.String | ||
| import kotlin.collections.MutableMap | ||
| import org.jetbrains.compose.resources.DrawableResource | ||
| import org.jetbrains.compose.resources.InternalResourceApi | ||
| import org.jetbrains.compose.resources.LanguageQualifier | ||
| import org.jetbrains.compose.resources.RegionQualifier | ||
| import org.jetbrains.compose.resources.ResourceContentHash | ||
| import org.jetbrains.compose.resources.ResourceItem | ||
| import org.jetbrains.compose.resources.ThemeQualifier | ||
|
|
||
| private const val MD: String = "composeResources/app.group.resources_test.generated.resources/" | ||
|
|
||
| @delegate:ResourceContentHash(-1_453_679_588) | ||
| internal val Res.drawable._3_strange_name: DrawableResource by lazy { | ||
| DrawableResource("drawable:_3_strange_name", setOf( | ||
| ResourceItem(setOf(), "${MD}drawable/3-strange-name.xml", -1, -1), | ||
| )) | ||
| } | ||
|
|
||
| @delegate:ResourceContentHash(-1_453_679_588) | ||
| internal val Res.drawable.camelCaseName: DrawableResource by lazy { | ||
| DrawableResource("drawable:camelCaseName", setOf( | ||
| ResourceItem(setOf(), "${MD}drawable/camelCaseName.xml", -1, -1), | ||
| )) | ||
| } | ||
|
|
||
| @delegate:ResourceContentHash(-1_453_679_588) | ||
| internal val Res.drawable.`is`: DrawableResource by lazy { | ||
| DrawableResource("drawable:is", setOf( | ||
| ResourceItem(setOf(), "${MD}drawable/is.xml", -1, -1), | ||
| )) | ||
| } | ||
|
|
||
| @delegate:ResourceContentHash(-737_454_820) | ||
| internal val Res.drawable.vector: DrawableResource by lazy { | ||
| DrawableResource("drawable:vector", setOf( | ||
| ResourceItem(setOf(LanguageQualifier("ast"), ), "${MD}drawable-ast/vector.xml", -1, -1), | ||
| ResourceItem(setOf(LanguageQualifier("au"), RegionQualifier("US"), ), "${MD}drawable-au-rUS/vector.xml", -1, -1), | ||
| ResourceItem(setOf(ThemeQualifier.DARK, LanguageQualifier("ge"), ), "${MD}drawable-dark-ge/vector.xml", -1, -1), | ||
| ResourceItem(setOf(LanguageQualifier("en"), ), "${MD}drawable-en/vector.xml", -1, -1), | ||
| ResourceItem(setOf(), "${MD}drawable/vector.xml", -1, -1), | ||
| )) | ||
| } | ||
|
|
||
| @delegate:ResourceContentHash(-1_453_679_588) | ||
| internal val Res.drawable.vector_2: DrawableResource by lazy { | ||
| DrawableResource("drawable:vector_2", setOf( | ||
| ResourceItem(setOf(), "${MD}drawable/vector_2.xml", -1, -1), | ||
| )) | ||
| } | ||
|
|
||
| @InternalResourceApi | ||
| internal fun _collectCommonMainDrawable0Resources(map: MutableMap<String, DrawableResource>) { | ||
| map.put("_3_strange_name", Res.drawable._3_strange_name) | ||
| map.put("camelCaseName", Res.drawable.camelCaseName) | ||
| map.put("is", Res.drawable.`is`) | ||
| map.put("vector", Res.drawable.vector) | ||
| map.put("vector_2", Res.drawable.vector_2) | ||
| } |
27 changes: 27 additions & 0 deletions
27
...monMainResourceAccessors/app/group/resources_test/generated/resources/Font0.commonMain.kt
This file contains hidden or 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,27 @@ | ||
| @file:OptIn(InternalResourceApi::class) | ||
|
|
||
| package app.group.resources_test.generated.resources | ||
|
|
||
| import kotlin.OptIn | ||
| import kotlin.String | ||
| import kotlin.collections.MutableMap | ||
| import org.jetbrains.compose.resources.FontResource | ||
| import org.jetbrains.compose.resources.InternalResourceApi | ||
| import org.jetbrains.compose.resources.LanguageQualifier | ||
| import org.jetbrains.compose.resources.ResourceContentHash | ||
| import org.jetbrains.compose.resources.ResourceItem | ||
|
|
||
| private const val MD: String = "composeResources/app.group.resources_test.generated.resources/" | ||
|
|
||
| @delegate:ResourceContentHash(1_893_715_104) | ||
| internal val Res.font.emptyFont: FontResource by lazy { | ||
| FontResource("font:emptyFont", setOf( | ||
| ResourceItem(setOf(LanguageQualifier("en"), ), "${MD}font-en/emptyFont.otf", -1, -1), | ||
| ResourceItem(setOf(), "${MD}font/emptyFont.otf", -1, -1), | ||
| )) | ||
| } | ||
|
|
||
| @InternalResourceApi | ||
| internal fun _collectCommonMainFont0Resources(map: MutableMap<String, FontResource>) { | ||
| map.put("emptyFont", Res.font.emptyFont) | ||
| } |
25 changes: 25 additions & 0 deletions
25
...MainResourceAccessors/app/group/resources_test/generated/resources/Plurals0.commonMain.kt
This file contains hidden or 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,25 @@ | ||
| @file:OptIn(InternalResourceApi::class) | ||
|
|
||
| package app.group.resources_test.generated.resources | ||
|
|
||
| import kotlin.OptIn | ||
| import kotlin.String | ||
| import kotlin.collections.MutableMap | ||
| import org.jetbrains.compose.resources.InternalResourceApi | ||
| import org.jetbrains.compose.resources.PluralStringResource | ||
| import org.jetbrains.compose.resources.ResourceContentHash | ||
| import org.jetbrains.compose.resources.ResourceItem | ||
|
|
||
| private const val MD: String = "composeResources/app.group.resources_test.generated.resources/" | ||
|
|
||
| @delegate:ResourceContentHash(-199_361_196) | ||
| internal val Res.plurals.numberOfSongsAvailable: PluralStringResource by lazy { | ||
| PluralStringResource("plurals:numberOfSongsAvailable", "numberOfSongsAvailable", setOf( | ||
| ResourceItem(setOf(), "${MD}values/strings.commonMain.cvr", 10, 124), | ||
| )) | ||
| } | ||
|
|
||
| @InternalResourceApi | ||
| internal fun _collectCommonMainPlurals0Resources(map: MutableMap<String, PluralStringResource>) { | ||
| map.put("numberOfSongsAvailable", Res.plurals.numberOfSongsAvailable) | ||
| } |
81 changes: 81 additions & 0 deletions
81
...nMainResourceAccessors/app/group/resources_test/generated/resources/String0.commonMain.kt
This file contains hidden or 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,81 @@ | ||
| @file:OptIn(InternalResourceApi::class) | ||
|
|
||
| package app.group.resources_test.generated.resources | ||
|
|
||
| import kotlin.OptIn | ||
| import kotlin.String | ||
| import kotlin.collections.MutableMap | ||
| import org.jetbrains.compose.resources.InternalResourceApi | ||
| import org.jetbrains.compose.resources.ResourceContentHash | ||
| import org.jetbrains.compose.resources.ResourceItem | ||
| import org.jetbrains.compose.resources.StringResource | ||
|
|
||
| private const val MD: String = "composeResources/app.group.resources_test.generated.resources/" | ||
|
|
||
| @delegate:ResourceContentHash(405_464_824) | ||
| internal val Res.string.PascalCase: StringResource by lazy { | ||
| StringResource("string:PascalCase", "PascalCase", setOf( | ||
| ResourceItem(setOf(), "${MD}values/strings.commonMain.cvr", 172, 34), | ||
| )) | ||
| } | ||
|
|
||
| @delegate:ResourceContentHash(-1_118_290_776) | ||
| internal val Res.string._1_kebab_case: StringResource by lazy { | ||
| StringResource("string:_1_kebab_case", "_1_kebab_case", setOf( | ||
| ResourceItem(setOf(), "${MD}values/strings.commonMain.cvr", 135, 36), | ||
| )) | ||
| } | ||
|
|
||
| @delegate:ResourceContentHash(64_828_505) | ||
| internal val Res.string.app_name: StringResource by lazy { | ||
| StringResource("string:app_name", "app_name", setOf( | ||
| ResourceItem(setOf(), "${MD}values/strings.commonMain.cvr", 207, 44), | ||
| )) | ||
| } | ||
|
|
||
| @delegate:ResourceContentHash(211_426_861) | ||
| internal val Res.string.camelCase: StringResource by lazy { | ||
| StringResource("string:camelCase", "camelCase", setOf( | ||
| ResourceItem(setOf(), "${MD}values/strings.commonMain.cvr", 252, 29), | ||
| )) | ||
| } | ||
|
|
||
| @delegate:ResourceContentHash(466_457_346) | ||
| internal val Res.string.hello: StringResource by lazy { | ||
| StringResource("string:hello", "hello", setOf( | ||
| ResourceItem(setOf(), "${MD}values/strings.commonMain.cvr", 282, 37), | ||
| )) | ||
| } | ||
|
|
||
| @delegate:ResourceContentHash(-1_288_591_563) | ||
| internal val Res.string.`info_using_release_$x`: StringResource by lazy { | ||
| StringResource("string:info_using_release_${'$'}x", "info_using_release_${'$'}x", setOf( | ||
| ResourceItem(setOf(), "${MD}values/strings.commonMain.cvr", 320, 57), | ||
| )) | ||
| } | ||
|
|
||
| @delegate:ResourceContentHash(-624_025_575) | ||
| internal val Res.string.multi_line: StringResource by lazy { | ||
| StringResource("string:multi_line", "multi_line", setOf( | ||
| ResourceItem(setOf(), "${MD}values/strings.commonMain.cvr", 378, 178), | ||
| )) | ||
| } | ||
|
|
||
| @delegate:ResourceContentHash(-1_332_636_786) | ||
| internal val Res.string.str_template: StringResource by lazy { | ||
| StringResource("string:str_template", "str_template", setOf( | ||
| ResourceItem(setOf(), "${MD}values/strings.commonMain.cvr", 557, 76), | ||
| )) | ||
| } | ||
|
|
||
| @InternalResourceApi | ||
| internal fun _collectCommonMainString0Resources(map: MutableMap<String, StringResource>) { | ||
| map.put("PascalCase", Res.string.PascalCase) | ||
| map.put("_1_kebab_case", Res.string._1_kebab_case) | ||
| map.put("app_name", Res.string.app_name) | ||
| map.put("camelCase", Res.string.camelCase) | ||
| map.put("hello", Res.string.hello) | ||
| map.put("info_using_release_${'$'}x", Res.string.`info_using_release_$x`) | ||
| map.put("multi_line", Res.string.multi_line) | ||
| map.put("str_template", Res.string.str_template) | ||
| } |
19 changes: 19 additions & 0 deletions
19
...sourceCollectors/app/group/resources_test/generated/resources/ExpectResourceCollectors.kt
This file contains hidden or 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,19 @@ | ||
| package app.group.resources_test.generated.resources | ||
|
|
||
| import kotlin.String | ||
| import kotlin.collections.Map | ||
| import org.jetbrains.compose.resources.DrawableResource | ||
| import org.jetbrains.compose.resources.FontResource | ||
| import org.jetbrains.compose.resources.PluralStringResource | ||
| import org.jetbrains.compose.resources.StringArrayResource | ||
| import org.jetbrains.compose.resources.StringResource | ||
|
|
||
| internal expect val Res.allDrawableResources: Map<String, DrawableResource> | ||
|
|
||
| internal expect val Res.allStringResources: Map<String, StringResource> | ||
|
|
||
| internal expect val Res.allStringArrayResources: Map<String, StringArrayResource> | ||
|
|
||
| internal expect val Res.allPluralStringResources: Map<String, PluralStringResource> | ||
|
|
||
| internal expect val Res.allFontResources: Map<String, FontResource> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.