summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/clangd
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Clean up code complete unit tests. NFCSam McCall2017-12-051-282/+151
| | | | llvm-svn: 319820
* [clangd] Set completion options per-request.Ilya Biryukov2017-12-052-26/+28
| | | | | | | | | | | | | | | | | | | | 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
* [clangd] Remove unused test param. NFCSam McCall2017-12-054-19/+17
| | | | llvm-svn: 319742
* [clangd] Split code-completion tests out of ClangdTests. NFC.Sam McCall2017-12-055-552/+636
| | | | | | | | | | | | | | Summary: Common parts are mostly FS related, so pulled out TestFS.h for the common stuff. Deliberately resisted cleaning up much here, so this is pretty mechanical. Reviewers: hokein Subscribers: klimek, mgorny, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D40784 llvm-svn: 319741
* [clangd] GlobalCompilationDatabase interface changesSam McCall2017-12-041-11/+7
| | | | | | | | | | | | | | | | | | Summary: - GlobalCompilationDatabase now returns a single command (that's all we use) - fallback flags are now part of the GlobalCompilationDatabase. There's a default implementation that they can optionally customize. - this allows us to avoid invoking the fallback logic on two separate codepaths - race on extra flags fixed by locking the mutex - made GCD const-correct (DBGCD does have mutating methods) Reviewers: hokein Subscribers: klimek, cfe-commits, ilya-biryukov Differential Revision: https://reviews.llvm.org/D40733 llvm-svn: 319647
* [clangd] Fuzzy match scorerSam McCall2017-12-012-0/+253
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This will be used for rescoring code completion results based on partial identifiers. Short-term use: - we want to limit the number of code completion results returned to improve performance of global completion. The scorer will be used to rerank the results to return when the user has applied a filter. Long-term use case: - ranking of completion results from in-memory index - merging of completion results from multiple sources (merging usually works best when done at the component-score level, rescoring the fuzzy-match quality avoids different backends needing to have comparable scores) Reviewers: ilya-biryukov Subscribers: cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D40060 llvm-svn: 319557
* [clangd] Filter completion results by fuzzy-matching identifiers.Sam McCall2017-12-011-0/+55
| | | | | | | | | | | | | | | | | | Summary: This allows us to limit the number of results we return and still allow them to be surfaced by refining a query (D39852). The initial algorithm is very conservative - it accepts a completion if the filter is any case-insensitive sub-sequence. It does not attempt to rank items based on match quality. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39882 llvm-svn: 319552
* [clangd] New conventions for JSON-marshalling functions, centralize machinerySam McCall2017-11-301-0/+58
| | | | | | | | | | | | | | | | | | 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] Switch from YAMLParser to JSONExprSam McCall2017-11-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clangd] Add missing (but documented!) JSONExpr typed accessorsSam McCall2017-11-281-1/+43
| | | | | | | | | | | | | | Summary: Noticed this when I tried to port the Protocol.h parsers. And tests for the inspect API, which caught a small bug. Reviewers: ioeric Subscribers: ilya-biryukov Differential Revision: https://reviews.llvm.org/D40399 llvm-svn: 319157
* [clangd] Tracing improvementsSam McCall2017-11-231-1/+1
| | | | | | | | | | | | | | | | | | | | Summary: [clangd] Tracing improvements Compose JSON using JSONExpr Allow attaching metadata to spans (and avoid it if tracing is off) Attach IDs and responses of JSON RPCs to their spans The downside is that large responses make the trace viewer sluggish. We should make our responses less huge :-) Or fix trace viewer. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D40132 llvm-svn: 318928
* [clangd] Drop impossible completions (unavailable or inaccessible)Sam McCall2017-11-231-10/+23
| | | | | | | | | | | | Summary: (There must be some reason why D38077 didn't just do this, but I don't get it!) Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39836 llvm-svn: 318925
* [clangd] avoid divide by literal zero to satisfy msvcSam McCall2017-11-211-1/+1
| | | | llvm-svn: 318798
* [clangd] use u8 strings in tests to avoid problems on windowsSam McCall2017-11-211-4/+4
| | | | llvm-svn: 318793
* [clangd] Add JSON tests with invalid unicodeSam McCall2017-11-211-1/+4
| | | | llvm-svn: 318791
* [clangd] Add parsing and value inspection to JSONExpr.Sam McCall2017-11-211-0/+74
| | | | | | | | | | | | | | | | | | | | | Summary: This will replace the places where we're using YAMLParser to parse JSON now: - the new marshalling code (T::parse()) should handle fewer cases and require fewer explicit casts - we'll early-reject invalid JSON that YAMLParser accepts - we'll be able to fix protocol-parsing bugs caused by the fact that YAML can only parse forward I plan to do the conversion as soon as this lands, but I don't want it in one patch as the protocol.cpp changes are conflict-prone. Reviewers: ioeric Subscribers: ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D40182 llvm-svn: 318774
* [clangd] Use in-memory preambles in clangd.Ilya Biryukov2017-11-161-6/+21
| | | | | | | | | | | | Reviewers: klimek, bkramer, sammccall Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39843 llvm-svn: 318412
* [clangd] clang-format the source code. NFC.Ilya Biryukov2017-11-151-14/+12
| | | | llvm-svn: 318317
* [clangd] Support returning a limited number of completion results.Sam McCall2017-11-151-4/+41
| | | | | | | | | | | | | | | | | | | | 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
* Fix compile issue on MSVC.Douglas Yung2017-11-081-3/+5
| | | | llvm-svn: 317642
* [clangd] MSVC - third time's the charmSam McCall2017-11-071-1/+1
| | | | llvm-svn: 317581
* [clangd] another try at fixing MSVCSam McCall2017-11-071-1/+1
| | | | llvm-svn: 317575
* ClangdTests/JSONExprTests.cpp: Appease g++-4.8 to move raw string literal ↵NAKAMURA Takumi2017-11-071-3/+5
| | | | | | out of macro arg. llvm-svn: 317538
* Adds a json::Expr type to represent intermediate JSON expressions.Sam McCall2017-11-062-0/+113
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix clangd test on platforms where get_thread_name does nothing.Sam McCall2017-11-021-2/+10
| | | | llvm-svn: 317194
* Performance tracing facility for clangd.Sam McCall2017-11-022-0/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This lets you visualize clangd's activity on different threads over time, and understand critical paths of requests and object lifetimes. The data produced can be visualized in Chrome (at chrome://tracing), or in a standalone copy of catapult (http://github.com/catapult-project/catapult) This patch consists of: - a command line flag "-trace" that causes clangd to emit JSON trace data - an API (in Trace.h) allowing clangd code to easily add events to the stream - several initial uses of this API to capture JSON-RPC requests, builds, logs Example result: https://photos.app.goo.gl/12L9swaz5REGQ1rm1 Caveats: - JSON serialization is ad-hoc (isn't it everywhere?) so the API is limited to naming events rather than attaching arbitrary metadata. I'd like to fix this (I think we could use a JSON-object abstraction). - The recording is very naive: events are written immediately by locking a mutex. Contention on the mutex might disturb performance. - For now it just traces instants or spans on the current thread. There are other things that make sense to show (cross-thread flows, non-thread resources such as ASTs). But we have to start somewhere. Reviewers: ioeric, ilya-biryukov Subscribers: cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D39086 llvm-svn: 317193
* [clangd] Report an error on findDefinitions/signatureHelp on an unopened ↵Benjamin Kramer2017-10-261-1/+1
| | | | | | | | file instead of crashing. Found by clangd-fuzzer. llvm-svn: 316659
* [clangd] Allow to pass code completion opts to ClangdServer.Ilya Biryukov2017-10-231-12/+212
| | | | | | | | | | | | Reviewers: bkramer, krasimir, sammccall Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D38731 llvm-svn: 316327
* [clangd] Added async API to run code completion.Ilya Biryukov2017-10-051-5/+12
| | | | | | | | | | | | | | | | | | Summary: ClangdServer now provides async code completion API. It is still used synchronously by ClangdLSPServer, more work is needed to allow processing other requests in parallel while completion (or any other request) is running. Reviewers: klimek, bkramer, krasimir Reviewed By: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D38583 llvm-svn: 314989
* [clangd] LSP extension to switch between source/header fileMarc-Andre Laperle2017-09-281-0/+79
| | | | | | | | | | | | | | | | | | Summary: Small extension to LSP to allow clients to use clangd to switch between C header files and source files. Final version will use the completed clangd indexer to use the index of symbols to be able to switch from header to source file when the file names don't match. Reviewers: malaperle, krasimir, bkramer, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: ilya-biryukov, cfe-commits, arphaman Patch by: William Enright Differential Revision: https://reviews.llvm.org/D36150 llvm-svn: 314377
* [clangd] Serialize onDiagnosticsReady callbacks for the same file.Ilya Biryukov2017-09-201-0/+63
| | | | | | | | | | | | | | | | | Summary: Calls to onDiagnosticsReady were done concurrently before. This sometimes led to older versions of diagnostics being reported to the user after the newer versions. Reviewers: klimek, bkramer, krasimir Reviewed By: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D38032 llvm-svn: 313754
* [clangd] Introduced Logger interface.Ilya Biryukov2017-09-201-8/+14
| | | | | | | | | | | | | | Summary: This fixes a bunch of logging-related FIXMEs. Reviewers: bkramer, krasimir, malaperle Reviewed By: malaperle Subscribers: malaperle, klimek, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D37972 llvm-svn: 313730
* [clangd] Add support for snippet completionsIlya Biryukov2017-09-121-8/+13
| | | | | | | | | | | | | | Enhances CompletionItemsCollector in such a way that snippet completions can be presented to the client. Enable snippet completion items by specifying -enable-snippets while invoking the clangd executable. See: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#completion-request See: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/browser/snippet.md Patch by Raoul Wols. llvm-svn: 313029
* Add braces to silence gcc dangling-else warnings. NFCI.Simon Pilgrim2017-08-141-2/+4
| | | | llvm-svn: 310830
* [clangd] Use multiple working threads in clangd.Ilya Biryukov2017-08-141-36/+306
| | | | | | | | | | | | Reviewers: bkramer, krasimir, klimek Reviewed By: klimek Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D36261 llvm-svn: 310821
* [clangd] Check if CompileCommand has changed on forceReparse.Ilya Biryukov2017-08-141-0/+47
| | | | | | | | | | | | Reviewers: krasimir, bkramer, klimek Reviewed By: klimek Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36398 llvm-svn: 310819
* ClangdTests: Try to unbreak the case CLANG_DEFAULT_CXX_STDLIB=libc++.NAKAMURA Takumi2017-08-031-1/+2
| | | | llvm-svn: 309936
* [clangd] Rewrote AST and Preamble management.Ilya Biryukov2017-08-011-13/+48
| | | | | | | | | | | | | | Summary: The new implementation allows code completion that never waits for AST. Reviewers: bkramer, krasimir, klimek Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36133 llvm-svn: 309696
* [clangd] Specified --gcc-toolchain explicitly in VFS test.Ilya Biryukov2017-07-211-5/+5
| | | | | | | In order to avoid platform-specific configuration quirks. (Possible fix for https://bugs.llvm.org/show_bug.cgi?id=33842) llvm-svn: 308721
* [clangd] Add -ffreestanding on VFS tests.Ilya Biryukov2017-07-031-7/+16
| | | | | | | | | | | | | | | | | | Summary: They don't provide proper gcc installations and may fail on implicit <stdc-predef.h> include. Reviewers: klimek, krasimir, bkramer Reviewed By: krasimir Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34936 llvm-svn: 307025
* [clangd] Run a test, searching for gcc install, only on Unix.Ilya Biryukov2017-06-291-0/+3
| | | | | | This should fix windows buildbots. llvm-svn: 306656
* [clangd] Added a test, checking that gcc install is searched via VFS.Ilya Biryukov2017-06-291-1/+62
| | | | | | | | | | | | Reviewers: bkramer, krasimir, klimek Reviewed By: klimek Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34755 llvm-svn: 306652
* [clangd] Add a filename parameter to FileSystemProvider.Ilya Biryukov2017-06-141-2/+14
| | | | | | | | | | | | | | Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34151 llvm-svn: 305376
* [clangd] Store references instead of unique_ptrs in ClangdServer.Ilya Biryukov2017-06-131-61/+46
| | | | | | | | | | | | | | | | Summary: ClangdServer owned objects passed to it in constructor for no good reason. Lots of stuff was moved from the heap to the stack thanks to this change. Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34148 llvm-svn: 305298
* [clangd] Allow to override contents of the file during completion.Ilya Biryukov2017-06-131-0/+64
| | | | | | | | | | | | | | | | Summary: This is a reapplied r305280 with a fix to the crash found by build bots (StringRef to an out-of-scope local std::string). Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34146 llvm-svn: 305291
* Revert "[clangd] Allow to override contents of the file during completion."Ilya Biryukov2017-06-131-64/+0
| | | | | | | This caused buildbots failures, reverting until we'll find out what's wrong. llvm-svn: 305283
* [clangd] Allow to override contents of the file during completion.Ilya Biryukov2017-06-131-0/+64
| | | | | | | | | | | | Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D34107 llvm-svn: 305280
* [clangd] Use 'std::string' for VFSTag instead of 'int'Ilya Biryukov2017-06-131-2/+2
| | | | | | | | | | | | | | Reviewers: krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34106 llvm-svn: 305279
* [clangd] Mark results of clangd requests with a tag provided by the ↵Ilya Biryukov2017-05-301-4/+36
| | | | | | | | | | | | | | | | | | | | FileSystemProvider. Summary: This allows an implementation of FileSystemProvider that can track which vfs::FileSystem were used for each of the requests. Reviewers: bkramer, krasimir Reviewed By: bkramer Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D33678 llvm-svn: 304214
* ClangdTests.cpp: Use "clang/Config/config.h" instead of "llvm/Config/config.h".NAKAMURA Takumi2017-05-271-1/+1
| | | | llvm-svn: 304082
OpenPOWER on IntegriCloud