summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/Protocol.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Remove possibility to change compile database path at runtimeSimon Marchi2018-10-161-1/+10
| | | | | | | | | | | | | | Summary: This patch removes the possibility to change the compilation database path at runtime using the didChangeConfiguration request. Instead, it is suggested to use the setting on the initialize request, and clangd whenever the user wants to use a different build configuration. Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53220 llvm-svn: 344614
* Introduce completionItemKind capability support.Kadir Cetinkaya2018-09-271-0/+51
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D52616 llvm-svn: 343237
* [clangd] Allow all LSP methods to signal cancellation via $/cancelRequestSam McCall2018-09-131-33/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The cancelable scopes are managed by JSONRPCDispatcher so that all Handlers run in cancelable contexts. (Previously ClangdServer did this, for code completion only). Cancellation request processing is therefore also in JSONRPCDispatcher. (Previously it was in ClangdLSPServer). This doesn't actually make any new commands *respect* cancellation - they'd need to check isCancelled() and bail out. But it opens the door to doing this incrementally, and putting such logic in common machinery like TUScheduler. I also rewrote the ClangdServer class/threading comments because I wanted to add to it and I got carried away. Reviewers: ilya-biryukov, kadircet Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D52004 llvm-svn: 342135
* [clangd] Add "Deprecated" field to Symbol and CodeCompletion.Eric Liu2018-09-061-0/+2
| | | | | | | | | | | | | | Summary: Also set "deprecated" field in LSP CompletionItem. Reviewers: sammccall, kadircet Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D51724 llvm-svn: 341576
* [clangd] Add xrefs LSP boilerplate implementation.Sam McCall2018-09-051-0/+5
| | | | | | | | | | Reviewers: ilya-biryukov, ioeric Subscribers: MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D50896 llvm-svn: 341462
* [clangd] Initial cancellation mechanism for LSP requests.Kadir Cetinkaya2018-08-241-0/+33
| | | | | | | | | | | | Reviewers: ilya-biryukov, ioeric, hokein Reviewed By: ilya-biryukov Subscribers: mgorny, ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50502 llvm-svn: 340607
* [clangd] send diagnostic categories only when 'categorySupport'Alex Lorenz2018-08-221-0/+1
| | | | | | | | | | | | capability was given by the client After r339738 Clangd started sending categories with each diagnostic, but that broke the eglot client. This commit puts the categories behind a capability to fix that breakage. Differential Revision: https://reviews.llvm.org/D51077 llvm-svn: 340449
* [clangd] extend the publishDiagnostics response to send back fixits to theAlex Lorenz2018-08-101-0/+10
| | | | | | | | | | | | | | client if the client supports this extension This commit extends the 'textDocument/publishDiagnostics' notification sent from Clangd to the client. When it's enabled, Clangd sends out the fixits associated with the appropriate diagnostic in the body of the 'publishDiagnostics' notification. The client can enable this extension by setting 'clangdFixSupport' to true in the textDocument capabilities during initialization. Differential Revision: https://reviews.llvm.org/D50415 llvm-svn: 339454
* [clangd] allow clients to control the compilation database by passing inAlex Lorenz2018-08-011-1/+9
| | | | | | | | | | | | | compilationDatabaseChanges in the 'workspace/didChangeConfiguration' request This commit allows clangd to use an in-memory compilation database that's controlled from the LSP client (-compile_args_from=lsp). It extends the 'workspace/didChangeConfiguration' request to allow the client to pass in a compilation database subset that needs to be updated in the workspace. Differential Revision: https://reviews.llvm.org/D49758 llvm-svn: 338597
* [clangd] Receive compilationDatabasePath in 'initialize' requestSimon Marchi2018-08-011-1/+1
| | | | | | | | | | | | | | | | | | Summary: That way, as soon as the "initialize" is received by the server, it can start parsing/indexing with a valid compilation database and not have to wait for a an initial 'didChangeConfiguration' that might or might not happen. Then, when the user changes configuration, a didChangeConfiguration can be sent. Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewers: malaperle Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D49833 llvm-svn: 338518
* [clangd] Fix (most) naming warnings from clang-tidy. NFCIlya Biryukov2018-07-261-3/+3
| | | | llvm-svn: 338021
* [clangd] Upgrade logging facilities with levels and formatv.Sam McCall2018-07-111-3/+4
| | | | | | | | | | | | | | | | | | | | | | Summary: log() is split into four functions: - elog()/log()/vlog() have different severity levels, allowing filtering - dlog() is a lazy macro which uses LLVM_DEBUG - it logs to the logger, but conditionally based on -debug-only flag and is omitted in release builds All logging functions use formatv-style format strings now, e.g: log("Could not resolve URI {0}: {1}", URI, Result.takeError()); Existing log sites have been split between elog/log/vlog by best guess. This includes a workaround for passing Error to formatv that can be simplified when D49170 or similar lands. Subscribers: ilya-biryukov, javed.absar, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D49008 llvm-svn: 336785
* [clangd] Remove JSON library in favor of llvm/Support/JSONSam McCall2018-07-091-90/+92
| | | | | | | | | | | | | | | | | | | | Summary: The library has graduated from clangd to llvm/Support. This is a mechanical change to move to the new API and remove the old one. Main API changes: - namespace clang::clangd::json --> llvm::json - json::Expr --> json::Value - Expr::asString() etc --> Value::getAsString() etc - unsigned longs need a cast (due to r336541 adding lossless integer support) Reviewers: ilya-biryukov Subscribers: mgorny, ioeric, MaskRay, jkorous, omtcyfz, cfe-commits Differential Revision: https://reviews.llvm.org/D49077 llvm-svn: 336549
* [clangd] Implementation of textDocument/documentSymbolMarc-Andre Laperle2018-07-051-0/+5
| | | | | | | | | | | | | | | | | Summary: An AST-based approach is used to retrieve the document symbols rather than an in-memory index query. The index is not an ideal fit to achieve this because of the file-centric query being done here whereas the index is suited for project-wide queries. Document symbols also includes more symbols and need to keep the order as seen in the file. Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Subscribers: tomgr, ilya-biryukov, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47846 llvm-svn: 336386
* PrintEscapedString -> printEscapedStringJonas Devlieghere2018-05-311-1/+1
| | | | | | Update PrintEscapedString after renaming it in ADT. llvm-svn: 333673
* [clangd] Remove LSP command-based #include insertion.Eric Liu2018-05-151-22/+0
| | | | | | | | | | | | | | | | | Summary: clangd will populate #include insertions as addtionalEdits in completion items. The code completion tests in ClangdServerTest will be added back in D46497. Reviewers: ilya-biryukov, sammccall Reviewed By: ilya-biryukov Subscribers: klimek, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D46676 llvm-svn: 332362
* [clangd] Implementation of workspace/symbol requestMarc-Andre Laperle2018-04-231-0/+78
| | | | | | | | | | | | | | | | | | | | | | | Summary: This is a basic implementation of the "workspace/symbol" request which is used to find symbols by a string query. Since this is similar to code completion in terms of result, this implementation reuses the "fuzzyFind" in order to get matches. For now, the scoring algorithm is the same as code completion and improvements could be done in the future. The index model doesn't contain quite enough symbols for this to cover common symbols like methods, enum class enumerators, functions in unamed namespaces, etc. The index model will be augmented separately to achieve this. Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: jkorous, hokein, simark, sammccall, klimek, mgorny, ilya-biryukov, mgrang, jkorous-apple, ioeric, MaskRay, cfe-commits Differential Revision: https://reviews.llvm.org/D44882 llvm-svn: 330637
* [clangd] Use operator<< to prevent printers issues in GtestMarc-Andre Laperle2018-04-101-0/+21
| | | | | | | | | | | | | | | | | | | | | | | Summary: It is possible that there will be two different instantiations of the printer template for a given type and some tests could end up calling the wrong (default) one. For example, it was seen in CodeCompleteTests.cpp when printing CompletionItems that it would use the wrong printer because the default is also instantiated in ClangdTests.cpp. With this change, objects that were previously printed with a custom Printer now get printed through the operator<< which is declared alongside the class. This rule of the thumb should make it less error-prone. Reviewers: simark, ilya-biryukov, sammccall Reviewed By: simark, ilya-biryukov, sammccall Subscribers: bkramer, hokein, sammccall, klimek, ilya-biryukov, jkorous-apple, ioeric, MaskRay, cfe-commits Differential Revision: https://reviews.llvm.org/D44764 llvm-svn: 329725
* [clangd] Support incremental document syncingSimon Marchi2018-03-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds support for incremental document syncing, as described in the LSP spec. The protocol specifies ranges in terms of Position (a line and a character), and our drafts are stored as plain strings. So I see two things that may not be super efficient for very large files: - Converting a Position to an offset (the positionToOffset function) requires searching for end of lines until we reach the desired line. - When we update a range, we construct a new string, which implies copying the whole document. However, for the typical size of a C++ document and the frequency of update (at which a user types), it may not be an issue. This patch aims at getting the basic feature in, and we can always improve it later if we find it's too slow. Signed-off-by: Simon Marchi <simon.marchi@ericsson.com> Reviewers: malaperle, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: MaskRay, klimek, mgorny, ilya-biryukov, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D44272 llvm-svn: 328500
* [clangd] don't insert new includes if either original header or canonical ↵Eric Liu2018-02-261-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | header is already included. Summary: Changes: o Store both the original header and the canonical header in LSP command. o Also check that both original and canonical headers are not already included by comparing both resolved header path and written literal includes. This addresses the use case where private IWYU pragma is defined in a private header while it would still be preferrable to include the private header, in the internal implementation file. If we have seen that the priviate header is already included, we don't try to insert the canonical include. Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D43510 llvm-svn: 326070
* [clangd] Extend textDocument/didChange to specify whether diagnostics should ↵Eric Liu2018-02-221-1/+2
| | | | | | | | | | | | | | | | be generated. Summary: This would allow us to disable diagnostics when didChange is called but diagnostics are not wanted (e.g. code completion). Reviewers: sammccall Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D43634 llvm-svn: 325813
* [clangd] DidChangeConfiguration NotificationSimon Marchi2018-02-221-0/+10
| | | | | | | | | | | | | | | | | | | | Summary: Implementation of DidChangeConfiguration notification handling in clangd. This currently only supports changing one setting: the path of the compilation database to be used for the current project. In other words, it is no longer necessary to restart clangd with a different command line argument in order to change the compilation database. Reviewers: malaperle, krasimir, bkramer, ilya-biryukov Subscribers: jkorous-apple, ioeric, simark, klimek, ilya-biryukov, arphaman, rwols, cfe-commits Differential Revision: https://reviews.llvm.org/D39571 Signed-off-by: Simon Marchi <simon.marchi@ericsson.com> Signed-off-by: William Enright <william.enright@polymtl.ca> llvm-svn: 325784
* [clangd] Rename some protocol field to lower caseMarc-Andre Laperle2018-02-161-6/+6
| | | | | | | | | | | | | Summary: Also fixes a GCC compilation error. Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Subscribers: klimek, ilya-biryukov, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D43411 llvm-svn: 325409
* [clangd] Implement textDocument/hoverMarc-Andre Laperle2018-02-161-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Implemention of textDocument/hover as described in LSP definition. This patch adds a basic Hover implementation. When hovering a variable, function, method or namespace, clangd will return a text containing the declaration's scope, as well as the declaration of the hovered entity. For example, for a variable: Declared in class Foo::Bar int hello = 2 For macros, the macro definition is returned. This patch doesn't include: - markdown support (the client I use doesn't support it yet) - range support (optional in the Hover response) - comments associated to variables/functions/classes They are kept as future work to keep this patch simpler. I added tests in XRefsTests.cpp. hover.test contains one simple smoketest to make sure the feature works from a black box perspective. Reviewers: malaperle, krasimir, bkramer, ilya-biryukov Subscribers: sammccall, mgrang, klimek, rwols, ilya-biryukov, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D35894 Signed-off-by: Simon Marchi <simon.marchi@ericsson.com> Signed-off-by: William Enright <william.enright@polymtl.ca> llvm-svn: 325395
* [clangd] collect symbol #include & insert #include in global code completion.Eric Liu2018-02-161-0/+29
| | | | | | | | | | | | | | | | | | Summary: o Collect suitable #include paths for index symbols. This also does smart mapping for STL symbols and IWYU pragma (code borrowed from include-fixer). o For global code completion, add a command for inserting new #include in each code completion item. Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, mgorny, ilya-biryukov, jkorous-apple, hintonda, cfe-commits Differential Revision: https://reviews.llvm.org/D42640 llvm-svn: 325343
* [clangd] Assert path is absolute when assigning to URIForFile.Ilya Biryukov2018-02-161-5/+8
| | | | | | | | | | | | | | | | Summary: The assertion will point directly to misbehaving code, so that debugging related problems (like the one fixed by r325029) is easier. Reviewers: hokein, ioeric, sammccall Reviewed By: sammccall Subscribers: klimek, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D43246 llvm-svn: 325337
* [clangd] Enable snippet completion based on client capabilities.Ilya Biryukov2018-02-151-0/+36
| | | | | | | | | | | | | | Summary: And remove -enable-snippets flag. Reviewers: hokein, ioeric, sammccall Reviewed By: ioeric Subscribers: klimek, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D43229 llvm-svn: 325242
* [clangd] Add a test URI scheme for lit tests to unbreak platform-specific ↵Eric Liu2018-01-311-1/+1
| | | | | | | | | | | | | | | | URI failures. Summary: This should also fix the current windows buildbot breakage (http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/9838/steps/ninja%20check%201/logs/stdio) Reviewers: sammccall Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D42735 llvm-svn: 323885
* [clangd] Pass Context implicitly using TLS.Sam McCall2018-01-311-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Instead of passing Context explicitly around, we now have a thread-local Context object `Context::current()` which is an implicit argument to every function. Most manipulation of this should use the WithContextValue helper, which augments the current Context to add a single KV pair, and restores the old context on destruction. Advantages are: - less boilerplate in functions that just propagate contexts - reading most code doesn't require understanding context at all, and using context as values in fewer places still - fewer options to pass the "wrong" context when it changes within a scope (e.g. when using Span) - contexts pass through interfaces we can't modify, such as VFS - propagating contexts across threads was slightly tricky (e.g. copy vs move, no move-init in lambdas), and is now encapsulated in the threadpool Disadvantages are all the usual TLS stuff - hidden magic, and potential for higher memory usage on threads that don't use the context. (In practice, it's just one pointer) Reviewers: ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D42517 llvm-svn: 323872
* [clangd] Fix windows path manipulationSam McCall2018-01-301-2/+6
| | | | llvm-svn: 323751
* [clangd] Use new URI with scheme support in place of the existing LSP URIEric Liu2018-01-291-32/+21
| | | | | | | | | | | | | | | | | | Summary: o Replace the existing clangd::URI with a wrapper of FileURI which also carries a resolved file path. o s/FileURI/URI/ o Get rid of the URI hack in vscode extension. Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D42419 llvm-svn: 323660
* [clangd] Add ClangdUnit diagnostics tests using annotated code.Sam McCall2018-01-251-0/+28
| | | | | | | | | | | | | | | | | | | Summary: This adds checks that our diagnostics emit correct ranges in a bunch of cases, as promised in D41118. The diagnostics-preamble test is also converted and extended to be a little more precise. diagnostics.test stays around as the smoke test for this feature. Reviewers: ilya-biryukov Subscribers: klimek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D41454 llvm-svn: 323448
* [clangd] Get rid of unnecessary global variable. No functionality change.Benjamin Kramer2017-12-281-1/+1
| | | | llvm-svn: 321525
* [clangd] Add debug printers for basic protocol types. NFCSam McCall2017-12-201-0/+16
| | | | llvm-svn: 321161
* [clangd] Put all #includes in one block in clangd source files. NFCEric Liu2017-12-141-1/+0
| | | | | | | Clang-format categorizes and sorts #includes with style. It doesn't make sense to manually managing #include blocks. llvm-svn: 320743
* [clangd] Document highlights for clangdIlya Biryukov2017-12-121-0/+7
| | | | | | | | | | | | | | | | | Summary: Implementation of Document Highlights Request as described in LSP. Contributed by William Enright (nebiroth). Reviewers: malaperle, krasimir, bkramer, ilya-biryukov Reviewed By: malaperle Subscribers: mgrang, sammccall, klimek, ioeric, rwols, cfe-commits, arphaman, ilya-biryukov Differential Revision: https://reviews.llvm.org/D38425 llvm-svn: 320474
* [clangd] New conventions for JSON-marshalling functions, centralize machinerySam McCall2017-11-301-382/+181
| | | | | | | | | | | | | | | | | | Summary: - JSON<->Obj interface is now ADL functions, so they play nicely with enums - recursive vector/map parsing and ObjectMapper moved to JSONExpr and tested - renamed (un)parse to (de)serialize, since text -> JSON is called parse - Protocol.cpp gets a bit shorter Sorry for the giant patch, it's prety mechanical though Reviewers: ilya-biryukov Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40596 llvm-svn: 319478
* [clangd] Simplify common JSON-parsing patterns in Protocol.Sam McCall2017-11-291-366/+258
| | | | | | | | | | | | | | | | | | | | | Summary: This makes the parse() functions about as short as they can be given the current signature, and moves all array-traversal etc code to a central location. We keep the ability to distinguish between optional and required fields: and we don't propagate parse errors for optional fields. I've made most fields required per the LSP spec - the looseness we had here was mostly a historical accident I think. Reviewers: ioeric Subscribers: klimek, cfe-commits, ilya-biryukov Differential Revision: https://reviews.llvm.org/D40564 llvm-svn: 319309
* [clangd] Switch from YAMLParser to JSONExprSam McCall2017-11-281-783/+325
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: - Converted Protocol.h parse() functions to take JSON::Expr. These no longer detect and log unknown fields, as this is not that useful and no longer free. I haven't changed the error handling too much: fields that were treated as optional before are still optional, even when it's wrong. Exception: object properties with the wrong type are now ignored. - Made JSONRPCDispatcher parse using json::parse - The bug where 'method' must come before 'params' in the stream is fixed as a side-effect. (And the same bug in executeCommand). - Some parser crashers fixed as a side effect. e.g. https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=3890 - The debug stream now prettyprints the input messages with --pretty. - Request params are attached to traces when tracing is enabled. - Fixed some bugs in tests (errors tolerated by YAMLParser, and off-by-ones in Content-Length that our null-termination was masking) - Fixed a random double-escape bug in ClangdLSPServer (it was our last use of YAMLParser!) Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D40406 llvm-svn: 319159
* Make helper function static. NFC.Benjamin Kramer2017-11-271-1/+1
| | | | llvm-svn: 319022
* [clangd] clang-format the source code. NFC.Ilya Biryukov2017-11-151-1/+1
| | | | llvm-svn: 318317
* [clangd] Support returning a limited number of completion results.Sam McCall2017-11-151-0/+7
| | | | | | | | | | | | | | | | | | | | Summary: All results are scored, we only process CodeCompletionStrings for the winners. We now return CompletionList rather than CompletionItem[] (both are valid). sortText is now based on CodeCompletionResult::orderedName (mostly the same). This is the first clangd-only completion option, so plumbing changed. It requires a small clangd patch (exposing CodeCompletionResult::orderedName). (This can't usefully be enabled yet: we don't support server-side filtering) Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39852 llvm-svn: 318287
* [clangd] Add rename support.Haojian Wu2017-11-091-0/+48
| | | | | | | | | | | | | | | | | | | Summary: Make clangd handle "textDocument/rename" request. The rename functionality comes from the "local-rename" sub-tool of clang-refactor. Currently clangd only supports local rename (only symbol occurrences in the main file will be renamed). Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: cfe-commits, ioeric, arphaman, mgorny Differential Revision: https://reviews.llvm.org/D39676 llvm-svn: 317780
* [clangd] Sort completion results.Sam McCall2017-11-081-0/+5
| | | | | | | | | | | | | | Summary: This is (probably) not required by LSP, but at least one buggy client wants it. It also simplifies some tests - changed a few completion tests to use -pretty. Reviewers: hokein, malaperle Subscribers: ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D39738 llvm-svn: 317670
* Adds a json::Expr type to represent intermediate JSON expressions.Sam McCall2017-11-061-131/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This form can be created with a nice clang-format-friendly literal syntax, and gets escaping right. It knows how to call unparse() on our Protocol types. All the places where we pass around JSON internally now use this type. Object properties are sorted (stored as std::map) and so serialization is canonicalized, with optional prettyprinting (triggered by a -pretty flag). This makes the lit tests much nicer to read and somewhat nicer to debug. (Unfortunately the completion tests use CHECK-DAG, which only has line-granularity, so pretty-printing is disabled there. In future we could make completion ordering deterministic, or switch to unittests). Compared to the current approach, it has some efficiencies like avoiding copies of string literals used as object keys, but is probably slower overall. I think the code/test quality benefits are worth it. This patch doesn't attempt to do anything about JSON *parsing*. It takes direction from the proposal in this doc[1], but is limited in scope and visibility, for now. I am of half a mind just to use Expr as the target of a parser, and maybe do a little string deduplication, but not bother with clever memory allocation. That would be simple, and fast enough for clangd... [1] https://docs.google.com/document/d/1OEF9IauWwNuSigZzvvbjc1cVS1uGHRyGTXaoy3DjqM4/edit +cc d0k so he can tell me not to use std::map. Reviewers: ioeric, malaperle Subscribers: bkramer, ilya-biryukov, mgorny, klimek Differential Revision: https://reviews.llvm.org/D39435 llvm-svn: 317486
* [clangd] Handle clangd.applyFix server-sideMarc-Andre Laperle2017-11-031-0/+160
| | | | | | | | | | | | | | | | | | | | | | | Summary: When the user selects a fix-it (or any code action with commands), it is possible to let the client forward the selected command to the server. When the clangd.applyFix command is handled on the server, it can send a workspace/applyEdit request to the client. This has the advantage that the client doesn't explicitly have to know how to handle clangd.applyFix. Therefore, the code to handle clangd.applyFix in the VS Code extension (and any other Clangd client) is not required anymore. Reviewers: ilya-biryukov, sammccall, Nebiroth, hokein Reviewed By: hokein Subscribers: ioeric, hokein, rwols, puremourning, bkramer, ilya-biryukov Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D39276 llvm-svn: 317322
* [clangd] less boilerplate in RPC dispatchSam McCall2017-10-121-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Make the ProtocolHandlers glue between JSONRPCDispatcher and ClangdLSPServer generic. Eliminate small differences between methods, de-emphasize the unimportant distinction between notifications and methods. ClangdLSPServer is no longer responsible for producing a complete JSON-RPC response, just the JSON of the result object. (In future, we should move that JSON serialization out, too). Handler methods now take a context object that we may hang more functionality off in the future. Added documentation to ProtocolHandlers. Reviewers: ilya-biryukov, bkramer Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D38464 llvm-svn: 315577
* [clangd] clang-format the source code. NFC.Ilya Biryukov2017-10-101-4/+8
| | | | llvm-svn: 315317
* [clangd] Add textDocument/signatureHelpIlya Biryukov2017-10-061-0/+55
| | | | | | | | | | | | | | | | | | Summary: Makes clangd respond to a client's "textDocument/signatureHelp" request by presenting function/method overloads. Patch by Raoul Wols. Reviewers: bkramer, ilya-biryukov, krasimir Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D38048 llvm-svn: 315055
* [clangd] Handle workspace/didChangeWatchedFilesMarc-Andre Laperle2017-10-021-0/+78
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The client can send notifications when it detects watched files have changed. This patch adds the protocol handling for this type of notification. For now, the notification will be passed down to the ClangdServer, but it will not be acted upon. However, this will become useful for the indexer to react to file changes. The events could also potentially be used to invalidate other caches (compilation database, etc). This change also updates the VSCode extension so that it sends the events. Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Reviewers: ilya-biryukov, Nebiroth Subscribers: ilya-biryukov Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D38422 llvm-svn: 314693
OpenPOWER on IntegriCloud