highlight record keys

This commit is contained in:
Vyacheslav Matyukhin 2022-06-26 11:42:56 +03:00
parent 7cbece9212
commit 81854702a7
No known key found for this signature in database
GPG Key ID: 3D2A774C5489F96C

View File

@ -3,7 +3,7 @@ import * as vscode from "vscode";
import { parse } from "@quri/squiggle-lang"; import { parse } from "@quri/squiggle-lang";
import { AnyPeggyNode } from "@quri/squiggle-lang/dist/src/rescript/Reducer/Reducer_Peggy/helpers"; import { AnyPeggyNode } from "@quri/squiggle-lang/dist/src/rescript/Reducer/Reducer_Peggy/helpers";
const tokenTypes = ["class", "interface", "enum", "function", "variable"]; const tokenTypes = ["enum", "function", "variable", "property"];
const tokenModifiers = ["declaration", "documentation"]; const tokenModifiers = ["declaration", "documentation"];
const legend = new vscode.SemanticTokensLegend(tokenTypes, tokenModifiers); const legend = new vscode.SemanticTokensLegend(tokenTypes, tokenModifiers);
@ -51,11 +51,17 @@ const populateTokensBuilder = (
populateTokensBuilder(tokensBuilder, node.falseExpression); populateTokensBuilder(tokensBuilder, node.falseExpression);
break; break;
case "KeyValue": case "KeyValue":
populateTokensBuilder(tokensBuilder, node.key); if (node.key.type === "String" && node.key.location) {
tokensBuilder.push(convertRange(node.key.location), "property", [
"declaration",
]);
} else {
populateTokensBuilder(tokensBuilder, node.key);
}
populateTokensBuilder(tokensBuilder, node.value); populateTokensBuilder(tokensBuilder, node.value);
break; break;
case "Identifier": case "Identifier":
tokensBuilder.push(convertRange(node.location), "variable", []); tokensBuilder.push(convertRange(node.location), "variable");
break; break;
} }
}; };