Skip to content

[IDE][Refactoring] Handle 'callAsFunction' specially in syntactic rename #30964

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

Conversation

nathawes
Copy link
Contributor

@nathawes nathawes commented Apr 10, 2020

This change makes us treat it exactly as we do init. We don't allow renaming the base name (just the labels), and don't fail if the base name doesn't match for calls.

Note: syntactically we can only go by the passed-in symbol name being spelled callAsFunction to check if we should treat it as such, so even non-instance methods with the same spelling are treated as having a special base name when they shouldn't at the moment.

This also fixes a bug where init references weren't reporting a keywordBase range, and cursor info was reporting rename as available on init references/calls with no arguments (meaning there was nothing that could be renamed from that occurrence). It also fixes bug where function calls were incorrectly being reported as references in some cases, so rename was missing their argument labels.

Resolves rdar://problem/60340429

@nathawes nathawes requested a review from benlangmuir April 10, 2020 22:45
@nathawes
Copy link
Contributor Author

@swift-ci please test

@nathawes
Copy link
Contributor Author

@swift-ci please stress test

…ame.

This change makes us treat it exactly as we do 'init'. We don't allow renaming the base name,
and don't fail if the basename doesn't match for calls.

Also:
  - explicit init calls/references like `MyType.init(42)` are now reported with
    'init' as a keywordBase range, rather than nothing.
  - cursor info no longer reports rename as available on init/callAsFunction
    calls without arguments, as there's nothing to rename in that case.
  - Improved detection of when a referenced function is a call (rather than
    reference) across syntactic rename, cursor-info, and indexing.

Resolves rdar://problem/60340429
@nathawes nathawes force-pushed the syntactic-rename-for-callAsFunction branch from b15e4c6 to bce68fa Compare April 13, 2020 00:17
@nathawes
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - b15e4c63adee472b95e4043314fd68961594a8b1

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - b15e4c63adee472b95e4043314fd68961594a8b1

@nathawes nathawes merged commit b3b7aa8 into swiftlang:master Apr 13, 2020
@nathawes nathawes deleted the syntactic-rename-for-callAsFunction branch April 13, 2020 18:36
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