Skip to content

Fixed UDT syntax highlighting - #14372

Merged
Marcin Jastrzebski (majastrz) merged 2 commits into
mainfrom
majastrz/type-highlighting
Jun 20, 2024
Merged

Marcin Jastrzebski (majastrz) merged 2 commits into
mainfrom
majastrz/type-highlighting

Conversation

@majastrz

@majastrz Marcin Jastrzebski (majastrz) commented Jun 19, 2024 •

Copy link
Copy Markdown
Member

Fixed the recent regression in syntax highlighting for user defined types:

  • Now emitting SemanticTokenType.Namespace for namespace symbols.
  • Now emitting SemanticTokenType.Type for TypeVariableAccessSyntax that resolves to a valid type symbol.
  • Now emitting SemanticTokenType.Keyword for null, true and false type keywords.

Examples of changes:
image

I will look into adding tests separately since we don't currently have baselines or meaningful unit tests for syntax highlighting. (I recall we had some issues with that in the past, but will need to confirm.)

This fixes #14147

Microsoft Reviewers: Open in CodeFlow

@github-actions

github-actions Bot commented Jun 19, 2024 •

Copy link
Copy Markdown
Contributor

Test this change out locally with the following install scripts (Action run 9590262619)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 9590262619
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 9590262619"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 9590262619
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 9590262619"

@jeskew Jonny Eskew (jeskew) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! :shipit:

@github-actions

Copy link
Copy Markdown
Contributor

Dotnet Test Results

    72 files   -     36      72 suites   - 36   23m 38s ⏱️ - 8m 42s
10 891 tests  -     20  10 890 ✅  -     20  1 💤 ±0  0 ❌ ±0 
25 678 runs   - 12 835  25 676 ✅  - 12 834  2 💤  - 1  0 ❌ ±0 

Results for commit 28c3da6. ± Comparison against base commit bf8a344.

private static SemanticTokenType GetSemanticTokenForPotentialTypeSymbol(Symbol? symbol) =>
symbol switch
{
PropertySymbol property => GetSemanticTokenForPotentialTypeSymbol(property.Type),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will this end up highlighting an imported variable (accessed as a property on a wildcard import) as a type? E.g.,

mod.bicep

@export()
var foo = 'foo'

main.bicep

import * as mod from 'mod.bicep'

output foo string = mod.foo

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It highlights the mod part as a namespace but foo is highlighted as a variable:
image

@majastrz
Marcin Jastrzebski (majastrz) deleted the majastrz/type-highlighting branch June 20, 2024 01:37
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.

Types are not highlighted in a different color

2 participants