[vscode] Fix alias and const LHS type highlighting
Previously, the type on the LHS of the `const` declaration was tagged
(and therefore colored) the same way as a constant value,
`storage.type`. This was simply incorrect.
The `alias` case is a bit more interesting: while the `variable.alias`
tag is probably more correct than the new `entity.name.type`
semantically, the highlighting it produced was a bit confusing. Aliases
names were a different color from other types at their declaration
sites, but not at their use sites, causing confusion. Since textMate
grammar is not able to deduce whether a name is resolved through an
alias or not, its best to just use one color for all "things that refer
to types" in all positions.
Fixed: 99302
Change-Id: I8fdd0ed5cf2ef1a546456a8d9cf20e4c789e35c3
Reviewed-on: https://fuchsia-review.googlesource.com/c/fidl-misc/+/762857
Reviewed-by: Zachary Stewart <zstewart@google.com>
diff --git a/vscode-language-fidl/syntaxes/fidl.tmLanguage.json b/vscode-language-fidl/syntaxes/fidl.tmLanguage.json
index cb8a8fe..faa848b 100644
--- a/vscode-language-fidl/syntaxes/fidl.tmLanguage.json
+++ b/vscode-language-fidl/syntaxes/fidl.tmLanguage.json
@@ -68,7 +68,7 @@
"name": "keyword.control"
},
"2": {
- "name": "variable.alias"
+ "name": "entity.name.type"
},
"3": {
"name": "punctuation.separator"
@@ -100,7 +100,7 @@
"name": "variable.constant"
},
"3": {
- "name": "storage.type"
+ "name": "entity.name.type"
},
"4": {
"name": "storage.type.basic"
diff --git a/vscode-language-fidl/tools/generate-syntax.ts b/vscode-language-fidl/tools/generate-syntax.ts
index a8ee0f6..e78ede0 100644
--- a/vscode-language-fidl/tools/generate-syntax.ts
+++ b/vscode-language-fidl/tools/generate-syntax.ts
@@ -390,7 +390,7 @@
name: "meta.type-alias",
begin: seq(
keyword("alias"),
- named(IDENTIFIER, "variable.alias"),
+ named(IDENTIFIER, "entity.name.type"),
separator("="),
LAYOUT_REFERENCE
),
@@ -404,7 +404,7 @@
begin: seq(
keyword("const"),
named(IDENTIFIER, "variable.constant"),
- named(one_of(COMPOUND_IDENTIFIER, PRIMITIVE_TYPE), "storage.type"),
+ named(one_of(COMPOUND_IDENTIFIER, PRIMITIVE_TYPE), "entity.name.type"),
separator("=")
),
end: EOL,