[5.1][IDE][Index] Property wrapper rename support #25871
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry-pick of #25758 for swift-5.1-branch
This PR fixes up rename support for property wrappers. There were three main issues this addresses:
@propertyWrapper
struct was failing due to rename'sNameMatcher
using the range of aDecl
itself, not including its attributes, to decide if it contained a location that needed to be resolved.@propertyWrapper
struct would not pick up occurrences of that constructor's argument labels used in custom attributes, e.g. renamingMyWrapper
'sinit(initialValue:minValue:maxValue)
constructor would miss the argument labels in custom attributes like@MyWrapper(initialValue: 50, minValue: 0, maxValue: 100)
. This is because the indexer didn't report an occurrence of the constructor call in custom attributes. Rename'sNameMatcher
also needed to be updated to handle resolving these newly-added occurrences, since the call expression in the AST doesn't have an explicit base (MyWrapper
is not part of the call expression, but is where the index reports the call taking place).foo
) wasn't updating the corresponding synthesized$
-prefixed backing property ($foo
). The synthesized backing property declarations were implicit, so the index wasn't recording them, and even if it did, it's a different property so wouldn't be picked up automatically.To resolve this, the index now records an occurrence of the wrapped property within the synthesized backing property occurrences (i.e. on the
foo
within each$foo
) so that rename on the wrapped property updates the synthesized backing property occurrences too. To support rename being invoked via an occurrence of a synthesized property, theCusorInfo
request that determines which symbol is renamed for a given location now treats occurrences of synthesized properties as if they were the corresponding wrapped properties. TheFindRelatedIdents
request was also similarly updated so that rename-like features that are based on it (like Xcode's edit-all-in-scope) can get both the underlying and synthesized property ranges, regardless of which is was invoked on.This PR also includes some small and/or incidental IDE issue fixes around custom attributes:
Resolves rdar://problem/49036613
Resolves rdar://problem/50073641
Resolves rdar://problem/51695783
Resolves rdar://problem/52053678