Get the VS Code extension working again. (#4037)

VSCode's JSON parser no longer accepts comments in at least textmate
grammars, so remove the comments. It's unclear whether VSCode changed
here or whether this hasn't worked since the comments were added.

Clean up the textmate grammar: refactor, add some missing operators and
keywords, classify keywords as introducer / modifier as appropriate, fix
comment grammar to require space after `//`, and generalize recognition
of iN, fN, uN to recognize all such type literals.

Be more cautious in language server -- I was seeing frequent crashes for
`IdentifierName` parse nodes whose token was not actually an identifier,
presumably due to error recovery.
This commit is contained in:
Richard Smith
2024-06-06 23:27:33 +00:00
committed by GitHub
parent 1c07f959a8
commit 202aae453f
6 changed files with 938 additions and 242 deletions
+4 -2
View File
@@ -83,8 +83,10 @@ static auto GetIdentifierName(const SharedValueStores& value_stores,
-> std::optional<llvm::StringRef> {
for (auto ch : p.children(node)) {
if (p.node_kind(ch) == Parse::NodeKind::IdentifierName) {
return value_stores.identifiers().Get(
tokens.GetIdentifier(p.node_token(ch)));
auto token = p.node_token(ch);
if (tokens.GetKind(token) == Lex::TokenKind::Identifier) {
return value_stores.identifiers().Get(tokens.GetIdentifier(token));
}
}
}
return std::nullopt;