Skip to content
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

Add recursive lookup for transitive preview annotations #71

Merged
merged 8 commits into from
Sep 29, 2023

Conversation

trevor-e
Copy link
Contributor

@trevor-e trevor-e commented Sep 27, 2023

Second part of correctly resolving multi-previews, now we can resolve arbitrary levels of multi-preview annotations.

  1. Finds all symbols that have a direct or transitive @Preview annotation by recursively checking annotation classes. Transitive @Preview annotations would be those from a multi-preview.
  2. Once we know the symbols annotated with a preview annotation, a second step filters that down to only functions.
  3. After we have the functions, we have to then fetch all direct or transitive preview annotations on the function and build up a list of unique snapshot configs. This bit was tricky and does repeat some of the step 1 work from earlier, but not too concerned about the perf impact here.
  4. Snapshot generation then proceeds like normal.

Testing:
I created a new @SnapshotTestingPreview and updated some existing previews to use this new annotation. The snapshot output is still the same:
Screenshot 2023-09-28 at 11 01 51 AM

@@ -25,8 +25,7 @@ fun TextRowWithIcon(
}

@Preview
@FontScalePreviews
@LocalePreviews
@SnapshotTestingPreview
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit: Could we make this a separate preview to make sure we can test both the outputs of stacked multipreviews directly on the composable and from the stacked multipreview annotation?

@rbro112 rbro112 changed the base branch from telkins/find-module-annotations to main September 29, 2023 16:56
@rbro112 rbro112 force-pushed the telkins/find-transitive-previews branch from 61d4dcd to 57419d7 Compare September 29, 2023 16:56
Copy link
Contributor

rbro112 commented Sep 29, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@trevor-e trevor-e merged commit 5b4f583 into main Sep 29, 2023
5 checks passed
@trevor-e trevor-e deleted the telkins/find-transitive-previews branch October 18, 2023 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants