-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit] Print backticks if needed in printDisplayName
#82481
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
Conversation
llvm::raw_ostream &print(llvm::raw_ostream &os, | ||
bool skipEmptyArgumentNames = false) const; | ||
bool skipEmptyArgumentNames = false, | ||
bool escapeIfNeeded = false) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably ought to default to true
, but I'm leaving that for a future PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we print raw identifiers in textual interfaces properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do, the ASTPrinter has its own implementation of this
@@ -6,7 +6,7 @@ | |||
{ | |||
key.kind: source.lang.swift.decl.class, | |||
key.accessibility: source.lang.swift.accessibility.internal, | |||
key.name: "<#MyCls#>", | |||
key.name: "`<#MyCls#>`", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is consistent with how we classify raw identifiers, but admittedly does seem a little odd. It does reflect how placeholders are treated in decl name position though, they are effectively raw identifiers, e.g:
struct S {
static func <#foo#>() {}
}
S.<#foo#>() // resolves to <#foo#>
S.<#bar#>() // error: type 'S' has no member '<#bar#>'
Any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely a bit of an odd case. I think my preference here would be to only add backticks if the name itself actually has backticks vs just being a placeholder. I assume a placeholder within backticks causes all sorts of weirdness though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's a weird case, really I would prefer if we could just ban editor placeholders in raw identifiers, although that would probably need some evolution discussion.
I think my preference here would be to only add backticks if the name itself actually has backticks
Trouble is that DeclName doesn't currently have that information, we'd either need to plumb it through, or this decision would need to be left up to the clients
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy leaving it for this PR 👍
Ensure we print raw identifier names with backticks for e.g the document structure request. rdar://152524780
618bf1d
to
55ef1bc
Compare
@swift-ci please test |
@swift-ci please test Linux |
Ensure we print raw identifier names with backticks for e.g the document structure request.
rdar://152524780