Skip to content

Conversation

d-ronnqvist
Copy link
Contributor

@d-ronnqvist d-ronnqvist commented Sep 29, 2025

  • Explanation: This improves the handling of snippet symbol graph files by no longer relying on main module / bystander logic and instead detecting snippets based on their symbol kind and handling them in a dedicated code path.
  • Scope: Snippets non-deterministically aren't recognized.
  • Issue: rdar://147926589 rdar://161164434 Snippet isn't consistently being recognized #1280
  • Risk: Low. (Isolated to Snippets and the projects that use them).
  • Testing: Added tests that verify that snippets are recognized, that they're not processed as "regular" symbols/modules, and that verifies the user-facing diagnostics when they correctly can't be found (for example because of misspellings). Existing automated tests pass.
  • Reviewer: @QuietMisdreavus @heckj
  • Original PR: Improve handling of snippet symbol graph files #1302

This also cherry-picks #1308 (a test-only change) which was reviewed by @patshaughnessy

* Separate snippets from other symbols

rdar://147926589 rdar://161164434 swiftlang#1280

* Rename tests to clarify what they're verifying

* Improve tests around optional snippet prefix components

* Add additional test about resolving and rendering snippets

* Make it easier to verify the diagnostic log output in tests

* Add additional test about snippet warnings

Also, update the behavior when a snippet slice is misspelled to match what's described in the warning.

* Move snippet diagnostic creation to resolver type

* Add near-miss suggestions for snippet paths and slices

* Only highlight the misspelled portion of snippet paths

* Update user-facing documentation about optional snippet paths prefixes

* Clarify that Snippet argument parsing problems are reported elsewhere

* Fix typo in code comment

* Update docs about earliest version with an optional snippet path prefix
@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

Depending on which symbol was _first_ in the dictionary of symbols, the entire symbol graph was categorized as either a snippet symbol graph or a regular symbol graph.
However, real symbol graph files don't mix snippets and framework symbols like that. This fixes the test to don't mix snippets with real symbols.
It also stops adding module nodes inside the symbol graph, because that also doesn't match real symbol graph files.
@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist d-ronnqvist requested a review from Teapane September 29, 2025 15:37
@d-ronnqvist d-ronnqvist merged commit 4be8229 into swiftlang:release/6.2 Sep 29, 2025
2 checks passed
@d-ronnqvist d-ronnqvist deleted the separate-snippets-resolver-6.2 branch September 29, 2025 15:46
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