summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/tool/ClangdMain.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Extract ClangdServer::Options struct.Sam McCall2018-03-051-18/+15
| | | | | | | | | | | | | | | | | | 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] Address FIXME and fix commentKirill Bobyrev2018-02-251-3/+4
| | | | | | | | | | | | | | | * Address a FIXME by warning the user that both -run-synchronously and -j X are passed. * Fix a comment to suppress clang-tidy warning by passing the correct argument name. Reviewers: ioeric Subscribers: ilya-biryukov, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D43671 llvm-svn: 326051
* [clangd] Dump stack on crashSam McCall2018-02-201-0/+1
| | | | llvm-svn: 325574
* [clangd] collect symbol #include & insert #include in global code completion.Eric Liu2018-02-161-0/+1
| | | | | | | | | | | | | | | | | | 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] Enable snippet completion based on client capabilities.Ilya Biryukov2018-02-151-8/+0
| | | | | | | | | | | | | | 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] Configure clangd tracing with CLANGD_TRACE env instead of -trace flagSam McCall2018-02-141-10/+8
| | | | llvm-svn: 325097
* [clangd] Collect definitions when indexing.Sam McCall2018-02-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Within a TU: - as now, collect a declaration from the first occurrence of a symbol (taking clang's canonical declaration) - when we first see a definition occurrence, copy the symbol and add it Across TUs/sources: - mergeSymbol in Merge.h is responsible for combining matching Symbols. This covers dynamic/static merges and cross-TU merges in the static index. - it prefers declarations from Symbols that have a definition. - GlobalSymbolBuilderMain is modified to use mergeSymbol as a reduce step. Random cleanups (can be pulled out): - SymbolFromYAML -> SymbolsFromYAML, new singular SymbolFromYAML added - avoid uninit'd SymbolLocations. Add an idiomatic way to check "absent". - CanonicalDeclaration (as well as Definition) are mapped as optional in YAML. - added operator<< for Symbol & SymbolLocation, for debugging Reviewers: ioeric, hokein Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D42942 llvm-svn: 324735
* [clangd] Support simpler JSON-RPC stream parsing for lit tests.Sam McCall2018-02-061-1/+21
| | | | | | | | | | | | | | 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] Enable completion index by default, limit results to 100.Sam McCall2018-01-301-5/+5
| | | | | | | | | | | | | | | | | | | | | Summary: This should speed up global code completion by avoiding deserializing preamble declarations to look up names. The tradeoff is memory usage. Currently the index is fairly naive and may not be much faster, but there's lots of performance headroom. These two changes go together because results from the index get copied a couple of times, so we should avoid it for huge sets. Also the flag should be -completion-limit, rather than -limit-completion. Reviewers: hokein, ioeric, ilya-biryukov Subscribers: klimek, jkorous-apple, cfe-commits Differential Revision: https://reviews.llvm.org/D42669 llvm-svn: 323734
* [clangd] Limit completion results.Haojian Wu2018-01-251-0/+7
| | | | | | | | | | | | | | | | | | Summary: * truncate symbols from static/dynamic index to the limited number (which would save lots of cost in constructing the merged symbols). * add an CLI option allowing to limit the number of returned completion results. (default to 100) Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D42484 llvm-svn: 323408
* [clangd] Add static index for the global code completion.Haojian Wu2018-01-101-1/+31
| | | | | | | | | | | | | | | | | | | | 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-1/+9
| | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: klimek, ilya-biryukov, cfe-commits Differential Revision: https://reviews.llvm.org/D41289 llvm-svn: 321092
* [clangd] Implemented tracing using ContextIlya Biryukov2017-12-141-2/+8
| | | | | | | | | | | | Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall Subscribers: klimek, luckygeck, cfe-commits Differential Revision: https://reviews.llvm.org/D40488 llvm-svn: 320706
* [clangd] Implemented logging using ContextIlya Biryukov2017-12-131-0/+2
| | | | | | | | | | | | Reviewers: sammccall, ioeric, hokein Reviewed By: sammccall Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D40486 llvm-svn: 320576
* [clangd] clang-format the code. NFCIlya Biryukov2017-12-121-2/+1
| | | | llvm-svn: 320476
* [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-3/+16
| | | | | | | | | | | | 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] Use in-memory preambles in clangd.Ilya Biryukov2017-11-161-2/+26
| | | | | | | | | | | | Reviewers: klimek, bkramer, sammccall Reviewed By: sammccall Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D39843 llvm-svn: 318412
* Adds a json::Expr type to represent intermediate JSON expressions.Sam McCall2017-11-061-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Performance tracing facility for clangd.Sam McCall2017-11-021-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Fix clang-tidy warnings.Benjamin Kramer2017-10-281-1/+0
| | | | | | No functionality change intended. llvm-svn: 316832
* [clangd] Don't use /// for non-doxygen comments.Benjamin Kramer2017-10-261-3/+3
| | | | llvm-svn: 316650
* [clangd] Handle exit notification (proper shutdown)Ilya Biryukov2017-10-251-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This changes the onShutdown handler to do essentially nothing (for now), and instead exits the runloop when we receive the exit notification from the client. Some clients may wait on the reply from the shutdown request before sending an exit notification. If we exit the runloop already in the shutdown request, a client might block forever. This also gives us the opportunity to do any global cleanups and/or serializations of PCH preambles to disk, but I've left that out for now. See the LSP protocol documentation for details. Reviewers: malaperle, krasimir, bkramer, sammccall, ilya-biryukov Reviewed By: malaperle, sammccall, ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D38939 llvm-svn: 316564
* Revert "Revert r315214 since diff -Z isn't portable, this is breaking:"Ilya Biryukov2017-10-101-2/+22
| | | | | | | | | This reverts commit r315242 and restores r315214. To fix original failure, replaced non-portable `diff -Z` with portable alternative: `diff -b`. llvm-svn: 315287
* Revert r315214 since diff -Z isn't portable, this is breaking:Bruno Cardoso Lopes2017-10-091-22/+2
| | | | | | | http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive http://green.lab.llvm.org/green/job/clang-stage1-configure-RA llvm-svn: 315242
* [clangd] Added a command-line arg to mirror clangd input into a file.Ilya Biryukov2017-10-091-2/+22
| | | | | | | | | | | | | | Summary: The arg is useful for debugging and creating test cases. Reviewers: bkramer, krasimir Reviewed By: bkramer Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37970 llvm-svn: 315214
* [clangd] Command line arg to specify compile_commands.json pathIlya Biryukov2017-10-021-4/+29
| | | | | | | | | | Summary: Adds compileCommands command line argument to specify an absolute path directly to the requested compile_commands.json for flags. Reviewed By: ilya-biryukov Differential Revision: https://reviews.llvm.org/D37150 llvm-svn: 314678
* [clangd] Add support for snippet completionsIlya Biryukov2017-09-121-1/+8
| | | | | | | | | | | | | | 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] Use multiple working threads in clangd.Ilya Biryukov2017-08-141-5/+23
| | | | | | | | | | | | Reviewers: bkramer, krasimir, klimek Reviewed By: klimek Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D36261 llvm-svn: 310821
* [clangd] Capitalized descriptions of clangd options. NFC.Ilya Biryukov2017-08-021-2/+2
| | | | | | To follow the style of other options shown on `clangd -help`. llvm-svn: 309800
* [clangd] Allow specifying -resource-dirKrasimir Georgiev2017-07-191-1/+9
| | | | | | | | | | | | | | | | 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
* [clangd] Split clangd into library+executable (mainly for unit tests).Ilya Biryukov2017-05-231-0/+40
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
OpenPOWER on IntegriCloud