Skip to content

Commit

Permalink
lspserver: fix string markup kind error
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Apr 18, 2024
1 parent 258dcb0 commit 5973aa0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lspserver/src/Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,14 @@ static llvm::StringRef toTextKind(MarkupKind Kind) {
llvm_unreachable("Invalid MarkupKind");
}

static MarkupKind fromTextKind(llvm::StringRef Kind) {
if (Kind == "plaintext")
return MarkupKind::PlainText;
if (Kind == "markdown")
return MarkupKind::Markdown;
llvm_unreachable("Invalid MarkupKind");
}

bool fromJSON(const llvm::json::Value &V, MarkupKind &K, llvm::json::Path P) {
auto Str = V.getAsString();
if (!Str) {
Expand Down Expand Up @@ -916,10 +924,9 @@ llvm::json::Value toJSON(const MarkupContent &MC) {
bool fromJSON(const llvm::json::Value &Params, MarkupContent &R,
llvm::json::Path P) {
llvm::json::ObjectMapper O(Params, P);
int Kind;
if (!O.map("kind", Kind))
return false;
R.kind = static_cast<MarkupKind>(Kind);
std::string MarkupKind;
O.map("kind", MarkupKind);
R.kind = fromTextKind(MarkupKind);
return O.mapOptional("value", R.value);
}

Expand Down

0 comments on commit 5973aa0

Please sign in to comment.