Skip to content

fix(snippets): clean up region tags, remove dummy getter blocks, and fix Kotlin/Java parity - #2451

Merged
dkhawk merged 1 commit into
mainfrom
fix/snippet-region-tags
Oct 14, 2026
Merged

dkhawk merged 1 commit into
mainfrom
fix/snippet-region-tags

Conversation

@dkhawk

@dkhawk dkhawk commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Cleans up DevSite region tags and snippet bodies across :snippets:kotlin-app and :snippets:java-app following the PR #2427 migration:

  • MapInitSnippets (maps_android_map_type & maps_android_map_fragment):
    • Fixes maps_android_map_type in MapInitSnippets.kt so it wraps map.mapType = GoogleMap.MAP_TYPE_HYBRID instead of map.setIndoorEnabled(true), and removes the extraneous indoor map enable/getter calls from both Kotlin and Java (maps_android_indoor_* snippets already exist in IndoorSnippets and EventsSnippets).
    • Exposes var mapType: Int on Kotlin TrackedMap.
    • Wraps the if (context is FragmentActivity) harness check in MapInitSnippets.kt (maps_android_map_fragment) in // [START_EXCLUDE silent] to match MapInitSnippets.java, and imports MapColorScheme in both files.
  • Remove Artificial Unused Getter Blocks (MarkerSnippets, OverlaySnippets, ShapesSnippets):
    • Removes dead .let { ... } / if (... != null) { ... } blocks that assigned unused local variables for every getter on Marker, GroundOverlay, TileOverlay, Polyline, Polygon, and Circle (which were un-excluded in Kotlin and leaking into DevSite snippets).
  • DatasetLayerSnippets & DataDrivenBoundarySnippets Region Tag Parity:
    • Wraps the sample app's custom Button filter UI in DatasetLayerSnippets.java inside // [START_EXCLUDE silent] and extends maps_android_dds_boulder_trails to include applyBoulderStyling(FeatureLayer layer).
    • Removes the _java suffix from region tags in DatasetLayerSnippets.java and DataDrivenBoundarySnippets.java so they match DatasetLayerSnippets.kt and DataDrivenBoundarySnippets.kt.
  • UtilsSnippets & OverlaySnippets Cleanup:
    • Moves demo-app map.moveCamera(...) calls outside maps_android_markers_draggable, maps_android_utils_heatmap_simple, and maps_android_utils_heatmap_customize, and replaces fully-qualified com.google.android.gms.maps.* references with imports.
    • Adds @SnippetItem(title = "7b. Remove KML Layer", ...) to UtilsSnippets.kt, adds clusterManager.cluster() to maps_android_utils_clustering_info_window in UtilsSnippets.java, and uses provider.setWeightedData(data) in UtilsSnippets.java.
    • Fixes the corrupted Apache license URL in OverlaySnippets.kt.
  • Catalog & Coverage Generator (catalog_api.py, CATALOG.md, COVERAGE.md):
    • Treats is* boolean getters the same as get*/set* when checking for missing non-getter/setter APIs.
    • Scans AGP 9's built_in_kotlinc output directory and skips Kotlin-only GoogleMapKt extensions in the Java coverage section.
    • Increases the @SnippetItem to [START ...] line window so 1. Dataset - Boulder Trails maps to maps_android_dds_boulder_trails.

Test Plan

  • ./gradlew :snippets:kotlin-app:assembleDebug :snippets:java-app:assembleDebug
  • python3 snippets/scripts/catalog_api.py (0 missing APIs in Kotlin and 0 in Java)

@dkhawk
dkhawk requested a review from LoyalAbbas October 13, 2026 17:20
@dkhawk
dkhawk marked this pull request as ready for review October 13, 2026 19:42
@snippet-bot

snippet-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Here is the summary of changes.

You are about to add 7 region tags.
You are about to delete 7 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

return null;
});
}
// [END maps_android_dds_boulder_trails]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

With the END moved here, maps_android_dds_boulder_trails now covers two methods: it starts in the middle of styleBoulderTrails(), includes its closing brace and the signature of applyBoulderStyling, and ends before that method's closing brace. On DevSite the braces will look unbalanced. Could we either keep the styling inline like the Kotlin version (or a local lambda, like the Kyoto snippet does), or give applyBoulderStyling its own region tag?

)
public void styleLocalityBoundary() {
// [START maps_android_dds_locality_boundary_java]
// [START maps_android_dds_locality_boundary]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just to double check: these _java tags only landed in #2426 on Oct 8, so I guess no DevSite page is pointing to them yet and renaming is safe, or do I miss anything?

Comment thread snippets/scripts/catalog_api.py Outdated
if filepath in region_tags:
for region in region_tags[filepath]:
if region['start'] <= (i + 15) and region['end'] >= i:
if region['start'] <= (i + 25) and region['end'] >= i:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: the window going from 15 to 25 lines will probably break again with the next long description. Just a random idea: could we take the first [START ...] after the @SnippetItem line instead of a fixed window?

@kikoso kikoso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM! Nice cleanup, the snippets read much better without the getter blocks. Just a few minor comments, nothing blocking.

@dkhawk
dkhawk force-pushed the fix/snippet-region-tags branch from 9767989 to 60765e4 Compare October 14, 2026 17:56
@dkhawk
dkhawk merged commit 1bcdae2 into main Oct 14, 2026
20 checks passed
@dkhawk
dkhawk deleted the fix/snippet-region-tags branch October 14, 2026 18:06
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