<div dir="ltr">Thanks Douglas.<div><br></div><div><span style="font-size:12.8px">This only happens when clangd explicitly forms an absolute path. Since r317585 this is done for the 'definition' call.</span><br></div><div><span style="font-size:12.8px">I think we should probably always do it so we have consistent behavior. (Hopefully editors won't get confused if they get back a different URI than they sent.)</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 9, 2017 at 4:26 AM, Yung, Douglas <span dir="ltr"><<a href="mailto:douglas.yung@sony.com" target="_blank">douglas.yung@sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="blue" vlink="purple">
<div class="m_7654313543924387895WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Hi Sam, first I want to thank you for fixing up the test so that the build bot is green again, that is very much appreciated!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Secondly, I want to say that this issue does not seem to affect everything on Windows. I’m not familiar with how JSON related stuff is supposed to work exactly,
 but even with the short example I provided before, not all of the URIs when run on Windows included the “C:/” part.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">To expand on this, here again is the original repro case that I sent:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:Consolas;color:#1f497d"># Begin failure.test<br>
Content-Length: 125<br>
<br>
{"jsonrpc":"2.0","id":0,"<wbr>method":"initialize","params":<wbr>{"processId":123,"rootPath":"<wbr>clangd","capabilities":{},"<wbr>trace":"off"}}<br>
<br>
Content-Length: 217<br>
<br>
{"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"uri"<wbr>:"<a>file:///main.cpp</a>","version":<wbr>7},"contentChanges":[{"text":"<wbr>#define FOO 1\nint a = FOO;\n#define FOO 2\nint b = FOO;\n#undef FOO\n"}]}}<br>
<br>
Content-Length: 148<br>
<br>
{"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocument":{"uri":"<a>file:///<wbr>main.cpp</a>"},"position":{"line":<wbr>1,"character":8}}}<br>
# End failure.test<br>
<br>
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">I have attached the full output of running “clangd.exe –pretty –run-synchronously < failure.test” as result.txt, but I want to specifically call out the output
 produced by the second and third calls. The second one produces the following uri value:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">"uri": “<a>file:///main.cpp</a>”<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">While the third one instead produces this uri value:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">"uri": “<a>file:///C:/main.cpp</a>”<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Both of these were produced by the same run on my Windows box, so it seems something else might be triggering the reinterpretation of the uri.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d">Douglas Yung<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d"><u></u> <u></u></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #b5c4df 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ilya Biryukov [mailto:<a href="mailto:ibiryukov@google.com" target="_blank">ibiryukov@google.com</a>]
<br>
<b>Sent:</b> Wednesday, November 08, 2017 8:08<br>
<b>To:</b> Marc-André Laperle<br>
<b>Cc:</b> Sam McCall; cfe-commits; Yung, Douglas<br>
<b>Subject:</b> Re: [clang-tools-extra] r317486 - Adds a json::Expr type to represent intermediate JSON expressions.<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Clang remembers the last name used to access the file in FileManager and we get the filename from FileManager later, so it's not that surprising that it all broke apart.<u></u><u></u></p>
<div>
<p class="MsoNormal">Sam said that using <a>file:///c:/main.cpp</a> crashes clang on Linux for some reason, we'll probably have to resort to regexes as an immediate solution and figure out how to fix the crash later.<u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">On Wed, Nov 8, 2017 at 8:47 PM, Marc-André Laperle <<a href="mailto:marc-andre.laperle@ericsson.com" target="_blank">marc-andre.laperle@ericsson.<wbr>com</a>> wrote:<u></u><u></u></p>
<div>
<div id="m_7654313543924387895m_7519689754056656976divtagdefaultwrapper">
<div id="m_7654313543924387895m_7519689754056656976divtagdefaultwrapper">
<p><span style="font-family:"Calibri","sans-serif";color:black">+1 for <span class="m_7654313543924387895m7519689754056656976owaautolink">
<a>file://c:/main.cpp</a></span><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">(A bit surprised we only see this problem now though?)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">Marc-André<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"><u></u> <u></u></span></p>
<div>
<div class="MsoNormal" align="center" style="text-align:center"><span style="font-family:"Calibri","sans-serif";color:black">
<hr size="2" width="98%" align="center">
</span></div>
<div id="m_7654313543924387895m_7519689754056656976divRplyFwdMsg">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black"> Ilya Biryukov <<a href="mailto:ibiryukov@google.com" target="_blank">ibiryukov@google.com</a>><br>
<b>Sent:</b> Wednesday, November 8, 2017 8:29 AM<br>
<b>To:</b> Sam McCall<br>
<b>Cc:</b> Marc-André Laperle; cfe-commits; Yung, Douglas<br>
<b>Subject:</b> Re: [clang-tools-extra] r317486 - Adds a json::Expr type to represent intermediate JSON expressions.</span><span style="font-family:"Calibri","sans-serif";color:black">
<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"> <u></u><u></u></span></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">Yeah and `file://c:/main.cpp` looks like the best option to me.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">On Wed, Nov 8, 2017 at 6:26 PM, Sam McCall <<a href="mailto:sam.mccall@gmail.com" target="_blank">sam.mccall@gmail.com</a>> wrote:<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">Oops, +list.
<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">r317686 makes just this test fuzzy, to unbreak the buildbot.<u></u><u></u></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">On Wed, Nov 8, 2017 at 1:15 PM, Sam McCall <<a href="mailto:sam.mccall@gmail.com" target="_blank">sam.mccall@gmail.com</a>> wrote:<u></u><u></u></span></p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">On Wed, Nov 8, 2017 at 12:55 PM, Ilya Biryukov <<a href="mailto:ibiryukov@google.com" target="_blank">ibiryukov@google.com</a>> wrote:<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">What's the exact problem with "file://" URIs on Windows? How to properly convert the Windows-style absolute paths into those? (i.e. "C:\Users\Admin\MyProject\<wbr>Main.cpp"?)
<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">If so, there is an overview in Wikipedia (<a href="https://en.wikipedia.org/wiki/File_URI_scheme#Windows_2" target="_blank">https://en.wikipedia.org/<wbr>wiki/File_URI_scheme#Windows_2</a><wbr>).
 In short, they should look this way: <a>
file:///c/Users/Admin/<wbr>MyProject/Main.cpp</a>..<u></u><u></u></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">nit: the c needs to keep its colon:
<a>file:///c:/Users/</a>...<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">Yeah, when I thought about this some more, it's mostly that the tests assume we can pretend there's a file /main.cpp =
<a>file:///main.cpp</a>.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">On windows, canonicalizing that filename results in C:\main.cpp =
<a>file:///C:/main.cpp</a>, which is not what our tests expect.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">Options I see:<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"> - make every test that checks a filename fuzzy (this seems doomed to failure)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"> - find a URI that works with both unix and windows paths (<a>file:///C:/main.cpp</a>?)<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"> - avoid canonicalizing filenames in ways visible to tests<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"> - ???<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"> <u></u><u></u></span></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">On Wed, Nov 8, 2017 at 4:37 PM, Sam McCall <<a href="mailto:sam.mccall@gmail.com" target="_blank">sam.mccall@gmail.com</a>> wrote:<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">I think all the JSON-related windows breakages are now fixed, and the remaining definitions.test breakage was caused by r317585.
<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">(Currently trying to get a windows machine to verify this)<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">I have to confess I don't know much about how file:// URIs should work on windows. Marc-Andre - any thoughts, or maybe we should revert until we can work this one out?<u></u><u></u></span></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">On Wed, Nov 8, 2017 at 3:39 AM, Yung, Douglas <<a href="mailto:douglas.yung@sony.com" target="_blank">douglas.yung@sony.com</a>> wrote:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black">Hi Sam,<br>
<br>
The test definitions.test is currently failing on the PS4 Windows bot because the URI returned is of the format "<a>file:///C:/main.cpp</a>" instead of the expected "<a>file:///main.cpp</a>" when run on a
 Windows machine. Can you please fix this ASAP so that we can get the bot green again?<br>
<br>
Here you can see the failure on the build bot:<br>
<a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/13343" target="_blank">http://lab.llvm.org:8011/<wbr>builders/llvm-clang-lld-x86_<wbr>64-scei-ps4-windows10pro-fast/<wbr>builds/13343</a><br>
<br>
You can reproduce the failure by feeding the following file to clangd on Windows:<br>
<br>
# Begin failure.test<br>
Content-Length: 125<br>
<br>
{"jsonrpc":"2.0","id":0,"<wbr>method":"initialize","params":<wbr>{"processId":123,"rootPath":"<wbr>clangd","capabilities":{},"<wbr>trace":"off"}}<br>
<br>
Content-Length: 217<br>
<br>
{"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"uri"<wbr>:"<a>file:///main.cpp</a>","version":<wbr>7},"contentChanges":[{"text":"<wbr>#define FOO 1\nint a = FOO;\n#define FOO 2\nint b = FOO;\n#undef FOO\n"}]}}<br>
<br>
Content-Length: 148<br>
<br>
{"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocument":{"uri":"<a>file:///<wbr>main.cpp</a>"},"position":{"line":<wbr>1,"character":8}}}<br>
# End failure.test<br>
<br>
<br>
This is cut down from test\clangd\definitions.test. The failure is on line 337 where it is looking for this:<br>
<br>
# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
<br>
However, clangd is generating:<br>
<br>
"uri": "<a>file:///C:/main.cpp</a>"<br>
<br>
If you could fix this as soon as possible it would be greatly appreciated since it is causing the PS4 Windows bot to be red.<br>
<br>
Thanks!<br>
<br>
Douglas Yung<br>
<br>
> -----Original Message-----<br>
> From: cfe-commits [mailto:<a href="mailto:cfe-commits-bounces@lists.llvm.org" target="_blank">cfe-commits-bounces@<wbr>lists.llvm.org</a>] On Behalf Of Sam<br>
> McCall via cfe-commits<br>
> Sent: Monday, November 06, 2017 7:41<br>
> To: <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> Subject: [clang-tools-extra] r317486 - Adds a json::Expr type to represent<br>
> intermediate JSON expressions.<br>
><br>
> Author: sammccall<br>
> Date: Mon Nov  6 07:40:30 2017<br>
> New Revision: 317486<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=317486&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project?rev=317486&view=rev</a><br>
> Log:<br>
> Adds a json::Expr type to represent intermediate JSON expressions.<br>
><br>
> Summary:<br>
> This form can be created with a nice clang-format-friendly literal syntax,<br>
> and gets escaping right. It knows how to call unparse() on our Protocol types.<br>
> All the places where we pass around JSON internally now use this type.<br>
><br>
> Object properties are sorted (stored as std::map) and so serialization is<br>
> canonicalized, with optional prettyprinting (triggered by a -pretty flag).<br>
> This makes the lit tests much nicer to read and somewhat nicer to debug.<br>
> (Unfortunately the completion tests use CHECK-DAG, which only has<br>
> line-granularity, so pretty-printing is disabled there. In future we<br>
> could make completion ordering deterministic, or switch to unittests).<br>
><br>
> Compared to the current approach, it has some efficiencies like avoiding<br>
> copies<br>
> of string literals used as object keys, but is probably slower overall.<br>
> I think the code/test quality benefits are worth it.<br>
><br>
> This patch doesn't attempt to do anything about JSON *parsing*.<br>
> It takes direction from the proposal in this doc[1], but is limited in scope<br>
> and visibility, for now.<br>
> I am of half a mind just to use Expr as the target of a parser, and maybe do a<br>
> little string deduplication, but not bother with clever memory allocation.<br>
> That would be simple, and fast enough for clangd...<br>
> [1]<br>
> <a href="https://docs.google.com/document/d/1OEF9IauWwNuSigZzvvbjc1cVS1uGHRyGTXaoy3DjqM" target="_blank">
https://docs.google.com/<wbr>document/d/<wbr>1OEF9IauWwNuSigZzvvbjc1cVS1uGH<wbr>RyGTXaoy3DjqM</a><br>
> 4/edit<br>
><br>
> +cc d0k so he can tell me not to use std::map.<br>
><br>
> Reviewers: ioeric, malaperle<br>
><br>
> Subscribers: bkramer, ilya-biryukov, mgorny, klimek<br>
><br>
> Differential Revision: <a href="https://reviews.llvm.org/D39435" target="_blank">
https://reviews.llvm.org/<wbr>D39435</a><br>
><br>
> Added:<br>
>     clang-tools-extra/trunk/<wbr>clangd/JSONExpr.cpp<br>
>     clang-tools-extra/trunk/<wbr>clangd/JSONExpr.h<br>
>     clang-tools-extra/trunk/<wbr>unittests/clangd/<wbr>JSONExprTests.cpp<br>
> Modified:<br>
>     clang-tools-extra/trunk/<wbr>clangd/CMakeLists.txt<br>
>     clang-tools-extra/trunk/<wbr>clangd/ClangdLSPServer.cpp<br>
>     clang-tools-extra/trunk/<wbr>clangd/JSONRPCDispatcher.cpp<br>
>     clang-tools-extra/trunk/<wbr>clangd/JSONRPCDispatcher.h<br>
>     clang-tools-extra/trunk/<wbr>clangd/Protocol.cpp<br>
>     clang-tools-extra/trunk/<wbr>clangd/Protocol.h<br>
>     clang-tools-extra/trunk/<wbr>clangd/tool/ClangdMain.cpp<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/authority-less-uri.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/completion-items-kinds.<wbr>test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/completion-priorities.<wbr>test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/completion-qualifiers.<wbr>test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/completion-snippet.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/completion.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/definitions.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/diagnostics-preamble.<wbr>test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/diagnostics.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/did-change-watch-files.<wbr>test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/execute-command.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/extra-flags.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/fixits.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/formatting.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/initialize-params-<wbr>invalid.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/initialize-params.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/input-mirror.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/protocol.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/signature-help.test<br>
>     clang-tools-extra/trunk/test/<wbr>clangd/unsupported-method.test<br>
>     clang-tools-extra/trunk/<wbr>unittests/clangd/CMakeLists.<wbr>txt<br>
><br>
> Modified: clang-tools-extra/trunk/<wbr>clangd/CMakeLists.txt<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/clangd/CMakeLists.<wbr>txt?rev=317486&r1=317485&r2=<wbr>317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/<wbr>clangd/CMakeLists.txt (original)<br>
> +++ clang-tools-extra/trunk/<wbr>clangd/CMakeLists.txt Mon Nov  6 07:40:30 2017<br>
> @@ -10,6 +10,7 @@ add_clang_library(clangDaemon<br>
>    DraftStore.cpp<br>
>    GlobalCompilationDatabase.cpp<br>
>    JSONRPCDispatcher.cpp<br>
> +  JSONExpr.cpp<br>
>    Logger.cpp<br>
>    Protocol.cpp<br>
>    ProtocolHandlers.cpp<br>
><br>
> Modified: clang-tools-extra/trunk/<wbr>clangd/ClangdLSPServer.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/clangd/<wbr>ClangdLSPServer.cpp?rev=<wbr>317486&r1=317485&r2=317486&<wbr>view=dif<br>
> f<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/<wbr>clangd/ClangdLSPServer.cpp (original)<br>
> +++ clang-tools-extra/trunk/<wbr>clangd/ClangdLSPServer.cpp Mon Nov  6 07:40:30<br>
> 2017<br>
> @@ -20,35 +20,46 @@ namespace {<br>
>  std::vector<TextEdit><br>
>  replacementsToEdits(StringRef Code,<br>
>                      const std::vector<tooling::<wbr>Replacement> &Replacements) {<br>
> -  std::vector<TextEdit> Edits;<br>
>    // Turn the replacements into the format specified by the Language Server<br>
> -  // Protocol.<br>
> +  // Protocol. Fuse them into one big JSON array.<br>
> +  std::vector<TextEdit> Edits;<br>
>    for (auto &R : Replacements) {<br>
>      Range ReplacementRange = {<br>
>          offsetToPosition(Code, R.getOffset()),<br>
>          offsetToPosition(Code, R.getOffset() + R.getLength())};<br>
>      Edits.push_back({<wbr>ReplacementRange, R.getReplacementText()});<br>
>    }<br>
> -<br>
>    return Edits;<br>
>  }<br>
><br>
>  } // namespace<br>
><br>
>  void ClangdLSPServer::onInitialize(<wbr>Ctx C, InitializeParams &Params) {<br>
> -  C.reply(<br>
> -      R"({"capabilities":{<br>
> -          "textDocumentSync": 1,<br>
> -          "documentFormattingProvider": true,<br>
> -          "<wbr>documentRangeFormattingProvide<wbr>r": true,<br>
> -          "<wbr>documentOnTypeFormattingProvid<wbr>er":<br>
> {"firstTriggerCharacter":"}","<wbr>moreTriggerCharacter":[]},<br>
> -          "codeActionProvider": true,<br>
> -          "completionProvider": {"resolveProvider": false,<br>
> "triggerCharacters": [".",">",":"]},<br>
> -          "signatureHelpProvider": {"triggerCharacters": ["(",","]},<br>
> -          "definitionProvider": true,<br>
> -          "executeCommandProvider": {"commands": [")" +<br>
> -      ExecuteCommandParams::CLANGD_<wbr>APPLY_FIX_COMMAND + R"("]}<br>
> -        }})");<br>
> +  C.reply(json::obj{<br>
> +      {"textDocumentSync", 1},<br>
> +      {"documentFormattingProvider", true},<br>
> +      {"<wbr>documentRangeFormattingProvide<wbr>r", true},<br>
> +      {"<wbr>documentOnTypeFormattingProvid<wbr>er",<br>
> +       json::obj{<br>
> +           {"firstTriggerCharacter", "}"},<br>
> +           {"moreTriggerCharacter", {}},<br>
> +       }},<br>
> +      {"codeActionProvider", true},<br>
> +      {"completionProvider",<br>
> +       json::obj{<br>
> +           {"resolveProvider", false},<br>
> +           {"triggerCharacters", {".", ">", ":"}},<br>
> +       }},<br>
> +      {"signatureHelpProvider",<br>
> +       json::obj{<br>
> +           {"triggerCharacters", {"(", ","}},<br>
> +       }},<br>
> +      {"definitionProvider", true},<br>
> +      {"executeCommandProvider",<br>
> +       json::obj{<br>
> +           {"commands", {ExecuteCommandParams::CLANGD_<wbr>APPLY_FIX_COMMAND}},<br>
> +       }},<br>
> +  });<br>
>    if (Params.rootUri && !Params.rootUri->file.empty())<br>
>      Server.setRootPath(Params.<wbr>rootUri->file);<br>
>    else if (Params.rootPath && !Params.rootPath->empty())<br>
> @@ -58,7 +69,7 @@ void ClangdLSPServer::onInitialize(<wbr>Ctx C<br>
>  void ClangdLSPServer::onShutdown(<wbr>Ctx C, ShutdownParams &Params) {<br>
>    // Do essentially nothing, just say we're ready to exit.<br>
>    ShutdownRequestReceived = true;<br>
> -  C.reply("null");<br>
> +  C.reply(nullptr);<br>
>  }<br>
><br>
>  void ClangdLSPServer::onExit(Ctx C, ExitParams &Params) { IsDone = true; }<br>
> @@ -98,7 +109,7 @@ void ClangdLSPServer::onCommand(Ctx C, E<br>
><br>
>      ApplyWorkspaceEditParams ApplyEdit;<br>
>      ApplyEdit.edit = *Params.workspaceEdit;<br>
> -    C.reply("\"Fix applied.\"");<br>
> +    C.reply("Fix applied.");<br>
>      // We don't need the response so id == 1 is OK.<br>
>      // Ideally, we would wait for the response and if there is no error, we<br>
>      // would reply success/failure to the original RPC.<br>
> @@ -121,51 +132,45 @@ void ClangdLSPServer::<wbr>onDocumentOnTypeFo<br>
>      Ctx C, DocumentOnTypeFormattingParams &Params) {<br>
>    auto File = Params.textDocument.uri.file;<br>
>    std::string Code = Server.getDocument(File);<br>
> -  std::string Edits = TextEdit::unparse(<br>
> -      replacementsToEdits(Code, Server.formatOnType(File, Params.position)));<br>
> -  C.reply(Edits);<br>
> +  C.reply(json::ary(<br>
> +      replacementsToEdits(Code, Server.formatOnType(File,<br>
> Params.position))));<br>
>  }<br>
><br>
>  void ClangdLSPServer::<wbr>onDocumentRangeFormatting(<br>
>      Ctx C, DocumentRangeFormattingParams &Params) {<br>
>    auto File = Params.textDocument.uri.file;<br>
>    std::string Code = Server.getDocument(File);<br>
> -  std::string Edits = TextEdit::unparse(<br>
> -      replacementsToEdits(Code, Server.formatRange(File, Params.range)));<br>
> -  C.reply(Edits);<br>
> +  C.reply(json::ary(<br>
> +      replacementsToEdits(Code, Server.formatRange(File, Params.range))));<br>
>  }<br>
><br>
>  void ClangdLSPServer::<wbr>onDocumentFormatting(Ctx C,<br>
>                                             DocumentFormattingParams &Params)<br>
> {<br>
>    auto File = Params.textDocument.uri.file;<br>
>    std::string Code = Server.getDocument(File);<br>
> -  std::string Edits =<br>
> -      TextEdit::unparse(<wbr>replacementsToEdits(Code, Server.formatFile(File)));<br>
> -  C.reply(Edits);<br>
> +  C.reply(json::ary(<wbr>replacementsToEdits(Code, Server.formatFile(File))));<br>
>  }<br>
><br>
>  void ClangdLSPServer::onCodeAction(<wbr>Ctx C, CodeActionParams &Params) {<br>
>    // We provide a code action for each diagnostic at the requested location<br>
>    // which has FixIts available.<br>
>    std::string Code = Server.getDocument(Params.<wbr>textDocument.uri.file);<br>
> -  std::string Commands;<br>
> +  json::ary Commands;<br>
>    for (Diagnostic &D : Params.context.diagnostics) {<br>
>      std::vector<clang::tooling::<wbr>Replacement> Fixes =<br>
>          getFixIts(Params.textDocument.<wbr>uri.file, D);<br>
>      auto Edits = replacementsToEdits(Code, Fixes);<br>
> -    WorkspaceEdit WE;<br>
> -    WE.changes = {{llvm::yaml::escape(Params.<wbr>textDocument.uri.uri), Edits}};<br>
> -<br>
> -    if (!Edits.empty())<br>
> -      Commands +=<br>
> -          R"({"title":"Apply FixIt ')" + llvm::yaml::escape(D.message) +<br>
> -          R"('", "command": ")" +<br>
> -          ExecuteCommandParams::CLANGD_<wbr>APPLY_FIX_COMMAND +<br>
> -          R"(", "arguments": [)" + WorkspaceEdit::unparse(WE) + R"(]},)";<br>
> +    if (!Edits.empty()) {<br>
> +      WorkspaceEdit WE;<br>
> +      WE.changes = {{Params.textDocument.uri.uri, std::move(Edits)}};<br>
> +      Commands.push_back(json::obj{<br>
> +          {"title", llvm::formatv("Apply FixIt {0}", D.message)},<br>
> +          {"command", ExecuteCommandParams::CLANGD_<wbr>APPLY_FIX_COMMAND},<br>
> +          {"arguments", {WE}},<br>
> +      });<br>
> +    }<br>
>    }<br>
> -  if (!Commands.empty())<br>
> -    Commands.pop_back();<br>
> -  C.reply("[" + Commands + "]");<br>
> +  C.reply(std::move(Commands));<br>
>  }<br>
><br>
>  void ClangdLSPServer::onCompletion(<wbr>Ctx C, TextDocumentPositionParams &Params)<br>
> {<br>
> @@ -177,15 +182,7 @@ void ClangdLSPServer::onCompletion(<wbr>Ctx C<br>
>                            // had an API that would allow to attach callbacks<br>
> to<br>
>                            // futures returned by ClangdServer.<br>
>                     .Value;<br>
> -<br>
> -  std::string Completions;<br>
> -  for (const auto &Item : Items) {<br>
> -    Completions += CompletionItem::unparse(Item);<br>
> -    Completions += ",";<br>
> -  }<br>
> -  if (!Completions.empty())<br>
> -    Completions.pop_back();<br>
> -  C.reply("[" + Completions + "]");<br>
> +  C.reply(json::ary(Items));<br>
>  }<br>
><br>
>  void ClangdLSPServer::<wbr>onSignatureHelp(Ctx C,<br>
> @@ -195,7 +192,7 @@ void ClangdLSPServer::<wbr>onSignatureHelp(Ct<br>
>        Position{Params.position.line, Params.position.character});<br>
>    if (!SignatureHelp)<br>
>      return C.replyError(-32602, llvm::toString(SignatureHelp.<wbr>takeError()));<br>
> -  C.reply(SignatureHelp::<wbr>unparse(SignatureHelp->Value))<wbr>;<br>
> +  C.reply(SignatureHelp->Value);<br>
>  }<br>
><br>
>  void ClangdLSPServer::<wbr>onGoToDefinition(Ctx C,<br>
> @@ -205,22 +202,14 @@ void ClangdLSPServer::<wbr>onGoToDefinition(C<br>
>        Position{Params.position.line, Params.position.character});<br>
>    if (!Items)<br>
>      return C.replyError(-32602, llvm::toString(Items.<wbr>takeError()));<br>
> -<br>
> -  std::string Locations;<br>
> -  for (const auto &Item : Items->Value) {<br>
> -    Locations += Location::unparse(Item);<br>
> -    Locations += ",";<br>
> -  }<br>
> -  if (!Locations.empty())<br>
> -    Locations.pop_back();<br>
> -  C.reply("[" + Locations + "]");<br>
> +  C.reply(json::ary(Items-><wbr>Value));<br>
>  }<br>
><br>
>  void ClangdLSPServer::<wbr>onSwitchSourceHeader(Ctx C,<br>
>                                             TextDocumentIdentifier &Params) {<br>
>    llvm::Optional<Path> Result = Server.switchSourceHeader(<wbr>Params.uri.file);<br>
>    std::string ResultUri;<br>
> -  C.reply(Result ? URI::unparse(URI::fromFile(*<wbr>Result)) : R"("")");<br>
> +  C.reply(Result ? URI::fromFile(*Result).uri : "");<br>
>  }<br>
><br>
>  ClangdLSPServer::<wbr>ClangdLSPServer(JSONOutput &Out, unsigned AsyncThreadsCount,<br>
> @@ -270,17 +259,16 @@ ClangdLSPServer::getFixIts(<wbr>StringRef Fil<br>
><br>
>  void ClangdLSPServer::<wbr>onDiagnosticsReady(<br>
>      PathRef File, Tagged<std::vector<<wbr>DiagWithFixIts>> Diagnostics) {<br>
> -  std::string DiagnosticsJSON;<br>
> +  json::ary DiagnosticsJSON;<br>
><br>
>    DiagnosticToReplacementMap LocalFixIts; // Temporary storage<br>
>    for (auto &DiagWithFixes : Diagnostics.Value) {<br>
>      auto Diag = DiagWithFixes.Diag;<br>
> -    DiagnosticsJSON +=<br>
> -        R"({"range":)" + Range::unparse(Diag.range) +<br>
> -        R"(,"severity":)" + std::to_string(Diag.severity) +<br>
> -        R"(,"message":")" + llvm::yaml::escape(Diag.<wbr>message) +<br>
> -        R"("},)";<br>
> -<br>
> +    DiagnosticsJSON.push_back(<wbr>json::obj{<br>
> +        {"range", Diag.range},<br>
> +        {"severity", Diag.severity},<br>
> +        {"message", Diag.message},<br>
> +    });<br>
>      // We convert to Replacements to become independent of the SourceManager.<br>
>      auto &FixItsForDiagnostic = LocalFixIts[Diag];<br>
>      std::copy(DiagWithFixes.<wbr>FixIts.begin(), DiagWithFixes.FixIts.end(),<br>
> @@ -295,10 +283,13 @@ void ClangdLSPServer::<wbr>onDiagnosticsReady<br>
>    }<br>
><br>
>    // Publish diagnostics.<br>
> -  if (!DiagnosticsJSON.empty())<br>
> -    DiagnosticsJSON.pop_back(); // Drop trailing comma.<br>
> -  Out.writeMessage(<br>
> -<br>
> R"({"jsonrpc":"2.0","method":"<wbr>textDocument/<wbr>publishDiagnostics","params":{<wbr>"uri"<br>
> :")" +<br>
> -      URI::fromFile(File).uri + R"(","diagnostics":[)" + DiagnosticsJSON +<br>
> -      R"(]}})");<br>
> +  Out.writeMessage(json::obj{<br>
> +      {"jsonrpc", "2.0"},<br>
> +      {"method", "textDocument/<wbr>publishDiagnostics"},<br>
> +      {"params",<br>
> +       json::obj{<br>
> +           {"uri", URI::fromFile(File)},<br>
> +           {"diagnostics", std::move(DiagnosticsJSON)},<br>
> +       }},<br>
> +  });<br>
>  }<br>
><br>
> Added: clang-tools-extra/trunk/<wbr>clangd/JSONExpr.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/clangd/JSONExpr.<wbr>cpp?rev=317486&view=auto<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/<wbr>clangd/JSONExpr.cpp (added)<br>
> +++ clang-tools-extra/trunk/<wbr>clangd/JSONExpr.cpp Mon Nov  6 07:40:30 2017<br>
> @@ -0,0 +1,216 @@<br>
> +#include "JSONExpr.h"<br>
> +<br>
> +#include "llvm/Support/Format.h"<br>
> +<br>
> +namespace clang {<br>
> +namespace clangd {<br>
> +namespace json {<br>
> +using namespace llvm;<br>
> +<br>
> +void Expr::copyFrom(const Expr &M) {<br>
> +  Type = M.Type;<br>
> +  switch (Type) {<br>
> +  case T_Null:<br>
> +  case T_Boolean:<br>
> +  case T_Number:<br>
> +    memcpy(Union.buffer, M.Union.buffer, sizeof(Union.buffer));<br>
> +    break;<br>
> +  case T_StringRef:<br>
> +    create<StringRef>(M.as<<wbr>StringRef>());<br>
> +    break;<br>
> +  case T_String:<br>
> +    create<std::string>(M.as<std::<wbr>string>());<br>
> +    break;<br>
> +  case T_Object:<br>
> +    create<Object>(M.as<Object>())<wbr>;<br>
> +    break;<br>
> +  case T_Array:<br>
> +    create<Array>(M.as<Array>());<br>
> +    break;<br>
> +  }<br>
> +}<br>
> +<br>
> +void Expr::moveFrom(const Expr &&M) {<br>
> +  Type = M.Type;<br>
> +  switch (Type) {<br>
> +  case T_Null:<br>
> +  case T_Boolean:<br>
> +  case T_Number:<br>
> +    memcpy(Union.buffer, M.Union.buffer, sizeof(Union.buffer));<br>
> +    break;<br>
> +  case T_StringRef:<br>
> +    create<StringRef>(M.as<<wbr>StringRef>());<br>
> +    break;<br>
> +  case T_String:<br>
> +    create<std::string>(std::move(<wbr>M.as<std::string>()));<br>
> +    M.Type = T_Null;<br>
> +    break;<br>
> +  case T_Object:<br>
> +    create<Object>(std::move(M.as<<wbr>Object>()));<br>
> +    M.Type = T_Null;<br>
> +    break;<br>
> +  case T_Array:<br>
> +    create<Array>(std::move(M.as<<wbr>Array>()));<br>
> +    M.Type = T_Null;<br>
> +    break;<br>
> +  }<br>
> +}<br>
> +<br>
> +void Expr::destroy() {<br>
> +  switch (Type) {<br>
> +  case T_Null:<br>
> +  case T_Boolean:<br>
> +  case T_Number:<br>
> +    break;<br>
> +  case T_StringRef:<br>
> +    as<StringRef>().~StringRef();<br>
> +    break;<br>
> +  case T_String:<br>
> +    as<std::string>().~basic_<wbr>string();<br>
> +    break;<br>
> +  case T_Object:<br>
> +    as<Object>().~Object();<br>
> +    break;<br>
> +  case T_Array:<br>
> +    as<Array>().~Array();<br>
> +    break;<br>
> +  }<br>
> +}<br>
> +<br>
> +} // namespace json<br>
> +} // namespace clangd<br>
> +} // namespace clang<br>
> +<br>
> +namespace {<br>
> +void quote(llvm::raw_ostream &OS, llvm::StringRef S) {<br>
> +  OS << '\"';<br>
> +  for (unsigned char C : S) {<br>
> +    if (C == 0x22 || C == 0x5C)<br>
> +      OS << '\\';<br>
> +    if (C >= 0x20) {<br>
> +      OS << C;<br>
> +      continue;<br>
> +    }<br>
> +    OS << '\\';<br>
> +    switch (C) {<br>
> +    // A few characters are common enough to make short escapes worthwhile.<br>
> +    case '\t':<br>
> +      OS << 't';<br>
> +      break;<br>
> +    case '\n':<br>
> +      OS << 'n';<br>
> +      break;<br>
> +    case '\r':<br>
> +      OS << 'r';<br>
> +      break;<br>
> +    default:<br>
> +      OS << 'u';<br>
> +      llvm::write_hex(OS, C, llvm::HexPrintStyle::Lower, 4);<br>
> +      break;<br>
> +    }<br>
> +  }<br>
> +  OS << '\"';<br>
> +}<br>
> +<br>
> +enum IndenterAction {<br>
> +  Indent,<br>
> +  Outdent,<br>
> +  Newline,<br>
> +  Space,<br>
> +};<br>
> +} // namespace<br>
> +<br>
> +// Prints JSON. The indenter can be used to control formatting.<br>
> +template <typename Indenter><br>
> +void clang::clangd::json::Expr::<wbr>print(raw_ostream &OS,<br>
> +                                      const Indenter &I) const {<br>
> +  switch (Type) {<br>
> +  case T_Null:<br>
> +    OS << "null";<br>
> +    break;<br>
> +  case T_Boolean:<br>
> +    OS << (as<bool>() ? "true" : "false");<br>
> +    break;<br>
> +  case T_Number:<br>
> +    OS << format("%g", as<double>());<br>
> +    break;<br>
> +  case T_StringRef:<br>
> +    quote(OS, as<StringRef>());<br>
> +    break;<br>
> +  case T_String:<br>
> +    quote(OS, as<std::string>());<br>
> +    break;<br>
> +  case T_Object: {<br>
> +    bool Comma = false;<br>
> +    OS << '{';<br>
> +    I(Indent);<br>
> +    for (const auto &P : as<Expr::Object>()) {<br>
> +      if (Comma)<br>
> +        OS << ',';<br>
> +      Comma = true;<br>
> +      I(Newline);<br>
> +      quote(OS, P.first);<br>
> +      OS << ':';<br>
> +      I(Space);<br>
> +      P.second.print(OS, I);<br>
> +    }<br>
> +    I(Outdent);<br>
> +    if (Comma)<br>
> +      I(Newline);<br>
> +    OS << '}';<br>
> +    break;<br>
> +  }<br>
> +  case T_Array: {<br>
> +    bool Comma = false;<br>
> +    OS << '[';<br>
> +    I(Indent);<br>
> +    for (const auto &E : as<Expr::Array>()) {<br>
> +      if (Comma)<br>
> +        OS << ',';<br>
> +      Comma = true;<br>
> +      I(Newline);<br>
> +      E.print(OS, I);<br>
> +    }<br>
> +    I(Outdent);<br>
> +    if (Comma)<br>
> +      I(Newline);<br>
> +    OS << ']';<br>
> +    break;<br>
> +  }<br>
> +  }<br>
> +}<br>
> +<br>
> +llvm::raw_ostream &clang::clangd::json::<wbr>operator<<(raw_ostream &OS,<br>
> +                                                   const Expr &E) {<br>
> +  E.print(OS, [](IndenterAction A) { /*ignore*/ });<br>
> +  return OS;<br>
> +}<br>
> +<br>
> +void llvm::format_provider<clang::<wbr>clangd::json::Expr>::format(<br>
> +    const clang::clangd::json::Expr &E, raw_ostream &OS, StringRef Options) {<br>
> +  if (Options.empty()) {<br>
> +    OS << E;<br>
> +    return;<br>
> +  }<br>
> +  unsigned IndentAmount = 0;<br>
> +  if (Options.getAsInteger(/*Radix=<wbr>*/10, IndentAmount))<br>
> +    assert(false && "json::Expr format options should be an integer");<br>
> +  unsigned IndentLevel = 0;<br>
> +  E.print(OS, [&](IndenterAction A) {<br>
> +    switch (A) {<br>
> +    case Newline:<br>
> +      OS << '\n';<br>
> +      OS.indent(IndentLevel);<br>
> +      break;<br>
> +    case Space:<br>
> +      OS << ' ';<br>
> +      break;<br>
> +    case Indent:<br>
> +      IndentLevel += IndentAmount;<br>
> +      break;<br>
> +    case Outdent:<br>
> +      IndentLevel -= IndentAmount;<br>
> +      break;<br>
> +    };<br>
> +  });<br>
> +}<br>
><br>
> Added: clang-tools-extra/trunk/<wbr>clangd/JSONExpr.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/clangd/JSONExpr.h?<wbr>rev=317486&view=auto<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/<wbr>clangd/JSONExpr.h (added)<br>
> +++ clang-tools-extra/trunk/<wbr>clangd/JSONExpr.h Mon Nov  6 07:40:30 2017<br>
> @@ -0,0 +1,247 @@<br>
> +//===--- JSONExpr.h - composable JSON expressions ---------------*- C++ -*-<br>
> ===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===------------------------<wbr>------------------------------<wbr>---------------<br>
> ===//<br>
> +<br>
> +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_<wbr>JSON_H<br>
> +#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_<wbr>JSON_H<br>
> +<br>
> +#include <map><br>
> +<br>
> +#include "llvm/ADT/SmallVector.h"<br>
> +#include "llvm/ADT/StringRef.h"<br>
> +#include "llvm/Support/FormatVariadic.<wbr>h"<br>
> +#include "llvm/Support/raw_ostream.h"<br>
> +<br>
> +namespace clang {<br>
> +namespace clangd {<br>
> +namespace json {<br>
> +<br>
> +// An Expr is an opaque temporary JSON structure used to compose documents.<br>
> +// They can be copied, but should generally be moved.<br>
> +//<br>
> +// You can implicitly construct literals from:<br>
> +//   - strings: std::string, SmallString, formatv, StringRef, char*<br>
> +//              (char*, and StringRef are references, not copies!)<br>
> +//   - numbers<br>
> +//   - booleans<br>
> +//   - null: nullptr<br>
> +//   - arrays: {"foo", 42.0, false}<br>
> +//   - serializable things: any T with a T::unparse(const T&) -> Expr<br>
> +//<br>
> +// They can also be constructed from object/array helpers:<br>
> +//   - json::obj is a type like map<StringExpr, Expr><br>
> +//   - json::ary is a type like vector<Expr><br>
> +// These can be list-initialized, or used to build up collections in a loop.<br>
> +// json::ary(Collection) converts all items in a collection to Exprs.<br>
> +//<br>
> +// Exprs can be serialized to JSON:<br>
> +//   1) raw_ostream << Expr                    // Basic formatting.<br>
> +//   2) raw_ostream << formatv("{0}", Expr)    // Basic formatting.<br>
> +//   3) raw_ostream << formatv("{0:2}", Expr)  // Pretty-print with indent 2.<br>
> +class Expr {<br>
> +public:<br>
> +  class Object;<br>
> +  class ObjectKey;<br>
> +  class Array;<br>
> +<br>
> +  // It would be nice to have Expr() be null. But that would make {} null<br>
> too...<br>
> +  Expr(const Expr &M) { copyFrom(M); }<br>
> +  Expr(Expr &&M) { moveFrom(std::move(M)); }<br>
> +  // "cheating" move-constructor for moving from initializer_list.<br>
> +  Expr(const Expr &&M) { moveFrom(std::move(M)); }<br>
> +  Expr(std::initializer_list<<wbr>Expr> Elements) : Expr(Array(Elements)) {}<br>
> +  Expr(Array &&Elements) : Type(T_Array) {<br>
> create<Array>(std::move(<wbr>Elements)); }<br>
> +  Expr(Object &&Properties) : Type(T_Object) {<br>
> +    create<Object>(std::move(<wbr>Properties));<br>
> +  }<br>
> +  // Strings: types with value semantics.<br>
> +  Expr(std::string &&V) : Type(T_String) { create<std::string>(std::move(<wbr>V));<br>
> }<br>
> +  Expr(const std::string &V) : Type(T_String) { create<std::string>(V); }<br>
> +  Expr(const llvm::SmallVectorImpl<char> &V) : Type(T_String) {<br>
> +    create<std::string>(V.begin(), V.end());<br>
> +  }<br>
> +  Expr(const llvm::formatv_object_base &V) : Expr(V.str()){};<br>
> +  // Strings: types with reference semantics.<br>
> +  Expr(llvm::StringRef V) : Type(T_StringRef) { create<llvm::StringRef>(V); }<br>
> +  Expr(const char *V) : Type(T_StringRef) { create<llvm::StringRef>(V); }<br>
> +  Expr(std::nullptr_t) : Type(T_Null) {}<br>
> +  // Prevent implicit conversions to boolean.<br>
> +  template <typename T, typename = typename std::enable_if<<br>
> +                            std::is_same<T, bool>::value>::type><br>
> +  Expr(T B) : Type(T_Boolean) {<br>
> +    create<bool>(B);<br>
> +  }<br>
> +  // Numbers: arithmetic types that are not boolean.<br>
> +  template <<br>
> +      typename T,<br>
> +      typename = typename std::enable_if<std::is_<wbr>arithmetic<T>::value>::type,<br>
> +      typename = typename std::enable_if<std::integral_<wbr>constant<<br>
> +          bool, !std::is_same<T, bool>::value>::value>::type><br>
> +  Expr(T D) : Type(T_Number) {<br>
> +    create<double>(D);<br>
> +  }<br>
> +  // Types with a static T::unparse function returning an Expr.<br>
> +  // FIXME: should this be a free unparse() function found by ADL?<br>
> +  template <typename T,<br>
> +            typename = typename std::enable_if<std::is_same<<br>
> +                Expr, decltype(T::unparse(*(const T *)nullptr))>::value>><br>
> +  Expr(const T &V) : Expr(T::unparse(V)) {}<br>
> +<br>
> +  Expr &operator=(const Expr &M) {<br>
> +    destroy();<br>
> +    copyFrom(M);<br>
> +    return *this;<br>
> +  }<br>
> +  Expr &operator=(Expr &&M) {<br>
> +    destroy();<br>
> +    moveFrom(std::move(M));<br>
> +    return *this;<br>
> +  }<br>
> +  ~Expr() { destroy(); }<br>
> +<br>
> +  friend llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Expr &);<br>
> +<br>
> +private:<br>
> +  void destroy();<br>
> +  void copyFrom(const Expr &M);<br>
> +  // We allow moving from *const* Exprs, by marking all members as mutable!<br>
> +  // This hack is needed to support initializer-list syntax efficiently.<br>
> +  // (std::initializer_list<T> is a container of const T).<br>
> +  void moveFrom(const Expr &&M);<br>
> +<br>
> +  template <typename T, typename... U> void create(U &&... V) {<br>
> +    new (&as<T>()) T(std::forward<U>(V)...);<br>
> +  }<br>
> +  template <typename T> T &as() const {<br>
> +    return *reinterpret_cast<T *>(Union.buffer);<br>
> +  }<br>
> +<br>
> +  template <typename Indenter><br>
> +  void print(llvm::raw_ostream &, const Indenter &) const;<br>
> +  friend struct llvm::format_provider<clang::<wbr>clangd::json::Expr>;<br>
> +<br>
> +  enum ExprType : char {<br>
> +    T_Null,<br>
> +    T_Boolean,<br>
> +    T_Number,<br>
> +    T_StringRef,<br>
> +    T_String,<br>
> +    T_Object,<br>
> +    T_Array,<br>
> +  };<br>
> +  mutable ExprType Type;<br>
> +<br>
> +public:<br>
> +  // ObjectKey is a used to capture keys in Expr::Objects. It's like Expr<br>
> but:<br>
> +  //   - only strings are allowed<br>
> +  //   - it's copyable (for std::map)<br>
> +  //   - we're slightly more eager to copy, to allow efficient key compares<br>
> +  //   - it's optimized for the string literal case (Owned == nullptr)<br>
> +  class ObjectKey {<br>
> +  public:<br>
> +    ObjectKey(const char *S) : Data(S) {}<br>
> +    ObjectKey(llvm::StringRef S) : Data(S) {}<br>
> +    ObjectKey(std::string &&V)<br>
> +        : Owned(new std::string(std::move(V))), Data(*Owned) {}<br>
> +    ObjectKey(const std::string &V) : Owned(new std::string(V)), Data(*Owned)<br>
> {}<br>
> +    ObjectKey(const llvm::SmallVectorImpl<char> &V)<br>
> +        : ObjectKey(std::string(V.begin(<wbr>), V.end())) {}<br>
> +    ObjectKey(const llvm::formatv_object_base &V) : ObjectKey(V.str()) {}<br>
> +<br>
> +    ObjectKey(const ObjectKey &C) { *this = C; }<br>
> +    ObjectKey(ObjectKey &&C) = default;<br>
> +    ObjectKey &operator=(const ObjectKey &C) {<br>
> +      if (C.Owned) {<br>
> +        Owned.reset(new std::string(*C.Owned));<br>
> +        Data = *Owned;<br>
> +      } else {<br>
> +        Data = C.Data;<br>
> +      }<br>
> +      return *this;<br>
> +    }<br>
> +    ObjectKey &operator=(ObjectKey &&) = default;<br>
> +<br>
> +    operator llvm::StringRef() const { return Data; }<br>
> +<br>
> +    friend bool operator<(const ObjectKey &L, const ObjectKey &R) {<br>
> +      return L.Data < R.Data;<br>
> +    }<br>
> +<br>
> +    // "cheating" move-constructor for moving from initializer_list.<br>
> +    ObjectKey(const ObjectKey &&V) {<br>
> +      Owned = std::move(V.Owned);<br>
> +      Data = V.Data;<br>
> +    }<br>
> +<br>
> +  private:<br>
> +    mutable std::unique_ptr<std::string> Owned; // mutable for cheating.<br>
> +    llvm::StringRef Data;<br>
> +  };<br>
> +<br>
> +  class Object : public std::map<ObjectKey, Expr> {<br>
> +  public:<br>
> +    explicit Object() {}<br>
> +    // Use a custom struct for list-init, because pair forces extra copies.<br>
> +    struct KV;<br>
> +    explicit Object(std::initializer_list<<wbr>KV> Properties);<br>
> +<br>
> +    // Allow [] as if Expr was default-constructible as null.<br>
> +    Expr &operator[](const ObjectKey &K) {<br>
> +      return emplace(K, Expr(nullptr)).first->second;<br>
> +    }<br>
> +    Expr &operator[](ObjectKey &&K) {<br>
> +      return emplace(std::move(K), Expr(nullptr)).first->second;<br>
> +    }<br>
> +  };<br>
> +<br>
> +  class Array : public std::vector<Expr> {<br>
> +  public:<br>
> +    explicit Array() {}<br>
> +    explicit Array(std::initializer_list<<wbr>Expr> Elements) {<br>
> +      reserve(Elements.size());<br>
> +      for (const Expr &V : Elements)<br>
> +        emplace_back(std::move(V));<br>
> +    };<br>
> +    template <typename Collection> explicit Array(const Collection &C) {<br>
> +      for (const auto &V : C)<br>
> +        emplace_back(V);<br>
> +    }<br>
> +  };<br>
> +<br>
> +private:<br>
> +  mutable llvm::AlignedCharArrayUnion<<wbr>bool, double, llvm::StringRef,<br>
> +                                      std::string, Array, Object><br>
> +      Union;<br>
> +};<br>
> +<br>
> +struct Expr::Object::KV {<br>
> +  ObjectKey K;<br>
> +  Expr V;<br>
> +};<br>
> +<br>
> +inline Expr::Object::Object(std::<wbr>initializer_list<KV> Properties) {<br>
> +  for (const auto &P : Properties)<br>
> +    emplace(std::move(P.K), std::move(P.V));<br>
> +}<br>
> +<br>
> +// Give Expr::{Object,Array} more convenient names for literal use.<br>
> +using obj = Expr::Object;<br>
> +using ary = Expr::Array;<br>
> +<br>
> +} // namespace json<br>
> +} // namespace clangd<br>
> +} // namespace clang<br>
> +<br>
> +namespace llvm {<br>
> +template <> struct format_provider<clang::clangd:<wbr>:json::Expr> {<br>
> +  static void format(const clang::clangd::json::Expr &, raw_ostream &,<br>
> +                     StringRef);<br>
> +};<br>
> +} // namespace llvm<br>
> +<br>
> +#endif<br>
><br>
> Modified: clang-tools-extra/trunk/<wbr>clangd/JSONRPCDispatcher.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/clangd/<wbr>JSONRPCDispatcher.cpp?rev=<wbr>317486&r1=317485&r2=317486&<wbr>view=d<br>
> iff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/<wbr>clangd/JSONRPCDispatcher.cpp (original)<br>
> +++ clang-tools-extra/trunk/<wbr>clangd/JSONRPCDispatcher.cpp Mon Nov  6 07:40:30<br>
> 2017<br>
> @@ -8,6 +8,7 @@<br>
>  //===-------------------------<wbr>------------------------------<wbr>---------------<br>
> ===//<br>
><br>
>  #include "JSONRPCDispatcher.h"<br>
> +#include "JSONExpr.h"<br>
>  #include "ProtocolHandlers.h"<br>
>  #include "Trace.h"<br>
>  #include "llvm/ADT/SmallString.h"<br>
> @@ -18,17 +19,22 @@<br>
>  using namespace clang;<br>
>  using namespace clangd;<br>
><br>
> -void JSONOutput::writeMessage(const Twine &Message) {<br>
> -  llvm::SmallString<128> Storage;<br>
> -  StringRef M = Message.toStringRef(Storage);<br>
> +void JSONOutput::writeMessage(const json::Expr &Message) {<br>
> +  std::string S;<br>
> +  llvm::raw_string_ostream OS(S);<br>
> +  if (Pretty)<br>
> +    OS << llvm::formatv("{0:2}", Message);<br>
> +  else<br>
> +    OS << Message;<br>
> +  OS.flush();<br>
><br>
>    std::lock_guard<std::mutex> Guard(StreamMutex);<br>
>    // Log without headers.<br>
> -  Logs << "--> " << M << '\n';<br>
> +  Logs << "--> " << S << '\n';<br>
>    Logs.flush();<br>
><br>
>    // Emit message with header.<br>
> -  Outs << "Content-Length: " << M.size() << "\r\n\r\n" << M;<br>
> +  Outs << "Content-Length: " << S.size() << "\r\n\r\n" << S;<br>
>    Outs.flush();<br>
>  }<br>
><br>
> @@ -47,30 +53,38 @@ void JSONOutput::mirrorInput(const Twine<br>
>    InputMirror->flush();<br>
>  }<br>
><br>
> -void RequestContext::reply(const llvm::Twine &Result) {<br>
> -  if (ID.empty()) {<br>
> +void RequestContext::reply(json::<wbr>Expr &&Result) {<br>
> +  if (!ID) {<br>
>      Out.log("Attempted to reply to a notification!\n");<br>
>      return;<br>
>    }<br>
> -  Out.writeMessage(llvm::Twine(<wbr>R"({"jsonrpc":"2.0","id":)") + ID +<br>
> -                   R"(,"result":)" + Result + "}");<br>
> +  Out.writeMessage(json::obj{<br>
> +      {"jsonrpc", "2.0"},<br>
> +      {"id", *ID},<br>
> +      {"result", std::move(Result)},<br>
> +  });<br>
>  }<br>
><br>
>  void RequestContext::replyError(int code, const llvm::StringRef &Message) {<br>
>    Out.log("Error " + llvm::Twine(code) + ": " + Message + "\n");<br>
> -  if (!ID.empty()) {<br>
> -    Out.writeMessage(llvm::Twine(<wbr>R"({"jsonrpc":"2.0","id":)") + ID +<br>
> -                     R"(,"error":{"code":)" + llvm::Twine(code) +<br>
> -                     R"(,"message":")" + llvm::yaml::escape(Message) +<br>
> -                     R"("}})");<br>
> +  if (ID) {<br>
> +    Out.writeMessage(json::obj{<br>
> +        {"jsonrpc", "2.0"},<br>
> +        {"id", *ID},<br>
> +        {"error", json::obj{{"code", code}, {"message", Message}}},<br>
> +    });<br>
>    }<br>
>  }<br>
><br>
> -void RequestContext::call(StringRef Method, StringRef Params) {<br>
> +void RequestContext::call(StringRef Method, json::Expr &&Params) {<br>
>    // FIXME: Generate/Increment IDs for every request so that we can get<br>
> proper<br>
>    // replies once we need to.<br>
> -  Out.writeMessage(llvm::Twine(<wbr>R"({"jsonrpc":"2.0","id":1,"<wbr>method":")" +<br>
> -                               Method + R"(","params":)" + Params + R"(})"));<br>
> +  Out.writeMessage(json::obj{<br>
> +      {"jsonrpc", "2.0"},<br>
> +      {"id", 1},<br>
> +      {"method", Method},<br>
> +      {"params", std::move(Params)},<br>
> +  });<br>
>  }<br>
><br>
>  void JSONRPCDispatcher::<wbr>registerHandler(StringRef Method, Handler H) {<br>
> @@ -80,7 +94,7 @@ void JSONRPCDispatcher::<wbr>registerHandler(<br>
><br>
>  static void<br>
>  callHandler(const llvm::StringMap<<wbr>JSONRPCDispatcher::Handler> &Handlers,<br>
> -            llvm::yaml::ScalarNode *Method, llvm::yaml::ScalarNode *Id,<br>
> +            llvm::yaml::ScalarNode *Method, llvm::Optional<json::Expr> ID,<br>
>              llvm::yaml::MappingNode *Params,<br>
>              const JSONRPCDispatcher::Handler &UnknownHandler, JSONOutput<br>
> &Out) {<br>
>    llvm::SmallString<64> MethodStorage;<br>
> @@ -88,7 +102,7 @@ callHandler(const llvm::StringMap<JSONRP<br>
>    auto I = Handlers.find(MethodStr);<br>
>    auto &Handler = I != Handlers.end() ? I->second : UnknownHandler;<br>
>    trace::Span Tracer(MethodStr);<br>
> -  Handler(RequestContext(Out, Id ? Id->getRawValue() : ""), Params);<br>
> +  Handler(RequestContext(Out, std::move(ID)), Params);<br>
>  }<br>
><br>
>  bool JSONRPCDispatcher::call(<wbr>StringRef Content, JSONOutput &Out) const {<br>
> @@ -106,7 +120,7 @@ bool JSONRPCDispatcher::call(<wbr>StringRef C<br>
>    llvm::yaml::ScalarNode *Version = nullptr;<br>
>    llvm::yaml::ScalarNode *Method = nullptr;<br>
>    llvm::yaml::MappingNode *Params = nullptr;<br>
> -  llvm::yaml::ScalarNode *Id = nullptr;<br>
> +  llvm::Optional<json::Expr> ID;<br>
>    for (auto &NextKeyValue : *Object) {<br>
>      auto *KeyString =<br>
>          dyn_cast_or_null<llvm::yaml::<wbr>ScalarNode>(NextKeyValue.<wbr>getKey());<br>
> @@ -127,7 +141,18 @@ bool JSONRPCDispatcher::call(<wbr>StringRef C<br>
>      } else if (KeyValue == "method") {<br>
>        Method = dyn_cast<llvm::yaml::<wbr>ScalarNode>(Value);<br>
>      } else if (KeyValue == "id") {<br>
> -      Id = dyn_cast<llvm::yaml::<wbr>ScalarNode>(Value);<br>
> +      // ID may be either a string or a number.<br>
> +      if (auto *IdNode = dyn_cast<llvm::yaml::<wbr>ScalarNode>(Value)) {<br>
> +        llvm::SmallString<32> S;<br>
> +        llvm::StringRef V = IdNode->getValue(S);<br>
> +        if (IdNode->getRawValue().<wbr>startswith("\"")) {<br>
> +          ID.emplace(V.str());<br>
> +        } else {<br>
> +          double D;<br>
> +          if (!V.getAsDouble(D))<br>
> +            ID.emplace(D);<br>
> +        }<br>
> +      }<br>
>      } else if (KeyValue == "params") {<br>
>        if (!Method)<br>
>          return false;<br>
> @@ -136,7 +161,7 @@ bool JSONRPCDispatcher::call(<wbr>StringRef C<br>
>        // because it will break clients that put the id after params. A<br>
> possible<br>
>        // fix would be to split the parsing and execution phases.<br>
>        Params = dyn_cast<llvm::yaml::<wbr>MappingNode>(Value);<br>
> -      callHandler(Handlers, Method, Id, Params, UnknownHandler, Out);<br>
> +      callHandler(Handlers, Method, std::move(ID), Params, UnknownHandler,<br>
> Out);<br>
>        return true;<br>
>      } else {<br>
>        return false;<br>
> @@ -147,7 +172,7 @@ bool JSONRPCDispatcher::call(<wbr>StringRef C<br>
>    // leftovers.<br>
>    if (!Method)<br>
>      return false;<br>
> -  callHandler(Handlers, Method, Id, nullptr, UnknownHandler, Out);<br>
> +  callHandler(Handlers, Method, std::move(ID), nullptr, UnknownHandler, Out);<br>
><br>
>    return true;<br>
>  }<br>
><br>
> Modified: clang-tools-extra/trunk/<wbr>clangd/JSONRPCDispatcher.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/clangd/<wbr>JSONRPCDispatcher.h?rev=<wbr>317486&r1=317485&r2=317486&<wbr>view=dif<br>
> f<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/<wbr>clangd/JSONRPCDispatcher.h (original)<br>
> +++ clang-tools-extra/trunk/<wbr>clangd/JSONRPCDispatcher.h Mon Nov  6 07:40:30<br>
> 2017<br>
> @@ -10,6 +10,7 @@<br>
>  #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_<wbr>JSONRPCDISPATCHER_H<br>
>  #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_<wbr>JSONRPCDISPATCHER_H<br>
><br>
> +#include "JSONExpr.h"<br>
>  #include "Logger.h"<br>
>  #include "clang/Basic/LLVM.h"<br>
>  #include "llvm/ADT/SmallString.h"<br>
> @@ -26,11 +27,11 @@ namespace clangd {<br>
>  class JSONOutput : public Logger {<br>
>  public:<br>
>    JSONOutput(llvm::raw_ostream &Outs, llvm::raw_ostream &Logs,<br>
> -             llvm::raw_ostream *InputMirror = nullptr)<br>
> -      : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}<br>
> +             llvm::raw_ostream *InputMirror = nullptr, bool Pretty = false)<br>
> +      : Outs(Outs), Logs(Logs), InputMirror(InputMirror), Pretty(Pretty) {}<br>
><br>
>    /// Emit a JSONRPC message.<br>
> -  void writeMessage(const Twine &Message);<br>
> +  void writeMessage(const json::Expr &Result);<br>
><br>
>    /// Write to the logging stream.<br>
>    /// No newline is implicitly added. (TODO: we should fix this!)<br>
> @@ -45,6 +46,7 @@ private:<br>
>    llvm::raw_ostream &Outs;<br>
>    llvm::raw_ostream &Logs;<br>
>    llvm::raw_ostream *InputMirror;<br>
> +  bool Pretty;<br>
><br>
>    std::mutex StreamMutex;<br>
>  };<br>
> @@ -52,18 +54,19 @@ private:<br>
>  /// Context object passed to handlers to allow replies.<br>
>  class RequestContext {<br>
>  public:<br>
> -  RequestContext(JSONOutput &Out, StringRef ID) : Out(Out), ID(ID) {}<br>
> +  RequestContext(JSONOutput &Out, llvm::Optional<json::Expr> ID)<br>
> +      : Out(Out), ID(std::move(ID)) {}<br>
><br>
> -  /// Sends a successful reply. Result should be well-formed JSON.<br>
> -  void reply(const Twine &Result);<br>
> +  /// Sends a successful reply.<br>
> +  void reply(json::Expr &&Result);<br>
>    /// Sends an error response to the client, and logs it.<br>
>    void replyError(int code, const llvm::StringRef &Message);<br>
>    /// Sends a request to the client.<br>
> -  void call(llvm::StringRef Method, StringRef Params);<br>
> +  void call(llvm::StringRef Method, json::Expr &&Params);<br>
><br>
>  private:<br>
>    JSONOutput &Out;<br>
> -  llvm::SmallString<64> ID; // Valid JSON, or empty for a notification.<br>
> +  llvm::Optional<json::Expr> ID;<br>
>  };<br>
><br>
>  /// Main JSONRPC entry point. This parses the JSONRPC "header" and calls the<br>
><br>
> Modified: clang-tools-extra/trunk/<wbr>clangd/Protocol.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/clangd/Protocol.<wbr>cpp?rev=317486&r1=317485&r2=<wbr>317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/<wbr>clangd/Protocol.cpp (original)<br>
> +++ clang-tools-extra/trunk/<wbr>clangd/Protocol.cpp Mon Nov  6 07:40:30 2017<br>
> @@ -63,7 +63,7 @@ URI URI::parse(llvm::yaml::<wbr>ScalarNode *P<br>
>    return URI::fromUri(Param->getValue(<wbr>Storage));<br>
>  }<br>
><br>
> -std::string URI::unparse(const URI &U) { return "\"" + U.uri + "\""; }<br>
> +json::Expr URI::unparse(const URI &U) { return U.uri; }<br>
><br>
>  llvm::Optional<<wbr>TextDocumentIdentifier><br>
>  TextDocumentIdentifier::parse(<wbr>llvm::yaml::MappingNode *Params,<br>
> @@ -125,11 +125,11 @@ llvm::Optional<Position> Position::parse<br>
>    return Result;<br>
>  }<br>
><br>
> -std::string Position::unparse(const Position &P) {<br>
> -  std::string Result;<br>
> -  llvm::raw_string_ostream(<wbr>Result)<br>
> -      << llvm::format(R"({"line": %d, "character": %d})", P.line,<br>
> P.character);<br>
> -  return Result;<br>
> +json::Expr Position::unparse(const Position &P) {<br>
> +  return json::obj{<br>
> +      {"line", P.line},<br>
> +      {"character", P.character},<br>
> +  };<br>
>  }<br>
><br>
>  llvm::Optional<Range> Range::parse(llvm::yaml::<wbr>MappingNode *Params,<br>
> @@ -165,20 +165,18 @@ llvm::Optional<Range> Range::parse(llvm:<br>
>    return Result;<br>
>  }<br>
><br>
> -std::string Range::unparse(const Range &P) {<br>
> -  std::string Result;<br>
> -  llvm::raw_string_ostream(<wbr>Result) << llvm::format(<br>
> -      R"({"start": %s, "end": %s})", Position::unparse(P.start).c_<wbr>str(),<br>
> -      Position::unparse(P.end).c_<wbr>str());<br>
> -  return Result;<br>
> +json::Expr Range::unparse(const Range &P) {<br>
> +  return json::obj{<br>
> +      {"start", P.start},<br>
> +      {"end", P.end},<br>
> +  };<br>
>  }<br>
><br>
> -std::string Location::unparse(const Location &P) {<br>
> -  std::string Result;<br>
> -  llvm::raw_string_ostream(<wbr>Result) << llvm::format(<br>
> -      R"({"uri": %s, "range": %s})", URI::unparse(P.uri).c_str(),<br>
> -      Range::unparse(P.range).c_str(<wbr>));<br>
> -  return Result;<br>
> +json::Expr Location::unparse(const Location &P) {<br>
> +  return json::obj{<br>
> +      {"uri", P.uri},<br>
> +      {"range", P.range},<br>
> +  };<br>
>  }<br>
><br>
>  llvm::Optional<<wbr>TextDocumentItem><br>
> @@ -279,25 +277,11 @@ llvm::Optional<TextEdit> TextEdit::parse<br>
>    return Result;<br>
>  }<br>
><br>
> -std::string TextEdit::unparse(const TextEdit &P) {<br>
> -  std::string Result;<br>
> -  llvm::raw_string_ostream(<wbr>Result) << llvm::format(<br>
> -      R"({"range": %s, "newText": "%s"})", Range::unparse(P.range).c_str(<wbr>),<br>
> -      llvm::yaml::escape(P.newText).<wbr>c_str());<br>
> -  return Result;<br>
> -}<br>
> -<br>
> -std::string TextEdit::unparse(const std::vector<TextEdit> &TextEdits) {<br>
> -  // Fuse all edits into one big JSON array.<br>
> -  std::string Edits;<br>
> -  for (auto &TE : TextEdits) {<br>
> -    Edits += TextEdit::unparse(TE);<br>
> -    Edits += ',';<br>
> -  }<br>
> -  if (!Edits.empty())<br>
> -    Edits.pop_back();<br>
> -<br>
> -  return "[" + Edits + "]";<br>
> +json::Expr TextEdit::unparse(const TextEdit &P) {<br>
> +  return json::obj{<br>
> +      {"range", P.range},<br>
> +      {"newText", P.newText},<br>
> +  };<br>
>  }<br>
><br>
>  namespace {<br>
> @@ -611,11 +595,11 @@ FormattingOptions::parse(llvm:<wbr>:yaml::Map<br>
>    return Result;<br>
>  }<br>
><br>
> -std::string FormattingOptions::unparse(<wbr>const FormattingOptions &P) {<br>
> -  std::string Result;<br>
> -  llvm::raw_string_ostream(<wbr>Result) << llvm::format(<br>
> -      R"({"tabSize": %d, "insertSpaces": %d})", P.tabSize, P.insertSpaces);<br>
> -  return Result;<br>
> +json::Expr FormattingOptions::unparse(<wbr>const FormattingOptions &P) {<br>
> +  return json::obj{<br>
> +      {"tabSize", P.tabSize},<br>
> +      {"insertSpaces", P.insertSpaces},<br>
> +  };<br>
>  }<br>
><br>
>  llvm::Optional<<wbr>DocumentRangeFormattingParams><br>
> @@ -982,28 +966,18 @@ ExecuteCommandParams::parse(<wbr>llvm::yaml::<br>
>    return Result;<br>
>  }<br>
><br>
> -std::string WorkspaceEdit::unparse(const WorkspaceEdit &WE) {<br>
> -  std::string Changes;<br>
> -  for (auto &Change : *WE.changes) {<br>
> -    Changes += llvm::formatv(R"("{0}": {1})", Change.first,<br>
> -                             TextEdit::unparse(Change.<wbr>second));<br>
> -    Changes += ',';<br>
> -  }<br>
> -  if (!Changes.empty())<br>
> -    Changes.pop_back();<br>
> -<br>
> -  std::string Result;<br>
> -  llvm::raw_string_ostream(<wbr>Result)<br>
> -      << llvm::format(R"({"changes": {%s}})", Changes.c_str());<br>
> -  return Result;<br>
> +json::Expr WorkspaceEdit::unparse(const WorkspaceEdit &WE) {<br>
> +  if (!WE.changes)<br>
> +    return json::obj{};<br>
> +  json::obj FileChanges;<br>
> +  for (auto &Change : *WE.changes)<br>
> +    FileChanges[Change.first] = json::ary(Change.second);<br>
> +  return json::obj{{"changes", std::move(FileChanges)}};<br>
>  }<br>
><br>
> -std::string<br>
> +json::Expr<br>
>  ApplyWorkspaceEditParams::<wbr>unparse(const ApplyWorkspaceEditParams &Params) {<br>
> -  std::string Result;<br>
> -  llvm::raw_string_ostream(<wbr>Result) << llvm::format(<br>
> -      R"({"edit": %s})", WorkspaceEdit::unparse(Params.<wbr>edit).c_str());<br>
> -  return Result;<br>
> +  return json::obj{{"edit", Params.edit}};<br>
>  }<br>
><br>
>  llvm::Optional<<wbr>TextDocumentPositionParams><br>
> @@ -1040,96 +1014,57 @@ TextDocumentPositionParams::<wbr>parse(llvm::<br>
>    return Result;<br>
>  }<br>
><br>
> -std::string CompletionItem::unparse(const CompletionItem &CI) {<br>
> -  std::string Result = "{";<br>
> -  llvm::raw_string_ostream Os(Result);<br>
> +json::Expr CompletionItem::unparse(const CompletionItem &CI) {<br>
>    assert(!CI.label.empty() && "completion item label is required");<br>
> -  Os << R"("label":")" << llvm::yaml::escape(CI.label) << R"(",)";<br>
> +  json::obj Result{{"label", CI.label}};<br>
>    if (CI.kind != CompletionItemKind::Missing)<br>
> -    Os << R"("kind":)" << static_cast<int>(CI.kind) << R"(,)";<br>
> +    Result["kind"] = static_cast<int>(CI.kind);<br>
>    if (!CI.detail.empty())<br>
> -    Os << R"("detail":")" << llvm::yaml::escape(CI.detail) << R"(",)";<br>
> +    Result["detail"] = CI.detail;<br>
>    if (!CI.documentation.empty())<br>
> -    Os << R"("documentation":")" << llvm::yaml::escape(CI.<wbr>documentation)<br>
> -       << R"(",)";<br>
> +    Result["documentation"] = CI.documentation;<br>
>    if (!CI.sortText.empty())<br>
> -    Os << R"("sortText":")" << llvm::yaml::escape(CI.<wbr>sortText) << R"(",)";<br>
> +    Result["sortText"] = CI.sortText;<br>
>    if (!CI.filterText.empty())<br>
> -    Os << R"("filterText":")" << llvm::yaml::escape(CI.<wbr>filterText) <<<br>
> R"(",)";<br>
> +    Result["filterText"] = CI.filterText;<br>
>    if (!CI.insertText.empty())<br>
> -    Os << R"("insertText":")" << llvm::yaml::escape(CI.<wbr>insertText) <<<br>
> R"(",)";<br>
> -  if (CI.insertTextFormat != InsertTextFormat::Missing) {<br>
> -    Os << R"("insertTextFormat":)" << static_cast<int>(CI.<wbr>insertTextFormat)<br>
> -       << R"(,)";<br>
> -  }<br>
> +    Result["insertText"] = CI.insertText;<br>
> +  if (CI.insertTextFormat != InsertTextFormat::Missing)<br>
> +    Result["insertTextFormat"] = static_cast<int>(CI.<wbr>insertTextFormat);<br>
>    if (CI.textEdit)<br>
> -    Os << R"("textEdit":)" << TextEdit::unparse(*CI.<wbr>textEdit) << ',';<br>
> -  if (!CI.additionalTextEdits.<wbr>empty()) {<br>
> -    Os << R"("additionalTextEdits":[)";<br>
> -    for (const auto &Edit : CI.additionalTextEdits)<br>
> -      Os << TextEdit::unparse(Edit) << ",";<br>
> -    Os.flush();<br>
> -    // The list additionalTextEdits is guaranteed nonempty at this point.<br>
> -    // Replace the trailing comma with right brace.<br>
> -    Result.back() = ']';<br>
> -  }<br>
> -  Os.flush();<br>
> -  // Label is required, so Result is guaranteed to have a trailing comma.<br>
> -  Result.back() = '}';<br>
> -  return Result;<br>
> +    Result["textEdit"] = *CI.textEdit;<br>
> +  if (!CI.additionalTextEdits.<wbr>empty())<br>
> +    Result["additionalTextEdits"] = json::ary(CI.<wbr>additionalTextEdits);<br>
> +  return std::move(Result);<br>
>  }<br>
><br>
> -std::string ParameterInformation::unparse(<wbr>const ParameterInformation &PI) {<br>
> -  std::string Result = "{";<br>
> -  llvm::raw_string_ostream Os(Result);<br>
> +json::Expr ParameterInformation::unparse(<wbr>const ParameterInformation &PI) {<br>
>    assert(!PI.label.empty() && "parameter information label is required");<br>
> -  Os << R"("label":")" << llvm::yaml::escape(PI.label) << '\"';<br>
> +  json::obj Result{{"label", PI.label}};<br>
>    if (!PI.documentation.empty())<br>
> -    Os << R"(,"documentation":")" << llvm::yaml::escape(PI.<wbr>documentation)<br>
> -       << '\"';<br>
> -  Os << '}';<br>
> -  Os.flush();<br>
> -  return Result;<br>
> +    Result["documentation"] = PI.documentation;<br>
> +  return std::move(Result);<br>
>  }<br>
><br>
> -std::string SignatureInformation::unparse(<wbr>const SignatureInformation &SI) {<br>
> -  std::string Result = "{";<br>
> -  llvm::raw_string_ostream Os(Result);<br>
> +json::Expr SignatureInformation::unparse(<wbr>const SignatureInformation &SI) {<br>
>    assert(!SI.label.empty() && "signature information label is required");<br>
> -  Os << R"("label":")" << llvm::yaml::escape(SI.label) << '\"';<br>
> +  json::obj Result{<br>
> +      {"label", SI.label},<br>
> +      {"parameters", json::ary(SI.parameters)},<br>
> +  };<br>
>    if (!SI.documentation.empty())<br>
> -    Os << R"(,"documentation":")" << llvm::yaml::escape(SI.<wbr>documentation)<br>
> -       << '\"';<br>
> -  Os << R"(,"parameters":[)";<br>
> -  for (const auto &Parameter : SI.parameters) {<br>
> -    Os << ParameterInformation::unparse(<wbr>Parameter) << ',';<br>
> -  }<br>
> -  Os.flush();<br>
> -  if (SI.parameters.empty())<br>
> -    Result.push_back(']');<br>
> -  else<br>
> -    Result.back() = ']'; // Replace the last `,` with an `]`.<br>
> -  Result.push_back('}');<br>
> -  return Result;<br>
> +    Result["documentation"] = SI.documentation;<br>
> +  return std::move(Result);<br>
>  }<br>
><br>
> -std::string SignatureHelp::unparse(const SignatureHelp &SH) {<br>
> -  std::string Result = "{";<br>
> -  llvm::raw_string_ostream Os(Result);<br>
> +json::Expr SignatureHelp::unparse(const SignatureHelp &SH) {<br>
>    assert(SH.activeSignature >= 0 &&<br>
>           "Unexpected negative value for number of active signatures.");<br>
>    assert(SH.activeParameter >= 0 &&<br>
>           "Unexpected negative value for active parameter index");<br>
> -  Os << R"("activeSignature":)" << SH.activeSignature<br>
> -     << R"(,"activeParameter":)" << SH.activeParameter <<<br>
> R"(,"signatures":[)";<br>
> -  for (const auto &Signature : SH.signatures) {<br>
> -    Os << SignatureInformation::unparse(<wbr>Signature) << ',';<br>
> -  }<br>
> -  Os.flush();<br>
> -  if (SH.signatures.empty())<br>
> -    Result.push_back(']');<br>
> -  else<br>
> -    Result.back() = ']'; // Replace the last `,` with an `]`.<br>
> -  Result.push_back('}');<br>
> -  return Result;<br>
> +  return json::obj{<br>
> +      {"activeSignature", SH.activeSignature},<br>
> +      {"activeParameter", SH.activeParameter},<br>
> +      {"signatures", json::ary(SH.signatures)},<br>
> +  };<br>
>  }<br>
><br>
> Modified: clang-tools-extra/trunk/<wbr>clangd/Protocol.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/clangd/Protocol.h?<wbr>rev=317486&r1=317485&r2=<wbr>317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/<wbr>clangd/Protocol.h (original)<br>
> +++ clang-tools-extra/trunk/<wbr>clangd/Protocol.h Mon Nov  6 07:40:30 2017<br>
> @@ -21,6 +21,7 @@<br>
>  #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_<wbr>PROTOCOL_H<br>
>  #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_<wbr>PROTOCOL_H<br>
><br>
> +#include "JSONExpr.h"<br>
>  #include "llvm/ADT/Optional.h"<br>
>  #include "llvm/Support/YAMLParser.h"<br>
>  #include <string><br>
> @@ -39,7 +40,7 @@ struct URI {<br>
>    static URI fromFile(llvm::StringRef file);<br>
><br>
>    static URI parse(llvm::yaml::ScalarNode *Param);<br>
> -  static std::string unparse(const URI &U);<br>
> +  static json::Expr unparse(const URI &U);<br>
><br>
>    friend bool operator==(const URI &LHS, const URI &RHS) {<br>
>      return LHS.uri == RHS.uri;<br>
> @@ -80,7 +81,7 @@ struct Position {<br>
><br>
>    static llvm::Optional<Position> parse(llvm::yaml::MappingNode *Params,<br>
>                                          clangd::Logger &Logger);<br>
> -  static std::string unparse(const Position &P);<br>
> +  static json::Expr unparse(const Position &P);<br>
>  };<br>
><br>
>  struct Range {<br>
> @@ -99,7 +100,7 @@ struct Range {<br>
><br>
>    static llvm::Optional<Range> parse(llvm::yaml::MappingNode *Params,<br>
>                                       clangd::Logger &Logger);<br>
> -  static std::string unparse(const Range &P);<br>
> +  static json::Expr unparse(const Range &P);<br>
>  };<br>
><br>
>  struct Location {<br>
> @@ -119,7 +120,7 @@ struct Location {<br>
>      return std::tie(LHS.uri, LHS.range) < std::tie(RHS.uri, RHS.range);<br>
>    }<br>
><br>
> -  static std::string unparse(const Location &P);<br>
> +  static json::Expr unparse(const Location &P);<br>
>  };<br>
><br>
>  struct Metadata {<br>
> @@ -140,8 +141,7 @@ struct TextEdit {<br>
><br>
>    static llvm::Optional<TextEdit> parse(llvm::yaml::MappingNode *Params,<br>
>                                          clangd::Logger &Logger);<br>
> -  static std::string unparse(const TextEdit &P);<br>
> -  static std::string unparse(const std::vector<TextEdit> &TextEdits);<br>
> +  static json::Expr unparse(const TextEdit &P);<br>
>  };<br>
><br>
>  struct TextDocumentItem {<br>
> @@ -283,7 +283,7 @@ struct FormattingOptions {<br>
><br>
>    static llvm::Optional<<wbr>FormattingOptions><br>
>    parse(llvm::yaml::MappingNode *Params, clangd::Logger &Logger);<br>
> -  static std::string unparse(const FormattingOptions &P);<br>
> +  static json::Expr unparse(const FormattingOptions &P);<br>
>  };<br>
><br>
>  struct DocumentRangeFormattingParams {<br>
> @@ -392,7 +392,7 @@ struct WorkspaceEdit {<br>
><br>
>    static llvm::Optional<WorkspaceEdit> parse(llvm::yaml::MappingNode *Params,<br>
>                                               clangd::Logger &Logger);<br>
> -  static std::string unparse(const WorkspaceEdit &WE);<br>
> +  static json::Expr unparse(const WorkspaceEdit &WE);<br>
>  };<br>
><br>
>  /// Exact commands are not specified in the protocol so we define the<br>
> @@ -420,7 +420,7 @@ struct ExecuteCommandParams {<br>
><br>
>  struct ApplyWorkspaceEditParams {<br>
>    WorkspaceEdit edit;<br>
> -  static std::string unparse(const ApplyWorkspaceEditParams &Params);<br>
> +  static json::Expr unparse(const ApplyWorkspaceEditParams &Params);<br>
>  };<br>
><br>
>  struct TextDocumentPositionParams {<br>
> @@ -527,7 +527,7 @@ struct CompletionItem {<br>
>    //<br>
>    // data?: any - A data entry field that is preserved on a completion item<br>
>    //              between a completion and a completion resolve request.<br>
> -  static std::string unparse(const CompletionItem &P);<br>
> +  static json::Expr unparse(const CompletionItem &P);<br>
>  };<br>
><br>
>  /// A single parameter of a particular signature.<br>
> @@ -539,7 +539,7 @@ struct ParameterInformation {<br>
>    /// The documentation of this parameter. Optional.<br>
>    std::string documentation;<br>
><br>
> -  static std::string unparse(const ParameterInformation &);<br>
> +  static json::Expr unparse(const ParameterInformation &);<br>
>  };<br>
><br>
>  /// Represents the signature of something callable.<br>
> @@ -554,7 +554,7 @@ struct SignatureInformation {<br>
>    /// The parameters of this signature.<br>
>    std::vector<<wbr>ParameterInformation> parameters;<br>
><br>
> -  static std::string unparse(const SignatureInformation &);<br>
> +  static json::Expr unparse(const SignatureInformation &);<br>
>  };<br>
><br>
>  /// Represents the signature of a callable.<br>
> @@ -569,7 +569,7 @@ struct SignatureHelp {<br>
>    /// The active parameter of the active signature.<br>
>    int activeParameter = 0;<br>
><br>
> -  static std::string unparse(const SignatureHelp &);<br>
> +  static json::Expr unparse(const SignatureHelp &);<br>
>  };<br>
><br>
>  } // namespace clangd<br>
><br>
> Modified: clang-tools-extra/trunk/<wbr>clangd/tool/ClangdMain.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/clangd/tool/<wbr>ClangdMain.cpp?rev=317486&r1=<wbr>317485&r2=317486&view=dif<br>
> f<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/<wbr>clangd/tool/ClangdMain.cpp (original)<br>
> +++ clang-tools-extra/trunk/<wbr>clangd/tool/ClangdMain.cpp Mon Nov  6 07:40:30<br>
> 2017<br>
> @@ -41,6 +41,10 @@ static llvm::cl::opt<bool> EnableSnippet<br>
>          "Present snippet completions instead of plaintext completions"),<br>
>      llvm::cl::init(false));<br>
><br>
> +static llvm::cl::opt<bool><br>
> +    PrettyPrint("pretty", llvm::cl::desc("Pretty-print JSON output"),<br>
> +                llvm::cl::init(false));<br>
> +<br>
>  static llvm::cl::opt<bool> RunSynchronously(<br>
>      "run-synchronously",<br>
>      llvm::cl::desc("Parse on main thread. If set, -j is ignored"),<br>
> @@ -104,7 +108,8 @@ int main(int argc, char *argv[]) {<br>
>    llvm::raw_ostream &Outs = llvm::outs();<br>
>    llvm::raw_ostream &Logs = llvm::errs();<br>
>    JSONOutput Out(Outs, Logs,<br>
> -                 InputMirrorStream ? InputMirrorStream.getPointer() :<br>
> nullptr);<br>
> +                 InputMirrorStream ? InputMirrorStream.getPointer() :<br>
> nullptr,<br>
> +                 PrettyPrint);<br>
><br>
>    // If --compile-commands-dir arg was invoked, check value and override<br>
> default<br>
>    // path.<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/authority-less-uri.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>authority-less-<br>
> uri.test?rev=317486&r1=317485&<wbr>r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/authority-less-uri.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/authority-less-uri.test Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -1,4 +1,4 @@<br>
> -# RUN: clangd -run-synchronously < %s | FileCheck %s<br>
> +# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace<br>
> %s<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
>  #<br>
>  # Test authority-less URI<br>
> @@ -15,22 +15,34 @@ Content-Length: 146<br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"file:/main.cpp"}<wbr>,"position":{"line":3,"<wbr>character":5}}}<br>
>  # Test authority-less URI<br>
>  #<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[<br>
> -# CHECK-DAG:<br>
> {"label":"a","kind":5,"detail"<wbr>:"int","sortText":"000035a","<wbr>filterText":"a","in<br>
> sertText":"a","<wbr>insertTextFormat":1}<br>
> -# CHECK: ]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +#      CHECK:      "filterText": "fake",<br>
> +# CHECK-NEXT:      "insertText": "fake",<br>
> +# CHECK-NEXT:      "insertTextFormat": 1,<br>
> +# CHECK-NEXT:      "kind": 7,<br>
> +# CHECK-NEXT:      "label": "fake::",<br>
> +# CHECK-NEXT:      "sortText": "000075fake"<br>
> +#      CHECK:  ]<br>
>  Content-Length: 172<br>
><br>
><br>
> {"jsonrpc":"2.0","id":2,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"uri":"<a>file:///main.cpp</a>","<wbr>position":{"line":3<br>
> ,"character":5}}}<br>
>  # Test params parsing in the presence of a 1.x-compatible client (inlined<br>
> "uri")<br>
>  #<br>
> -# CHECK: {"jsonrpc":"2.0","id":2,"<wbr>result":[<br>
> -# CHECK-DAG:<br>
> {"label":"a","kind":5,"detail"<wbr>:"int","sortText":"000035a","<wbr>filterText":"a","in<br>
> sertText":"a","<wbr>insertTextFormat":1}<br>
> -# CHECK: ]}<br>
> +#      CHECK:  "id": 2,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +#      CHECK:      "filterText": "fake",<br>
> +# CHECK-NEXT:      "insertText": "fake",<br>
> +# CHECK-NEXT:      "insertTextFormat": 1,<br>
> +# CHECK-NEXT:      "kind": 7,<br>
> +# CHECK-NEXT:      "label": "fake::",<br>
> +# CHECK-NEXT:      "sortText": "000075fake"<br>
> +#      CHECK:  ]<br>
>  Content-Length: 44<br>
><br>
>  {"jsonrpc":"2.0","id":3,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":3,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/completion-items-kinds.<wbr>test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>completion-items-<br>
> kinds.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/completion-items-kinds.<wbr>test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/completion-items-kinds.<wbr>test Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -11,27 +11,26 @@ Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":4,"<wbr>character":7}}}<br>
>  Content-Length: 58<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[<br>
> +# CHECK: {"id":1,"jsonrpc":"2.0","<wbr>result":[<br>
>  #<br>
>  # Keyword<br>
> -# CHECK-DAG:<br>
> {"label":"int","kind":14,"<wbr>sortText":"000050int","<wbr>filterText":"int","insertText<br>
> ":"int","insertTextFormat":1}<br>
> +# CHECK-DAG:<br>
> {"filterText":"int","<wbr>insertText":"int","<wbr>insertTextFormat":1,"kind":14,<wbr>"label":<br>
> "int","sortText":"000050int"}<br>
>  #<br>
>  # Code pattern<br>
> -# CHECK-DAG:<br>
> {"label":"static_cast<type>(<wbr>expression)","kind":15,"<wbr>sortText":"000040static_ca<br>
> st","filterText":"static_cast"<wbr>,"insertText":"static_cast<${<wbr>1:type}>(${2:expres<br>
> sion})","insertTextFormat":2}<br>
> +# CHECK-DAG:<br>
> {"filterText":"static_cast","<wbr>insertText":"static_cast<${1:<wbr>type}>(${2:expressio<br>
> n})","insertTextFormat":2,"<wbr>kind":15,"label":"static_cast<<wbr>type>(expression)","s<br>
> ortText":"000040static_cast"}<br>
>  #<br>
>  # Struct<br>
> -# CHECK-DAG:<br>
> {"label":"Struct","kind":7,"<wbr>sortText":"000050Struct","<wbr>filterText":"Struct","in<br>
> sertText":"Struct","<wbr>insertTextFormat":1}<br>
> +# CHECK-DAG:<br>
> {"filterText":"Struct","<wbr>insertText":"Struct","<wbr>insertTextFormat":1,"kind":7,"<wbr>la<br>
> bel":"Struct","sortText":"<wbr>000050Struct"}<br>
>  #<br>
>  # Macro<br>
> -# CHECK-DAG:<br>
> {"label":"MACRO","kind":1,"<wbr>sortText":"000070MACRO","<wbr>filterText":"MACRO","inser<br>
> tText":"MACRO","<wbr>insertTextFormat":1}<br>
> +# CHECK-DAG:<br>
> {"filterText":"MACRO","<wbr>insertText":"MACRO","<wbr>insertTextFormat":1,"kind":1,"<wbr>labe<br>
> l":"MACRO","sortText":"<wbr>000070MACRO"}<br>
>  #<br>
>  # Variable<br>
> -# CHECK-DAG:<br>
> {"label":"variable","kind":6,"<wbr>detail":"int","sortText":"<wbr>000012variable","filte<br>
> rText":"variable","insertText"<wbr>:"variable","insertTextFormat"<wbr>:1}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>variable","insertText":"<wbr>variable","insertTextFor<br>
> mat":1,"kind":6,"label":"<wbr>variable","sortText":"<wbr>000012variable"}<br>
>  #<br>
>  # Function<br>
> -# CHECK-DAG:<br>
> {"label":"function()","kind":<wbr>3,"detail":"int","sortText":"<wbr>000012function","fil<br>
> terText":"function","<wbr>insertText":"function()","<wbr>insertTextFormat":1}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>function","insertText":"<wbr>function()","insertTextF<br>
> ormat":1,"kind":3,"label":"<wbr>function()","sortText":"<wbr>000012function"}<br>
>  #<br>
> -#<br>
> -# CHECK: ]}<br>
> +# CHECK-SAME: ]}<br>
><br>
>  {"jsonrpc":"2.0","id":3,"<wbr>method":"shutdown","params":<wbr>null}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/completion-priorities.<wbr>test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>completion-<br>
> priorities.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/completion-priorities.<wbr>test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/completion-priorities.<wbr>test Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -16,25 +16,24 @@ Content-Length: 151<br>
>  # The order of results returned by codeComplete seems to be<br>
>  # nondeterministic, so we check regardless of order.<br>
>  #<br>
> -# CHECK: {"jsonrpc":"2.0","id":2,"<wbr>result":[<br>
> -# CHECK-DAG:<br>
> {"label":"pub()","kind":2,"<wbr>detail":"void","sortText":"<wbr>000034pub","filterText":<br>
> "pub","insertText":"pub","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"prot()","kind":2,"<wbr>detail":"void","sortText":"<wbr>000034prot","filterText<br>
> ":"prot","insertText":"prot","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"priv()","kind":2,"<wbr>detail":"void","sortText":"<wbr>000034priv","filterText<br>
> ":"priv","insertText":"priv","<wbr>insertTextFormat":1}<br>
> -# CHECK: ]}<br>
> +# CHECK: {"id":2,"jsonrpc":"2.0","<wbr>result":[<br>
> +# CHECK-DAG:<br>
> {"detail":"void","filterText":<wbr>"pub","insertText":"pub","<wbr>insertTextFormat":1,"k<br>
> ind":2,"label":"pub()","<wbr>sortText":"000034pub"}<br>
> +# CHECK-DAG:<br>
> {"detail":"void","filterText":<wbr>"prot","insertText":"prot","<wbr>insertTextFormat":1,<br>
> "kind":2,"label":"prot()","<wbr>sortText":"000034prot"}<br>
> +# CHECK-DAG:<br>
> {"detail":"void","filterText":<wbr>"priv","insertText":"priv","<wbr>insertTextFormat":1,<br>
> "kind":2,"label":"priv()","<wbr>sortText":"000034priv"}<br>
> +# CHECK-SAME: ]}<br>
><br>
>  Content-Length: 151<br>
><br>
><br>
> {"jsonrpc":"2.0","id":3,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":17,"<wbr>character":4}}}<br>
> -# CHECK: {"jsonrpc":"2.0","id":3,"<wbr>result":[<br>
> -# CHECK-DAG:<br>
> {"label":"pub()","kind":2,"<wbr>detail":"void","sortText":"<wbr>000034pub","filterText":<br>
> "pub","insertText":"pub","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"prot()","kind":2,"<wbr>detail":"void","sortText":"<wbr>200034prot","filterText<br>
> ":"prot","insertText":"prot","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"priv()","kind":2,"<wbr>detail":"void","sortText":"<wbr>200034priv","filterText<br>
> ":"priv","insertText":"priv","<wbr>insertTextFormat":1}<br>
> -# CHECK: ]}<br>
> +# CHECK: {"id":3,"jsonrpc":"2.0","<wbr>result":[<br>
> +# CHECK-DAG:<br>
> {"detail":"void","filterText":<wbr>"pub","insertText":"pub","<wbr>insertTextFormat":1,"k<br>
> ind":2,"label":"pub()","<wbr>sortText":"000034pub"}<br>
> +# CHECK-DAG:<br>
> {"detail":"void","filterText":<wbr>"prot","insertText":"prot","<wbr>insertTextFormat":1,<br>
> "kind":2,"label":"prot()","<wbr>sortText":"200034prot"}<br>
> +# CHECK-DAG:<br>
> {"detail":"void","filterText":<wbr>"priv","insertText":"priv","<wbr>insertTextFormat":1,<br>
> "kind":2,"label":"priv()","<wbr>sortText":"200034priv"}<br>
> +# CHECK-SAME: ]}<br>
><br>
>  Content-Length: 58<br>
><br>
>  {"jsonrpc":"2.0","id":4,"<wbr>method":"shutdown","params":<wbr>null}<br>
> -# CHECK: {"jsonrpc":"2.0","id":4,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/completion-qualifiers.<wbr>test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>completion-<br>
> qualifiers.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/completion-qualifiers.<wbr>test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/completion-qualifiers.<wbr>test Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -8,15 +8,14 @@ Content-Length: 297<br>
>  Content-Length: 151<br>
><br>
><br>
> {"jsonrpc":"2.0","id":2,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":11,"<wbr>character":8}}}<br>
> -# CHECK: {"jsonrpc":"2.0","id":2,"<wbr>result":[<br>
> -# CHECK-DAG: {"label":"foo()<br>
> const","kind":2,"detail":"int"<wbr>,"sortText":"200035foo","<wbr>filterText":"foo","inse<br>
> rtText":"foo","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG: {"label":"bar()<br>
> const","kind":2,"detail":"int"<wbr>,"sortText":"000037bar","<wbr>filterText":"bar","inse<br>
> rtText":"bar","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG: {"label":"Foo::foo()<br>
> const","kind":2,"detail":"int"<wbr>,"sortText":"000037foo","<wbr>filterText":"foo","inse<br>
> rtText":"foo","<wbr>insertTextFormat":1}<br>
> -# CHECK: ]}<br>
> +# CHECK: {"id":2,"jsonrpc":"2.0","<wbr>result":[<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>foo","insertText":"foo","<wbr>insertTextFormat":1,"ki<br>
> nd":2,"label":"foo() const","sortText":"200035foo"}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>bar","insertText":"bar","<wbr>insertTextFormat":1,"ki<br>
> nd":2,"label":"bar() const","sortText":"000037bar"}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>foo","insertText":"foo","<wbr>insertTextFormat":1,"ki<br>
> nd":2,"label":"Foo::foo() const","sortText":"000037foo"}<br>
> +# CHECK-SAME: ]}<br>
>  Content-Length: 44<br>
><br>
>  {"jsonrpc":"2.0","id":4,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":4,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/completion-snippet.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>completion-<br>
> snippet.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/completion-snippet.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/completion-snippet.test Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -15,27 +15,27 @@ Content-Length: 148<br>
>  # The order of results returned by codeComplete seems to be<br>
>  # nondeterministic, so we check regardless of order.<br>
>  #<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[<br>
> -# CHECK-DAG:<br>
> {"label":"a","kind":5,"detail"<wbr>:"int","sortText":"000035a","<wbr>filterText":"a","in<br>
> sertText":"a","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"bb","kind":5,"<wbr>detail":"int","sortText":"<wbr>000035bb","filterText":"bb",<br>
> "insertText":"bb","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"ccc","kind":5,"<wbr>detail":"int","sortText":"<wbr>000035ccc","filterText":"cc<br>
> c","insertText":"ccc","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake<br>
> &","sortText":"000079operator=<wbr>","filterText":"operator=","<wbr>insertText":"operato<br>
> r=(${1:const fake &})","insertTextFormat":2}<br>
> -# CHECK-DAG:<br>
> {"label":"~fake()","kind":4,"<wbr>detail":"void","sortText":"<wbr>000079~fake","filterTe<br>
> xt":"~fake","insertText":"~<wbr>fake()","insertTextFormat":1}<br>
> -# CHECK-DAG: {"label":"f(int i, const float f)<br>
> const","kind":2,"detail":"int"<wbr>,"sortText":"000035f","<wbr>filterText":"f","insertTe<br>
> xt":"f(${1:int i}, ${2:const float f})","insertTextFormat":2}<br>
> -# CHECK: ]}<br>
> +# CHECK: {"id":1,"jsonrpc":"2.0","<wbr>result":[<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>a","insertText":"a","<wbr>insertTextFormat":1,"kind":<br>
> 5,"label":"a","sortText":"<wbr>000035a"}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>bb","insertText":"bb","<wbr>insertTextFormat":1,"kind<br>
> ":5,"label":"bb","sortText":"<wbr>000035bb"}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>ccc","insertText":"ccc","<wbr>insertTextFormat":1,"ki<br>
> nd":5,"label":"ccc","sortText"<wbr>:"000035ccc"}<br>
> +# CHECK-DAG: {"detail":"fake<br>
> &","filterText":"operator=","<wbr>insertText":"operator=(${1:<wbr>const fake<br>
> &})","insertTextFormat":2,"<wbr>kind":2,"label":"operator=(<wbr>const fake<br>
> &)","sortText":"<wbr>000079operator="}<br>
> +# CHECK-DAG:<br>
> {"detail":"void","filterText":<wbr>"~fake","insertText":"~fake()"<wbr>,"insertTextFormat<br>
> ":1,"kind":4,"label":"~fake()"<wbr>,"sortText":"000079~fake"}<br>
> +# CHECK-DAG: {"detail":"int","filterText":"<wbr>f","insertText":"f(${1:int i},<br>
> ${2:const float f})","insertTextFormat":2,"<wbr>kind":2,"label":"f(int i, const<br>
> float f) const","sortText":"000035f"}<br>
> +# CHECK-SAME: ]}<br>
>  Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":2,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":3,"<wbr>character":5}}}<br>
>  # Repeat the completion request, expect the same results.<br>
>  #<br>
> -# CHECK: {"jsonrpc":"2.0","id":2,"<wbr>result":[<br>
> -# CHECK-DAG:<br>
> {"label":"a","kind":5,"detail"<wbr>:"int","sortText":"000035a","<wbr>filterText":"a","in<br>
> sertText":"a","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"bb","kind":5,"<wbr>detail":"int","sortText":"<wbr>000035bb","filterText":"bb",<br>
> "insertText":"bb","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"ccc","kind":5,"<wbr>detail":"int","sortText":"<wbr>000035ccc","filterText":"cc<br>
> c","insertText":"ccc","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake<br>
> &","sortText":"000079operator=<wbr>","filterText":"operator=","<wbr>insertText":"operato<br>
> r=(${1:const fake &})","insertTextFormat":2}<br>
> -# CHECK-DAG:<br>
> {"label":"~fake()","kind":4,"<wbr>detail":"void","sortText":"<wbr>000079~fake","filterTe<br>
> xt":"~fake","insertText":"~<wbr>fake()","insertTextFormat":1}<br>
> -# CHECK-DAG: {"label":"f(int i, const float f)<br>
> const","kind":2,"detail":"int"<wbr>,"sortText":"000035f","<wbr>filterText":"f","insertTe<br>
> xt":"f(${1:int i}, ${2:const float f})","insertTextFormat":2}<br>
> -# CHECK: ]}<br>
> +# CHECK: {"id":2,"jsonrpc":"2.0","<wbr>result":[<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>a","insertText":"a","<wbr>insertTextFormat":1,"kind":<br>
> 5,"label":"a","sortText":"<wbr>000035a"}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>bb","insertText":"bb","<wbr>insertTextFormat":1,"kind<br>
> ":5,"label":"bb","sortText":"<wbr>000035bb"}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>ccc","insertText":"ccc","<wbr>insertTextFormat":1,"ki<br>
> nd":5,"label":"ccc","sortText"<wbr>:"000035ccc"}<br>
> +# CHECK-DAG: {"detail":"fake<br>
> &","filterText":"operator=","<wbr>insertText":"operator=(${1:<wbr>const fake<br>
> &})","insertTextFormat":2,"<wbr>kind":2,"label":"operator=(<wbr>const fake<br>
> &)","sortText":"<wbr>000079operator="}<br>
> +# CHECK-DAG:<br>
> {"detail":"void","filterText":<wbr>"~fake","insertText":"~fake()"<wbr>,"insertTextFormat<br>
> ":1,"kind":4,"label":"~fake()"<wbr>,"sortText":"000079~fake"}<br>
> +# CHECK-DAG: {"detail":"int","filterText":"<wbr>f","insertText":"f(${1:int i},<br>
> ${2:const float f})","insertTextFormat":2,"<wbr>kind":2,"label":"f(int i, const<br>
> float f) const","sortText":"000035f"}<br>
> +# CHECK-SAME: ]}<br>
>  # Update the source file and check for completions again.<br>
>  Content-Length: 226<br>
><br>
> @@ -44,15 +44,12 @@ Content-Length: 226<br>
>  Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":3,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":3,"<wbr>character":5}}}<br>
> -# Repeat the completion request, expect the same results.<br>
> -#<br>
> -# CHECK: {"jsonrpc":"2.0","id":3,"<wbr>result":[<br>
> -# CHECK-DAG: {"label":"func()","kind":2,"<wbr>detail":"int (*)(int,<br>
> int)","sortText":"000034func",<wbr>"filterText":"func","<wbr>insertText":"func()","inser<br>
> tTextFormat":1}<br>
> -# CHECK: ]}<br>
> +# CHECK: {"id":3,"jsonrpc":"2.0","<wbr>result":[<br>
> +# CHECK-DAG: {"detail":"int (*)(int,<br>
> int)","filterText":"func","<wbr>insertText":"func()","<wbr>insertTextFormat":1,"kind":2,<br>
> "label":"func()","sortText":"<wbr>000034func"}<br>
> +# CHECK-SAME: ]}<br>
>  Content-Length: 44<br>
><br>
>  {"jsonrpc":"2.0","id":4,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":4,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/completion.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>completion.test?rev=317486&r1=<wbr>317485&r2=317486&view=di<br>
> ff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/completion.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/completion.test Mon Nov  6 07:40:30<br>
> 2017<br>
> @@ -15,27 +15,27 @@ Content-Length: 148<br>
>  # The order of results returned by codeComplete seems to be<br>
>  # nondeterministic, so we check regardless of order.<br>
>  #<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[<br>
> -# CHECK-DAG:<br>
> {"label":"a","kind":5,"detail"<wbr>:"int","sortText":"000035a","<wbr>filterText":"a","in<br>
> sertText":"a","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"bb","kind":5,"<wbr>detail":"int","sortText":"<wbr>000035bb","filterText":"bb",<br>
> "insertText":"bb","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"ccc","kind":5,"<wbr>detail":"int","sortText":"<wbr>000035ccc","filterText":"cc<br>
> c","insertText":"ccc","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake<br>
> &","sortText":"000079operator=<wbr>","filterText":"operator=","<wbr>insertText":"operato<br>
> r=","insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"~fake()","kind":4,"<wbr>detail":"void","sortText":"<wbr>000079~fake","filterTe<br>
> xt":"~fake","insertText":"~<wbr>fake","insertTextFormat":1}<br>
> -# CHECK-DAG: {"label":"f(int i, const float f)<br>
> const","kind":2,"detail":"int"<wbr>,"sortText":"000035f","<wbr>filterText":"f","insertTe<br>
> xt":"f","insertTextFormat":1}<br>
> -# CHECK: ]}<br>
> +# CHECK: {"id":1,"jsonrpc":"2.0","<wbr>result":[<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>a","insertText":"a","<wbr>insertTextFormat":1,"kind":<br>
> 5,"label":"a","sortText":"<wbr>000035a"}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>bb","insertText":"bb","<wbr>insertTextFormat":1,"kind<br>
> ":5,"label":"bb","sortText":"<wbr>000035bb"}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>ccc","insertText":"ccc","<wbr>insertTextFormat":1,"ki<br>
> nd":5,"label":"ccc","sortText"<wbr>:"000035ccc"}<br>
> +# CHECK-DAG: {"detail":"fake<br>
> &","filterText":"operator=","<wbr>insertText":"operator=","<wbr>insertTextFormat":1,"kin<br>
> d":2,"label":"operator=(const fake &)","sortText":"<wbr>000079operator="}<br>
> +# CHECK-DAG:<br>
> {"detail":"void","filterText":<wbr>"~fake","insertText":"~fake","<wbr>insertTextFormat":<br>
> 1,"kind":4,"label":"~fake()","<wbr>sortText":"000079~fake"}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>f","insertText":"f","<wbr>insertTextFormat":1,"kind":<br>
> 2,"label":"f(int i, const float f) const","sortText":"000035f"}<br>
> +# CHECK-SAME: ]}<br>
>  Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":2,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":3,"<wbr>character":5}}}<br>
>  # Repeat the completion request, expect the same results.<br>
>  #<br>
> -# CHECK: {"jsonrpc":"2.0","id":2,"<wbr>result":[<br>
> -# CHECK-DAG:<br>
> {"label":"a","kind":5,"detail"<wbr>:"int","sortText":"000035a","<wbr>filterText":"a","in<br>
> sertText":"a","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"bb","kind":5,"<wbr>detail":"int","sortText":"<wbr>000035bb","filterText":"bb",<br>
> "insertText":"bb","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"ccc","kind":5,"<wbr>detail":"int","sortText":"<wbr>000035ccc","filterText":"cc<br>
> c","insertText":"ccc","<wbr>insertTextFormat":1}<br>
> -# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake<br>
> &","sortText":"000079operator=<wbr>","filterText":"operator=","<wbr>insertText":"operato<br>
> r=","insertTextFormat":1}<br>
> -# CHECK-DAG:<br>
> {"label":"~fake()","kind":4,"<wbr>detail":"void","sortText":"<wbr>000079~fake","filterTe<br>
> xt":"~fake","insertText":"~<wbr>fake","insertTextFormat":1}<br>
> -# CHECK-DAG: {"label":"f(int i, const float f)<br>
> const","kind":2,"detail":"int"<wbr>,"sortText":"000035f","<wbr>filterText":"f","insertTe<br>
> xt":"f","insertTextFormat":1}<br>
> -# CHECK: ]}<br>
> +# CHECK: {"id":2,"jsonrpc":"2.0","<wbr>result":[<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>a","insertText":"a","<wbr>insertTextFormat":1,"kind":<br>
> 5,"label":"a","sortText":"<wbr>000035a"}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>bb","insertText":"bb","<wbr>insertTextFormat":1,"kind<br>
> ":5,"label":"bb","sortText":"<wbr>000035bb"}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>ccc","insertText":"ccc","<wbr>insertTextFormat":1,"ki<br>
> nd":5,"label":"ccc","sortText"<wbr>:"000035ccc"}<br>
> +# CHECK-DAG: {"detail":"fake<br>
> &","filterText":"operator=","<wbr>insertText":"operator=","<wbr>insertTextFormat":1,"kin<br>
> d":2,"label":"operator=(const fake &)","sortText":"<wbr>000079operator="}<br>
> +# CHECK-DAG:<br>
> {"detail":"void","filterText":<wbr>"~fake","insertText":"~fake","<wbr>insertTextFormat":<br>
> 1,"kind":4,"label":"~fake()","<wbr>sortText":"000079~fake"}<br>
> +# CHECK-DAG:<br>
> {"detail":"int","filterText":"<wbr>f","insertText":"f","<wbr>insertTextFormat":1,"kind":<br>
> 2,"label":"f(int i, const float f) const","sortText":"000035f"}<br>
> +# CHECK-SAME: ]}<br>
>  # Update the source file and check for completions again.<br>
>  Content-Length: 226<br>
><br>
> @@ -46,13 +46,12 @@ Content-Length: 148<br>
><br>
> {"jsonrpc":"2.0","id":3,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":3,"<wbr>character":5}}}<br>
>  # Repeat the completion request, expect the same results.<br>
>  #<br>
> -# CHECK: {"jsonrpc":"2.0","id":3,"<wbr>result":[<br>
> -# CHECK-DAG: {"label":"func()","kind":2,"<wbr>detail":"int (*)(int,<br>
> int)","sortText":"000034func",<wbr>"filterText":"func","<wbr>insertText":"func","insertT<br>
> extFormat":1}<br>
> -# CHECK: ]}<br>
> +# CHECK: {"id":3,"jsonrpc":"2.0","<wbr>result":[<br>
> +# CHECK-DAG: {"detail":"int (*)(int,<br>
> int)","filterText":"func","<wbr>insertText":"func","<wbr>insertTextFormat":1,"kind":2,"<wbr>l<br>
> abel":"func()","sortText":"<wbr>000034func"}<br>
> +# CHECK-SAME: ]}<br>
>  Content-Length: 44<br>
><br>
>  {"jsonrpc":"2.0","id":4,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":4,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/definitions.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>definitions.test?rev=317486&<wbr>r1=317485&r2=317486&view=d<br>
> iff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/definitions.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/definitions.test Mon Nov  6 07:40:30<br>
> 2017<br>
> @@ -1,4 +1,4 @@<br>
> -# RUN: clangd -run-synchronously < %s | FileCheck %s<br>
> +# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace<br>
> %s<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
>  #<br>
>  Content-Length: 125<br>
> @@ -13,14 +13,44 @@ Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":2,"<wbr>character":0}}}<br>
>  # Go to local variable<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 1, "character": 0}, "end": {"line": 1,<br>
> "character": 5}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 5,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 0,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":2,"<wbr>character":1}}}<br>
>  # Go to local variable, end of token<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 1, "character": 0}, "end": {"line": 1,<br>
> "character": 5}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 5,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 0,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 214<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":2},"contentChanges":[<wbr>{"text":"struct Foo<br>
> {\nint x;\n};\nint main() {\n  Foo bar = { x : 1 };\n}\n"}]}}<br>
> @@ -29,8 +59,23 @@ Content-Length: 149<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":4,"<wbr>character":14}}}<br>
>  # Go to field, GNU old-style field designator<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 1, "character": 0}, "end": {"line": 1,<br>
> "character": 5}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 5,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 0,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 215<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":3},"contentChanges":[<wbr>{"text":"struct Foo<br>
> {\nint x;\n};\nint main() {\n  Foo baz = { .x = 2 };\n}\n"}]}}<br>
> @@ -39,8 +84,23 @@ Content-Length: 149<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":4,"<wbr>character":15}}}<br>
>  # Go to field, field designator<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 1, "character": 0}, "end": {"line": 1,<br>
> "character": 5}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 5,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 0,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 187<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":4},"contentChanges":[<wbr>{"text":"int main() {\n<br>
> main();\n   return 0;\n}"}]}}<br>
> @@ -49,8 +109,23 @@ Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":1,"<wbr>character":3}}}<br>
>  # Go to function declaration, function call<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 0, "character": 0}, "end": {"line": 3,<br>
> "character": 1}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 1,<br>
> +# CHECK-NEXT:          "line": 3<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 0,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 208<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":5},"contentChanges":[<wbr>{"text":"struct Foo<br>
> {\n};\nint main() {\n   Foo bar;\n   return 0;\n}\n"}]}}<br>
> @@ -59,8 +134,23 @@ Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":3,"<wbr>character":3}}}<br>
>  # Go to struct declaration, new struct instance<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 0, "character": 0}, "end": {"line": 1,<br>
> "character": 1}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 1,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 0,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 231<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":5},"contentChanges":[<wbr>{"text":"namespace n1<br>
> {\nstruct Foo {\n};\n}\nint main() {\n   n1::Foo bar;\n   return 0;\n}\n"}]}}<br>
> @@ -69,8 +159,23 @@ Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":5,"<wbr>character":4}}}<br>
>  # Go to struct declaration, new struct instance, qualified name<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 0, "character": 0}, "end": {"line": 3,<br>
> "character": 1}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 1,<br>
> +# CHECK-NEXT:          "line": 3<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 0,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 215<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":6},"contentChanges":[<wbr>{"text":"struct Foo {\n<br>
> int x;\n};\nint main() {\n   Foo bar;\n   bar.x;\n}\n"}]}}<br>
> @@ -79,8 +184,23 @@ Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":5,"<wbr>character":7}}}<br>
>  # Go to field declaration, field reference<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 1, "character": 2}, "end": {"line": 1,<br>
> "character": 7}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 7,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 2,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 220<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":7},"contentChanges":[<wbr>{"text":"struct Foo {\n<br>
> void x();\n};\nint main() {\n   Foo bar;\n   bar.x();\n}\n"}]}}<br>
> @@ -89,8 +209,23 @@ Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":5,"<wbr>character":7}}}<br>
>  # Go to method declaration, method call<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 1, "character": 2}, "end": {"line": 1,<br>
> "character": 10}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 10,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 2,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 240<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":7},"contentChanges":[<wbr>{"text":"struct Foo<br>
> {\n};\ntypedef Foo TypedefFoo;\nint main() {\n   TypedefFoo bar;\n   return<br>
> 0;\n}\n"}]}}<br>
> @@ -99,8 +234,23 @@ Content-Length: 149<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":4,"<wbr>character":10}}}<br>
>  # Go to typedef<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 2, "character": 0}, "end": {"line": 2,<br>
> "character": 22}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 22,<br>
> +# CHECK-NEXT:          "line": 2<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 0,<br>
> +# CHECK-NEXT:          "line": 2<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 254<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":7},"contentChanges":[<wbr>{"text":"template<br>
> <typename MyTemplateParam>\nvoid foo() {\n MyTemplateParam a;\n}\nint main()<br>
> {\n   return 0;\n}\n"}]}}<br>
> @@ -109,8 +259,9 @@ Content-Length: 149<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":2,"<wbr>character":13}}}<br>
>  # Go to template type parameter. Fails until clangIndex is modified to handle<br>
> those.<br>
> -# no-CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 0, "character": 10}, "end": {"line": 0,<br>
> "character": 34}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": []<br>
>  Content-Length: 256<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":7},"contentChanges":[<wbr>{"text":"namespace ns<br>
> {\nstruct Foo {\nstatic void bar() {}\n};\n}\nint main() {\n<br>
> ns::Foo::bar();\n   return 0;\n}\n"}]}}<br>
> @@ -119,8 +270,23 @@ Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":6,"<wbr>character":4}}}<br>
>  # Go to namespace, static method call<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 0, "character": 0}, "end": {"line": 4,<br>
> "character": 1}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 1,<br>
> +# CHECK-NEXT:          "line": 4<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 0,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 265<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":7},"contentChanges":[<wbr>{"text":"namespace ns<br>
> {\nstruct Foo {\n  int field;\n  Foo(int param) : field(param) {}\n};\n}\nint<br>
> main() {\n   return 0;\n}\n"}]}}<br>
> @@ -128,9 +294,24 @@ Content-Length: 265<br>
>  Content-Length: 149<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":3,"<wbr>character":21}}}<br>
> -# Go to field, member initializer<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 2, "character": 2}, "end": {"line": 2,<br>
> "character": 11}}}]}<br>
> -<br>
> +# Go to field, member initializer<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 11,<br>
> +# CHECK-NEXT:          "line": 2<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 2,<br>
> +# CHECK-NEXT:          "line": 2<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 204<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":7},"contentChanges":[<wbr>{"text":"#define<br>
> MY_MACRO 0\nint main() {\n  return MY_MACRO;\n}\n"}]}}<br>
> @@ -139,8 +320,23 @@ Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":2,"<wbr>character":9}}}<br>
>  # Go to macro.<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///{{([A-Za-<br>
> z]:/)?}}main.cpp</a>", "range": {"start": {"line": 0, "character": 8}, "end":<br>
> {"line": 0, "character": 18}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 18,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 8,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 217<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///main.cpp</a>","<wbr>version":7},"contentChanges":[<wbr>{"text":"#define FOO<br>
> 1\nint a = FOO;\n#define FOO 2\nint b = FOO;\n#undef FOO\n"}]}}<br>
> @@ -149,29 +345,77 @@ Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":1,"<wbr>character":8}}}<br>
>  # Go to macro, re-defined later<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///{{([A-Za-<br>
> z]:/)?}}main.cpp</a>", "range": {"start": {"line": 0, "character": 8}, "end":<br>
> {"line": 0, "character": 13}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 13,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 8,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":3,"<wbr>character":8}}}<br>
>  # Go to macro, undefined later<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 2, "character": 8}, "end": {"line": 2,<br>
> "character": 13}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 13,<br>
> +# CHECK-NEXT:          "line": 2<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 8,<br>
> +# CHECK-NEXT:          "line": 2<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 148<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///main.cpp</a><wbr>"},"position":{"line":4,"<wbr>character":7}}}<br>
>  # Go to macro, being undefined<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"uri": "<a>file:///main.cpp</a>",<br>
> "range": {"start": {"line": 2, "character": 8}, "end": {"line": 2,<br>
> "character": 13}}}]}<br>
> -<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 13,<br>
> +# CHECK-NEXT:          "line": 2<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 8,<br>
> +# CHECK-NEXT:          "line": 2<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 156<br>
><br>
><br>
> {"jsonrpc":"2.0","id":2,"<wbr>method":"textDocument/<wbr>definition","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///<wbr>doesnotexist.cpp</a>"},"position":<wbr>{"line":4,"character":7}}}<br>
> -# CHECK: {"jsonrpc":"2.0","id":2,"<wbr>error":{"code":-<br>
> 32602,"message":"<wbr>findDefinitions called on non-added file"}}<br>
> -<br>
> +#      CHECK:  "error": {<br>
> +# CHECK-NEXT:    "code": -32602,<br>
> +# CHECK-NEXT:    "message": "findDefinitions called on non-added file"<br>
> +# CHECK-NEXT:  },<br>
> +# CHECK-NEXT:  "id": 2,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0"<br>
>  Content-Length: 48<br>
><br>
>  {"jsonrpc":"2.0","id":10000,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":10000,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/diagnostics-preamble.<wbr>test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>diagnostics-<br>
> preamble.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/diagnostics-preamble.<wbr>test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/diagnostics-preamble.<wbr>test Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -1,4 +1,4 @@<br>
> -# RUN: clangd -run-synchronously < %s | FileCheck %s<br>
> +# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace<br>
> %s<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
>  #<br>
>  Content-Length: 125<br>
> @@ -8,12 +8,14 @@ Content-Length: 125<br>
>  Content-Length: 206<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didOpen","params"<wbr>:{"textDocument":{"ur<br>
> i":"<a>file:///main.cpp</a>","<wbr>languageId":"cpp","version":1,<wbr>"text":"#ifndef<br>
> FOO\n#define FOO\nint a;\n#else\nint a = b;#endif\n\n\n"}}}<br>
> -# CHECK:<br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/<wbr>publishDiagnostics","params":{<wbr>"uri":"f<br>
> ile:///main.cpp","diagnostics"<wbr>:[]}}<br>
> -<br>
> +#      CHECK:  "method": "textDocument/<wbr>publishDiagnostics",<br>
> +# CHECK-NEXT:  "params": {<br>
> +# CHECK-NEXT:    "diagnostics": [],<br>
> +# CHECK-NEXT:    "uri": "<a>file:///main.cpp</a>"<br>
> +# CHECK-NEXT:  }<br>
>  Content-Length: 58<br>
><br>
>  {"jsonrpc":"2.0","id":2,"<wbr>method":"shutdown","params":<wbr>null}<br>
> -# CHECK: {"jsonrpc":"2.0","id":2,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/diagnostics.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>diagnostics.test?rev=317486&<wbr>r1=317485&r2=317486&view=d<br>
> iff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/diagnostics.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/diagnostics.test Mon Nov  6 07:40:30<br>
> 2017<br>
> @@ -1,4 +1,4 @@<br>
> -# RUN: clangd -run-synchronously < %s | FileCheck %s<br>
> +# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace<br>
> %s<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
>  #<br>
>  Content-Length: 125<br>
> @@ -8,14 +8,43 @@ Content-Length: 125<br>
>  Content-Length: 152<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didOpen","params"<wbr>:{"textDocument":{"ur<br>
> i":"<a>file:///foo.c</a>","<wbr>languageId":"c","version":1,"<wbr>text":"void main() {}"}}}<br>
> -#<br>
> -# CHECK:<br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/<wbr>publishDiagnostics","params":{<wbr>"uri":"f<br>
> ile:///foo.c","diagnostics":[{<wbr>"range":{"start": {"line": 0, "character": 1},<br>
> "end": {"line": 0, "character": 1}},"severity":2,"message":"<wbr>return type of<br>
> 'main' is not 'int'"},{"range":{"start": {"line": 0, "character": 1}, "end":<br>
> {"line": 0, "character": 1}},"severity":3,"message":"<wbr>change return type to<br>
> 'int'"}]}}<br>
> -#<br>
> -#<br>
> +#      CHECK:  "method": "textDocument/<wbr>publishDiagnostics",<br>
> +# CHECK-NEXT:  "params": {<br>
> +# CHECK-NEXT:    "diagnostics": [<br>
> +# CHECK-NEXT:      {<br>
> +# CHECK-NEXT:        "message": "return type of 'main' is not 'int'",<br>
> +# CHECK-NEXT:        "range": {<br>
> +# CHECK-NEXT:          "end": {<br>
> +# CHECK-NEXT:            "character": 1,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          "start": {<br>
> +# CHECK-NEXT:            "character": 1,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "severity": 2<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      {<br>
> +# CHECK-NEXT:        "message": "change return type to 'int'",<br>
> +# CHECK-NEXT:        "range": {<br>
> +# CHECK-NEXT:          "end": {<br>
> +# CHECK-NEXT:            "character": 1,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          "start": {<br>
> +# CHECK-NEXT:            "character": 1,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "severity": 3<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    ],<br>
> +# CHECK-NEXT:    "uri": "<a>file:///foo.c</a>"<br>
> +# CHECK-NEXT:  }<br>
>  Content-Length: 44<br>
><br>
>  {"jsonrpc":"2.0","id":5,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":5,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/did-change-watch-files.<wbr>test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/did-<wbr>change-watch-<br>
> files.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/did-change-watch-files.<wbr>test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/did-change-watch-files.<wbr>test Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -5,18 +5,7 @@<br>
>  Content-Length: 143<br>
><br>
><br>
> {"jsonrpc":"2.0","id":0,"<wbr>method":"initialize","params":<wbr>{"processId":123,"rootU<br>
> ri":"<a>file:///path/to/workspace</a><wbr>","capabilities":{},"trace":"<wbr>off"}}<br>
> -# CHECK: Content-Length: 466<br>
> -# CHECK: {"jsonrpc":"2.0","id":0,"<wbr>result":{"capabilities":{<br>
> -# CHECK:   "textDocumentSync": 1,<br>
> -# CHECK:   "documentFormattingProvider": true,<br>
> -# CHECK:   "<wbr>documentRangeFormattingProvide<wbr>r": true,<br>
> -# CHECK:   "<wbr>documentOnTypeFormattingProvid<wbr>er":<br>
> {"firstTriggerCharacter":"}","<wbr>moreTriggerCharacter":[]},<br>
> -# CHECK:   "codeActionProvider": true,<br>
> -# CHECK:   "completionProvider": {"resolveProvider": false,<br>
> "triggerCharacters": [".",">",":"]},<br>
> -# CHECK:   "definitionProvider": true<br>
> -# CHECK: }}}<br>
> -#<br>
> -#Normal case<br>
> +# Normal case.<br>
>  Content-Length: 217<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>workspace/<wbr>didChangeWatchedFiles","<wbr>params":{"changes<br>
> ":[{"uri":"<a>file:///path/to/<wbr>file.cpp</a>","type":1},{"uri":"<a>fi<wbr>le:///path/to/file2.c<br>
> pp</a>","type":2},{"uri":"<a>file:///<wbr>path/to/file3.cpp</a>","type":3}]}<wbr>}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/execute-command.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>execute-<br>
> command.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/execute-command.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/execute-command.test Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -1,4 +1,4 @@<br>
> -# RUN: clangd -run-synchronously < %s | FileCheck %s<br>
> +# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace<br>
> %s<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
>  #<br>
>  Content-Length: 125<br>
> @@ -8,9 +8,54 @@ Content-Length: 125<br>
>  Content-Length: 180<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didOpen","params"<wbr>:{"textDocument":{"ur<br>
> i":"<a>file:///foo.c</a>","<wbr>languageId":"c","version":1,"<wbr>text":"int main(int i, char<br>
> **a) { if (i = 2) {}}"}}}<br>
> -#<br>
> -# CHECK:<br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/<wbr>publishDiagnostics","params":{<wbr>"uri":"f<br>
> ile:///foo.c","diagnostics":[{<wbr>"range":{"start": {"line": 0, "character": 35},<br>
> "end": {"line": 0, "character": 35}},"severity":2,"message":"<wbr>using the result<br>
> of an assignment as a condition without parentheses"},{"range":{"<wbr>start":<br>
> {"line": 0, "character": 35}, "end": {"line": 0, "character":<br>
> 35}},"severity":3,"message":"<wbr>place parentheses around the assignment to<br>
> silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end":<br>
> {"line": 0, "character": 35}},"severity":3,"message":"<wbr>use '==' to turn this<br>
> assignment into an equality comparison"}]}}<br>
> -#<br>
> +#      CHECK:  "method": "textDocument/<wbr>publishDiagnostics",<br>
> +# CHECK-NEXT:  "params": {<br>
> +# CHECK-NEXT:    "diagnostics": [<br>
> +# CHECK-NEXT:      {<br>
> +# CHECK-NEXT:        "message": "using the result of an assignment as a<br>
> condition without parentheses",<br>
> +# CHECK-NEXT:        "range": {<br>
> +# CHECK-NEXT:          "end": {<br>
> +# CHECK-NEXT:            "character": 35,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          "start": {<br>
> +# CHECK-NEXT:            "character": 35,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "severity": 2<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      {<br>
> +# CHECK-NEXT:        "message": "place parentheses around the assignment to<br>
> silence this warning",<br>
> +# CHECK-NEXT:        "range": {<br>
> +# CHECK-NEXT:          "end": {<br>
> +# CHECK-NEXT:            "character": 35,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          "start": {<br>
> +# CHECK-NEXT:            "character": 35,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "severity": 3<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      {<br>
> +# CHECK-NEXT:        "message": "use '==' to turn this assignment into an<br>
> equality comparison",<br>
> +# CHECK-NEXT:        "range": {<br>
> +# CHECK-NEXT:          "end": {<br>
> +# CHECK-NEXT:            "character": 35,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          "start": {<br>
> +# CHECK-NEXT:            "character": 35,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "severity": 3<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    ],<br>
> +# CHECK-NEXT:    "uri": "<a>file:///foo.c</a>"<br>
> +# CHECK-NEXT:  }<br>
>  Content-Length: 72<br>
><br>
>  {"jsonrpc":"2.0","id":3,"<wbr>method":"workspace/<wbr>executeCommand","params":{}}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/extra-flags.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/extra-<br>
> flags.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/extra-flags.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/extra-flags.test Mon Nov  6 07:40:30<br>
> 2017<br>
> @@ -1,4 +1,4 @@<br>
> -# RUN: clangd -run-synchronously < %s | FileCheck %s<br>
> +# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace<br>
> %s<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
>  #<br>
>  Content-Length: 125<br>
> @@ -8,17 +8,80 @@ Content-Length: 125<br>
>  Content-Length: 205<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didOpen","params"<wbr>:{"textDocument":{"ur<br>
> i":"<a>file:///foo.c</a>","<wbr>languageId":"c","version":1,"<wbr>text":"int main() { int i;<br>
> return i; }"},"metadata":{"extraFlags":[<wbr>"-Wall"]}}}<br>
> -# CHECK:<br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/<wbr>publishDiagnostics","params":{<wbr>"uri":"f<br>
> ile:///foo.c","diagnostics":[{<wbr>"range":{"start": {"line": 0, "character": 28},<br>
> "end": {"line": 0, "character": 28}},"severity":2,"message":"<wbr>variable 'i' is<br>
> uninitialized when used here"},{"range":{"start": {"line": 0, "character":<br>
> 19}, "end": {"line": 0, "character": 19}},"severity":3,"message":"<wbr>initialize<br>
> the variable 'i' to silence this warning"}]}}<br>
> -#<br>
> +#      CHECK:  "method": "textDocument/<wbr>publishDiagnostics",<br>
> +# CHECK-NEXT:  "params": {<br>
> +# CHECK-NEXT:    "diagnostics": [<br>
> +# CHECK-NEXT:      {<br>
> +# CHECK-NEXT:        "message": "variable 'i' is uninitialized when used<br>
> here",<br>
> +# CHECK-NEXT:        "range": {<br>
> +# CHECK-NEXT:          "end": {<br>
> +# CHECK-NEXT:            "character": 28,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          "start": {<br>
> +# CHECK-NEXT:            "character": 28,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "severity": 2<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      {<br>
> +# CHECK-NEXT:        "message": "initialize the variable 'i' to silence this<br>
> warning",<br>
> +# CHECK-NEXT:        "range": {<br>
> +# CHECK-NEXT:          "end": {<br>
> +# CHECK-NEXT:            "character": 19,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          "start": {<br>
> +# CHECK-NEXT:            "character": 19,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "severity": 3<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    ],<br>
> +# CHECK-NEXT:    "uri": "<a>file:///foo.c</a>"<br>
> +# CHECK-NEXT:  }<br>
>  Content-Length: 175<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///foo.c</a>","version"<wbr>:2},"contentChanges":[{"text":<wbr>"int main() { int<br>
> i; return i; }"}]}}<br>
> -# CHECK:<br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/<wbr>publishDiagnostics","params":{<wbr>"uri":"f<br>
> ile:///foo.c","diagnostics":[{<wbr>"range":{"start": {"line": 0, "character": 28},<br>
> "end": {"line": 0, "character": 28}},"severity":2,"message":"<wbr>variable 'i' is<br>
> uninitialized when used here"},{"range":{"start": {"line": 0, "character":<br>
> 19}, "end": {"line": 0, "character": 19}},"severity":3,"message":"<wbr>initialize<br>
> the variable 'i' to silence this warning"}]}}<br>
> -#<br>
> +#      CHECK:  "method": "textDocument/<wbr>publishDiagnostics",<br>
> +# CHECK-NEXT:  "params": {<br>
> +# CHECK-NEXT:    "diagnostics": [<br>
> +# CHECK-NEXT:      {<br>
> +# CHECK-NEXT:        "message": "variable 'i' is uninitialized when used<br>
> here",<br>
> +# CHECK-NEXT:        "range": {<br>
> +# CHECK-NEXT:          "end": {<br>
> +# CHECK-NEXT:            "character": 28,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          "start": {<br>
> +# CHECK-NEXT:            "character": 28,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "severity": 2<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      {<br>
> +# CHECK-NEXT:        "message": "initialize the variable 'i' to silence this<br>
> warning",<br>
> +# CHECK-NEXT:        "range": {<br>
> +# CHECK-NEXT:          "end": {<br>
> +# CHECK-NEXT:            "character": 19,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          "start": {<br>
> +# CHECK-NEXT:            "character": 19,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "severity": 3<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    ],<br>
> +# CHECK-NEXT:    "uri": "<a>file:///foo.c</a>"<br>
> +# CHECK-NEXT:  }<br>
>  Content-Length: 44<br>
><br>
>  {"jsonrpc":"2.0","id":5,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":5,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/fixits.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>fixits.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/fixits.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/fixits.test Mon Nov  6 07:40:30 2017<br>
> @@ -1,4 +1,4 @@<br>
> -# RUN: clangd -run-synchronously < %s | FileCheck %s<br>
> +# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace<br>
> %s<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
>  #<br>
>  Content-Length: 125<br>
> @@ -8,30 +8,242 @@ Content-Length: 125<br>
>  Content-Length: 180<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didOpen","params"<wbr>:{"textDocument":{"ur<br>
> i":"<a>file:///foo.c</a>","<wbr>languageId":"c","version":1,"<wbr>text":"int main(int i, char<br>
> **a) { if (i = 2) {}}"}}}<br>
> -#<br>
> -# CHECK:<br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/<wbr>publishDiagnostics","params":{<wbr>"uri":"f<br>
> ile:///foo.c","diagnostics":[{<wbr>"range":{"start": {"line": 0, "character": 35},<br>
> "end": {"line": 0, "character": 35}},"severity":2,"message":"<wbr>using the result<br>
> of an assignment as a condition without parentheses"},{"range":{"<wbr>start":<br>
> {"line": 0, "character": 35}, "end": {"line": 0, "character":<br>
> 35}},"severity":3,"message":"<wbr>place parentheses around the assignment to<br>
> silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end":<br>
> {"line": 0, "character": 35}},"severity":3,"message":"<wbr>use '==' to turn this<br>
> assignment into an equality comparison"}]}}<br>
> -#<br>
> +#      CHECK:    "method": "textDocument/<wbr>publishDiagnostics",<br>
> +# CHECK-NEXT:  "params": {<br>
> +# CHECK-NEXT:    "diagnostics": [<br>
> +# CHECK-NEXT:      {<br>
> +# CHECK-NEXT:        "message": "using the result of an assignment as a<br>
> condition without parentheses",<br>
> +# CHECK-NEXT:        "range": {<br>
> +# CHECK-NEXT:          "end": {<br>
> +# CHECK-NEXT:            "character": 35,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          "start": {<br>
> +# CHECK-NEXT:            "character": 35,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "severity": 2<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      {<br>
> +# CHECK-NEXT:        "message": "place parentheses around the assignment to<br>
> silence this warning",<br>
> +# CHECK-NEXT:        "range": {<br>
> +# CHECK-NEXT:          "end": {<br>
> +# CHECK-NEXT:            "character": 35,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          "start": {<br>
> +# CHECK-NEXT:            "character": 35,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "severity": 3<br>
> +# CHECK-NEXT:      },<br>
> +# CHECK-NEXT:      {<br>
> +# CHECK-NEXT:        "message": "use '==' to turn this assignment into an<br>
> equality comparison",<br>
> +# CHECK-NEXT:        "range": {<br>
> +# CHECK-NEXT:          "end": {<br>
> +# CHECK-NEXT:            "character": 35,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          "start": {<br>
> +# CHECK-NEXT:            "character": 35,<br>
> +# CHECK-NEXT:            "line": 0<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "severity": 3<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    ],<br>
> +# CHECK-NEXT:    "uri": "<a>file:///foo.c</a>"<br>
> +# CHECK-NEXT:  }<br>
>  Content-Length: 746<br>
><br>
><br>
> {"jsonrpc":"2.0","id":2,"<wbr>method":"textDocument/<wbr>codeAction","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///foo.c</a>"},<wbr>"range":{"start":{"line":104,"<wbr>character":13},"en<br>
> d":{"line":0,"character":35}},<wbr>"context":{"diagnostics":[{"<wbr>range":{"start":<br>
> {"line": 0, "character": 35}, "end": {"line": 0, "character":<br>
> 35}},"severity":2,"message":"<wbr>using the result of an assignment as a condition<br>
> without parentheses"},{"range":{"<wbr>start": {"line": 0, "character": 35}, "end":<br>
> {"line": 0, "character": 35}},"severity":3,"message":"<wbr>place parentheses around<br>
> the assignment to silence this warning"},{"range":{"start": {"line": 0,<br>
> "character": 35}, "end": {"line": 0, "character":<br>
> 35}},"severity":3,"message":"<wbr>use '==' to turn this assignment into an equality<br>
> comparison"}]}}}<br>
> -#<br>
> -# CHECK: {"jsonrpc":"2.0","id":2,"<wbr>result":[{"title":"Apply FixIt 'place<br>
> parentheses around the assignment to silence this warning'", "command":<br>
> "clangd.applyFix", "arguments": [{"changes": {"<a>file:///foo.c</a>": [{"range":<br>
> {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}},<br>
> "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end":<br>
> {"line": 0, "character": 37}}, "newText": ")"}]}}]},{"title":"Apply FixIt 'use<br>
> '==' to turn this assignment into an equality comparison'", "command":<br>
> "clangd.applyFix", "arguments": [{"changes": {"<a>file:///foo.c</a>": [{"range":<br>
> {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}},<br>
> "newText": "=="}]}}]}]}<br>
> -#<br>
> +#      CHECK:  "id": 2,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "arguments": [<br>
> +# CHECK-NEXT:        {<br>
> +# CHECK-NEXT:          "changes": {<br>
> +# CHECK-NEXT:            "<a>file:///foo.c</a>": [<br>
> +# CHECK-NEXT:              {<br>
> +# CHECK-NEXT:                "newText": "(",<br>
> +# CHECK-NEXT:                "range": {<br>
> +# CHECK-NEXT:                  "end": {<br>
> +# CHECK-NEXT:                    "character": 32,<br>
> +# CHECK-NEXT:                    "line": 0<br>
> +# CHECK-NEXT:                  },<br>
> +# CHECK-NEXT:                  "start": {<br>
> +# CHECK-NEXT:                    "character": 32,<br>
> +# CHECK-NEXT:                    "line": 0<br>
> +# CHECK-NEXT:                  }<br>
> +# CHECK-NEXT:                }<br>
> +# CHECK-NEXT:              },<br>
> +# CHECK-NEXT:              {<br>
> +# CHECK-NEXT:                "newText": ")",<br>
> +# CHECK-NEXT:                "range": {<br>
> +# CHECK-NEXT:                  "end": {<br>
> +# CHECK-NEXT:                    "character": 37,<br>
> +# CHECK-NEXT:                    "line": 0<br>
> +# CHECK-NEXT:                  },<br>
> +# CHECK-NEXT:                  "start": {<br>
> +# CHECK-NEXT:                    "character": 37,<br>
> +# CHECK-NEXT:                    "line": 0<br>
> +# CHECK-NEXT:                  }<br>
> +# CHECK-NEXT:                }<br>
> +# CHECK-NEXT:              }<br>
> +# CHECK-NEXT:            ]<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      ],<br>
> +# CHECK-NEXT:      "command": "clangd.applyFix",<br>
> +# CHECK-NEXT:      "title": "Apply FixIt place parentheses around the<br>
> assignment to silence this warning"<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "arguments": [<br>
> +# CHECK-NEXT:        {<br>
> +# CHECK-NEXT:          "changes": {<br>
> +# CHECK-NEXT:            "<a>file:///foo.c</a>": [<br>
> +# CHECK-NEXT:              {<br>
> +# CHECK-NEXT:                "newText": "==",<br>
> +# CHECK-NEXT:                "range": {<br>
> +# CHECK-NEXT:                  "end": {<br>
> +# CHECK-NEXT:                    "character": 35,<br>
> +# CHECK-NEXT:                    "line": 0<br>
> +# CHECK-NEXT:                  },<br>
> +# CHECK-NEXT:                  "start": {<br>
> +# CHECK-NEXT:                    "character": 34,<br>
> +# CHECK-NEXT:                    "line": 0<br>
> +# CHECK-NEXT:                  }<br>
> +# CHECK-NEXT:                }<br>
> +# CHECK-NEXT:              }<br>
> +# CHECK-NEXT:            ]<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      ],<br>
> +# CHECK-NEXT:      "command": "clangd.applyFix",<br>
> +# CHECK-NEXT:      "title": "Apply FixIt use '==' to turn this assignment<br>
> into an equality comparison"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 771<br>
><br>
> -<br>
> {"jsonrpc":"2.0","id":2,"<wbr>method":"textDocument/<wbr>codeAction","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///foo.c</a>"},<wbr>"range":{"start":{"line":104,"<wbr>character":13},"en<br>
> d":{"line":0,"character":35}},<wbr>"context":{"diagnostics":[{"<wbr>range":{"start":<br>
> {"line": 0, "character": 35}, "end": {"line": 0, "character":<br>
> 35}},"severity":2,"code":"1","<wbr>source":"foo","message":"using the result of an<br>
> assignment as a condition without parentheses"},{"range":{"<wbr>start": {"line": 0,<br>
> "character": 35}, "end": {"line": 0, "character":<br>
> 35}},"severity":3,"message":"<wbr>place parentheses around the assignment to<br>
> silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end":<br>
> {"line": 0, "character": 35}},"severity":3,"message":"<wbr>use '==' to turn this<br>
> assignment into an equality comparison"}]}}}<br>
> +{"jsonrpc":"2.0","id":3,"<wbr>method":"textDocument/<wbr>codeAction","params":{"textDoc<br>
> ument":{"uri":"<a>file:///foo.c</a>"}<wbr>,"range":{"start":{"line":104,<wbr>"character":13},"e<br>
> nd":{"line":0,"character":35}}<wbr>,"context":{"diagnostics":[{"<wbr>range":{"start":<br>
> {"line": 0, "character": 35}, "end": {"line": 0, "character":<br>
> 35}},"severity":2,"code":"1","<wbr>source":"foo","message":"using the result of an<br>
> assignment as a condition without parentheses"},{"range":{"<wbr>start": {"line": 0,<br>
> "character": 35}, "end": {"line": 0, "character":<br>
> 35}},"severity":3,"message":"<wbr>place parentheses around the assignment to<br>
> silence this warning"},{"range":{"start": {"line": 0, "character": 35}, "end":<br>
> {"line": 0, "character": 35}},"severity":3,"message":"<wbr>use '==' to turn this<br>
> assignment into an equality comparison"}]}}}<br>
>  # Make sure unused "code" and "source" fields ignored gracefully<br>
> -# CHECK: {"jsonrpc":"2.0","id":2,"<wbr>result":[{"title":"Apply FixIt 'place<br>
> parentheses around the assignment to silence this warning'", "command":<br>
> "clangd.applyFix", "arguments": [{"changes": {"<a>file:///foo.c</a>": [{"range":<br>
> {"start": {"line": 0, "character": 32}, "end": {"line": 0, "character": 32}},<br>
> "newText": "("},{"range": {"start": {"line": 0, "character": 37}, "end":<br>
> {"line": 0, "character": 37}}, "newText": ")"}]}}]},{"title":"Apply FixIt 'use<br>
> '==' to turn this assignment into an equality comparison'", "command":<br>
> "clangd.applyFix", "arguments": [{"changes": {"<a>file:///foo.c</a>": [{"range":<br>
> {"start": {"line": 0, "character": 34}, "end": {"line": 0, "character": 35}},<br>
> "newText": "=="}]}}]}]}<br>
> -#<br>
> +#      CHECK:  "id": 3,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "arguments": [<br>
> +# CHECK-NEXT:        {<br>
> +# CHECK-NEXT:          "changes": {<br>
> +# CHECK-NEXT:            "<a>file:///foo.c</a>": [<br>
> +# CHECK-NEXT:              {<br>
> +# CHECK-NEXT:                "newText": "(",<br>
> +# CHECK-NEXT:                "range": {<br>
> +# CHECK-NEXT:                  "end": {<br>
> +# CHECK-NEXT:                    "character": 32,<br>
> +# CHECK-NEXT:                    "line": 0<br>
> +# CHECK-NEXT:                  },<br>
> +# CHECK-NEXT:                  "start": {<br>
> +# CHECK-NEXT:                    "character": 32,<br>
> +# CHECK-NEXT:                    "line": 0<br>
> +# CHECK-NEXT:                  }<br>
> +# CHECK-NEXT:                }<br>
> +# CHECK-NEXT:              },<br>
> +# CHECK-NEXT:              {<br>
> +# CHECK-NEXT:                "newText": ")",<br>
> +# CHECK-NEXT:                "range": {<br>
> +# CHECK-NEXT:                  "end": {<br>
> +# CHECK-NEXT:                    "character": 37,<br>
> +# CHECK-NEXT:                    "line": 0<br>
> +# CHECK-NEXT:                  },<br>
> +# CHECK-NEXT:                  "start": {<br>
> +# CHECK-NEXT:                    "character": 37,<br>
> +# CHECK-NEXT:                    "line": 0<br>
> +# CHECK-NEXT:                  }<br>
> +# CHECK-NEXT:                }<br>
> +# CHECK-NEXT:              }<br>
> +# CHECK-NEXT:            ]<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      ],<br>
> +# CHECK-NEXT:      "command": "clangd.applyFix",<br>
> +# CHECK-NEXT:      "title": "Apply FixIt place parentheses around the<br>
> assignment to silence this warning"<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "arguments": [<br>
> +# CHECK-NEXT:        {<br>
> +# CHECK-NEXT:          "changes": {<br>
> +# CHECK-NEXT:            "<a>file:///foo.c</a>": [<br>
> +# CHECK-NEXT:              {<br>
> +# CHECK-NEXT:                "newText": "==",<br>
> +# CHECK-NEXT:                "range": {<br>
> +# CHECK-NEXT:                  "end": {<br>
> +# CHECK-NEXT:                    "character": 35,<br>
> +# CHECK-NEXT:                    "line": 0<br>
> +# CHECK-NEXT:                  },<br>
> +# CHECK-NEXT:                  "start": {<br>
> +# CHECK-NEXT:                    "character": 34,<br>
> +# CHECK-NEXT:                    "line": 0<br>
> +# CHECK-NEXT:                  }<br>
> +# CHECK-NEXT:                }<br>
> +# CHECK-NEXT:              }<br>
> +# CHECK-NEXT:            ]<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      ],<br>
> +# CHECK-NEXT:      "command": "clangd.applyFix",<br>
> +# CHECK-NEXT:      "title": "Apply FixIt use '==' to turn this assignment<br>
> into an equality comparison"<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 329<br>
><br>
> -<br>
> {"jsonrpc":"2.0","id":3,"<wbr>method":"workspace/<wbr>executeCommand","params":{"<wbr>command<br>
> ":"clangd.applyFix","<wbr>arguments":[{"changes":{"<a>file:<wbr>///foo.c</a>":[{"range":{"start<br>
> ":{"line":0,"character":32},"<wbr>end":{"line":0,"character":32}<wbr>},"newText":"("},{"<br>
> range":{"start":{"line":0,"<wbr>character":37},"end":{"line":<wbr>0,"character":37}},"ne<br>
> wText":")"}]}}]}}<br>
> -# CHECK: {"jsonrpc":"2.0","id":3,"<wbr>result":"Fix applied."}<br>
> -# CHECK:<br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"workspace/applyEdit",<wbr>"params":{"edit":<br>
> {"changes": {"<a>file:///foo.c</a>": [{"range": {"start": {"line": 0, "character":<br>
> 32}, "end": {"line": 0, "character": 32}}, "newText": "("},{"range": {"start":<br>
> {"line": 0, "character": 37}, "end": {"line": 0, "character": 37}}, "newText":<br>
> ")"}]}}}}<br>
> +{"jsonrpc":"2.0","id":4,"<wbr>method":"workspace/<wbr>executeCommand","params":{"<wbr>comman<br>
> d":"clangd.applyFix","<wbr>arguments":[{"changes":{"<a>file:<wbr>///foo.c</a>":[{"range":{"star<br>
> t":{"line":0,"character":32},"<wbr>end":{"line":0,"character":32}<wbr>},"newText":"("},{<br>
> "range":{"start":{"line":0,"<wbr>character":37},"end":{"line":<wbr>0,"character":37}},"n<br>
> ewText":")"}]}}]}}<br>
> +#      CHECK:  "id": 4,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": "Fix applied."<br>
> +#<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "method": "workspace/applyEdit",<br>
> +# CHECK-NEXT:  "params": {<br>
> +# CHECK-NEXT:    "edit": {<br>
> +# CHECK-NEXT:      "changes": {<br>
> +# CHECK-NEXT:        "<a>file:///foo.c</a>": [<br>
> +# CHECK-NEXT:          {<br>
> +# CHECK-NEXT:            "newText": "(",<br>
> +# CHECK-NEXT:            "range": {<br>
> +# CHECK-NEXT:              "end": {<br>
> +# CHECK-NEXT:                "character": 32,<br>
> +# CHECK-NEXT:                "line": 0<br>
> +# CHECK-NEXT:              },<br>
> +# CHECK-NEXT:              "start": {<br>
> +# CHECK-NEXT:                "character": 32,<br>
> +# CHECK-NEXT:                "line": 0<br>
> +# CHECK-NEXT:              }<br>
> +# CHECK-NEXT:            }<br>
> +# CHECK-NEXT:          },<br>
> +# CHECK-NEXT:          {<br>
> +# CHECK-NEXT:            "newText": ")",<br>
> +# CHECK-NEXT:            "range": {<br>
> +# CHECK-NEXT:              "end": {<br>
> +# CHECK-NEXT:                "character": 37,<br>
> +# CHECK-NEXT:                "line": 0<br>
> +# CHECK-NEXT:              },<br>
> +# CHECK-NEXT:              "start": {<br>
> +# CHECK-NEXT:                "character": 37,<br>
> +# CHECK-NEXT:                "line": 0<br>
> +# CHECK-NEXT:              }<br>
> +# CHECK-NEXT:            }<br>
> +# CHECK-NEXT:          }<br>
> +# CHECK-NEXT:        ]<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  }<br>
>  Content-Length: 44<br>
><br>
> -{"jsonrpc":"2.0","id":3,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":3,"<wbr>result":null}<br>
> +{"jsonrpc":"2.0","id":4,"<wbr>method":"shutdown"}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/formatting.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>formatting.test?rev=317486&r1=<wbr>317485&r2=317486&view=di<br>
> ff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/formatting.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/formatting.test Mon Nov  6 07:40:30<br>
> 2017<br>
> @@ -1,30 +1,71 @@<br>
> -# RUN: clangd < %s | FileCheck %s<br>
> +# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace<br>
> %s<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
>  #<br>
>  Content-Length: 125<br>
><br>
><br>
> {"jsonrpc":"2.0","id":0,"<wbr>method":"initialize","params":<wbr>{"processId":123,"rootP<br>
> ath":"clangd","capabilities":{<wbr>},"trace":"off"}}<br>
> -# CHECK: {"jsonrpc":"2.0","id":0,"<wbr>result":{"capabilities":{<br>
> -# CHECK:   "textDocumentSync": 1,<br>
> -# CHECK:   "documentFormattingProvider": true,<br>
> -# CHECK:   "<wbr>documentRangeFormattingProvide<wbr>r": true,<br>
> -# CHECK:   "<wbr>documentOnTypeFormattingProvid<wbr>er":<br>
> {"firstTriggerCharacter":"}","<wbr>moreTriggerCharacter":[]},<br>
> -# CHECK:   "codeActionProvider": true,<br>
> -# CHECK:   "completionProvider": {"resolveProvider": false,<br>
> "triggerCharacters": [".",">",":"]},<br>
> -# CHECK:   "definitionProvider": true<br>
> -# CHECK: }}}<br>
> -#<br>
>  Content-Length: 193<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didOpen","params"<wbr>:{"textDocument":{"ur<br>
> i":"<a>file:///foo.c</a>","<wbr>languageId":"c","version":1,"<wbr>text":"int foo ( int x ) {\n<br>
> x = x+1;\n    return x;\n    }"}}}<br>
> -#<br>
> -#<br>
>  Content-Length: 233<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>rangeFormatting","params":{"<wbr>tex<br>
> tDocument":{"uri":"<a>file:///<wbr>foo.c</a>"},"range":{"start":{"<wbr>line":1,"character":4},"<br>
> end":{"line":1,"character":12}<wbr>},"options":{"tabSize":4,"<wbr>insertSpaces":true}}}<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[{"range": {"start": {"line": 0,<br>
> "character": 19}, "end": {"line": 1, "character": 4}}, "newText": "\n<br>
> "},{"range": {"start": {"line": 1, "character": 9}, "end": {"line": 1,<br>
> "character": 9}}, "newText": " "},{"range": {"start": {"line": 1, "character":<br>
> 10}, "end": {"line": 1, "character": 10}}, "newText": " "},{"range": {"start":<br>
> {"line": 1, "character": 12}, "end": {"line": 2, "character": 4}}, "newText":<br>
> "\n  "}]}<br>
> -#<br>
> -#<br>
> +#      CHECK:   "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "newText": "\n  ",<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 4,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 19,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "newText": " ",<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 9,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 9,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "newText": " ",<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 10,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 10,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "newText": "\n  ",<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 4,<br>
> +# CHECK-NEXT:          "line": 2<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 12,<br>
> +# CHECK-NEXT:          "line": 1<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 197<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///foo.c</a>","version"<wbr>:5},"contentChanges":[{"text":<wbr>"int foo ( int x )<br>
> {\n  x = x + 1;\n  return x;\n    }"}]}}<br>
> @@ -33,14 +74,68 @@ Content-Length: 197<br>
>  Content-Length: 233<br>
><br>
><br>
> {"jsonrpc":"2.0","id":2,"<wbr>method":"textDocument/<wbr>rangeFormatting","params":{"<wbr>tex<br>
> tDocument":{"uri":"<a>file:///<wbr>foo.c</a>"},"range":{"start":{"<wbr>line":1,"character":2},"<br>
> end":{"line":1,"character":12}<wbr>},"options":{"tabSize":4,"<wbr>insertSpaces":true}}}<br>
> -# CHECK: {"jsonrpc":"2.0","id":2,"<wbr>result":[]}<br>
> -#<br>
> +#      CHECK:  "id": 2,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": []<br>
>  Content-Length: 153<br>
><br>
><br>
> {"jsonrpc":"2.0","id":3,"<wbr>method":"textDocument/<wbr>formatting","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///foo.c</a>"},<wbr>"options":{"tabSize":4,"<wbr>insertSpaces":true}}}<br>
> -# CHECK: {"jsonrpc":"2.0","id":3,"<wbr>result":[{"range": {"start": {"line": 0,<br>
> "character": 7}, "end": {"line": 0, "character": 8}}, "newText": ""},{"range":<br>
> {"start": {"line": 0, "character": 9}, "end": {"line": 0, "character": 10}},<br>
> "newText": ""},{"range": {"start": {"line": 0, "character": 15}, "end":<br>
> {"line": 0, "character": 16}}, "newText": ""},{"range": {"start": {"line": 2,<br>
> "character": 11}, "end": {"line": 3, "character": 4}}, "newText": "\n"}]}<br>
> -#<br>
> -#<br>
> +#      CHECK:  "id": 3,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "newText": "",<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 8,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 7,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "newText": "",<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 10,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 9,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "newText": "",<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 16,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 15,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "newText": "\n",<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 4,<br>
> +# CHECK-NEXT:          "line": 3<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 11,<br>
> +# CHECK-NEXT:          "line": 2<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
>  Content-Length: 190<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///foo.c</a>","version"<wbr>:9},"contentChanges":[{"text":<wbr>"int foo(int x)<br>
> {\n  x = x + 1;\n  return x;\n}"}]}}<br>
> @@ -49,8 +144,9 @@ Content-Length: 190<br>
>  Content-Length: 153<br>
><br>
><br>
> {"jsonrpc":"2.0","id":4,"<wbr>method":"textDocument/<wbr>formatting","params":{"<wbr>textDocu<br>
> ment":{"uri":"<a>file:///foo.c</a>"},<wbr>"options":{"tabSize":4,"<wbr>insertSpaces":true}}}<br>
> -# CHECK: {"jsonrpc":"2.0","id":4,"<wbr>result":[]}<br>
> -#<br>
> +#      CHECK:  "id": 4,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": []<br>
>  Content-Length: 193<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didChange","<wbr>params":{"textDocument":{"<br>
> uri":"<a>file:///foo.c</a>","version"<wbr>:5},"contentChanges":[{"text":<wbr>"int foo ( int x )<br>
> {\n  x = x + 1;\n  return x;\n}"}]}}<br>
> @@ -59,13 +155,53 @@ Content-Length: 193<br>
>  Content-Length: 204<br>
><br>
><br>
> {"jsonrpc":"2.0","id":5,"<wbr>method":"textDocument/<wbr>onTypeFormatting","params":{"<wbr>te<br>
> xtDocument":{"uri":"<a>file:///<wbr>foo.c</a>"},"position":{"line":3,"<wbr>character":1},"ch":"<br>
> }","options":{"tabSize":4,"<wbr>insertSpaces":true}}}<br>
> -# CHECK: {"jsonrpc":"2.0","id":5,"<wbr>result":[{"range": {"start": {"line": 0,<br>
> "character": 7}, "end": {"line": 0, "character": 8}}, "newText": ""},{"range":<br>
> {"start": {"line": 0, "character": 9}, "end": {"line": 0, "character": 10}},<br>
> "newText": ""},{"range": {"start": {"line": 0, "character": 15}, "end":<br>
> {"line": 0, "character": 16}}, "newText": ""}]}<br>
> -#<br>
> +#      CHECK:  "id": 5,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "newText": "",<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 8,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 7,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "newText": "",<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 10,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 9,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    {<br>
> +# CHECK-NEXT:      "newText": "",<br>
> +# CHECK-NEXT:      "range": {<br>
> +# CHECK-NEXT:        "end": {<br>
> +# CHECK-NEXT:          "character": 16,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        },<br>
> +# CHECK-NEXT:        "start": {<br>
> +# CHECK-NEXT:          "character": 15,<br>
> +# CHECK-NEXT:          "line": 0<br>
> +# CHECK-NEXT:        }<br>
> +# CHECK-NEXT:      }<br>
> +# CHECK-NEXT:    }<br>
> +# CHECK-NEXT:  ]<br>
><br>
>  Content-Length: 44<br>
><br>
>  {"jsonrpc":"2.0","id":6,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":6,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/initialize-params-<wbr>invalid.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>initialize-params-<br>
> invalid.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/initialize-params-<wbr>invalid.test<br>
> (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/initialize-params-<wbr>invalid.test Mon Nov<br>
> 6 07:40:30 2017<br>
> @@ -1,27 +1,45 @@<br>
> -# RUN: clangd -run-synchronously < %s | FileCheck %s<br>
> +# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace<br>
> %s<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
>  #<br>
>  # Test with invalid initialize request parameters<br>
>  Content-Length: 142<br>
><br>
><br>
> {"jsonrpc":"2.0","id":0,"<wbr>method":"initialize","params":<wbr>{"processId":"","rootUr<br>
> i":"<a>file:///path/to/workspace</a>"<wbr>,"capabilities":{},"trace":"<wbr>off"}}<br>
> -# CHECK: Content-Length: 606<br>
> -# CHECK: {"jsonrpc":"2.0","id":0,"<wbr>result":{"capabilities":{<br>
> -# CHECK:   "textDocumentSync": 1,<br>
> -# CHECK:   "documentFormattingProvider": true,<br>
> -# CHECK:   "<wbr>documentRangeFormattingProvide<wbr>r": true,<br>
> -# CHECK:   "<wbr>documentOnTypeFormattingProvid<wbr>er":<br>
> {"firstTriggerCharacter":"}","<wbr>moreTriggerCharacter":[]},<br>
> -# CHECK:   "codeActionProvider": true,<br>
> -# CHECK:   "completionProvider": {"resolveProvider": false,<br>
> "triggerCharacters": [".",">",":"]},<br>
> -# CHECK:   "signatureHelpProvider": {"triggerCharacters": ["(",","]},<br>
> -# CHECK:   "definitionProvider": true,<br>
> -# CHECK:   "executeCommandProvider": {"commands": ["clangd.applyFix"]}<br>
> -# CHECK: }}}<br>
> -#<br>
> +#      CHECK:  "id": 0,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": {<br>
> +# CHECK-NEXT:    "codeActionProvider": true,<br>
> +# CHECK-NEXT:    "completionProvider": {<br>
> +# CHECK-NEXT:      "resolveProvider": false,<br>
> +# CHECK-NEXT:      "triggerCharacters": [<br>
> +# CHECK-NEXT:        ".",<br>
> +# CHECK-NEXT:        ">",<br>
> +# CHECK-NEXT:        ":"<br>
> +# CHECK-NEXT:      ]<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    "definitionProvider": true,<br>
> +# CHECK-NEXT:    "documentFormattingProvider": true,<br>
> +# CHECK-NEXT:    "<wbr>documentOnTypeFormattingProvid<wbr>er": {<br>
> +# CHECK-NEXT:      "firstTriggerCharacter": "}",<br>
> +# CHECK-NEXT:      "moreTriggerCharacter": []<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    "<wbr>documentRangeFormattingProvide<wbr>r": true,<br>
> +# CHECK-NEXT:    "executeCommandProvider": {<br>
> +# CHECK-NEXT:      "commands": [<br>
> +# CHECK-NEXT:        "clangd.applyFix"<br>
> +# CHECK-NEXT:      ]<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    "signatureHelpProvider": {<br>
> +# CHECK-NEXT:      "triggerCharacters": [<br>
> +# CHECK-NEXT:        "(",<br>
> +# CHECK-NEXT:        ","<br>
> +# CHECK-NEXT:      ]<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    "textDocumentSync": 1<br>
> +# CHECK-NEXT:  }<br>
>  Content-Length: 44<br>
><br>
>  {"jsonrpc":"2.0","id":3,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":3,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/initialize-params.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>initialize-<br>
> params.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/initialize-params.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/initialize-params.test Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -1,27 +1,48 @@<br>
> -# RUN: clangd -run-synchronously < %s | FileCheck %s<br>
> +# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace<br>
> %s<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
>  #<br>
>  # Test initialize request parameters with rootUri<br>
>  Content-Length: 143<br>
><br>
><br>
> {"jsonrpc":"2.0","id":0,"<wbr>method":"initialize","params":<wbr>{"processId":123,"rootU<br>
> ri":"<a>file:///path/to/workspace</a><wbr>","capabilities":{},"trace":"<wbr>off"}}<br>
> -# CHECK: Content-Length: 606<br>
> -# CHECK: {"jsonrpc":"2.0","id":0,"<wbr>result":{"capabilities":{<br>
> -# CHECK:   "textDocumentSync": 1,<br>
> -# CHECK:   "documentFormattingProvider": true,<br>
> -# CHECK:   "<wbr>documentRangeFormattingProvide<wbr>r": true,<br>
> -# CHECK:   "<wbr>documentOnTypeFormattingProvid<wbr>er":<br>
> {"firstTriggerCharacter":"}","<wbr>moreTriggerCharacter":[]},<br>
> -# CHECK:   "codeActionProvider": true,<br>
> -# CHECK:   "completionProvider": {"resolveProvider": false,<br>
> "triggerCharacters": [".",">",":"]},<br>
> -# CHECK:   "signatureHelpProvider": {"triggerCharacters": ["(",","]},<br>
> -# CHECK:   "definitionProvider": true,<br>
> -# CHECK:   "executeCommandProvider": {"commands": ["clangd.applyFix"]}<br>
> -# CHECK: }}}<br>
> -#<br>
> +#      CHECK:  "id": 0,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": {<br>
> +# CHECK-NEXT:    "codeActionProvider": true,<br>
> +# CHECK-NEXT:    "completionProvider": {<br>
> +# CHECK-NEXT:      "resolveProvider": false,<br>
> +# CHECK-NEXT:      "triggerCharacters": [<br>
> +# CHECK-NEXT:        ".",<br>
> +# CHECK-NEXT:        ">",<br>
> +# CHECK-NEXT:        ":"<br>
> +# CHECK-NEXT:      ]<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    "definitionProvider": true,<br>
> +# CHECK-NEXT:    "documentFormattingProvider": true,<br>
> +# CHECK-NEXT:    "<wbr>documentOnTypeFormattingProvid<wbr>er": {<br>
> +# CHECK-NEXT:      "firstTriggerCharacter": "}",<br>
> +# CHECK-NEXT:      "moreTriggerCharacter": []<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    "<wbr>documentRangeFormattingProvide<wbr>r": true,<br>
> +# CHECK-NEXT:    "executeCommandProvider": {<br>
> +# CHECK-NEXT:      "commands": [<br>
> +# CHECK-NEXT:        "clangd.applyFix"<br>
> +# CHECK-NEXT:      ]<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    "signatureHelpProvider": {<br>
> +# CHECK-NEXT:      "triggerCharacters": [<br>
> +# CHECK-NEXT:        "(",<br>
> +# CHECK-NEXT:        ","<br>
> +# CHECK-NEXT:      ]<br>
> +# CHECK-NEXT:    },<br>
> +# CHECK-NEXT:    "textDocumentSync": 1<br>
> +# CHECK-NEXT:  }<br>
>  Content-Length: 44<br>
><br>
>  {"jsonrpc":"2.0","id":3,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":3,"<wbr>result":null}<br>
> +#      CHECK:  "id": 3,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": null<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/input-mirror.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/input-<br>
> mirror.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/input-mirror.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/input-mirror.test Mon Nov  6 07:40:30<br>
> 2017<br>
> @@ -1,4 +1,4 @@<br>
> -# RUN: clangd -run-synchronously -input-mirror-file %t < %s<br>
> +# RUN: clangd -pretty -run-synchronously -input-mirror-file %t < %s<br>
>  # Note that we have to use '-b' as -input-mirror-file does not have a newline<br>
> at the end of file.<br>
>  # RUN: diff -b %t %s<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
> @@ -152,7 +152,6 @@ Content-Length: 148<br>
>  Content-Length: 44<br>
><br>
>  {"jsonrpc":"2.0","id":3,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":3,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/protocol.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>protocol.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/protocol.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/protocol.test Mon Nov  6 07:40:30 2017<br>
> @@ -1,5 +1,5 @@<br>
> -# RUN: not clangd -run-synchronously < %s | FileCheck %s<br>
> -# RUN: not clangd -run-synchronously < %s 2>&1 | FileCheck -check-<br>
> prefix=STDERR %s<br>
> +# RUN: not clangd -pretty -run-synchronously < %s | FileCheck -strict-<br>
> whitespace %s<br>
> +# RUN: not clangd -pretty -run-synchronously < %s 2>&1 | FileCheck -check-<br>
> prefix=STDERR %s<br>
>  # vim: fileformat=dos<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
>  #<br>
> @@ -12,16 +12,9 @@ Content-Type: application/vscode-jsonrpc<br>
><br>
> {"jsonrpc":"2.0","id":0,"<wbr>method":"initialize","params":<wbr>{"processId":123,"rootP<br>
> ath":"clangd","capabilities":{<wbr>},"trace":"off"}}<br>
>  # Test message with Content-Type after Content-Length<br>
>  #<br>
> -# CHECK: "jsonrpc":"2.0","id":0,"<wbr>result":{"capabilities":{<br>
> -# CHECK-DAG: "textDocumentSync": 1,<br>
> -# CHECK-DAG: "documentFormattingProvider": true,<br>
> -# CHECK-DAG: "<wbr>documentRangeFormattingProvide<wbr>r": true,<br>
> -# CHECK-DAG: "<wbr>documentOnTypeFormattingProvid<wbr>er":<br>
> {"firstTriggerCharacter":"}","<wbr>moreTriggerCharacter":[]},<br>
> -# CHECK-DAG: "codeActionProvider": true,<br>
> -# CHECK-DAG: "completionProvider": {"resolveProvider": false,<br>
> "triggerCharacters": [".",">",":"]},<br>
> -# CHECK-DAG: "definitionProvider": true<br>
> -# CHECK: }}<br>
> -<br>
> +#      CHECK:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": {<br>
> +#      CHECK:  }<br>
>  Content-Length: 246<br>
><br>
><br>
> {"jsonrpc":"2.0","method":"<wbr>textDocument/didOpen","params"<wbr>:{"textDocument":{"ur<br>
> i":"<a>file:///main.cpp</a>","<wbr>languageId":"cpp","version":1,<wbr>"text":"struct fake { int<br>
> a, bb, ccc; int f(int i, const float f) const; };\nint main() {\n  fake f;\n<br>
> f.\n}\n"}}}<br>
> @@ -36,9 +29,16 @@ Content-Length: 146<br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"file:/main.cpp"}<wbr>,"position":{"line":3,"<wbr>character":5}}}<br>
>  # Test message with Content-Type before Content-Length<br>
>  #<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>result":[<br>
> -# CHECK-DAG:<br>
> {"label":"a","kind":5,"detail"<wbr>:"int","sortText":"000035a","<wbr>filterText":"a","in<br>
> sertText":"a","<wbr>insertTextFormat":1}<br>
> -# CHECK: ]}<br>
> +#      CHECK:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +#      CHECK:      "filterText": "fake",<br>
> +# CHECK-NEXT:      "insertText": "fake",<br>
> +# CHECK-NEXT:      "insertTextFormat": 1,<br>
> +# CHECK-NEXT:      "kind": 7,<br>
> +# CHECK-NEXT:      "label": "fake::",<br>
> +# CHECK-NEXT:      "sortText": "000075fake"<br>
> +#      CHECK:  ]<br>
><br>
>  X-Test: Testing<br>
>  Content-Type: application/vscode-jsonrpc; charset-utf-8<br>
> @@ -55,9 +55,16 @@ Content-Length: 146<br>
><br>
> {"jsonrpc":"2.0","id":3,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"file:/main.cpp"}<wbr>,"position":{"line":3,"<wbr>character":5}}}<br>
>  # Test message with duplicate Content-Length headers<br>
>  #<br>
> -# CHECK: {"jsonrpc":"2.0","id":3,"<wbr>result":[<br>
> -# CHECK-DAG:<br>
> {"label":"a","kind":5,"detail"<wbr>:"int","sortText":"000035a","<wbr>filterText":"a","in<br>
> sertText":"a","<wbr>insertTextFormat":1}<br>
> -# CHECK: ]}<br>
> +#      CHECK:  "id": 3,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +#      CHECK:      "filterText": "fake",<br>
> +# CHECK-NEXT:      "insertText": "fake",<br>
> +# CHECK-NEXT:      "insertTextFormat": 1,<br>
> +# CHECK-NEXT:      "kind": 7,<br>
> +# CHECK-NEXT:      "label": "fake::",<br>
> +# CHECK-NEXT:      "sortText": "000075fake"<br>
> +#      CHECK:  ]<br>
>  # STDERR: Warning: Duplicate Content-Length header received. The previous<br>
> value for this message (10) was ignored.<br>
><br>
>  Content-Type: application/vscode-jsonrpc; charset-utf-8<br>
> @@ -74,10 +81,16 @@ Content-Length: 146<br>
><br>
> {"jsonrpc":"2.0","id":5,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"file:/main.cpp"}<wbr>,"position":{"line":3,"<wbr>character":5}}}<br>
>  # Test message with Content-Type before Content-Length<br>
>  #<br>
> -# CHECK: {"jsonrpc":"2.0","id":5,"<wbr>result":[<br>
> -# CHECK-DAG:<br>
> {"label":"a","kind":5,"detail"<wbr>:"int","sortText":"000035a","<wbr>filterText":"a","in<br>
> sertText":"a","<wbr>insertTextFormat":1}<br>
> -# CHECK: ]}<br>
> -<br>
> +#      CHECK:  "id": 5,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0",<br>
> +# CHECK-NEXT:  "result": [<br>
> +#      CHECK:      "filterText": "fake",<br>
> +# CHECK-NEXT:      "insertText": "fake",<br>
> +# CHECK-NEXT:      "insertTextFormat": 1,<br>
> +# CHECK-NEXT:      "kind": 7,<br>
> +# CHECK-NEXT:      "label": "fake::",<br>
> +# CHECK-NEXT:      "sortText": "000075fake"<br>
> +#      CHECK:  ]<br>
>  Content-Length: 1024<br>
><br>
><br>
> {"jsonrpc":"2.0","id":5,"<wbr>method":"textDocument/<wbr>completion","params":{"<wbr>textDocu<br>
> ment":{"uri":"file:/main.cpp"}<wbr>,"position":{"line":3,"<wbr>character":5}}}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/signature-help.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>signature-<br>
> help.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/signature-help.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/signature-help.test Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -15,12 +15,12 @@ Content-Length: 333<br>
>  Content-Length: 151<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>signatureHelp","params":{"<wbr>textD<br>
> ocument":{"uri":"<a>file:///main.<wbr>cpp</a>"},"position":{"line":8,"<wbr>character":9}}}<br>
> -# CHECK:<br>
> {"jsonrpc":"2.0","id":1,"<wbr>result":{"activeSignature":0,"<wbr>activeParameter":0,"sig<br>
> natures":[<br>
> +# CHECK:<br>
> {"id":1,"jsonrpc":"2.0","<wbr>result":{"activeParameter":0,"<wbr>activeSignature":0,"sig<br>
> natures":[<br>
>  # CHECK-DAG: {"label":"foo(float x, float y) -><br>
> void","parameters":[{"label":"<wbr>float x"},{"label":"float y"}]}<br>
>  # CHECK-DAG: {"label":"foo(float x, int y) -><br>
> void","parameters":[{"label":"<wbr>float x"},{"label":"int y"}]}<br>
>  # CHECK-DAG: {"label":"foo(int x, float y) -><br>
> void","parameters":[{"label":"<wbr>int x"},{"label":"float y"}]}<br>
>  # CHECK-DAG: {"label":"foo(int x, int y) -> void","parameters":[{"label":"<wbr>int<br>
> x"},{"label":"int y"}]}<br>
> -# CHECK: ]}<br>
> +# CHECK-SAME: ]}<br>
><br>
>  # Modify the document<br>
>  Content-Length: 333<br>
> @@ -31,21 +31,20 @@ Content-Length: 333<br>
>  Content-Length: 151<br>
><br>
><br>
> {"jsonrpc":"2.0","id":2,"<wbr>method":"textDocument/<wbr>signatureHelp","params":{"<wbr>textD<br>
> ocument":{"uri":"<a>file:///main.<wbr>cpp</a>"},"position":{"line":8,"<wbr>character":9}}}<br>
> -# CHECK:<br>
> {"jsonrpc":"2.0","id":2,"<wbr>result":{"activeSignature":0,"<wbr>activeParameter":0,"sig<br>
> natures":[<br>
> +# CHECK:<br>
> {"id":2,"jsonrpc":"2.0","<wbr>result":{"activeParameter":0,"<wbr>activeSignature":0,"sig<br>
> natures":[<br>
>  # CHECK-DAG: {"label":"bar(int x, int y = 0) -><br>
> void","parameters":[{"label":"<wbr>int x"},{"label":"int y = 0"}]}<br>
>  # CHECK-DAG: {"label":"bar(float x = 0, int y = 42) -><br>
> void","parameters":[{"label":"<wbr>float x = 0"},{"label":"int y = 42"}]}<br>
> -# CHECK: ]}<br>
> +# CHECK-SAME: ]}<br>
><br>
>  Content-Length: 159<br>
><br>
><br>
> {"jsonrpc":"2.0","id":3,"<wbr>method":"textDocument/<wbr>signatureHelp","params":{"<wbr>textD<br>
> ocument":{"uri":"<a>file:///<wbr>doesnotexist.cpp</a>"},"position":<wbr>{"line":8,"character":9<br>
> }}}<br>
> -# CHECK: {"jsonrpc":"2.0","id":3,"<wbr>error":{"code":-<br>
> 32602,"message":"signatureHelp is called for non-added document"}}<br>
> +# CHECK: {"error":{"code":-32602,"<wbr>message":"signatureHelp is called for non-<br>
> added document"},"id":3,"jsonrpc":"<wbr>2.0"}<br>
><br>
>  # Shutdown.<br>
>  Content-Length: 49<br>
><br>
>  {"jsonrpc":"2.0","id":100000,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":100000,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/test/<wbr>clangd/unsupported-method.test<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/test/clangd/<wbr>unsupported-<br>
> method.test?rev=317486&r1=<wbr>317485&r2=317486&view=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/test/<wbr>clangd/unsupported-method.test (original)<br>
> +++ clang-tools-extra/trunk/test/<wbr>clangd/unsupported-method.test Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -1,4 +1,4 @@<br>
> -# RUN: clangd -run-synchronously < %s | FileCheck %s<br>
> +# RUN: clangd -pretty -run-synchronously < %s | FileCheck -strict-whitespace<br>
> %s<br>
>  # It is absolutely vital that this file has CRLF line endings.<br>
>  #<br>
>  Content-Length: 125<br>
> @@ -12,12 +12,16 @@ Content-Length: 143<br>
>  Content-Length: 92<br>
><br>
><br>
> {"jsonrpc":"2.0","id":1,"<wbr>method":"textDocument/<wbr>jumpInTheAirLikeYouJustDontCar<wbr>e<br>
> ","params":{}}<br>
> -# CHECK: {"jsonrpc":"2.0","id":1,"<wbr>error":{"code":-32601,"<wbr>message":"method not<br>
> found"}}<br>
> +#      CHECK:  "error": {<br>
> +# CHECK-NEXT:    "code": -32601,<br>
> +# CHECK-NEXT:    "message": "method not found"<br>
> +# CHECK-NEXT:  },<br>
> +# CHECK-NEXT:  "id": 1,<br>
> +# CHECK-NEXT:  "jsonrpc": "2.0"<br>
><br>
>  Content-Length: 44<br>
><br>
>  {"jsonrpc":"2.0","id":2,"<wbr>method":"shutdown"}<br>
> -# CHECK: {"jsonrpc":"2.0","id":2,"<wbr>result":null}<br>
>  Content-Length: 33<br>
><br>
>  {"jsonrpc":"2.0":"method":"<wbr>exit"}<br>
><br>
> Modified: clang-tools-extra/trunk/<wbr>unittests/clangd/CMakeLists.<wbr>txt<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/unittests/clangd/<wbr>CMakeLists.txt?rev=317486&r1=<wbr>317485&r2=317486&vie<br>
> w=diff<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/<wbr>unittests/clangd/CMakeLists.<wbr>txt (original)<br>
> +++ clang-tools-extra/trunk/<wbr>unittests/clangd/CMakeLists.<wbr>txt Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -10,6 +10,7 @@ include_directories(<br>
><br>
>  add_extra_unittest(ClangdTests<br>
>    ClangdTests.cpp<br>
> +  JSONExprTests.cpp<br>
>    TraceTests.cpp<br>
>    )<br>
><br>
><br>
> Added: clang-tools-extra/trunk/<wbr>unittests/clangd/<wbr>JSONExprTests.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" target="_blank">
http://llvm.org/viewvc/llvm-<wbr>project/clang-tools-</a><br>
> extra/trunk/unittests/clangd/<wbr>JSONExprTests.cpp?rev=317486&<wbr>view=auto<br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- clang-tools-extra/trunk/<wbr>unittests/clangd/<wbr>JSONExprTests.cpp (added)<br>
> +++ clang-tools-extra/trunk/<wbr>unittests/clangd/<wbr>JSONExprTests.cpp Mon Nov  6<br>
> 07:40:30 2017<br>
> @@ -0,0 +1,112 @@<br>
> +//===-- JSONExprTests.cpp - JSON expression unit tests ----------*- C++ -*-<br>
> ===//<br>
> +//<br>
> +//                     The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===------------------------<wbr>------------------------------<wbr>----------------<br>
> ===//<br>
> +<br>
> +#include "JSONExpr.h"<br>
> +<br>
> +#include "gmock/gmock.h"<br>
> +#include "gtest/gtest.h"<br>
> +<br>
> +namespace clang {<br>
> +namespace clangd {<br>
> +namespace json {<br>
> +namespace {<br>
> +<br>
> +std::string s(const Expr &E) { return llvm::formatv("{0}", E).str(); }<br>
> +std::string sp(const Expr &E) { return llvm::formatv("{0:2}", E).str(); }<br>
> +<br>
> +TEST(JSONExprTests, Types) {<br>
> +  EXPECT_EQ("true", s(true));<br>
> +  EXPECT_EQ("null", s(nullptr));<br>
> +  EXPECT_EQ("2.5", s(2.5));<br>
> +  EXPECT_EQ(R"("foo")", s("foo"));<br>
> +  EXPECT_EQ("[1,2,3]", s({1, 2, 3}));<br>
> +  EXPECT_EQ(R"({"x":10,"y":20})"<wbr>, s(obj{{"x", 10}, {"y", 20}}));<br>
> +}<br>
> +<br>
> +TEST(JSONExprTests, Constructors) {<br>
> +  // Lots of edge cases around empty and singleton init lists.<br>
> +  EXPECT_EQ("[[[3]]]", s({{{3}}}));<br>
> +  EXPECT_EQ("[[[]]]", s({{{}}}));<br>
> +  EXPECT_EQ("[[{}]]", s({{obj{}}}));<br>
> +  EXPECT_EQ(R"({"A":{"B":{}}})", s(obj{{"A", obj{{"B", obj{}}}}}));<br>
> +  EXPECT_EQ(R"({"A":{"B":{"X":"<wbr>Y"}}})",<br>
> +            s(obj{{"A", obj{{"B", obj{{"X", "Y"}}}}}}));<br>
> +}<br>
> +<br>
> +TEST(JSONExprTests, StringOwnership) {<br>
> +  char X[] = "Hello";<br>
> +  Expr Alias = static_cast<const char *>(X);<br>
> +  X[1] = 'a';<br>
> +  EXPECT_EQ(R"("Hallo")", s(Alias));<br>
> +<br>
> +  std::string Y = "Hello";<br>
> +  Expr Copy = Y;<br>
> +  Y[1] = 'a';<br>
> +  EXPECT_EQ(R"("Hello")", s(Copy));<br>
> +}<br>
> +<br>
> +TEST(JSONExprTests, CanonicalOutput) {<br>
> +  // Objects are sorted (but arrays aren't)!<br>
> +  EXPECT_EQ(R"({"a":1,"b":2,"c":<wbr>3})", s(obj{{"a", 1}, {"c", 3}, {"b", 2}}));<br>
> +  EXPECT_EQ(R"(["a","c","b"])", s({"a", "c", "b"}));<br>
> +  EXPECT_EQ("3", s(3.0));<br>
> +}<br>
> +<br>
> +TEST(JSONExprTests, Escaping) {<br>
> +  std::string test = {<br>
> +      0,                    // Strings may contain nulls.<br>
> +      '\b',   '\f',         // Have mnemonics, but we escape numerically.<br>
> +      '\r',   '\n',   '\t', // Escaped with mnemonics.<br>
> +      'S',    '\"',   '\\', // Printable ASCII characters.<br>
> +      '\x7f',               // Delete is not escaped.<br>
> +      '\xce', '\x94',       // Non-ASCII UTF-8 is not escaped.<br>
> +  };<br>
> +  EXPECT_EQ(R"("\u0000\u0008\<wbr>u000c\r\n\tS\"\\)"<br>
> +            u8"\x7fΔ\"",<br>
> +            s(test));<br>
> +<br>
> +  EXPECT_EQ(R"({"object keys are\nescaped":true})",<br>
> +            s(obj{{"object keys are\nescaped", true}}));<br>
> +}<br>
> +<br>
> +TEST(JSONExprTests, PrettyPrinting) {<br>
> +  EXPECT_EQ(<br>
> +      R"({<br>
> +  "empty_array": [],<br>
> +  "empty_object": {},<br>
> +  "full_array": [<br>
> +    1,<br>
> +    null<br>
> +  ],<br>
> +  "full_object": {<br>
> +    "nested_array": [<br>
> +      {<br>
> +        "property": "value"<br>
> +      }<br>
> +    ]<br>
> +  }<br>
> +})",<br>
> +      sp(obj{<br>
> +          {"empty_object", obj{}},<br>
> +          {"empty_array", {}},<br>
> +          {"full_array", {1, nullptr}},<br>
> +          {"full_object",<br>
> +           obj{<br>
> +               {"nested_array",<br>
> +                {obj{<br>
> +                    {"property", "value"},<br>
> +                }}},<br>
> +           }},<br>
> +      }));<br>
> +}<br>
> +<br>
> +} // namespace<br>
> +} // namespace json<br>
> +} // namespace clangd<br>
> +} // namespace clang<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank">
http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"><u></u> <u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#888888"><br>
<br clear="all">
</span><span class="m_7654313543924387895m7519689754056656976xm-775294545546306911hoenzb"><span style="color:#888888"><u></u><u></u></span></span></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal"><span class="m_7654313543924387895m7519689754056656976xm-775294545546306911hoenzb"><span style="font-family:"Calibri","sans-serif";color:#888888">--
</span><u></u><u></u></span></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#888888">Regards,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#888888">Ilya Biryukov<u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"><u></u> <u></u></span></p>
</div>
</div>
</div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:black"><u></u> <u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#888888"><br>
<br clear="all">
</span><span class="m_7654313543924387895hoenzb"><span style="color:#888888"><u></u><u></u></span></span></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal"><span class="m_7654313543924387895hoenzb"><span style="font-family:"Calibri","sans-serif";color:#888888">--
</span><u></u><u></u></span></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#888888">Regards,</span><u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Calibri","sans-serif";color:#888888">Ilya Biryukov<u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Regards,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Ilya Biryukov<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

</blockquote></div><br></div>