Skip to content

Conversation

@ahoppen
Copy link
Member

@ahoppen ahoppen commented Apr 16, 2024

Eg. when requesting type hierarchy of a class when the project hasn’t been built, sourcekit-lsp returns an empty array. That causes VS Code to fail with very ambiguous error messages

  • MISSING provider
  • Cannot read properties of null (reading 'kind')

To work around this, instead of returning an empty array, return nil instead.

rdar://126228814

…kit-lsp should return `nil`

Eg. when requesting type hierarchy of a class when the project hasn’t been built, sourcekit-lsp returns an empty array. That causes VS Code to fail with very ambiguous error messages
- MISSING provider
- Cannot read properties of null (reading 'kind')

To work around this, instead of returning an empty array, return `nil` instead.

rdar://126228814
@ahoppen ahoppen requested a review from bnbarham April 16, 2024 18:26
@ahoppen ahoppen requested a review from benlangmuir as a code owner April 16, 2024 18:26
@ahoppen ahoppen force-pushed the nil-for-empty-prepare-type-hierarchy branch from 5b0caf1 to f482982 Compare April 16, 2024 18:26
@ahoppen
Copy link
Member Author

ahoppen commented Apr 16, 2024

@swift-ci Please test

.sorted(by: { $0.name < $1.name })

if typeHierarchyItems.isEmpty {
// When returning an empty array, VS Code fails with the following two errors. Returning `nil` works around those
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is because it always expects at least the original element itself? Does call hierarchy have the same issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

Call hierarchy doesn’t seem to have that issue.

@dschaefer2
Copy link
Member

You're ahead of me. :). Saw that today too. Thanks!

@ahoppen ahoppen merged commit 63171ab into swiftlang:main Apr 17, 2024
@ahoppen ahoppen deleted the nil-for-empty-prepare-type-hierarchy branch August 4, 2025 10:48
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.

3 participants