From e1ae330d4b94232f03fe8211780624648fa83e22 Mon Sep 17 00:00:00 2001 From: Vinay Gaba Date: Tue, 8 Feb 2022 09:24:53 -0800 Subject: [PATCH] Fix super small previews when @Preview annotation doesn't specify width and height (#219) --- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- ...adata_com_airbnb_android_showkase_processor_testing.kt | 8 ++------ ...adata_com_airbnb_android_showkase_processor_testing.kt | 2 -- .../output/TestShowkaseRootCodegen.kt | 2 -- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- .../output/TestShowkaseRootCodegen.kt | 2 -- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- ...adata_com_airbnb_android_showkase_processor_testing.kt | 2 -- ...adata_com_airbnb_android_showkase_processor_testing.kt | 6 +----- .../output/TestShowkaseRootCodegen.kt | 4 ---- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- .../output/TestShowkaseRootCodegen.kt | 2 -- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- ...adata_com_airbnb_android_showkase_processor_testing.kt | 4 +--- .../android/showkase/processor/models/ShowkaseMetadata.kt | 7 +++++-- 24 files changed, 23 insertions(+), 72 deletions(-) diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_companion_object_with_preview_annotation_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_companion_object_with_preview_annotation_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 5e48df08..007901aa 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_companion_object_with_preview_annotation_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_companion_object_with_preview_annotation_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -17,9 +17,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { showkaseKDoc = "", enclosingClass = [ShowkaseClass::class], showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun group_name(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_companion_object_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_companion_object_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 89a052ca..9eec7251 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_companion_object_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_companion_object_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -17,9 +17,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { showkaseKDoc = "", enclosingClass = [WrapperClass::class], showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun group_name(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_object_with_preview_annotation_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_object_with_preview_annotation_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 76e37a76..08f58462 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_object_with_preview_annotation_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_object_with_preview_annotation_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -17,9 +17,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { showkaseKDoc = "", enclosingClass = [ShowkaseObject::class], showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun group_name(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_object_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_object_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 7ac01c43..ea8c2b14 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_object_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_function_inside_object_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -17,9 +17,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { showkaseKDoc = "", enclosingClass = [WrapperObject::class], showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun group_name(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_with_preview_annotation_inside_class_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_with_preview_annotation_inside_class_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 70c77a72..068afb22 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_with_preview_annotation_inside_class_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/composable_with_preview_annotation_inside_class_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -17,9 +17,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { showkaseKDoc = "", enclosingClass = [Composables::class], showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun group_name(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/function_inside_class_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/function_inside_class_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 02304d36..704611b3 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/function_inside_class_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/function_inside_class_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -17,9 +17,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { showkaseKDoc = "", enclosingClass = [WrapperClass::class], showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun WrapperClass_TestComposable(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/function_inside_companion_object_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/function_inside_companion_object_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index d18ab753..78e88a66 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/function_inside_companion_object_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/function_inside_companion_object_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -17,9 +17,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { showkaseKDoc = "", enclosingClass = [WrapperClass::class], showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun WrapperClass_TestComposable(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/function_inside_object_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/function_inside_object_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index d18ab753..78e88a66 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/function_inside_object_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/function_inside_object_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -17,9 +17,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { showkaseKDoc = "", enclosingClass = [WrapperClass::class], showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun WrapperClass_TestComposable(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/multiple_composable_functions_with_preview_and_showkase_annotations_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/multiple_composable_functions_with_preview_and_showkase_annotations_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 276e36b2..bcfea0c1 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/multiple_composable_functions_with_preview_and_showkase_annotations_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/multiple_composable_functions_with_preview_and_showkase_annotations_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -15,9 +15,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { insideWrapperClass = false, showkaseKDoc = "", showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun group1_name1(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/multiple_composable_functions_with_preview_annotations_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/multiple_composable_functions_with_preview_annotations_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index cea781be..bcfea0c1 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/multiple_composable_functions_with_preview_annotations_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/multiple_composable_functions_with_preview_annotations_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -15,9 +15,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { insideWrapperClass = false, showkaseKDoc = "", showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun group1_name1(): Unit { } @@ -32,9 +30,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { insideWrapperClass = false, showkaseKDoc = "", showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun group1_name2(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/object_function_with_preview_annotation_and_preview_parameter_and_showkaseroot/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/object_function_with_preview_annotation_and_preview_parameter_and_showkaseroot/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 3e3cc374..fc35ecd9 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/object_function_with_preview_annotation_and_preview_parameter_and_showkaseroot/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/object_function_with_preview_annotation_and_preview_parameter_and_showkaseroot/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -19,8 +19,6 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { enclosingClass = [WrapperClass::class], showkaseMetadataType = "COMPONENT", isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1, previewParameterClass = [ParameterProvider::class] ) public fun group_name(): Unit { diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/object_function_with_preview_annotation_and_preview_parameter_and_showkaseroot/output/TestShowkaseRootCodegen.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/object_function_with_preview_annotation_and_preview_parameter_and_showkaseroot/output/TestShowkaseRootCodegen.kt index 7ff1538f..32d77e20 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/object_function_with_preview_annotation_and_preview_parameter_and_showkaseroot/output/TestShowkaseRootCodegen.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/object_function_with_preview_annotation_and_preview_parameter_and_showkaseroot/output/TestShowkaseRootCodegen.kt @@ -28,8 +28,6 @@ public class TestShowkaseRootCodegen : ShowkaseProvider { componentKey = """com.airbnb.android.showkase_processor_testing_com.airbnb.android.showkase_processor_testing.WrapperClass_group_name_null_$index""", isDefaultStyle = false, - widthDp = -1, - heightDp = -1, component = @Composable { WrapperClass.TestComposable(previewParam) } ) ) diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_and_showkaseroot_generates_1_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_and_showkaseroot_generates_1_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 4206cd2a..0334d0e6 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_and_showkaseroot_generates_1_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_and_showkaseroot_generates_1_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -15,9 +15,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { insideWrapperClass = false, showkaseKDoc = "", showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun group_name(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_and_showkaseroot_generates_1_file/output/TestShowkaseRootCodegen.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_and_showkaseroot_generates_1_file/output/TestShowkaseRootCodegen.kt index fbafa36d..103c198c 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_and_showkaseroot_generates_1_file/output/TestShowkaseRootCodegen.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_and_showkaseroot_generates_1_file/output/TestShowkaseRootCodegen.kt @@ -24,8 +24,6 @@ public class TestShowkaseRootCodegen : ShowkaseProvider { componentKDoc = "", componentKey = """com.airbnb.android.showkase_processor_testing_null_group_name_null""", isDefaultStyle = false, - widthDp = -1, - heightDp = -1, component = @Composable { TestComposable() }) ) diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_annotation_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_annotation_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 4206cd2a..0334d0e6 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_annotation_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_annotation_compiles_ok/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -15,9 +15,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { insideWrapperClass = false, showkaseKDoc = "", showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun group_name(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 4206cd2a..0334d0e6 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -15,9 +15,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { insideWrapperClass = false, showkaseKDoc = "", showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun group_name(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_parameter_and_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_parameter_and_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 64d8bc7b..7747b9f4 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_parameter_and_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_composable_function_with_preview_parameter_and_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -17,8 +17,6 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { showkaseKDoc = "", showkaseMetadataType = "COMPONENT", isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1, previewParameterClass = [ParameterProvider::class] ) public fun group_name(): Unit { diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_preview_parameter_and_showkaseroot_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_preview_parameter_and_showkaseroot_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 930399d7..3cafea18 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_preview_parameter_and_showkaseroot_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_preview_parameter_and_showkaseroot_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -16,9 +16,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { insideWrapperClass = false, showkaseKDoc = "", showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun Default_Group_TestComposable(): Unit { } @@ -34,8 +32,6 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { showkaseKDoc = "", showkaseMetadataType = "COMPONENT", isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1, previewParameterClass = [ParameterProvider::class] ) public fun Default_Group_TestComposable2(): Unit { diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_preview_parameter_and_showkaseroot_and_no_name_or_group/output/TestShowkaseRootCodegen.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_preview_parameter_and_showkaseroot_and_no_name_or_group/output/TestShowkaseRootCodegen.kt index 722be2f2..deccfa03 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_preview_parameter_and_showkaseroot_and_no_name_or_group/output/TestShowkaseRootCodegen.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_preview_parameter_and_showkaseroot_and_no_name_or_group/output/TestShowkaseRootCodegen.kt @@ -25,8 +25,6 @@ public class TestShowkaseRootCodegen : ShowkaseProvider { componentKey = """com.airbnb.android.showkase_processor_testing_null_DefaultGroup_TestComposable_null""", isDefaultStyle = false, - widthDp = -1, - heightDp = -1, component = @Composable { TestComposable() }) ).apply { ParameterProvider().values.iterator().asSequence().forEachIndexed { index, previewParam -> @@ -39,8 +37,6 @@ public class TestShowkaseRootCodegen : ShowkaseProvider { componentKey = """com.airbnb.android.showkase_processor_testing_null_DefaultGroup_TestComposable2_null_$index""", isDefaultStyle = false, - widthDp = -1, - heightDp = -1, component = @Composable { TestComposable2(previewParam) } ) ) diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_showkaseroot_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_showkaseroot_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 5d018700..432c101d 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_showkaseroot_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_showkaseroot_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -15,9 +15,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { insideWrapperClass = false, showkaseKDoc = "", showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun Default_Group_TestComposable(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_showkaseroot_and_no_name_or_group/output/TestShowkaseRootCodegen.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_showkaseroot_and_no_name_or_group/output/TestShowkaseRootCodegen.kt index c75f7af8..311dce9b 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_showkaseroot_and_no_name_or_group/output/TestShowkaseRootCodegen.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_and_showkaseroot_and_no_name_or_group/output/TestShowkaseRootCodegen.kt @@ -25,8 +25,6 @@ public class TestShowkaseRootCodegen : ShowkaseProvider { componentKey = """com.airbnb.android.showkase_processor_testing_null_DefaultGroup_TestComposable_null""", isDefaultStyle = false, - widthDp = -1, - heightDp = -1, component = @Composable { TestComposable() }) ) diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 810473b2..e799de00 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/top_level_function_with_preview_annotation_and_no_name_or_group/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -15,9 +15,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { insideWrapperClass = false, showkaseKDoc = "", showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun Default_Group_TestComposable(): Unit { } diff --git a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/wrapped_composable_function_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/wrapped_composable_function_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt index 4363df8b..e15511cc 100644 --- a/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/wrapped_composable_function_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt +++ b/showkase-processor-testing/src/test/resources/ShowkaseProcessorTest/wrapped_composable_function_with_preview_annotation_generates_only_metadata_file/output/ShowkaseMetadata_com_airbnb_android_showkase_processor_testing.kt @@ -17,9 +17,7 @@ public class ShowkaseMetadata_com_airbnb_android_showkase_processor_testing { showkaseKDoc = "", enclosingClass = [WrapperClass::class], showkaseMetadataType = "COMPONENT", - isDefaultStyle = false, - showkaseWidthDp = -1, - showkaseHeightDp = -1 + isDefaultStyle = false ) public fun group_name(): Unit { } diff --git a/showkase-processor/src/main/java/com/airbnb/android/showkase/processor/models/ShowkaseMetadata.kt b/showkase-processor/src/main/java/com/airbnb/android/showkase/processor/models/ShowkaseMetadata.kt index a28c31b6..e055a6fe 100644 --- a/showkase-processor/src/main/java/com/airbnb/android/showkase/processor/models/ShowkaseMetadata.kt +++ b/showkase-processor/src/main/java/com/airbnb/android/showkase/processor/models/ShowkaseMetadata.kt @@ -263,6 +263,9 @@ internal fun getShowkaseMetadataFromPreview( commonMetadata.enclosingClass, ) + val width = previewAnnotation.getAsInt("widthDp") + val height = previewAnnotation.getAsInt("heightDp") + return ShowkaseMetadata.Component( packageSimpleName = commonMetadata.moduleName, packageName = commonMetadata.packageName, @@ -271,8 +274,8 @@ internal fun getShowkaseMetadataFromPreview( showkaseKDoc = commonMetadata.kDoc, showkaseName = showkaseName, showkaseGroup = showkaseGroup, - showkaseWidthDp = previewAnnotation.getAsInt("widthDp"), - showkaseHeightDp = previewAnnotation.getAsInt("heightDp"), + showkaseWidthDp = if (width == -1) null else width, + showkaseHeightDp = if (height == -1) null else width, insideWrapperClass = commonMetadata.showkaseFunctionType == ShowkaseFunctionType.INSIDE_CLASS, insideObject = commonMetadata.showkaseFunctionType.insideObject(), element = element,