summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/ClangdLSPServer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Revert "[clangd] Implement "textDocument/documentLink" protocol ↵Sam McCall2020-01-021-0/+24
| | | | | | | | | | support"" This reverts commit 079ef783dd5530b5f87beefe624b9179547ded7e. The revert describes a test failure without details, after offline discussion this in in a private/unsupported build system and doesn't seem to reflect a real upstream bug.
* Revert "[clangd] Implement "textDocument/documentLink" protocol support"Dmitri Gribenko2019-12-161-24/+0
| | | | | | This reverts commit d6417f5584aa7673fa0212029a96cc9cacb1aad5. The tests depend on builtin headers, which is not intentionally supported in clangd tests; these tests are broken in some build environments.
* [clangd] Introduce paragraph, the first part of new rendering structsKadir Cetinkaya2019-12-131-2/+2
| | | | | | | | | | | | | | | Summary: Initial patch for new rendering structs in clangd. Splitting implementation into smaller chunks, for a full view of the API see D71063. Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71248 Reviewers: sammccall
* [clangd] Implement "textDocument/documentLink" protocol supportMichael Forster2019-12-121-0/+24
| | | | | | | | | | | | | | | | | | | Summary: This adds an implementation for the "textDocument/documentLink" LSP request. It returns links for all `#include` directives to the resolved target files. Fixes https://github.com/clangd/clangd/issues/217. Reviewers: sammccall Reviewed By: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70872
* [clangd] (take 2) Try harder to find a plausible `clang` as argv0, ↵Sam McCall2019-12-061-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | particularly on Mac. Summary: This was originally committed in 88bccded8fa169481fa367debf5ec615640635a1, and reverted in 93f77617abba512d2861e2fc50ce385883f587b6. This version is now much more testable: the "detect toolchain properties" part is still not tested but also not active in tests. All the command manipulation based on the detected properties is directly tested, and also not active in other tests. Fixes https://github.com/clangd/clangd/issues/211 Fixes https://github.com/clangd/clangd/issues/178 Reviewers: kbobyrev, ilya-biryukov Subscribers: mgorny, ormris, cfe-commits, usaxena95, kadircet, arphaman, jkorous, MaskRay Tags: #clang Differential Revision: https://reviews.llvm.org/D71029
* [clangd] Implement cross-file rename.Haojian Wu2019-11-261-15/+21
| | | | | | | | | | | | | | | | | Summary: This is the initial version. The cross-file rename is purely based on the index. It is hidden under a command-line flag, and only available for a small set of symbols. Reviewers: ilya-biryukov, sammccall Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69263
* [clangd] Expose the xref's incomplete flag to clangdServer API.Haojian Wu2019-11-181-1/+7
| | | | | | | | | | | | Summary: so that clangd C++ API users (via ClangdServer) can access it. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70380
* [clangd] abort if shutdown takes more than a minute.Sam McCall2019-10-231-3/+5
| | | | | | | | | | | | | | | | | | | | Summary: A certain class of bug (e.g. infloop on an AST worker thread) currently means clangd never terminates, even if the editor shuts down the protocol and closes our stdin, and the main thread recognizes that. Instead, let's wait 60 seconds for threads to finish cleanly, and then crash if they haven't. (Obviously, we should still fix these bugs). Reviewers: kadircet Subscribers: MaskRay, jkorous, arphaman, jfb, usaxena95, cfe-commits, ilya-biryukov Tags: #clang Differential Revision: https://reviews.llvm.org/D69329
* [clangd] Propagate main context into ClangdServerKadir Cetinkaya2019-10-151-9/+16
| | | | | | | | | | | | | | | | | | | | Summary: Currently clangd initializes the ClangdServer lazily during onInitialize request, and it results in propagation of caller's context rather than the main context created ClangdLSPServer. This patch changes the logic to store main context that created ClangdLSPServer and pass it onto to ClangdServer and other objects like CDBs. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68978 llvm-svn: 374892
* [clangd] Make sure ReplyCallbacks are destroyed before RequestCancelersMutexKadir Cetinkaya2019-10-091-10/+13
| | | | | | | | | | | | | | | | | Summary: After rL374163, replycallbacks might have a cancellable context, which will try to access RequestCancellers on destruction. See http://45.33.8.238/mac/1245/step_7.txt for a sample failure. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits, thakis Tags: #clang Differential Revision: https://reviews.llvm.org/D68702 llvm-svn: 374168
* [clangd] Catch an unchecked "Expected<T>" in HeaderSourceSwitch.Haojian Wu2019-10-071-1/+1
| | | | | | | | | | | | | | Summary: Also fixes a potential user-after-scope issue of "Path". Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68564 llvm-svn: 373897
* [clangd] Always send file URIs to editorsKadir Cetinkaya2019-10-021-1/+1
| | | | | | | | | | | | | | | | Summary: Editors only know about file URIs, make sure we do not use any custom schemes while sending edits. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68324 llvm-svn: 373435
* [clangd] Use the index-based API to do the header-source switch.Haojian Wu2019-10-011-4/+10
| | | | | | | | | | | | | | | | Summary: If the file heuristic fails, we try to use the index&AST to do the header/source inference. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68211 llvm-svn: 373320
* [clangd] Add semantic selection to ClangdLSPServer.Utkarsh Saxena2019-09-241-0/+45
| | | | | | | | | | | | | | | | | | | | | | Summary: This adds semantic selection to the LSP Server. Adds support for serialization of input request and the output reply. Also adds regression tests for the feature. Currently we do not support multi cursor.The LSP Server only accepts single position in the request as opposed to many position in the spec. Spec: https://github.com/microsoft/language-server-protocol/blob/dbaeumer/3.15/specification.md#textDocument_selectionRange Reviewers: hokein Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67720 llvm-svn: 372753
* [clangd] Support multifile edits as output of TweaksKadir Cetinkaya2019-09-091-9/+50
| | | | | | | | | | | | | | | | | | | | Summary: First patch for propogating multifile changes from tweak outputs to LSP WorkspaceEdits. Uses SM to convert tooling::Replacements to TextEdits. Errors out if there are any inconsistencies between the draft version and the version generated the edits. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66637 llvm-svn: 371392
* [clangd] Replace HighlightingKind::NumKinds with LastKind. NFCIlya Biryukov2019-09-091-1/+1
| | | | | | | | | | | | | | | | | | Summary: The latter simplifies the client code by avoiding the need to handle it as a separate case statement. Reviewers: hokein Reviewed By: hokein Subscribers: nridge, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67277 llvm-svn: 371375
* [clangd] Send highlighting diff beyond the end of the file.Haojian Wu2019-08-261-3/+2
| | | | | | | | | | | | | | Summary: This would make the client life (tracking the changes) easier. Reviewers: jvikstrom Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66541 llvm-svn: 369884
* [clangd] Send suppported codeActionKinds to the client.Haojian Wu2019-08-221-1/+11
| | | | | | | | | | | | | | | | | | | Summary: This would make client know which codeActionKinds that clangd may return. VSCode will add a new entry "Refactor..." (which shows all refactoring-kind code actions) in the right-click menu. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66592 llvm-svn: 369656
* [clangd] suppress -Wparentheses warning: suggest parentheses around ‘&&’ ↵Haojian Wu2019-08-161-1/+1
| | | | | | within ‘||’ llvm-svn: 369105
* [clangd] Simplify code of ClangdLSPServer::onCommandIlya Biryukov2019-08-161-41/+33
| | | | | | | | | | | | | | | | | | | | Summary: By inlining a complicated lambda into its single call-site. Also ensure we call Reply() exactly once even if tweaks return both ShowMessage and ApplyEdit effects. Reviewers: hokein Reviewed By: hokein Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66343 llvm-svn: 369100
* [clangd] Remove Bind, use C++14 lambda captures instead. NFCIlya Biryukov2019-08-161-4/+12
| | | | llvm-svn: 369089
* [clangd] Don't use Bind() where C++14 move capture worksBenjamin Kramer2019-08-151-132/+110
| | | | llvm-svn: 369005
* [clang-tools-extra] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-1/+1
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368944
* [clangd] Add a callback mechanism for handling responses from client.Haojian Wu2019-08-051-23/+113
| | | | | | | | | | | | | | | | | | | Summary: The callback will be invoked in clangd when we receive a reply from the client. This is a prerequisite of implementing a generic mechanism for chainable refactorings (e.g. extract variable and rename), this would allow server to trigger a new request to the LSP client after receiving a reply from the client. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65387 llvm-svn: 367845
* [clangd] Duplicate lines of semantic highlightings sent removed.Johan Vikstrom2019-08-011-2/+17
| | | | | | | | | | | | | | Summary: Added a class for diffing highlightings and removing duplicate lines. Integrated into the highlighting generation flow. Only works correctly if all tokens are on a single line. Also returns empty lines if the IDE should remove previous highlightings on a line. Reviewers: hokein, sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64475 llvm-svn: 367521
* [clangd] Implement "prepareRename"Haojian Wu2019-07-241-1/+16
| | | | | | | | | | | | | | | | | | Summary: - "prepareRename" request is added in LSP v3.12.0 - also update the vscode-client dependency to pick-up the rename bug fix[1] [1]: https://github.com/microsoft/vscode-languageserver-node/issues/447 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63126 llvm-svn: 366873
* [clangd] Implement typeHierarchy/resolve for subtypesNathan Ridge2019-07-131-0/+8
| | | | | | | | | | | | | | | | | | Summary: This allows the client to resolve subtypes one level at a time. For supertypes, this is not necessary, because we eagerly compute supertypes and return all levels. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64308 llvm-svn: 365986
* Revert "[clangd] Implement typeHierarchy/resolve for subtypes"Russell Gallop2019-07-121-8/+0
| | | | | | | | Causing test failure on Windows bot This reverts commit 5b9484e559d44bd923fc290e335891b1dd2e17c4. llvm-svn: 365899
* [clangd] Implement typeHierarchy/resolve for subtypesNathan Ridge2019-07-121-0/+8
| | | | | | | | | | | | | | | | | | Summary: This allows the client to resolve subtypes one level at a time. For supertypes, this is not necessary, because we eagerly compute supertypes and return all levels. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64308 llvm-svn: 365867
* [clangd] Add a flag to clangdServer rename function to control whether we ↵Haojian Wu2019-07-101-1/+1
| | | | | | | | | | | | | | | | | | | want format the replacements. Summary: This would allow clangd embedders to use the ClangdServer::rename for other purposes (highlighting all the occurrences of the symbol in prepare stage). Reviewers: sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64481 llvm-svn: 365631
* [clangd] Use -completion-style=bundled by default if signature help is availableSam McCall2019-07-081-0/+2
| | | | | | | | | | | | | | | | Summary: I didn't manage to find something nicer than optional<bool>, but at least I found a sneakier comment. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D64216 llvm-svn: 365356
* [clangd] Some tweaks on semantic highlighting lookuptable.Haojian Wu2019-07-041-1/+12
| | | | | | | | | | | | | | | | Summary: - move toTextMateScope to SemanticHighlighting.h; - move the buildLookupTable to LSP layer (as LSP requires such form); Reviewers: sammccall, jvikstrom Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64202 llvm-svn: 365135
* [clangd] Emit publishSemanticHighlighting in LSP if enabledJohan Vikstrom2019-07-041-0/+20
| | | | | | | | | | | | | | Summary: Emit publishSemanticHighlighting in LSP if enabled Reviewers: hokein, kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63919 llvm-svn: 365111
* [clangd] Enable extraction of system includes from custom toolchainsKadir Cetinkaya2019-06-261-1/+7
| | | | | | | | | | | | | | | | | | Summary: Some custom toolchains come with their own header files and compiler drivers. Those compiler drivers implicitly know about include search path for those headers. This patch aims to extract that information from drivers and add it to the command line when invoking clang frontend. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62804 llvm-svn: 364389
* Revert "[clangd] Return vector<TextEdit> from applyTweak. NFC"Sam McCall2019-06-191-2/+2
| | | | | | This reverts commit r363691. llvm-svn: 363766
* [clangd] Return vector<TextEdit> from applyTweak. NFCIlya Biryukov2019-06-181-2/+2
| | | | | | | | | For the same reasons as r363150, which got overwritten by changes in r363680. Sending without review to unbreak our integrate. llvm-svn: 363691
* [clangd] Add hidden tweaks to dump AST/selection.Sam McCall2019-06-181-10/+25
| | | | | | | | | | | | | | | | | | | | | | | Summary: This introduces a few new concepts: - tweaks have an Intent (they don't all advertise as refactorings) - tweaks may produce messages (for ShowMessage notification). Generalized Replacements -> Effect. - tweaks (and other features) may be hidden (clangd -hidden-features flag). We may choose to promote these one day. I'm not sure they're worth their own feature flags though. Verified it in vim-clangd (not yet open source), curious if the UI is ok in VSCode. Reviewers: ilya-biryukov Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62538 llvm-svn: 363680
* [clangd] Add a capability to enable completions with fixes.Sam McCall2019-06-181-0/+1
| | | | | | | | | | | | Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63091 llvm-svn: 363664
* [clangd] Return TextEdits from ClangdServer::applyTweakIlya Biryukov2019-06-121-2/+2
| | | | | | | | | | | | | | | | | | | | Summary: Instead of `tooling::Replacements`. So that embedders do not need to store the contents of the file. This also aligns better with `ClangdServer::rename`. Reviewers: kadircet, hokein Reviewed By: hokein Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63140 llvm-svn: 363150
* [clangd] Revamp textDocument/onTypeFormatting.Sam McCall2019-06-101-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The existing implementation (which triggers on }) is fairly simple and has flaws: - doesn't trigger frequently/regularly enough (particularly in editors that type the } for you) - often reformats too much code around the edit - has jarring cases that I don't have clear ideas for fixing This implementation is designed to trigger on newline, which feels to me more intuitive than } or ;. It does have allow for reformatting after other characters - it has a basic behavior and a model for adding specialized behavior for particular characters. But at least initially I'd stick to advertising \n in the capabilities. This also handles comment splitting: when you insert a line break inside a line comment, it will make the new line into an aligned line comment. Working on tests, but want people to patch it in and try it - it's hard to see if "feel" is right purely by looking at a test. Reviewers: ilya-biryukov, hokein Subscribers: mgorny, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60605 llvm-svn: 362939
* [clangd] Return empty results on spurious completion triggersIlya Biryukov2019-06-071-12/+6
| | | | | | | | | | | | | | | | | | | | | Summary: We currently return an error, this causes `coc.nvim` and VSCode to show an error message in the logs. Returning empty list of completions allows to avod the error message without altering other user-visible behavior. Reviewers: sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62999 llvm-svn: 362811
* Fix Wshadow warningSimon Pilgrim2019-06-041-2/+2
| | | | llvm-svn: 362489
* [clangd] Support offsets for parameters in signatureHelpIlya Biryukov2019-06-041-1/+17
| | | | | | | | | | | | | | | | Summary: Added to LSP in version 3.14 Reviewers: hokein Reviewed By: hokein Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62476 llvm-svn: 362481
* [clangd] Represent Hover result using FormattedStringIlya Biryukov2019-05-291-10/+22
| | | | | | | | | | | | | | Reviewers: sammccall, kadircet Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61601 llvm-svn: 361940
* [clangd] Introduce a structured hover responseKadir Cetinkaya2019-05-281-1/+14
| | | | | | | | | | | | | | | | Summary: Change ClangdServer layer to output a structured response for Hover, which can be rendered by client according to their needs. Reviewers: sammccall, ilya-biryukov Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61497 llvm-svn: 361803
* [clangd] Oops, switchSourceHeader still needs to return a URI.Sam McCall2019-05-071-2/+2
| | | | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61630 llvm-svn: 360121
* [clangd] switchSourceHeader uses null not empty string as sentinel.Sam McCall2019-05-071-4/+7
| | | | | | As far as I can see, only theia actually implements this, and it expects null. llvm-svn: 360119
* [clangd] Support relatedInformation in diagnostics.Sam McCall2019-04-181-0/+2
| | | | | | | | | | | | | | Summary: We already have the structure internally, we just need to expose it. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60267 llvm-svn: 358675
* [clangd] Return clangd::TextEdit in ClangdServer::rename. NFCIlya Biryukov2019-04-031-12/+6
| | | | | | | | | | | | | | | | | | | | Summary: Instead of tooling::Replacement. To avoid the need to have contents of the file at the caller site. This also aligns better with other methods in ClangdServer, majority of those already return LSP-specific data types. Reviewers: hokein, ioeric, sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60179 llvm-svn: 357561
* [clangd] Support utf-8 offsets (rather than utf-16) as a protocol extensionSam McCall2019-03-271-10/+38
| | | | | | | | | | | | | | | | Summary: Still some pieces to go here: unit tests for new SourceCode functionality and a command-line flag to force utf-8 mode. But wanted to get early feedback. Reviewers: hokein Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, kadircet, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58275 llvm-svn: 357102
OpenPOWER on IntegriCloud