PowerShell / PowerShell/vscode-powershell

Add support for all token types with the new semantic highlighting

Open
#2,852 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Semantic Highlighting Area-UI Issue-Enhancement
Dominant language
TypeScript
Stars
1.9k
Forks
547
PR merge metrics
No merged PRs in 30d

Description

Summary of the new feature

Powershell has 20 tokentypes and it would be nice if the semantic highlighting supported all of them. See: https://docs.microsoft.com/en-us/dotnet/api/system.management.automation.pstokentype

The current semantic highlighting implementation is currently missing the following types:

  • Attribute
  • CommandArgument
  • GroupEnd/GroupStart
  • LineContinuation (backtick)
  • LoopLabel
  • StatementSeparator (Semicolon)

If/When these gets added I would suggest changing the following mappings:

  • Value in Using namespace <Value> should use CommandArgument scope. Currently it uses Function.
  • Attributes like [cmdletbinding()] should use Attribute scope. Currently it uses Type.
  • Names in functions and configurations should use CommandArgument scope. Currently they use the Function scope except functions with no dashes which has no semantic token type.
  • Unquoted parameter values like "C:\SomePath" in Get-ChildItem C:\SomePath should use CommandArgument scope. Currently they use the function scope.

The following screenshot hopefully shows what I mean:
Mapping issue

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the current semantic highlighting implementation and compare its token mappings with the documented PowerShell PSTokenType values. Check the listed missing token types and proposed remappings, then verify that all are represented and that the examples use the requested scopes.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell, typescript
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.