summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* [clangd] Don't rename the namespace.Haojian Wu2019-06-262-10/+29
| | | | | | | | | | | | | | | | | Summary: Also fix a small bug -- the extra argument "-xc++" doesn't overwrite the language if the argument is present after the file name in the compiler command. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63759 llvm-svn: 364392
* [clangd] Add Value field to HoverInfoKadir Cetinkaya2019-06-261-3/+70
| | | | | | | | | | | | | | | | Summary: Put a symbols value information which is deduced from initializer expression into HoverInfo struct. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63330 llvm-svn: 364390
* [clangd] Fix NestedNameSpecifierLoc in SelectionTreeSam McCall2019-06-251-2/+8
| | | | | | | | | | | | Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63708 llvm-svn: 364284
* [clangd] Narrow rename to local symbols.Haojian Wu2019-06-251-0/+65
| | | | | | | | | | | | | | | | | | | Summary: Previously, we performed rename for all kinds of symbols (local, global). This patch narrows the scope by only renaming symbols not being used outside of the main file (with index asisitance). Renaming global symbols is not supported at the moment (return an error). Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63426 llvm-svn: 364283
* [clangd] Add include-mapping for C symbols.Haojian Wu2019-06-212-2/+16
| | | | | | | | | | | | | | | | | | | Summary: This resolves the issue of introducing c++-style includes for C files. - refactor the gen_std.py, make it reusable for parsing C symbols. - add a language mode to the mapping method to use different mapping for C and C++ files. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63270 llvm-svn: 364044
* [clangd] Collect tokens of main files when building the ASTIlya Biryukov2019-06-192-0/+34
| | | | | | | | | | | | | | | | | | | | 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
* [clangd] Add ClangdServer accessor for buffer contentsSam McCall2019-06-191-2/+6
| | | | llvm-svn: 363765
* [TEST] Fix test on Windows by looking for substrings rather than a regexDouglas Yung2019-06-191-4/+7
| | | | | | since the escaping of special characters appears to break on Windows. llvm-svn: 363761
* [clangd] Add hidden tweaks to dump AST/selection.Sam McCall2019-06-182-6/+75
| | | | | | | | | | | | | | | | | | | | | | | 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] Parse files without extensions if we don't have a compile command.Haojian Wu2019-06-181-0/+4
| | | | | | | | | | | | | | 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
* [clangd] Perform merge for main file symbols.Haojian Wu2019-06-171-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clangd] Type hierarchy subtypesNathan Ridge2019-06-161-1/+153
| | | | | | | | | | | | | | | | | 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
* [clangd] Index API and implementations for relationsNathan Ridge2019-06-158-89/+181
| | | | | | | | | | | | | | | | | 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
* [Clangd] Fixed clangd diagnostics priorityKadir Cetinkaya2019-06-131-2/+11
| | | | | | | | | | | | | | | | | | | | 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
* [clangd] Treat lambdas as functions when preparing hover responseKadir Cetinkaya2019-06-131-5/+75
| | | | | | | | | | | | Reviewers: sammccall, ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62814 llvm-svn: 363237
* [clangd] Revamp textDocument/onTypeFormatting.Sam McCall2019-06-102-0/+309
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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] Minor cleanup. NFCIlya Biryukov2019-06-041-1/+0
| | | | | | Removed unused using declaration from TweakTests.cpp llvm-svn: 362517
* [clangd] Also apply adjustArguments when returning fallback commandsKadir Cetinkaya2019-06-041-2/+5
| | | | | | | | | | | | Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62856 llvm-svn: 362496
* [clangd] Support offsets for parameters in signatureHelpIlya Biryukov2019-06-041-55/+62
| | | | | | | | | | | | | | | | 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] SymbolCollector support for relationsNathan Ridge2019-06-041-8/+23
| | | | | | | | | | | | | | | | | | | 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
* [CodeComplete] Add a bit more whitespace to completed patternsIlya Biryukov2019-06-031-1/+1
| | | | | | | | | | | | | | | | | | | | 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
* [clangd] Serialization support for RelationSlabNathan Ridge2019-06-031-2/+27
| | | | | | | | | | | | | | 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
* [clangd] Add RelationSlabNathan Ridge2019-06-031-0/+39
| | | | | | | | | | | | | | | | 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
* [Index] Compute correct symbol kind for variable templatesIlya Biryukov2019-05-291-0/+25
| | | | | | | | | | | | | | | | | | 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
* [Index] Correctly set symbol kind of IndirectFieldDeclIlya Biryukov2019-05-291-0/+14
| | | | | | | | | | | | | | | | Summary: The kind has been 'unknown' before, now it is 'field'. Reviewers: kadircet Reviewed By: kadircet Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62573 llvm-svn: 361941
* [clangd] Represent Hover result using FormattedStringIlya Biryukov2019-05-291-61/+208
| | | | | | | | | | | | | | 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] Add SourceManager accessor to ParsedAST. NFCSam McCall2019-05-283-5/+4
| | | | llvm-svn: 361883
* [clangd] Fix test output for r361841Ilya Biryukov2019-05-281-1/+1
| | | | llvm-svn: 361846
* [clangd] Place cursor better after completing patternsIlya Biryukov2019-05-282-2/+45
| | | | | | | | | | | | | | | | | | | | | | | | Summary: By producing the $0 marker in the snippets at the last placeholder. This produces nicer results in most cases, e.g. for namespace <#name#> { <#decls#> } we now produce ${0:decls} instead of ${2:decls} and the final cursor placement is more convenient. Reviewers: hokein Reviewed By: hokein Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62389 llvm-svn: 361841
* [clangd] Compute expected type for templatesIlya Biryukov2019-05-281-5/+27
| | | | | | | | | | | | | | Reviewers: sammccall Reviewed By: sammccall Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62515 llvm-svn: 361823
* [clangd] Introduce a structured hover responseKadir Cetinkaya2019-05-282-28/+328
| | | | | | | | | | | | | | | | 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] Limit the size of synthesized fix messageIlya Biryukov2019-05-241-1/+31
| | | | | | | | | | | | | | | | Summary: A temporary workaround until we figure out a better way to present fixes. Reviewers: kadircet Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62372 llvm-svn: 361625
* [CodeComplete] Filter override completions by function nameIlya Biryukov2019-05-241-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | Summary: We put only part of the signature starting with a function name into "typed text" chunks now, previously the whole signature was "typed text". This leads to meaningful fuzzy match scores, giving better signals to compare with other completion items. Ideally, we would not display the result type to the user, but that requires adding a new kind of completion chunk. Reviewers: kadircet Reviewed By: kadircet Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62298 llvm-svn: 361623
* [Index] Fix reported references in presence of template type aliasesIlya Biryukov2019-05-231-0/+11
| | | | | | | | | | | | | | | | Summary: See the added test for an example. Reviewers: kadircet Reviewed By: kadircet Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62303 llvm-svn: 361511
* [clangd] Turn no-parse-completion on by when preamble isn't ready. Add flag ↵Sam McCall2019-05-211-7/+14
| | | | | | | | | | | | | | to force it. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62135 llvm-svn: 361258
* [clangd] Add tweak to convert normal to raw string literal, when it contains ↵Sam McCall2019-05-211-3/+35
| | | | | | | | | | | | | | escapes. Reviewers: ilya-biryukov Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62151 llvm-svn: 361252
* [clangd] Fix naming warning from clang-tidy. NFCIlya Biryukov2019-05-201-5/+2
| | | | | | Also remove newlines and braces. llvm-svn: 361147
* [clangd] Respect WarningsAsErrors configuration for clang-tidyFangrui Song2019-05-193-0/+41
| | | | | | | | | | | | This completes the fix for https://bugs.llvm.org/show_bug.cgi?id=41218. Reviewed By: sammccall Patch by Nathan Ridge! Differential Revision: https://reviews.llvm.org/D61841 llvm-svn: 361113
* [clangd] Respect clang-tidy suppression commentsFangrui Song2019-05-191-0/+21
| | | | | | | | | | | | This partially fixes https://bugs.llvm.org/show_bug.cgi?id=41218. Reviewed By: sammccall Patch by Nathan Ridge! Differential Revision: https://reviews.llvm.org/D60953 llvm-svn: 361112
* [clangd] Count number of references while merging RefSlabs inside FileIndexKadir Cetinkaya2019-05-092-14/+54
| | | | | | | | | | | | | | | | | | | | | | | Summary: For counting number of references clangd was relying on merging every duplication of a symbol. Unfortunately this does not apply to FileIndex(and one of its users' BackgroundIndex), since we get rid of duplication by simply dropping symbols coming from non-canonical locations. So only one or two(coming from canonical declaration header and defined source file, if exists) replications of the same symbol reaches merging step. This patch changes reference counting logic to rather count number of different RefSlabs a given SymbolID exists. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, mgrang, arphaman, jdoerfert, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59481 llvm-svn: 360344
* [clangd] Fix a TSAN warning in TUSchedulerTestsIlya Biryukov2019-05-091-2/+6
| | | | llvm-svn: 360336
* Fix gcc compilation warning in test case [NFC]Mikael Holmen2019-05-091-1/+1
| | | | | | | | | | Without this, gcc (7.4) complains with ../tools/clang/tools/extra/clangd/unittests/PrintASTTests.cpp:99:28: error: ISO C++11 requires at least one argument for the "..." in a variadic macro [-Werror] }))); ^ llvm-svn: 360334
* [clangd] Introduce intermediate representation of formatted textIlya Biryukov2019-05-072-0/+157
| | | | | | | | | | | | | | | | Summary: That can render to markdown or plain text. Used for findHover requests. Reviewers: malaperle, sammccall, kadircet Reviewed By: sammccall Subscribers: mgorny, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58547 llvm-svn: 360151
* [clangd] Add test that r360116 accidentally fixed a duplicate-edits bug in ↵Sam McCall2019-05-071-20/+65
| | | | | | rename. NFC llvm-svn: 360118
* [clangd] Move Rename into its own file, and add unit test. NFCSam McCall2019-05-072-0/+48
| | | | | | | | | | | | Reviewers: kadircet Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61596 llvm-svn: 360116
* [clangd] Expose whether no-compile completion was used.Sam McCall2019-05-061-0/+3
| | | | | | | | | | | | | | Summary: Embedding clients want to experiment with showing such results in e.g. a different color. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61588 llvm-svn: 360039
* [clangd] Boost code completion results that were named in the last few lines.Sam McCall2019-05-063-2/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The hope is this will catch a few patterns with repetition: SomeClass* S = ^SomeClass::Create() int getFrobnicator() { return ^frobnicator_; } // discard the factory, it's no longer valid. ^MyFactory.reset(); Without triggering antipatterns too often: return Point(x.first, x.^second); I'm going to gather some data on whether this turns out to be a win overall. Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, jfb, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61537 llvm-svn: 360030
* [clangd] Qualify uses of ::testing everywhere. NFCIlya Biryukov2019-05-0615-113/+110
| | | | | | | | | Add an initial '::' qualifier to all usages of 'testing' namespace that did not have one. The goal is to make our code style in tests more consistent. llvm-svn: 360026
* Fix test to avoid assuming clang will diagnose problems in unreachable code.Richard Smith2019-05-061-0/+2
| | | | llvm-svn: 360009
* [clangd] Fix header-guard check for include insertion, and don't index ↵Sam McCall2019-05-031-1/+22
| | | | | | | | | | | | | | | | | | | | | header guards. Summary: Both of these attempt to check whether a header guard exists while parsing the file. However the file is only marked as guarded once clang finishes processing it. We defer the checks and work until SymbolCollector::finish(). This is ugly and ad-hoc, deferring *all* work might be cleaner. Reviewers: kadircet Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61442 llvm-svn: 359880
OpenPOWER on IntegriCloud