summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/ClangdUnit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Filter completion results by fuzzy-matching identifiers.Sam McCall2017-12-011-0/+36
| | | | | | | | | | | | | | | | | | 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] Logger implicitly adds newlineSam McCall2017-11-301-1/+1
| | | | llvm-svn: 319497
* [clangd] Log file compile commandsSam McCall2017-11-301-0/+3
| | | | llvm-svn: 319496
* Fix MSVC double-float implicit truncation warning. NFCISimon Pilgrim2017-11-241-1/+1
| | | | llvm-svn: 318961
* [clangd] Ensure preamble outlives the ASTIlya Biryukov2017-11-241-35/+27
| | | | | | | | | | | | | | | | Summary: In-memory preambles will not be copied anymore, so we need to make sure they outlive the AST. Reviewers: bkramer, sammccall, klimek Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D40301 llvm-svn: 318944
* [clangd] Tracing improvementsSam McCall2017-11-231-2/+4
| | | | | | | | | | | | | | | | | | | | 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] Make completion scores use 0-1 floats internally.Sam McCall2017-11-231-19/+31
| | | | | | | | | | | | | | | Summary: This scale is much easier to mix with other signals, such as fuzzy match strength. Mostly NFC, but it does reorder some low-priority items that get folded together at a score of 0 (see completion-qualifiers.test). Removed the exact sortText from the testcases, because it's the ranking that we want to test. Reviewers: hokein Subscribers: ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D40089 llvm-svn: 318927
* [clangd] Drop impossible completions (unavailable or inaccessible)Sam McCall2017-11-231-17/+6
| | | | | | | | | | | | 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] Release the old preamble before building a new one.Ilya Biryukov2017-11-171-3/+10
| | | | llvm-svn: 318544
* [clangd] Use in-memory preambles in clangd.Ilya Biryukov2017-11-161-4/+9
| | | | | | | | | | | | Reviewers: klimek, bkramer, sammccall Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39843 llvm-svn: 318412
* [clangd] Support returning a limited number of completion results.Sam McCall2017-11-151-64/+91
| | | | | | | | | | | | | | | | | | | | 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-38/+40
| | | | | | | | | | | | | | | | | | | 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/+1
| | | | | | | | | | | | | | 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
* [clangd] Fix opening declarations located in non-preamble inclusionMarc-Andre Laperle2017-11-071-4/+9
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: When an inclusion is not processed as part of the preamble, its path is not made into an absolute path as part of the precompiled header code (adjustFilenameForRelocatableAST in ASTWriter.cpp). Because of this, when we convert a Decl location to retrieve the file name with FileEntry->getName(), it is possible for this path to be relative. Instead, we should try to use tryGetRealPathName first which returns an absolute path. Fixes bug 35217. Reviewers: sammccall, ilya-biryukov, rwols, Nebiroth Reviewed By: sammccall Subscribers: cfe-commits, ilya-biryukov Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D39705 llvm-svn: 317585
* Performance tracing facility for clangd.Sam McCall2017-11-021-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add LLVM_FALLTHROUGH to silence warning. NFCI.Simon Pilgrim2017-11-011-1/+1
| | | | llvm-svn: 317083
* [clangd] Fix clang-tidy warnings.Benjamin Kramer2017-10-281-9/+9
| | | | | | No functionality change intended. llvm-svn: 316832
* [clangd] Allow to pass code completion opts to ClangdServer.Ilya Biryukov2017-10-231-22/+47
| | | | | | | | | | | | Reviewers: bkramer, krasimir, sammccall Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D38731 llvm-svn: 316327
* [clangd] Report proper kinds for 'Keyword' and 'Snippet' completion items.Ilya Biryukov2017-10-231-3/+19
| | | | | | | | | | | | Reviewers: rwols, malaperle, krasimir, bkramer, sammccall Reviewed By: rwols, sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D38720 llvm-svn: 316311
* [clangd] Use UniqueFunction for deferred computations.Ilya Biryukov2017-10-101-7/+7
| | | | | | | Previsouly, `std::future` that were results of `std::async(std::launch::deferred, ...` were used. llvm-svn: 315325
* Fix signed/unsigned warningSimon Pilgrim2017-10-071-1/+1
| | | | llvm-svn: 315149
* [clangd] Add textDocument/signatureHelpIlya Biryukov2017-10-061-56/+221
| | | | | | | | | | | | | | | | | | 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] Skip informative qualifier chunks.Ilya Biryukov2017-09-281-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Completion results look much nicer without them. Informative qualifiers are stored for every method from a base class, even when calling those methods does not require any qualifiers. For example, struct Foo { int foo(); }; struct Bar : Foo { }; void test() { Bar(). // Completion item label was 'Foo::foo' before, // but inserted text was simply 'foo'. // We now simply show 'foo' in completion item label. They effectively cluttered the completion list without providing much value. Reviewers: bkramer, krasimir, rwols Reviewed By: rwols Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D38083 llvm-svn: 314445
* [clangd] Put inacessible items to the end of completion list.Ilya Biryukov2017-09-201-5/+31
| | | | | | | | | | | | Reviewers: bkramer, krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D38077 llvm-svn: 313759
* [clangd] Run clang-format on ClangdUnit.cpp. NFC.Ilya Biryukov2017-09-201-2/+3
| | | | llvm-svn: 313749
* [clangd] Introduced Logger interface.Ilya Biryukov2017-09-201-17/+23
| | | | | | | | | | | | | | 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-42/+239
| | | | | | | | | | | | | | 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
* [clangd] Fixed a data race.Ilya Biryukov2017-08-141-8/+31
| | | | | | | | | | | | | | | | | | | | Summary: Calling addDocument after removeDocument could have resulted in an invalid program state (AST and Preamble for the valid document could have been incorrectly removed). This commit also includes an improved CppFile::cancelRebuild implementation that allows to cancel reparse without waiting for ongoing rebuild to finish. Reviewers: krasimir, bkramer, klimek Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D36397 llvm-svn: 310818
* [clangd] Run clang-format on all clangd sources. NFC.Ilya Biryukov2017-08-021-1/+2
| | | | llvm-svn: 309801
* [clangd] Fix more MSVC compilation failures.Ilya Biryukov2017-08-011-6/+6
| | | | | | | It turns out MSVC does not allow non-copyable classes in std::future and std::promise template arguments. llvm-svn: 309720
* [clangd] Rewrote AST and Preamble management.Ilya Biryukov2017-08-011-164/+339
| | | | | | | | | | | | | | 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] Don't reverse priorities of completion items.Ilya Biryukov2017-07-271-6/+2
| | | | | | | | | | | | | | Summary: Current algorithm incorrectly provides completion results in a reverse order. Reviewers: krasimir, bkramer Reviewed By: krasimir Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D35950 llvm-svn: 309295
* [clangd] Reuse compile commands during reparseKrasimir Georgiev2017-07-251-0/+4
| | | | | | | | | | | | | | | | Summary: Previously we always queried the compilation database and discarded the results if the file was already opened. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D35825 llvm-svn: 308970
* [clangd] Replace ASTUnit with manual AST management.Ilya Biryukov2017-07-211-134/+495
| | | | | | | | | | | | | | | | | | Summary: This refactoring does not aim to introduce any significant changes to the behaviour of clangd to keep the change as simple as possible. Reviewers: klimek, krasimir, bkramer Reviewed By: krasimir Subscribers: malaperle, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D35406 llvm-svn: 308738
* [clangd] Check failure of Lexer::getRawToken in GoToDeclaration.Ilya Biryukov2017-06-291-2/+6
| | | | | | There was an access to unitialized memory because it wasn't checked. llvm-svn: 306705
* [clangd] Cleanup ClangdUnit.cpp, update docs; NFCKirill Bobyrev2017-06-281-15/+15
| | | | | | | | * Enforce 80 characters limit where appropriate * Use slightly more descriptive names for searched locations * Update docs to reflect D34269, which adds "Go To Declaration" functionality llvm-svn: 306598
* [clangd] Add "Go to Declaration" functionalityMarc-Andre Laperle2017-06-281-0/+150
| | | | | | | | | | | | | | | | Summary: This change allows to navigate to most identifiers' declarations in code. This is a first step towards implementing "Go to Definition". It reuses clangIndex in order to detect which occurrences corresponds to the position requested. The occurrences' Decls are then used to generate locations suitable for navigating to the declarations. Reviewers: krasimir, bkramer, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: cfe-commits, mgorny Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34269 llvm-svn: 306558
* [clangd] Allow to override resource dir in ClangdServer.Ilya Biryukov2017-06-281-4/+2
| | | | | | | | | | | | | | Reviewers: bkramer, krasimir, klimek Reviewed By: klimek Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34470 llvm-svn: 306530
* [clangd] Add priority to completion item sort textKrasimir Georgiev2017-06-151-1/+12
| | | | | | | | | | | | | | | | | | Summary: This patch adds the priority of a completion item to the sort text of the returned LSP result. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34137 llvm-svn: 305454
* [clangd] Update for ASTUnit API change.Argyrios Kyrtzidis2017-06-091-0/+1
| | | | llvm-svn: 305046
* [clangd] Add parameter and return type information to completion resultsKrasimir Georgiev2017-06-081-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds information about the parameters and return types of completion candidates. Previously, for the following code: ``` struct S { int func(int a, double b) const; }; ``` the completer would only return the label of the candidate `func`. Now it will also return the return type `int` and will format the label for the candidate as `func(int a, double b) const`. Reviewers: bkramer, ilya-biryukov Reviewed By: ilya-biryukov Subscribers: cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D34033 llvm-svn: 304980
* [clangd] Allow to use vfs::FileSystem for file accesses.Ilya Biryukov2017-05-261-9/+20
| | | | | | | | | | | | | | | | Summary: Custom vfs::FileSystem is currently used for unit tests. This revision depends on https://reviews.llvm.org/D33397. Reviewers: bkramer, krasimir Reviewed By: bkramer, krasimir Subscribers: klimek, cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D33416 llvm-svn: 303977
* [clangd] Replaced WorkerRequest with std::function...Ilya Biryukov2017-05-231-0/+4
| | | | | | | | | | | | | | | | | | Summary: And implemented a helper function to dump an AST of a file for testing/debugging purposes. Reviewers: bkramer, krasimir Reviewed By: krasimir Subscribers: klimek, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D33415 llvm-svn: 303634
* [clangd] Switch to incomplete translation unitsKrasimir Georgiev2017-05-221-1/+1
| | | | | | | | | | | | | | Summary: This speeds up code completion. All the cool kids (ycmd) are doing it. Reviewers: bkramer, ilya-biryukov Reviewed By: bkramer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D33350 llvm-svn: 303547
* Restored r303067 and fixed failing test.Ilya Biryukov2017-05-161-0/+224
| | | | | | | | | | | | | | | | | | | | | Summary: This commit restores r303067(reverted by r303094) and fixes the 'formatting.test' failure. The failure is due to destructors of `ClangdLSPServer`'s fields(`FixItsMap` and `FixItsMutex`) being called before destructor of `Server`. It led to the worker thread calling `consumeDiagnostics` after `FixItsMutex` and `FixItsMap` destructors were called. Also, clangd is now run with '-run-synchronously' flag in 'formatting.test'. Reviewers: bkramer, krasimir Reviewed By: krasimir Subscribers: mgorny, cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D33233 llvm-svn: 303151
* Revert "[ClangD] Refactor clangd into separate components"Adam Nemet2017-05-151-224/+0
| | | | | | | | | | This reverts commit r303067. Caused http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/34305/ And even after Simon's fix there is still a test failure. llvm-svn: 303094
* [ClangD] Refactor clangd into separate componentsIlya Biryukov2017-05-151-0/+224
Summary: Major refactoring to split LSP implementation, Clang API calls and threading(mostly synchronization) Reviewers: bkramer, krasimir Reviewed By: bkramer Subscribers: cfe-commits, mgorny, klimek Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D33047 llvm-svn: 303067
OpenPOWER on IntegriCloud