-
Notifications
You must be signed in to change notification settings - Fork 314
Add semantic highlighting for function parameter labels #983
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
6a2ef94
to
b8420eb
Compare
@swift-ci Please test |
There's some documentation, just not in the specification itself - https://code.visualstudio.com/api/language-extensions/semantic-highlight-guide#standard-token-types-and-modifiers. IMO the argument name (first name) should be Is the screenshot you included just from the syntax tree, or does it include the semantic tokens? |
Good idea with just considering the labels part of the function itself.
It includes semantic tokens. The two states of syntax highlighting that we have in LSP land are
|
b8420eb
to
cb078c2
Compare
Token(line: 6, utf16index: 7, length: 8, kind: .struct), | ||
] | ||
) | ||
} | ||
|
||
func testArgumentLabels() async throws { |
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 have a first + second name test at all? Is the second name a parameter or an identifier?
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 have a test for it in swift-syntax: https://github.com/apple/swift-syntax/pull/2375/files#diff-0f770f38aaec515fed644ee83824ed0dcfb2e86ec67a6da535f2de9fef15f9f3R531
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.
Fair enough, I'd expect one here too since the sourcekitd response could add more information if it wanted to (eg. all params + references could be "parameters").
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.
Added a test case
@swift-ci Please test |
cb078c2
to
7424558
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
This highlights
arg
in the following as aparameter
.LSP doesn’t explicitly state what
parameter
means.clangd
usesparameter
for parameter declarations, Python also usesparameter
for parameter labels.Here’s how syntax coloring looks with this patch in VS Code with the GitHub light theme (underlined are the changed tokens).
Companion of swiftlang/swift-syntax#2375.