Skip to content

[Index] Avoid forming relations to non-indexed decls #72930

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

Merged
merged 2 commits into from
Apr 10, 2024

Conversation

hamishknight
Copy link
Contributor

Make sure to check whether we are able to index a decl before reporting it as a relation. Additionally for containers, walk up the stack to find the first container that we can index, avoiding treating local variables as containers when we're not indexing them.

rdar://126137541


if (!Entry.ActiveKey)
return;
SmallVector<const Decl *, 4> Containers;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could have a bool for whether we actually allowed any decls or not and then just use f(D) in the two if's, but if you prefer this I'd move the Containers out of the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, don't feel too strongly, switched to using a bool

Check to see whether we can index the given decl
before reporting it as a container, walking up to
a parent if we need to. This also lets us simplify
the AnyPattern handling a bit.

rdar://126137541
If we shouldn't index the related decl, don't record
it as a relation.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit f933f2a into swiftlang:main Apr 10, 2024
5 checks passed
@hamishknight hamishknight deleted the containment branch April 10, 2024 09:48
ahoppen added a commit to ahoppen/sourcekit-lsp that referenced this pull request Apr 19, 2024
With swiftlang/swift#72930 we can use the `containedBy` instead of `calledBy` relation for the call hierarchy, which allows us to show unapplied function references in the call hierarchy as well.

rdar://123769825
ahoppen added a commit to ahoppen/sourcekit-lsp that referenced this pull request Apr 19, 2024
With swiftlang/swift#72930 we can use the `containedBy` instead of `calledBy` relation for the call hierarchy, which allows us to show unapplied function references in the call hierarchy as well.

rdar://123769825
ahoppen added a commit to ahoppen/sourcekit-lsp that referenced this pull request Apr 20, 2024
With swiftlang/swift#72930 we can use the `containedBy` instead of `calledBy` relation for the call hierarchy, which allows us to show unapplied function references in the call hierarchy as well.

rdar://123769825
plemarquand pushed a commit to plemarquand/sourcekit-lsp that referenced this pull request Apr 24, 2024
With swiftlang/swift#72930 we can use the `containedBy` instead of `calledBy` relation for the call hierarchy, which allows us to show unapplied function references in the call hierarchy as well.

rdar://123769825
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