summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/ClangdLSPServer.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] send diagnostic categories only when 'categorySupport'Alex Lorenz2018-08-221-1/+3
| | | | | | | | | | | | 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] add an extension field to LSP to transfer the diagnostic's categoryAlex Lorenz2018-08-141-0/+2
| | | | | | | | | This patch adds a 'category' extension field to the LSP diagnostic that's sent by Clangd. This extension is always on by default. Differential Revision: https://reviews.llvm.org/D50571 llvm-svn: 339738
* NFC: Enforce good formatting across multiple clang-tools-extra filesKirill Bobyrev2018-08-141-1/+1
| | | | | | | | | | | This patch improves readability of multiple files in clang-tools-extra and enforces LLVM Coding Guidelines. Reviewed by: ioeric Differential Revision: https://reviews.llvm.org/D50707 llvm-svn: 339687
* [clangd] extend the publishDiagnostics response to send back fixits to theAlex Lorenz2018-08-101-1/+17
| | | | | | | | | | | | | | 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-10/+92
| | | | | | | | | | | | | 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-5/+11
| | | | | | | | | | | | | | | | | | 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] Upgrade logging facilities with levels and formatv.Sam McCall2018-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | 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-20/+21
| | | | | | | | | | | | | | | | | | | | 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/+14
| | | | | | | | | | | | | | | | | 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
* [clangd] ClangdServer::codeComplete return CodeCompleteResult, not LSP struct.Sam McCall2018-07-021-2/+6
| | | | | | | | | | | | | | | | | | | | Summary: This provides more structured information that embedders can use for rendering. ClangdLSPServer continues to call render(), so NFC. The patch is: - trivial changes to ClangdServer/ClangdLSPServer - mostly-mechanical updates to CodeCompleteTests etc for the new API - new direct tests of render() in CodeCompleteTests - tiny cleanups to CodeCompletionItem (operator<< and missing initializers) Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48821 llvm-svn: 336094
* [clangd] Move caching of compile args out of ClangdServer.Ilya Biryukov2018-06-131-9/+14
| | | | | | | | | | | | | | | | | | | | | Summary: Caching is now handled by ClangdLSPServer and hidden behind the GlobalCompilationDatabase interface. This simplifies ClangdServer. This change also removes the SkipCache flag from addDocument, which is now obsolete. No behavioral changes are intended, the clangd binary still caches the compile commands on the first read. Reviewers: sammccall Reviewed By: sammccall Subscribers: mgorny, ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48068 llvm-svn: 334585
* [clangd] Rewrite JSON dispatcher loop using C IO (FILE*) instead of ↵Sam McCall2018-06-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | std::istream. Summary: The EINTR loop around getline was added to fix an issue with mac gdb, but seems to loop infinitely in rare cases on linux where the parent editor exits (most reports with VSCode). I can't work out how to fix this in a portable way with std::istream, but the C APIs have clearer contracts and LLVM has a RetryAfterSignal function for use with them which seems battle-tested. While here, clean up some inconsistency around \n in log messages (now add it only after JSON payloads), and reduce the scope of the long-message handling which was only really added to fight fuzzers. Reviewers: malaperle, ilya-biryukov Subscribers: klimek, ioeric, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47643 llvm-svn: 333993
* [clangd] Hover should return null when not hovering over anything.Sam McCall2018-06-041-1/+1
| | | | | | | | | | | | Summary: Also made JSON serialize Optional<T> to simplify this. Reviewers: ioeric Subscribers: klimek, ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47701 llvm-svn: 333881
* [clangd] Remove LSP command-based #include insertion.Eric Liu2018-05-151-39/+1
| | | | | | | | | | | | | | | | | 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] Move helpers that convert Replacements to TextEdits to SourceCode.hEric Liu2018-05-111-27/+5
| | | | | | | | | | | | Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: klimek, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D46670 llvm-svn: 332089
* [clangd] Implementation of workspace/symbol requestMarc-Andre Laperle2018-04-231-0/+32
| | | | | | | | | | | | | | | | | | | | | | | 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
* s/LLVM_ON_WIN32/_WIN32/, clang-tools-extraNico Weber2018-04-101-1/+1
| | | | | | | | | | | LLVM_ON_WIN32 is set exactly with MSVC and MinGW (but not Cygwin) in HandleLLVMOptions.cmake, which is where _WIN32 defined too. Just use the default macro instead of a reinvented one. See thread "Replacing LLVM_ON_WIN32 with just _WIN32" on llvm-dev and cfe-dev. No intended behavior change. llvm-svn: 329695
* [clangd] Support incremental document syncingSimon Marchi2018-03-261-9/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Move DraftMgr from ClangdServer to ClangdLSPServerSimon Marchi2018-03-161-12/+30
| | | | | | | | | | | | | | | | | | | | Summary: This patch moves the draft manager closer to the edge of Clangd, from ClangdServer to ClangdLSPServer. This will make it easier to implement incremental document sync, by making ClangdServer only deal with complete documents. As a result, DraftStore doesn't have to deal with versioning, and thus its API can be simplified. It is replaced by a StringMap in ClangdServer holding a current version number for each file. Signed-off-by: Simon Marchi <simon.marchi@ericsson.com> Subscribers: klimek, mgorny, ilya-biryukov, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D44408 llvm-svn: 327711
* [clangd] Remove Tagged and some related APIs from ClangdServer.Sam McCall2018-03-121-12/+17
| | | | | | | | | | | | Context can do what Tagged was intended to support (snapshot filesystems), and less intrusively. getTaggedFileSystem() no longer needs a filename. Cleanups while here: - code-complete now returns errors as Expected, like other functions - added an alias Callback<T> for the usual callback function type llvm-svn: 327344
* [clangd] Revamp handling of diagnostics.Ilya Biryukov2018-03-121-16/+18
| | | | | | | | | | | | | | | | Summary: The new implementation attaches notes to diagnostic message and shows the original diagnostics in the message of the note. Reviewers: hokein, ioeric, sammccall Reviewed By: sammccall Subscribers: klimek, mgorny, cfe-commits, jkorous-apple Differential Revision: https://reviews.llvm.org/D44142 llvm-svn: 327282
* [clangd] Remove unused field in HandlerRegistererSimon Marchi2018-03-071-1/+1
| | | | | | | | | | Summary: Tested by rebuilding. Subscribers: klimek, ilya-biryukov, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D44213 llvm-svn: 326947
* [clangd] Extract ClangdServer::Options struct.Sam McCall2018-03-051-8/+3
| | | | | | | | | | | | | | | | | | Summary: This subsumes most of the params to ClangdServer and ClangdLSPServer. Adjacent changes: - tests use a consistent set of options, except when testing specific options - tests that previously used synchronous mode for convenience no longer do - added a runAddDocument helper to SyncAPIs to mitigate the extra code - rearranged main a bit to follow the structure of the options Reviewers: ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D44088 llvm-svn: 326719
* [clangd] Debounce streams of updates.Sam McCall2018-03-021-1/+1
| | | | | | | | | | | | | | | | | | | Summary: Don't actually start building ASTs for new revisions until either: - 500ms have passed since the last revision, or - we actually need the revision for something (or to unblock the queue) In practice, this avoids the "first keystroke results in diagnostics" problem. This is kind of awkward to test, and the test is pretty bad. It can be observed nicely by capturing a trace, though. Reviewers: hokein, ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D43648 llvm-svn: 326546
* [clangd] don't insert new includes if either original header or canonical ↵Eric Liu2018-02-261-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | 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/+5
| | | | | | | | | | | | | | | | 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/+12
| | | | | | | | | | | | | | | | | | | | 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] Allow embedders some control over when diagnostics are generated.Sam McCall2018-02-221-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Through the C++ API, we support for a given snapshot version: - Yes: make sure we generate diagnostics for exactly this version - Auto: generate eventually-consistent diagnostics for at least this version - No: don't generate diagnostics for this version Eventually auto should be debounced for better UX. Through LSP, we force diagnostics for initial load (bypassing future debouncing) and all updates follow the "auto" policy. This is complicated to implement under the CancellationFlag design, so rewrote that part to just inspect the queue instead. It turns out we never pass None to the diagnostics callback, so remove Optional from the signature. The questionable behavior of not invoking the callback at all if CppFile::rebuild fails is not changed. Reviewers: ilya-biryukov Subscribers: klimek, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D43518 llvm-svn: 325774
* [clangd] Implement textDocument/hoverMarc-Andre Laperle2018-02-161-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-7/+39
| | | | | | | | | | | | | | | | | | 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-17/+17
| | | | | | | | | | | | | | | | 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-4/+8
| | | | | | | | | | | | | | 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] Make functions of ClangdServer callback-basedIlya Biryukov2018-02-151-35/+39
| | | | | | | | | | | | | | | | | | Summary: As a consequence, all LSP operations are now handled asynchronously, i.e. they never block the main processing thread. However, if -run-synchronously flag is specified, clangd still runs everything on the main thread. Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall, ioeric Subscribers: klimek, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D43227 llvm-svn: 325233
* [clangd] Explicitly initialize all primitive fields in Protocol.hIlya Biryukov2018-02-141-12/+7
| | | | | | | | | | | | | | | | | | Summary: Some of the existing structs had primimtive fields that were not explicitly initialized on construction. After this commit every struct consistently sets a defined value for every field when default-initialized. Reviewers: hokein, ioeric, sammccall Reviewed By: sammccall Subscribers: klimek, cfe-commits, jkorous-apple Differential Revision: https://reviews.llvm.org/D43230 llvm-svn: 325113
* [clangd] Support simpler JSON-RPC stream parsing for lit tests.Sam McCall2018-02-061-2/+2
| | | | | | | | | | | | | | Summary: Instead of content-length, we delimit messages with ---. This also removes the need for (most) dos-formatted test files. Reviewers: ioeric Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D42919 llvm-svn: 324333
* [clangd] Fix URI scheme conflict and an unused variable warning in tests. NFCEric Liu2018-02-011-1/+2
| | | | llvm-svn: 323957
* [clangd] Add a test URI scheme for lit tests to unbreak platform-specific ↵Eric Liu2018-01-311-0/+39
| | | | | | | | | | | | | | | | 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-79/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Use new URI with scheme support in place of the existing LSP URIEric Liu2018-01-291-5/+5
| | | | | | | | | | | | | | | | | | 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] Don't crash on LSP calls for non-added filesIlya Biryukov2018-01-171-12/+33
| | | | | | | | | | | | | | | | | | | | | Summary: We will return errors for non-added files for now. Another alternative for clangd would be to read non-added files from disk and provide useful features anyway. There are still some cases that fail with assertion (e.g., code complete). We should address those too, but they require more subtle changes to the code and therefore out of scope of this patch. Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42164 llvm-svn: 322637
* [clangd] Pass Context to onDiagnosticsReady callbackIlya Biryukov2018-01-101-1/+2
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D41907 llvm-svn: 322199
* [clangd] Add static index for the global code completion.Haojian Wu2018-01-101-2/+4
| | | | | | | | | | | | | | | | | | | | Summary: Use the YAML-format symbols (generated by the global-symbol-builder tool) to do the global code completion. It is **experimental** only , but it allows us to experience global code completion on a relatively small project. Tested with LLVM project. Reviewers: sammccall, ioeric Reviewed By: sammccall, ioeric Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41668 llvm-svn: 322191
* [clangd] Build dynamic index and use it for code completion.Eric Liu2017-12-191-2/+3
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41289 llvm-svn: 321092
* [clangd] Expose offset <-> LSP position functions, and fix bugsSam McCall2017-12-191-0/+1
| | | | | | | | | | | | | | | | | | | | | | | Summary: - Moved these functions to SourceCode.h - added unit tests - fix off by one in positionToOffset: Offset - 1 in final calculation was wrong - fixed formatOnType which had an equal and opposite off-by-one - positionToOffset and offsetToPosition both consistently clamp to beginning/end of file when input is out of range - gave variables more descriptive names - removed windows line ending fixmes where there is nothing to fix - elaborated on UTF-8 fixmes This will conflict with Eric's D41281, but in a pretty easy-to-resolve way. Reviewers: ioeric Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41351 llvm-svn: 321073
* [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] Implemented logging using ContextIlya Biryukov2017-12-131-56/+58
| | | | | | | | | | | | Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40486 llvm-svn: 320576
* [clangd] Emit ranges for clangd diagnostics, and fix off-by-one positionsSam McCall2017-12-131-5/+3
| | | | | | | | | | | | | | | | | | | Summary: - when the diagnostic has an explicit range, we prefer that - if the diagnostic has a fixit, its RemoveRange is our next choice - otherwise we try to expand the diagnostic location into a whole token. (inspired by VSCode, which does this client-side when given an empty range) - if all else fails, we return the zero-width range as now. (clients react in different ways to this, highlighting a token or a char) - this includes the off-by-one fix from D40860, and borrows heavily from it Reviewers: rwols, hokein Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41118 llvm-svn: 320555
* [clangd] (Attempt to) read clang-format file for document formattingRaoul Wols2017-12-121-11/+35
| | | | | | | | | | | | | | | | | Summary: Takes into account the clang-format file of the project, if any. Reverts to LLVM if nothing is found. Replies with an error if any error occured. For instance, a parse error in the clang-format YAML file. Reviewers: ilya-biryukov, sammccall, Nebiroth, malaperle, krasimir Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D41031 llvm-svn: 320524
* [clangd] Document highlights for clangdIlya Biryukov2017-12-121-0/+17
| | | | | | | | | | | | | | | | | 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] Set completion options per-request.Ilya Biryukov2017-12-051-11/+12
| | | | | | | | | | | | | | | | | | | | Summary: Previously, completion options were set per ClangdServer instance. It will allow to change completion preferences during the lifetime of a single ClangdServer instance. Also rewrote ClangdCompletionTest.CompletionOptions to reuse single ClangdServer instance, the test now runs 2x faster on my machine. Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall, ioeric Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40654 llvm-svn: 319753
OpenPOWER on IntegriCloud