sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

changes is in fact optional, indicated by the `?` in `changes?: { [uri: 
DocumentUri]: TextEdit[]; };`.

But the spec requires *some* field to be set, and this is the only one we 
support, so it's not optional in practice for us.



================
Comment at: clang-tools-extra/clangd/Protocol.cpp:811
 llvm::json::Value toJSON(const WorkspaceEdit &WE) {
-  if (!WE.changes)
+  if (WE.changes.empty())
     return llvm::json::Object{};
----------------
I'd suggest deleting this special case.
We no longer have two distinct states of our WorkspaceEdit struct to represent 
`{changes:{}}` and `{}`.

`{changes:{}}` is a well-defined empty edit, even if that never makes sense to 
actually send.
`{}` conforms to the typescript type definition of the spec, but doesn't 
actually define an edit per the spec text.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103449/new/

https://reviews.llvm.org/D103449

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to