Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdded Handler for Semantic Tokenization #1328
Conversation
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
|
Given that this is quite a nice, standalone service, we probably should add some e2e tests for this |
|
Looking good - I had a few more comments. Don't forget that curly braces start on their own line:
instead of
Also gave a bit of context in @rjmholt's comments |
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...owerShellEditorServices/Services/DebugAdapter/Handlers/SemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/DebugAdapter/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/DebugAdapter/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/DebugAdapter/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/DebugAdapter/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/DebugAdapter/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/DebugAdapter/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/DebugAdapter/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
|
|
||
| namespace Microsoft.PowerShell.EditorServices.Handlers | ||
| { | ||
| //Disable warnings having to do with SemanticTokensHandler being labelled obsolete | ||
| //SemanticTokensHandler is labeled "Obsolete" because that is how Omnisharp marks proposed LSP features. Since we want this proposed feature, we disable this warning. |
rjmholt
Jul 20, 2020
Member
Suggested change
//SemanticTokensHandler is labeled "Obsolete" because that is how Omnisharp marks proposed LSP features. Since we want this proposed feature, we disable this warning.
// SemanticTokensHandler is labeled "Obsolete" because that is how Omnisharp marks proposed LSP features. Since we want this proposed feature, we disable this warning.
| //SemanticTokensHandler is labeled "Obsolete" because that is how Omnisharp marks proposed LSP features. Since we want this proposed feature, we disable this warning. | |
| // SemanticTokensHandler is labeled "Obsolete" because that is how Omnisharp marks proposed LSP features. Since we want this proposed feature, we disable this warning. |
rjmholt
Jul 20, 2020
Member
A question here: we already compile with warnings today, and while that's not a good thing, this particular warning should eventually disappear.
If we keep the pragma we suppress a warning that should eventually either go away, or which we should pay attention to since it will indicate that the proposed API hasn't stabilised. When it is stabilised, we would need to remove the pragma, but we won't know because of the pragma, meaning it may hang around in the code indefinitely (like so many fxcop suppressions).
Instead I think it probably makes sense for us to see the warning and not use a suppression pragma
A question here: we already compile with warnings today, and while that's not a good thing, this particular warning should eventually disappear.
If we keep the pragma we suppress a warning that should eventually either go away, or which we should pay attention to since it will indicate that the proposed API hasn't stabilised. When it is stabilised, we would need to remove the pragma, but we won't know because of the pragma, meaning it may hang around in the code indefinitely (like so many fxcop suppressions).
Instead I think it probably makes sense for us to see the warning and not use a suppression pragma
...ShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
.../PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs
Outdated
Show resolved
Hide resolved
.../PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs
Outdated
Show resolved
Hide resolved
.../PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs
Outdated
Show resolved
Hide resolved
.../PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
...ShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
|
|
||
| namespace Microsoft.PowerShell.EditorServices.Handlers | ||
| { | ||
| internal class PsesSemanticTokens : SemanticTokensHandler |
rjmholt
Jul 21, 2020
•
Member
Suggested change
internal class PsesSemanticTokens : SemanticTokensHandler
internal class PsesSemanticTokensHandler : SemanticTokensHandler
| internal class PsesSemanticTokens : SemanticTokensHandler | |
| internal class PsesSemanticTokensHandler : SemanticTokensHandler |
TylerLeonhardt
Jul 21, 2020
Member
Tokens*
Tokens*
rjmholt
Jul 23, 2020
Member
(Fixed in my suggestion)
(Fixed in my suggestion)
...ShellEditorServices/Services/TextDocument/Handlers/PsesSemanticTokens.cs
Outdated
Show resolved
Hide resolved
| public SemanticToken(string text, SemanticTokenType type, int line, int column, IEnumerable<string> tokenModifiers) | ||
| { | ||
| Line = line; | ||
| Text = text; | ||
| Column = column; | ||
| Type = type; | ||
| TokenModifiers = tokenModifiers; | ||
| } |
TylerLeonhardt
Jul 30, 2020
Member
Non-blocking but just wanted to say that if you get rid of this ctor, you can do:
new SemanticToken
{
Text = "asdf",
Line = 1,
Column = 2,
...
}
and that will work the same way.
We can defer that for now.
Non-blocking but just wanted to say that if you get rid of this ctor, you can do:
new SemanticToken
{
Text = "asdf",
Line = 1,
Column = 2,
...
}and that will work the same way.
We can defer that for now.
.../PowerShellEditorServices.Test.E2E/LanguageServerProtocolMessageTests.cs
Outdated
Show resolved
Hide resolved
| @@ -0,0 +1,201 @@ | |||
| [ | |||
TylerLeonhardt
Jul 30, 2020
Member
What's this?
What's this?
6095ae5
into
PowerShell:master
|
|
Description
Fixes PowerShell/vscode-powershell#2813
Added a handler that utilizes the Parser in System.Management.Automation.Language to get PowerShell tokens and convert them to the semantic tokens that VS Code expects.
To use this, add "semanticHighlighting": true in the theme.json file.
Make sure a call is made to languageServerClient.registerProposedFeatures() in session.ts (vscode-powershell)
See PowerShell/vscode-powershell#2834
Before:

After:

Some issues this helps address:
PowerShell/EditorSyntax#143
PowerShell/EditorSyntax#157
PowerShell/EditorSyntax#167
PowerShell/EditorSyntax#191
PowerShell/EditorSyntax#198
PowerShell/EditorSyntax#199
PowerShell/EditorSyntax#200
PowerShell/EditorSyntax#201