Skip to content

[CodeCompletion] Suggest the property name in its didSet clause #28319

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 1 commit into from
Dec 4, 2019

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Nov 18, 2019

Previously, property names are hidden in the whole range of the declarations. Now, it's only hidden in its own initializer range.

Also, mark them as "NotRecommended" in their get accessors.

rdar://problem/49697202

@rintaro rintaro force-pushed the ide-completion-rdar49697202 branch from f68a140 to 8e93a9e Compare November 18, 2019 04:49
@rintaro
Copy link
Member Author

rintaro commented Nov 18, 2019

@swift-ci Please smoke test

@rintaro rintaro requested a review from benlangmuir November 18, 2019 04:50
@@ -2168,6 +2168,12 @@ class CompletionLookup final : public swift::VisibleDeclConsumer {
addValueBaseName(Builder, Name);
setClangDeclKeywords(VD, Pairs, Builder);

// "not recommended" in its own getter.
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this impact keypaths? I think that would still be "okay". Technically you can also call the setter safely from the getter if it doesn't mutually recurse, but I don't care much about that case.

Copy link
Member Author

@rintaro rintaro Dec 4, 2019

Choose a reason for hiding this comment

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

It did. I updated the PR to ensure it doesn't mark it "NotRecommended" in case of keypaths or explicit self.
I want to mark it because the compiler emit warnings for them:

class MyClass {
  var value: Int {
    get {
      value = 12 // warning: attempting to access 'value' within its own getter
                 // note: access 'self' explicitly to silence this warning
      return 1
    }
    set {
    }
  }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM, thanks!

@rintaro rintaro force-pushed the ide-completion-rdar49697202 branch from 8e93a9e to 493fa4e Compare December 4, 2019 02:11
Previously, property names are hidden in the whole range of the
declarations. Now, it's only hidden in its own initializer range.

rdar://problem/49697202
@rintaro rintaro force-pushed the ide-completion-rdar49697202 branch from 493fa4e to ad4b9df Compare December 4, 2019 02:13
@rintaro
Copy link
Member Author

rintaro commented Dec 4, 2019

@swift-ci Please smoke test

@rintaro rintaro merged commit 12fd207 into swiftlang:master Dec 4, 2019
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