summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/ClangdLSPServer.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Send empty diagnostics when a file is closedIlya Biryukov2019-03-251-7/+23
| | | | | | | | | | | | | | | | | | | | | | Summary: The LSP clients cannot know clangd will not send diagnostic updates for closed files, so we send them an empty list of diagnostics to avoid showing stale diagnostics for closed files in the UI, e.g. in the "Problems" pane of VSCode. Fixes PR41217. Reviewers: hokein Reviewed By: hokein Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59757 llvm-svn: 356880
* [clangd] Add support for type hierarchy (super types only for now)Kadir Cetinkaya2019-03-191-0/+9
| | | | | | | | | | | | | | | | | | | | | | | Summary: Patch by Nathan Ridge(@nridge)! This is an LSP extension proposed here: https://github.com/Microsoft/vscode-languageserver-node/pull/426 An example client implementation can be found here: https://github.com/theia-ide/theia/pull/3802 Reviewers: kadircet, sammccall Reviewed By: kadircet Subscribers: jdoerfert, sammccall, cfe-commits, mgorny, dschaefer, simark, ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet Tags: #clang Differential Revision: https://reviews.llvm.org/D56370 llvm-svn: 356445
* Remove trailing semicolon. NFCI.Simon Pilgrim2019-02-031-1/+1
| | | | llvm-svn: 352990
* [Clangd] textDocument/definition and textDocument/declaration "bounce" ↵Sam McCall2019-02-021-7/+33
| | | | | | | | | | | | | | | | | | between definition and declaration location when they are distinct. Summary: This helps minimize the disruption of not returning declarations as part of a find-definition response (r352864). Reviewers: hokein Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, ilya-biryukov Tags: #clang Differential Revision: https://reviews.llvm.org/D57580 llvm-svn: 352953
* [clangd] Implement textDocument/declaration from LSP 3.14Sam McCall2019-02-011-2/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: LSP now reflects the declaration/definition distinction. Language server changes: - textDocument/definition now returns a definition if one is found, otherwise the declaration. It no longer returns declaration + definition if they are distinct. - textDocument/declaration returns the best declaration we can find. - For macros, the active macro definition is returned for both methods. - For include directive, the top of the target file is returned for both. There doesn't appear to be a discovery mechanism (we can't return everything to clients that only know about definition), so this changes existing behavior. In practice, it should greatly reduce the fraction of the time we need to show the user a menu of options. C++ API changes: - findDefinitions is replaced by locateSymbolAt, which returns a vector<LocatedSymbol> - one for each symbol under the cursor. - this contains the preferred declaration, the definition (if found), and the symbol name This API enables some potentially-neat extensions, like swapping between decl and def, and exposing the symbol name to the UI in the case of multiple symbols. Reviewers: hokein Subscribers: ilya-biryukov, javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D57388 llvm-svn: 352864
* [clangd] Drop fixes if replying with tweaks resulted in an errorIlya Biryukov2019-01-301-8/+2
| | | | | | | | | | This should not happen in normal operation, as it implies that the diagnostics with some available fixes were produced but the AST is invalid. Moreover, the code had an error: always returned code actions ignoring the SupportsCodeAction capability and writing a test for this is impossible, since this can only happen due to programmer's error rather than invalid inputs. llvm-svn: 352624
* [clangd] Fix a use after moveIlya Biryukov2019-01-301-2/+2
| | | | | | Introduced in r352494. llvm-svn: 352612
* [clangd] Interfaces for writing code tweaksIlya Biryukov2019-01-291-16/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The code tweaks are an implementation of mini-refactorings exposed via the LSP code actions. They run in two stages: - Stage 1. Decides whether the action is available to the user and collects all the information required to finish the action. Should be cheap, since this will run over all the actions known to clangd on each textDocument/codeAction request from the client. - Stage 2. Uses information from stage 1 to produce the actual edits that the code action should perform. This stage can be expensive and will only run if the user chooses to perform the specified action in the UI. One unfortunate consequence of this change is increased latency of processing the textDocument/codeAction requests, which now wait for an AST. However, we cannot avoid this with what we have available in the LSP today. Reviewers: kadircet, ioeric, hokein, sammccall Reviewed By: sammccall Subscribers: mgrang, mgorny, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D56267 llvm-svn: 352494
* [clangd] Support clang-tidy configuration in clangd.Haojian Wu2019-01-221-1/+3
| | | | | | | | | | | | | | | | | | | | | Summary: This patch adds some basic supports for clang-tidy configurations in clangd: - clangd will respect .clang-tidy configurations for each file - we don't aim to support all clang-tidy options in clangd, only a small subset of condfigurations (options related to which checks will be enabled) are supported. - add a `clang-tidy-checks` CLI option that can override options from .clang-tidy file Reviewers: ilya-biryukov, sammccall Reviewed By: sammccall Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D55256 llvm-svn: 351792
* [clangd] Filter out plugin related flags and move all commandline ↵Kadir Cetinkaya2019-01-221-1/+2
| | | | | | | | | | | | | | | | | | | | manipulations into OverlayCDB. Summary: Some projects make use of clang plugins when building, but clangd is not aware of those plugins therefore can't work with the same compile command arguments. There were multiple places clangd performed commandline manipulations, this one also moves them all into OverlayCDB. Reviewers: ilya-biryukov Subscribers: klimek, sammccall, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D56841 llvm-svn: 351788
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [clangd] Add Limit parameter for xref.Haojian Wu2019-01-141-1/+1
| | | | | | | | | | Reviewers: sammccall Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D56597 llvm-svn: 351081
* [clangd] Remove 'using namespace llvm' from .cpp files. NFCIlya Biryukov2019-01-071-94/+96
| | | | | | | | The new guideline is to qualify with 'llvm::' explicitly both in '.h' and '.cpp' files. This simplifies moving the code between header and source files and is easier to keep consistent. llvm-svn: 350531
* [clangd] Check preceding char when completion triggers on ':' or '>'Ilya Biryukov2019-01-031-1/+49
| | | | | | | | | | | | | | | | | | Summary: Only run completion when we were trigerred on '->' and '::', otherwise send an error code in return. To avoid automatically invoking completions in cases like 'a >^' or 'a ? b :^'. Reviewers: hokein Reviewed By: hokein Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D55994 llvm-svn: 350304
* [clangd] clang-format everything. NFCIlya Biryukov2019-01-031-19/+19
| | | | llvm-svn: 350303
* [clangd] Expose FileStatus to LSP.Haojian Wu2018-12-201-1/+14
| | | | | | | | | | | | | Summary: Add an LSP extension "textDocument/clangd.fileStatus" to emit file-status information. Reviewers: ilya-biryukov Subscribers: javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D55363 llvm-svn: 349768
* [clangd] Canonicalize file path in URIForFile.Eric Liu2018-11-281-1/+1
| | | | | | | | | | | | | | | | | | | Summary: File paths in URIForFile can come from index or local AST. Path from index goes through URI transformation and the final path is resolved by URI scheme and could be potentially different from the original path. Hence, we should do the same transformation for all paths. We do this in URIForFile, which now converts a path to URI and back to a canonicalized path. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54845 llvm-svn: 347739
* [clangd] textDocument/SymbolInfo extensionJan Korous2018-11-271-0/+7
| | | | | | | | | | New method returning symbol info for given source position. Differential Revision: https://reviews.llvm.org/D54799 rdar://problem/46050281 llvm-svn: 347675
* [clangd] Enable auto-index behind a flag.Sam McCall2018-11-261-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Ownership and configuration: The auto-index (background index) is maintained by ClangdServer, like Dynamic. (This means ClangdServer will be able to enqueue preamble indexing in future). For now it's enabled by a simple boolean flag in ClangdServer::Options, but we probably want to eventually allow injecting the storage strategy. New 'sync' command: In order to meaningfully test the integration (not just unit-test components) we need a way for tests to ensure the asynchronous index reads/writes occur before a certain point. Because these tests and assertions are few, I think exposing an explicit "sync" command for use in tests is simpler than allowing threading to be completely disabled in the background index (as we do for TUScheduler). Bugs: I fixed a couple of trivial bugs I found while testing, but there's one I can't. JSONCompilationDatabase::getAllFiles() may return relative paths, and currently we trigger an assertion that assumes they are absolute. There's no efficient way to resolve them (you have to retrieve the corresponding command and then resolve against its directory property). In general I think this behavior is broken and we should fix it in JSONCompilationDatabase and require CompilationDatabase::getAllFiles() to be absolute. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D54894 llvm-svn: 347567
* [clangd] Add support for hierarchical documentSymbolIlya Biryukov2018-11-231-8/+47
| | | | | | | | | | | | Reviewers: ioeric, sammccall, simark Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52311 llvm-svn: 347498
* [clangd] Cleanup: stop passing around list of supported URI schemes.Eric Liu2018-11-221-37/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Instead of passing around a list of supported URI schemes in clangd, we expose an interface to convert a path to URI using any compatible scheme that has been registered. It favors customized schemes and falls back to "file" when no other scheme works. Changes in this patch are: - URI::create(AbsPath, URISchemes) -> URI::create(AbsPath). The new API finds a compatible scheme from the registry. - Remove URISchemes option everywhere (ClangdServer, SymbolCollecter, FileIndex etc). - Unit tests will use "unittest" by default. - Move "test" scheme from ClangdLSPServer to ClangdMain.cpp, and only register the test scheme when lit-test or enable-lit-scheme is set. (The new flag is added to make lit protocol.test work; I wonder if there is alternative here.) Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54800 llvm-svn: 347467
* [clangd] Add fallbackFlags initialization extension.Sam McCall2018-11-021-3/+4
| | | | | | | | | | | | | | Summary: This allows customizing the flags used when no compile database is available. It addresses some uses of the old extraFlags extension. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53688 llvm-svn: 345973
* [clangd] Make in-memory CDB always available as an overlay, refactor.Sam McCall2018-11-021-39/+16
| | | | | | | | | | | | | | | | | | | | | | | Summary: The new implementation is a GlobalCompilationDatabase that overlays a base. Normally this is the directory-based CDB. To preserve the behavior of compile_args_from=LSP, the base may be null. The OverlayCDB is always present, and so the extensions to populate it are always supported. It also allows overriding the flags of the fallback command. This is just unit-tested for now, but the plan is to expose this as an extension on the initialize message. This addresses use cases like https://github.com/thomasjo/atom-ide-cpp/issues/16 Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53687 llvm-svn: 345970
* [clangd] Remove didOpen extraFlags extension.Sam McCall2018-11-021-14/+0
| | | | | | | | | | | | | | | | | | | | Summary: This was added in D34947 to support YCM, but YCM actually provides *all* args, and this was never actually used. Meanwhile, we grew another extension that allows specifying all args. I did find one user of this extension: https://github.com/thomasjo/atom-ide-cpp. I'll reach out, there are multiple good alternatives: - compile_commands.txt can serve the same purpose as .clang_complete there - we can add an extension to support setting the fallback command Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53641 llvm-svn: 345969
* [clangd] Clean up LSP structs around configuration. NFC, no protocol changes.Sam McCall2018-10-251-21/+17
| | | | | | | | | - align struct names/comments with LSP, remove redundant "clangd" prefixes. - don't map config structs as Optional<> when their presence/absence doesn't signal anything and all fields must have sensible "absent" values - be more lax around parsing of 'any'-typed messages llvm-svn: 345235
* [clangd] Fix -compile-commands-dir flag, broken in r345031Sam McCall2018-10-251-2/+3
| | | | llvm-svn: 345232
* [clangd] Don't invalidate LSP-set compile commands when closing a file.Sam McCall2018-10-251-7/+0
| | | | | | | | | | | | | | | | Summary: It doesn't make much sense: setting them is not coupled to opening the file, it's an asynchronous notification. I don't think this is a breaking change - this behavior is hard to observe! Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53642 llvm-svn: 345231
* [clangd] When replying, log the method name and latency.Sam McCall2018-10-241-24/+18
| | | | | | | | | | | | | | Summary: This information is strictly available in the log (you can find the original call) but it makes the log easier to follow in practice. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53647 llvm-svn: 345150
* [clangd] Ensure that we reply to each call exactly once. NFC (I think!)Sam McCall2018-10-241-31/+76
| | | | | | | | | | | | | | | | | | Summary: In debug builds, getting this wrong will trigger asserts. In production builds, it will send an error reply if none was sent, and drop redundant replies. (And log). No tests because this is always a programming error. (We did have some cases of this, but I fixed them with the new dispatcher). Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53399 llvm-svn: 345144
* [clangd] Embed fixes as CodeAction, instead of clangd_fixes. Clean up ↵Sam McCall2018-10-241-37/+11
| | | | | | | | | | | | | | | | | | | serialization. Summary: CodeAction provides us with a standard way of representing fixes inline, so use it, replacing our existing ad-hoc extension. After this, it's easy to serialize diagnostics using the structured toJSON/Protocol.h mechanism rather than assembling JSON ad-hoc. Reviewers: hokein, arphaman Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53391 llvm-svn: 345119
* [clangd] Lazily create CDB, remove setCompileCommandsDir.Sam McCall2018-10-231-31/+16
| | | | | | | | | | | | | | Summary: The only way to actually set the directory is at initialize time, so now CDB is lazy we can pass it to the constructor. Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53572 llvm-svn: 345031
* [clangd] Remove caching of compilation database commands.Sam McCall2018-10-231-13/+2
| | | | | | | | | | | | | | | | | Summary: The CDB implementations used in open-source code are fast, and our private slow CDB will soon do the relevant caching itself. Simplifying the GlobalCDB layer in clangd is important to get auto-index implemented at the right layer. Reviewers: ioeric, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53439 llvm-svn: 345024
* [clangd] Namespace style cleanup in cpp files. NFC.Sam McCall2018-10-201-40/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Standardize on the most common namespace setup in our *.cpp files: using namespace llvm; namespace clang { namespace clangd { void foo(StringRef) { ... } And remove redundant llvm:: qualifiers. (Except for cases like make_unique where this causes problems with std:: and ADL). This choice is pretty arbitrary, but some broad consistency is nice. This is going to conflict with everything. Sorry :-/ Squash the other configurations: A) using namespace llvm; using namespace clang; using namespace clangd; void clangd::foo(StringRef); This is in some of the older files. (It prevents accidentally defining a new function instead of one in the header file, for what that's worth). B) namespace clang { namespace clangd { void foo(llvm::StringRef) { ... } This is fine, but in practice the using directive often gets added over time. C) namespace clang { namespace clangd { using namespace llvm; // inside the namespace This was pretty common, but is a bit misleading: name lookup preferrs clang::clangd::foo > clang::foo > llvm:: foo (no matter where the using directive is). llvm-svn: 344850
* [clangd] Set workspace root when initializing ClangdServer, disallow mutation.Sam McCall2018-10-191-5/+4
| | | | | | | | | | | | | | | | | | Summary: Rename instance variable to WorkspaceRoot to match what we call it internally. Add fixme to set it automatically. Don't do it yet, clients have assumptions that the constructor won't access the FS. Don't second-guess the provided root. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53404 llvm-svn: 344787
* [clangd] Enforce rules around "initialize" request, and create ClangdServer ↵Sam McCall2018-10-181-7/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lazily. Summary: LSP is a slightly awkward map to C++ object lifetimes: the initialize request is part of the protocol and provides information that doesn't change over the lifetime of the server. Until now, we handled this by initializing ClangdServer and ClangdLSPServer right away, and making anything that can be set in the "initialize" request mutable. With this patch, we create ClangdLSPServer immediately, but defer creating ClangdServer until "initialize". This opens the door to passing the relevant initialize params in the constructor and storing them immutably. (That change isn't actually done in this patch). To make this safe, we have the MessageDispatcher enforce that the "initialize" method is called before any other (as required by LSP). That way each method handler can assume Server is initialized, as today. As usual, while implementing this I found places where our test cases violated the protocol. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53398 llvm-svn: 344741
* [clangd] Lay JSONRPCDispatcher to rest.Sam McCall2018-10-181-164/+351
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Most of its functionality is moved into ClangdLSPServer. The decoupling between JSONRPCDispatcher, ProtocolCallbacks, ClangdLSPServer was never real, and only served to obfuscate. Some previous implicit/magic stuff is now explicit: - the return type of LSP method calls are now in the signature - no more reply() that gets the ID using global context magic - arg tracing no longer relies on RequestArgs::stash context magic either This is mostly refactoring, but some deliberate fixes while here: - LSP method params are now by const reference - notifications and calls are now distinct namespaces. (some tests had protocol errors and needed updating) - we now reply to calls we failed to decode - outgoing calls use distinct IDs A few error codes and message IDs changed in unimportant ways (see tests). Reviewers: ioeric Subscribers: mgorny, ilya-biryukov, javed.absar, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53387 llvm-svn: 344737
* [clangd] Simplify client capabilities parsing.Sam McCall2018-10-171-23/+8
| | | | | | | | | | | | | | | | | | Summary: Instead of parsing into structs that mirror LSP, simply parse into a flat struct that contains the info we need. This is an exception to our strategy with Protocol.h, which seems justified: - the structure here is very large and deeply nested - we care about almost none of it - we should never have to serialize client capabilities Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53266 llvm-svn: 344673
* [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction. ↵Sam McCall2018-10-171-21/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | (re-land r344620) Summary: This paves the way for alternative transports (mac XPC, maybe messagepack?), and also generally improves layering: testing ClangdLSPServer becomes less of a pipe dream, we split up the JSONOutput monolith, etc. This isn't a final state, much of what remains in JSONRPCDispatcher can go away, handlers can call reply() on the transport directly, JSONOutput can be renamed to StreamLogger and removed, etc. But this patch is sprawling already. The main observable change (see tests) is that hitting EOF on input is now an error: the client should send the 'exit' notification. This is defensible: the protocol doesn't spell this case out. Reproducing the current behavior for all combinations of shutdown/exit/EOF clutters interfaces. We can iterate on this if desired. Reviewers: jkorous, ioeric, hokein Subscribers: mgorny, ilya-biryukov, MaskRay, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53286 llvm-svn: 344672
* Revert "[clangd] Refactor JSON-over-stdin/stdout code into Transport ↵Krasimir Georgiev2018-10-161-22/+21
| | | | | | | | | abstraction." This reverts commit r344620. Breaks upstream bots. llvm-svn: 344637
* [clangd] Refactor JSON-over-stdin/stdout code into Transport abstraction.Sam McCall2018-10-161-21/+22
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This paves the way for alternative transports (mac XPC, maybe messagepack?), and also generally improves layering: testing ClangdLSPServer becomes less of a pipe dream, we split up the JSONOutput monolith, etc. This isn't a final state, much of what remains in JSONRPCDispatcher can go away, handlers can call reply() on the transport directly, JSONOutput can be renamed to StreamLogger and removed, etc. But this patch is sprawling already. The main observable change (see tests) is that hitting EOF on input is now an error: the client should send the 'exit' notification. This is defensible: the protocol doesn't spell this case out. Reproducing the current behavior for all combinations of shutdown/exit/EOF clutters interfaces. We can iterate on this if desired. Reviewers: jkorous, ioeric, hokein Subscribers: mgorny, ilya-biryukov, MaskRay, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D53286 llvm-svn: 344620
* [clangd] Send CodeAction responses to textDocument/codeAction (LSP 3.8)Sam McCall2018-10-161-15/+41
| | | | | | | | | | | | | | Summary: I don't bother mirroring the full capabilities struct, just parse the bits we care about. I'll send a new patch to use this approach elsewhere too. Reviewers: kadircet Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53213 llvm-svn: 344617
* Remove possibility to change compile database path at runtimeSimon Marchi2018-10-161-13/+14
| | | | | | | | | | | | | | 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
* [clangd] Return Command objects from onCodeAction, rather than ad-hoc JSON. NFCSam McCall2018-10-121-8/+9
| | | | llvm-svn: 344363
* [clangd] NFC: Migrate to LLVM STLExtras API where possibleKirill Bobyrev2018-10-071-2/+1
| | | | | | | | | | | | | | This patch improves readability by migrating `std::function(ForwardIt start, ForwardIt end, ...)` to LLVM's STLExtras range-based equivalent `llvm::function(RangeT &&Range, ...)`. Similar change in Clang: D52576. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D52650 llvm-svn: 343937
* Introduce completionItemKind capability support.Kadir Cetinkaya2018-09-271-3/+23
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, ioeric, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D52616 llvm-svn: 343237
* [clangd] Fix crash if pending computations were active on exitIlya Biryukov2018-09-261-61/+65
| | | | | | | | | | | | | | | | Summary: Make sure JSONRPCDispatcher outlives the worker threads, they access its fields to remove the stored cancellations when Context dies. Reviewers: sammccall, ioeric Reviewed By: ioeric Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52420 llvm-svn: 343067
* [clangd] Allow all LSP methods to signal cancellation via $/cancelRequestSam McCall2018-09-131-66/+10
| | | | | | | | | | | | | | | | | | | | | | | | | 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] Simplify cancellation public APISam McCall2018-09-131-5/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Task is no longer exposed: - task cancellation is hidden as a std::function - task creation returns the new context directly - checking is via free function only, with no way to avoid the context lookup The implementation is essentially the same, but a bit terser as it's hidden. isCancelled() is now safe to use outside any task (it returns false). This will leave us free to sprinkle cancellation in e.g. TUScheduler without needing elaborate test setup, and lets callers that don't cancel "just work". Updated the docs to describe the new expected use pattern. One thing I noticed: there's nothing async-specific about the cancellation. Async tasks can be cancelled from any thread (typically the one that created them), sync tasks can be cancelled from any *other* thread in the same way. So the docs now refer to "long-running" tasks instead of async ones. Updated usage in code complete, without any structural changes. I didn't update all the names of the helpers in ClangdLSPServer (these will likely be moved to JSONRPCDispatcher anyway). Reviewers: ilya-biryukov, kadircet Subscribers: ioeric, MaskRay, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D51996 llvm-svn: 342130
* [clangd] Add xrefs LSP boilerplate implementation.Sam McCall2018-09-051-0/+12
| | | | | | | | | | 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-19/+76
| | | | | | | | | | | | 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
OpenPOWER on IntegriCloud