Skip to content

[CodeCompletion] Escape declaration base name if needed #23372

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

rintaro
Copy link
Member

@rintaro rintaro commented Mar 18, 2019

These should be escaped identifiers in code completion:

  • As primary expression: Any keyword name except for self and Self.
  • After dot: Something named `init`.

rdar://problem/16232627

@rintaro rintaro force-pushed the ide-completion-escapedident-16232627 branch from 935ce76 to e7cf5cc Compare March 18, 2019 00:25
@rintaro
Copy link
Member Author

rintaro commented Mar 18, 2019

@swift-ci Please smoke test

@rintaro rintaro requested a review from benlangmuir March 18, 2019 03:19
Copy link
Contributor

@benlangmuir benlangmuir left a comment

Choose a reason for hiding this comment

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

Mostly LGTM

// e.g. 'func `init`()' should be 'expe.`init`()'.
(!ExprType || NameStr == "init") &&
// 'self' and 'Self' are special
NameStr != "self" && NameStr != "Self";
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't see any error writing x.Self as a property reference.

Copy link
Member Author

@rintaro rintaro Mar 19, 2019

Choose a reason for hiding this comment

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

foo.self, foo.Self, self and Self are all valid. We don't have to escape self and Self at use-site.

class C {
  func foo() {
    var `self` = 12
    let `Self` = 42
    self += Self
    print(self)
  }
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, I was wrong.

class C {
   var `self` = 12
}
print(C().self) // C
print(C().`self`) // 12

I will update this part to clarify the intent.

@rintaro rintaro force-pushed the ide-completion-escapedident-16232627 branch from e7cf5cc to e8652bc Compare March 19, 2019 17:37
@rintaro
Copy link
Member Author

rintaro commented Mar 19, 2019

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Mar 19, 2019

@swift-ci Please smoke test OS X platform

2 similar comments
@rintaro
Copy link
Member Author

rintaro commented Mar 19, 2019

@swift-ci Please smoke test OS X platform

@rintaro
Copy link
Member Author

rintaro commented Mar 19, 2019

@swift-ci Please smoke test OS X platform

There should be escaped identifiers in code completion:
- As primary expression: Any keyword name except for `self` and `Self`.
- After dot: Something named `init`.

rdar://problem/16232627
@rintaro rintaro force-pushed the ide-completion-escapedident-16232627 branch from e8652bc to df473f6 Compare March 19, 2019 23:43
@rintaro
Copy link
Member Author

rintaro commented Mar 19, 2019

@swift-ci Please smoke test

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