Commit Graph

1232 Commits

Author SHA1 Message Date
Nathan Ridge 8df5f444a2 [clangd] Include the diagnostics's code when comparing diagnostics
Summary: This fixes https://github.com/clangd/clangd/issues/60

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363889
2019-06-19 23:11:02 +00:00
Ilya Biryukov 482269b9fa [clangd] Consume error returned by cleanupAndFormat
When called by ClangdServer::applyTweak.
No idea how to actually trigger this in practice, so no tests.

llvm-svn: 363844
2019-06-19 17:30:02 +00:00
Ilya Biryukov a7acc7e855 [clangd] Format changes produced by rename
Reviewers: hokein, kadircet, sammccall

Reviewed By: kadircet

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363843
2019-06-19 17:25:24 +00:00
Ilya Biryukov d0aa6c58be [clangd] Collect tokens of main files when building the AST
Summary:
The first use of this is a code tweak to expand macro calls.
Will later be used to build syntax trees.

The memory overhead is small as we only store tokens of the main file.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 363803
2019-06-19 14:03:19 +00:00
Haojian Wu 982a1cf028 [clangd] Correct the MessageType enum values.
llvm-svn: 363798
2019-06-19 13:14:59 +00:00
Sam McCall 08372eb73b Revert "[clangd] Return vector<TextEdit> from applyTweak. NFC"
This reverts commit r363691.

llvm-svn: 363766
2019-06-19 07:29:10 +00:00
Sam McCall 38047dbca4 [clangd] Add ClangdServer accessor for buffer contents
llvm-svn: 363765
2019-06-19 07:29:05 +00:00
Douglas Yung c4d5c37285 [TEST] Fix test on Windows by looking for substrings rather than a regex
since the escaping of special characters appears to break on Windows.

llvm-svn: 363761
2019-06-19 03:02:33 +00:00
Ilya Biryukov df9ee08b64 [clangd] Return vector<TextEdit> from applyTweak. NFC
For the same reasons as r363150, which got overwritten by changes in
r363680.

Sending without review to unbreak our integrate.

llvm-svn: 363691
2019-06-18 15:15:41 +00:00
Haojian Wu 9483bcf781 [clangd] Remove the extra ";", NFC
llvm-svn: 363681
2019-06-18 13:52:00 +00:00
Sam McCall 395fde753c [clangd] Add hidden tweaks to dump AST/selection.
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
2019-06-18 13:37:54 +00:00
Sam McCall 8d41294c18 [clangd] Add a capability to enable completions with fixes.
Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 363664
2019-06-18 11:57:26 +00:00
Haojian Wu 8ddf31bc33 [clangd] Parse files without extensions if we don't have a compile command.
Summary: This would enable clangd for C++ standard library files.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 363663
2019-06-18 11:54:17 +00:00
Haojian Wu 40fdd7a643 [clangd] Detect C++ language based on well-known file path in vscode extension
Summary:
Matching the "C++" pattern on the first line of the file doesn't cover
all cases, MSVC C++ headers doesn't have such pattern. This patch
introduce a new heuristic to detect language based on the file path.

MSVC C++ standard headers are in the directory like
"c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726\include"

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 363662
2019-06-18 11:53:14 +00:00
Haojian Wu b5ce4e5ea3 [clangd] Perform merge for main file symbols.
Summary:
Previously, we randomly pick one main file symbol in dynamic index, we
may loose the ideal symbol (with definition location) in the index.

It fixes the issue where sometimes we fail to go to the symbol definition, see:

1. call go-to-decl on Foo in Foo.cpp
2. jump to Foo.h, call go-to-def on Foo in Foo.h

we can't go back to Foo.cpp -- because we open Foo.cpp, Foo.h in clangd, both
files have Foo symbol (one with def&decl, one with decl only), we randomely
choose one.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363568
2019-06-17 14:49:18 +00:00
Haojian Wu 7dc917603b [clangd] Bump vscode-clangd v0.0.15.
CHANGELOG:
- support detecting C++ language from first line (`-*- C++ -*-`) of the file.

llvm-svn: 363555
2019-06-17 13:18:24 +00:00
Haojian Wu d53027697c [clangd] Detect C++ for extension-less source files in vscode extension
Summary:
Extend our extension to support detecting these files as C++ files based on the first
line (`-*- C++ -*-`), it will make clangd work on C++ standard headers
(e.g. iostream).

We use the contributes.languages[1] to enrich the builtin VScode C++
support.

[1]: https://code.visualstudio.com/api/references/contribution-points#contributes.languages

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363554
2019-06-17 12:59:14 +00:00
Nathan Ridge a552508841 [clangd] Type hierarchy subtypes
Summary:
This builds on the relations support added in D59407, D62459, D62471,
and D62839 to implement type hierarchy subtypes.

Reviewers: kadircet

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, mgrang, arphaman,
jdoerfert, cfe-commits

Tags: #clang

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

llvm-svn: 363506
2019-06-16 02:31:37 +00:00
Don Hinton b3fc9fde2c Fix gcc-05.4 bot failures caused by in r363481 "[clangd] Index API and implementations for relations"
Use std::make_tuple instead of initializer list to make gcc-5.4 happy.

See https://reviews.llvm.org/D62839 for details.

llvm-svn: 363504
2019-06-16 01:09:41 +00:00
Nathan Ridge f1e6f5713c [clangd] Index API and implementations for relations
Summary:
This builds on the relations support added in D59407, D62459,
and D62471 to expose relations in SymbolIndex and its
implementations.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363481
2019-06-15 02:26:47 +00:00
Haojian Wu f907849e2e [clangd] Bump vscode-clangd v0.0.14
CHANGELOG:
- use the vscode-buildin feature to detect language (rather than using
  file extensions), this fixes the extension not working on
  non-standard C++ files (e.g. via files.associations)

llvm-svn: 363375
2019-06-14 12:11:04 +00:00
Haojian Wu 30557ace0f [clangd] Don't maintain a list of c-family extensions in vscode extension.
Summary:
There is no need to maintain this list by ourself, vscode already
provides this feature.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363372
2019-06-14 11:56:13 +00:00
Shaurya Gupta 822794ef85 Test commit
llvm-svn: 363365
2019-06-14 09:40:42 +00:00
Kadir Cetinkaya 88e636dfc1 [Clangd] Fixed clangd diagnostics priority
Summary:
- Fixed diagnostics where zero width inserted ranges were being used instead of the whole token
- Added unit tests

Patch by @SureYeaah !

Reviewers: sammccall, kadircet

Reviewed By: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang-tools-extra, #clang

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

llvm-svn: 363253
2019-06-13 12:31:36 +00:00
Kadir Cetinkaya 4977927536 [clangd] Treat lambdas as functions when preparing hover response
Reviewers: sammccall, ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363237
2019-06-13 08:51:44 +00:00
Ilya Biryukov 04112ecd41 [clangd] Return TextEdits from ClangdServer::applyTweak
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
2019-06-12 12:03:24 +00:00
Nikolai Kosjar f6efac67e1 [clangd] Fix typo in GUARDED_BY()
Reviewers: ilya-biryukov, kadircet, sammccall

Subscribers: javed.absar, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 363139
2019-06-12 11:01:19 +00:00
Haojian Wu b011ee8ae8 [clangd] Add missing header guard.
llvm-svn: 363037
2019-06-11 08:50:35 +00:00
Mikael Holmen e2acbeb94c [clangd] Fix gcc warning by removing extra ";"
llvm-svn: 363034
2019-06-11 06:02:01 +00:00
Sam McCall c920c37361 [clangd] Remove old hidden -use-dex-index flag
llvm-svn: 362978
2019-06-10 20:38:16 +00:00
Sam McCall 25c6257ba0 [clangd] Revamp textDocument/onTypeFormatting.
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
2019-06-10 14:26:21 +00:00
Sam McCall 149786d5b7 [clangd] Stop marshalling/requiring FormattingOptions. We never did anything with them.
llvm-svn: 362934
2019-06-10 13:01:49 +00:00
Ilya Biryukov a7a1147d4f [clangd] Return empty results on spurious completion triggers
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
2019-06-07 16:24:38 +00:00
Ilya Biryukov 54eeb3f40a [clangd] Remove unused signature help quality signal. NFC
ContainsActiveParameter is not used anywhere, set incorrectly (see the
removed FIXME) and has no unit tests.
Removing it to simplify the code.

llvm-svn: 362686
2019-06-06 08:32:25 +00:00
Ilya Biryukov 2df387b057 [clangd] Minor cleanup. NFC
Removed unused using declaration from TweakTests.cpp

llvm-svn: 362517
2019-06-04 16:19:11 +00:00
Kadir Cetinkaya a7f9f42d28 [clangd] Also apply adjustArguments when returning fallback commands
Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 362496
2019-06-04 13:38:36 +00:00
Simon Pilgrim 5b41fe58de Fix -Wparentheses warning. NFCI.
llvm-svn: 362491
2019-06-04 11:31:45 +00:00
Simon Pilgrim 5f7c20e279 Fix Wshadow warning
llvm-svn: 362489
2019-06-04 11:11:51 +00:00
Ilya Biryukov 4ef0f82b71 [clangd] Support offsets for parameters in signatureHelp
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
2019-06-04 09:36:59 +00:00
Ilya Biryukov 65de43bc8b [clangd] Fix a crash when clang-tidy is disabled
llvm-svn: 362469
2019-06-04 07:19:11 +00:00
Nathan Ridge 73e6f47da2 [clangd] SymbolCollector support for relations
Summary:
The only relation currently collected is RelationBaseOf, because this is
all we need for type hierarchy subtypes. Additional relations can be
collected in the future as the need arises.

This patch builds on D59407 and D62459.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 362467
2019-06-04 04:25:44 +00:00
Ilya Biryukov 1a44584588 [CodeComplete] Add a bit more whitespace to completed patterns
Summary:
E.g. we now turn `while(<#cond#>){` into `while (<#cond#>) {`

This slightly improves the final output. Should not affect clients that
format the result on their own.

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 362363
2019-06-03 08:34:25 +00:00
Nathan Ridge 92524f9bf8 [clangd] Serialization support for RelationSlab
Summary: This builds on D59407 to provide YAML and RIFF serialization support.

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 362353
2019-06-03 05:07:52 +00:00
Nathan Ridge 3fc299df3d [clangd] Add RelationSlab
Summary:
RelationSlab is a new index data structure that stores relations between
symbols.

Reviewers: kadircet

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 362352
2019-06-03 04:55:46 +00:00
Haojian Wu 488c509d45 [clangd] Add missing license for rename.cpp, NFC.
llvm-svn: 362226
2019-05-31 14:38:16 +00:00
Nathan Ridge b2f45ac299 [clangd] clang-format SymbolCollector.cpp
llvm-svn: 362176
2019-05-30 23:54:43 +00:00
Chris Bieneman 760a9ee63c Support codesigning bundles and forcing
Summary:
Clangd's framework is assembled by copying binaries from the lib and bin directories into a bundle shape. This results in an invalid bundle code signature because the signature only applies to the binaries not the resources.

This patch adds two new options to `llvm_codesign` to enable re-signing the library and XPC service as bundles.

The `BUNDLE_PATH` option allow specifying an explicit path to codesign, which enables signing bundles which aren't generated using CMake's `FRAMEWORK` or `BUNDLE` target properties.

The `FORCE` option allows re-signing binaries that have already been signed. This is required for how clangd exposes the clangd library and tools as both XPC and non-XPC services using the same binary.

Reviewers: jkorous, bogner

Reviewed By: bogner

Subscribers: mgorny, ilya-biryukov, dexonsmith, arphaman, kadircet, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 362169
2019-05-30 22:25:48 +00:00
Ilya Biryukov f6faa382f3 [Index] Compute correct symbol kind for variable templates
Summary:
The index library itself seems to never pass variable templates as
input, however clangd does.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 361996
2019-05-29 17:49:30 +00:00
Ilya Biryukov c450874cb8 [clangd] Map typedefs to the same LSP completion kind as VSCode
For consistency and, more importantly, to get a nicer icon for those in VSCode.

llvm-svn: 361969
2019-05-29 15:10:19 +00:00
Haojian Wu 228b130a4b [clangd] Fix buildbot error.
llvm-svn: 361960
2019-05-29 14:11:53 +00:00