Commit Graph

89 Commits

Author SHA1 Message Date
Ilya Biryukov 1fab4f8a59 clangd: Tolerate additional headers
Summary:
The language server protocol specified 2 headers (Content-Length and Content-Type), but does not specify their sequence. It specifies that an empty line ends
headers. Clangd has been updated to handle arbitrary sequences of headers, extracting only the content length.

Patch by puremourning (Ben Jackson).

Reviewers: bkramer, klimek, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: cfe-commits, ilya-biryukov

Differential Revision: https://reviews.llvm.org/D37282

llvm-svn: 312483
2017-09-04 12:28:15 +00:00
Ilya Biryukov 75337e8d66 [clangd] Updated ClangdServer comments. NFC.
llvm-svn: 311436
2017-08-22 09:16:46 +00:00
Ilya Biryukov db8b2d7b20 [clangd] Use multiple working threads in clangd.
Reviewers: bkramer, krasimir, klimek

Reviewed By: klimek

Subscribers: arphaman, cfe-commits

Differential Revision: https://reviews.llvm.org/D36261

llvm-svn: 310821
2017-08-14 08:45:47 +00:00
Ilya Biryukov 91dbf5b6b4 [clangd] Check if CompileCommand has changed on forceReparse.
Reviewers: krasimir, bkramer, klimek

Reviewed By: klimek

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D36398

llvm-svn: 310819
2017-08-14 08:37:32 +00:00
Ilya Biryukov c5ad35fb23 [clangd] Fixed a data race.
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
2017-08-14 08:17:24 +00:00
Ilya Biryukov c22824a6fc [clangd] Fixed a bug in make_tagged.
It accidentally std::move'd from Value parameter if it deduced to an
l-value ref.

llvm-svn: 310470
2017-08-09 12:55:13 +00:00
Ilya Biryukov 574b753bfd [clangd] Run clang-format on all clangd sources. NFC.
llvm-svn: 309801
2017-08-02 09:08:39 +00:00
Ilya Biryukov 4ca7d85d2a [clangd] Capitalized descriptions of clangd options. NFC.
To follow the style of other options shown on `clangd -help`.

llvm-svn: 309800
2017-08-02 08:53:48 +00:00
Ilya Biryukov 6e1f3b1c90 [clangd] Fix more MSVC compilation failures.
It turns out MSVC does not allow non-copyable classes in std::future
and std::promise template arguments.

llvm-svn: 309720
2017-08-01 18:27:58 +00:00
Ilya Biryukov e925caf416 [clangd] Fixed MSVC compilation failures.
llvm-svn: 309705
2017-08-01 17:17:37 +00:00
Ilya Biryukov 02d5870de3 [clangd] Rewrote AST and Preamble management.
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
2017-08-01 15:51:38 +00:00
Ilya Biryukov ed99e4c5b2 [clangd] Allow to get vfs::FileSystem used inside codeComplete.
Summary: This is useful for managing lifetime of VFS-based caches.

Reviewers: bkramer, krasimir

Reviewed By: bkramer

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D36095

llvm-svn: 309585
2017-07-31 17:09:29 +00:00
Ilya Biryukov a2e7ca99e0 [clangd] Add ':' to completion trigger characters.
Summary:
Without it we don't get completion requests from VSCode after
nested name qualifiers (e.g. after 'std::').

Reviewers: krasimir, bkramer

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D35986

llvm-svn: 309550
2017-07-31 09:27:52 +00:00
Ilya Biryukov de46274d7b [clangd] Don't reverse priorities of completion items.
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
2017-07-27 17:43:07 +00:00
Krasimir Georgiev e4130d52da [clangd] Reuse compile commands during reparse
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
2017-07-25 11:37:43 +00:00
NAKAMURA Takumi 3545ee5f3f clangDaemon: Update libdeps in r308738.
llvm-svn: 308807
2017-07-21 23:48:26 +00:00
Ilya Biryukov 04db368a3f [clangd] Replace ASTUnit with manual AST management.
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
2017-07-21 13:29:29 +00:00
Krasimir Georgiev 0dcb48eab1 [clangd] Allow specifying -resource-dir
Summary: This patch allows clangd to specify its -resource-dir.

Reviewers: bkramer, klimek

Reviewed By: bkramer

Subscribers: cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D35617

llvm-svn: 308486
2017-07-19 15:43:35 +00:00
Marc-Andre Laperle 9647a28fb7 [clangd] Fix Go to Definition not working in VSCode extension
Summary:
The URI conversion logic was returning 'undefined' when going from server to
VSCode which broke the Go to Definition functionality.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D35215

llvm-svn: 307715
2017-07-11 21:26:18 +00:00
Petr Hosek fe0e145aed [CMake] Use tools template for clangd and modularize
This makes them usable as distribution components in the build.

Differential Revision: https://reviews.llvm.org/D35017

llvm-svn: 307601
2017-07-11 00:18:07 +00:00
Krasimir Georgiev c2a16a3567 [clangd] Add support for per-file extra flags
Summary:
This patch adds the ability to specify user-defined extra flags per opened file
through the LSP layer. This is a non-standard extension to the protocol.
I've already created a feature request about it for upstream lsp:
https://github.com/Microsoft/language-server-protocol/issues/255

The particular use-case is ycmd, which has a python script for figuring out
extra flags per file:
https://github.com/Valloric/ycmd#flagsforfile-filename-kwargs-

Reviewers: ilya-biryukov, klimek, bkramer

Reviewed By: ilya-biryukov

Subscribers: cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D34947

llvm-svn: 307241
2017-07-06 08:44:54 +00:00
NAKAMURA Takumi 7a0fb798ae ClangdServer.cpp: Suppress a warning. [-Wunused-lambda-capture]
llvm-svn: 307068
2017-07-04 12:12:14 +00:00
Ilya Biryukov 4203d2adcc [clangd] Check failure of Lexer::getRawToken in GoToDeclaration.
There was an access to unitialized memory because it wasn't checked.

llvm-svn: 306705
2017-06-29 17:11:32 +00:00
NAKAMURA Takumi 396a3a45e2 clangDaemon requires clangLex.
llvm-svn: 306612
2017-06-28 22:57:15 +00:00
Kirill Bobyrev 4621387d9d [clangd] Cleanup ClangdUnit.cpp, update docs; NFC
* 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
2017-06-28 20:57:28 +00:00
Marc-Andre Laperle 2cbf03728a [clangd] Add "Go to Declaration" functionality
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
2017-06-28 16:12:10 +00:00
Ilya Biryukov a46f7a9bf4 [clangd] Allow to override resource dir in ClangdServer.
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
2017-06-28 10:34:50 +00:00
Krasimir Georgiev a1de3c91e5 [clangd] Add priority to completion item sort text
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
2017-06-15 09:11:57 +00:00
Ilya Biryukov af0c04b30b [clangd] Add a filename parameter to FileSystemProvider.
Reviewers: krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D34151

llvm-svn: 305376
2017-06-14 09:46:44 +00:00
Ilya Biryukov 0bdafe5b63 [clangd] A comment for ClangdServer's constructor. NFC.
llvm-svn: 305299
2017-06-13 16:02:27 +00:00
Ilya Biryukov 103c951c52 [clangd] Store references instead of unique_ptrs in ClangdServer.
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
2017-06-13 15:59:43 +00:00
Ilya Biryukov 0e27ce4271 [clangd] Allow to override contents of the file during completion.
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
2017-06-13 14:15:56 +00:00
Ilya Biryukov 8cc09eb8dd Revert "[clangd] Allow to override contents of the file during completion."
This caused buildbots failures, reverting until we'll find out what's
wrong.

llvm-svn: 305283
2017-06-13 10:01:11 +00:00
Ilya Biryukov b23ff10c67 [clangd] Allow to override contents of the file during completion.
Reviewers: krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D34107

llvm-svn: 305280
2017-06-13 08:32:27 +00:00
Ilya Biryukov e36035b121 [clangd] Use 'std::string' for VFSTag instead of 'int'
Reviewers: krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D34106

llvm-svn: 305279
2017-06-13 08:24:48 +00:00
Argyrios Kyrtzidis 783e4c2e32 [clangd] Update for ASTUnit API change.
llvm-svn: 305046
2017-06-09 02:04:19 +00:00
Krasimir Georgiev e6035a51f7 [clangd] Add parameter and return type information to completion results
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
2017-06-08 15:11:51 +00:00
Ilya Biryukov 2260299830 [clangd] Mark results of clangd requests with a tag provided by the 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
2017-05-30 15:11:02 +00:00
Ilya Biryukov 0f62ed2bbe [clangd] Allow to use vfs::FileSystem for file accesses.
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
2017-05-26 12:26:51 +00:00
Ilya Biryukov 9bab8eab49 [clangd] Added a missing dependency on clangdAST to fix the build
llvm-svn: 303636
2017-05-23 13:59:37 +00:00
Ilya Biryukov f01af686a2 [clangd] Replaced WorkerRequest with std::function...
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
2017-05-23 13:42:59 +00:00
Benjamin Kramer 85c7827a0a [clangd] Explicitly link against pthread.
llvm-svn: 303625
2017-05-23 10:29:54 +00:00
Benjamin Kramer b2dfa0b840 [clangd] Pick up deps via LLVM components, which will hopefully include pthread.
llvm-svn: 303623
2017-05-23 10:17:48 +00:00
Ilya Biryukov af4ed4528a [clangd] Split clangd into library+executable (mainly for unit tests).
Summary:
This commit itself doesn't add any unit tests, but one that does will
follow shortly.

Reviewers: krasimir, bkramer

Reviewed By: bkramer

Subscribers: mgorny, klimek, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D33395

llvm-svn: 303616
2017-05-23 08:12:45 +00:00
Krasimir Georgiev d814533851 [clangd] Switch to incomplete translation units
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
2017-05-22 12:49:08 +00:00
Ilya Biryukov 687b92a993 Added missing includes in clangd to fix the build.
This commit should fix buildbot failures.

llvm-svn: 303177
2017-05-16 15:23:55 +00:00
Ilya Biryukov afb555473e [clangd] Refactor ProtocolHandlers to decouple them from ClangdLSPServer
Summary:
A refactoring to decouple ProtocolHandlers and Language Server input parsing
loop from the ClangdLSPServer.
The input parsing was extracted from `main` to a function(runLanguageServerLoop).
ProtocolHandlers now provide an interface to handle various LSP methods,
this interface is used by ClangdLSPServer.
Methods for code formatting were moved from ProtocolHandlers to ClangdServer.
ClangdLSPServer now provides a cleaner interface that only runs Language Server
input loop.

Reviewers: bkramer, krasimir

Reviewed By: krasimir

Subscribers: cfe-commits, klimek

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D33201

llvm-svn: 303173
2017-05-16 14:40:30 +00:00
Ilya Biryukov 2f314104e0 Fixing compilation failures on buildbots.
llvm-svn: 303154
2017-05-16 10:06:20 +00:00
Ilya Biryukov 38d79774d0 Restored r303067 and fixed failing test.
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
2017-05-16 09:38:59 +00:00
Adam Nemet 076047b4d9 Revert "[ClangD] Refactor clangd into separate components"
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
2017-05-15 18:14:35 +00:00