summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/FuzzyMatch.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Tune the fuzzy-matching algorithmIlya Biryukov2019-03-151-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: To reduce the gap between prefix and initialism matches. The motivation is producing better scoring in one particular example, but the change does not seem to cause large regressions in other cases. The examples is matching 'up' against 'unique_ptr' and 'upper_bound'. Before the change, we had: - "[u]nique_[p]tr" with a score of 0.3, - "[up]per_bound" with a score of 1.0. A 3x difference meant that symbol quality signals were almost always ignored and 'upper_bound' was always ranked higher. However, intuitively, the match scores should be very close for the two. After the change we have the following scores: - "[u]nique_[p]tr" with a score of 0.75, - "[up]per_bound" with a score of 1.0. Reviewers: ioeric Reviewed By: ioeric Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59300 llvm-svn: 356261
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [clangd] Remove 'using namespace llvm' from .cpp files. NFCIlya Biryukov2019-01-071-23/+23
| | | | | | | | The new guideline is to qualify with 'llvm::' explicitly both in '.h' and '.cpp' files. This simplifies moving the code between header and source files and is easier to keep consistent. llvm-svn: 350531
* [clangd] Namespace style cleanup in cpp files. NFC.Sam McCall2018-10-201-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Standardize on the most common namespace setup in our *.cpp files: using namespace llvm; namespace clang { namespace clangd { void foo(StringRef) { ... } And remove redundant llvm:: qualifiers. (Except for cases like make_unique where this causes problems with std:: and ADL). This choice is pretty arbitrary, but some broad consistency is nice. This is going to conflict with everything. Sorry :-/ Squash the other configurations: A) using namespace llvm; using namespace clang; using namespace clangd; void clangd::foo(StringRef); This is in some of the older files. (It prevents accidentally defining a new function instead of one in the header file, for what that's worth). B) namespace clang { namespace clangd { void foo(llvm::StringRef) { ... } This is fine, but in practice the using directive often gets added over time. C) namespace clang { namespace clangd { using namespace llvm; // inside the namespace This was pretty common, but is a bit misleading: name lookup preferrs clang::clangd::foo > clang::foo > llvm:: foo (no matter where the using directive is). llvm-svn: 344850
* [clangd] FuzzyMatch exposes an API for its word segmentation. NFCSam McCall2018-07-201-40/+13
| | | | | | | | | | | | Summary: This is intended to be used for indexing, e.g. in D49417 Reviewers: ioeric, omtcyfz Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D49540 llvm-svn: 337527
* [clangd] FuzzyMatch: forbid tail-tail matches after a miss: [pat] !~ "panther"Sam McCall2018-06-141-21/+25
| | | | | | | | | | | | | | | | | Summary: This is a small code change but vastly reduces noise in code completion results. The intent of allowing this was to let [sc] ~ "strncpy" and [strcpy] ~ "strncpy" however the benefits for unsegmented names aren't IMO worth the costs. Test cases should be representative of the changes here. Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47950 llvm-svn: 334712
* [clangd] Boost fuzzy match score by 2x (so a maximum of 2) when the query is ↵Sam McCall2018-06-061-1/+7
| | | | | | | | | | | | | | the full identifier name. Summary: Fix a couple of bugs in tests an in Quality to keep tests passing. Reviewers: ioeric Subscribers: ilya-biryukov, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D47815 llvm-svn: 334089
* [clangd] Fix unintentionally loose fuzzy matching, and the tests masking it.Sam McCall2018-03-051-14/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The intent was that [ar] doesn't match "FooBar"; the first character must match a Head character (hard requirement, not just a low score). This matches VSCode, and was "tested" but the tests were defective. The tests expected matches("FooBar") to fail for lack of a match. But instead it fails because the string should be annotated - matches("FooB[ar]"). This patch makes matches("FooBar") ignore annotations, as was intended. Fixing the code to reject weak matches for the first char causes problems: - [bre] no longer matches "HTMLBRElement". We allow matching against an uppercase char even if we don't think it's head. Only do this if there's at least one lowercase, to avoid triggering on MACROS - [print] no longer matches "sprintf". This is hard to fix without false positives (e.g. [int] vs "sprintf"]) This patch leaves this case broken. A future patch will add a dictionary providing custom segmentation to common names from the standard library. Fixed a couple of index tests that indirectly relied on broken fuzzy matching. Added const in a couple of missing places for consistency with new code. Subscribers: klimek, ilya-biryukov, jkorous-apple, ioeric, cfe-commits Differential Revision: https://reviews.llvm.org/D44003 llvm-svn: 326721
* [clangd] Fix memcpy(?, null, 0) UB by switching to std::copySam McCall2018-01-191-2/+2
| | | | llvm-svn: 322949
* [clangd] Avoid divide-by-zeroSam McCall2018-01-171-1/+1
| | | | llvm-svn: 322668
* [clangd] Fix uninitialized-read found by asanSam McCall2018-01-131-3/+15
| | | | llvm-svn: 322443
* [clangd] Fix FuzzyMatch tests on windows, NFCSam McCall2017-12-021-2/+2
| | | | | | | | Without specifying the signedness of the underlying type for Action, packing it in a 1-bit field may restrict its range to [-1, 0] which can't represent Match. llvm-svn: 319606
* [clangd] Try to appease gcc constexpr bug (58541)Sam McCall2017-12-021-2/+2
| | | | llvm-svn: 319604
* [clangd] Define constants in the right namespace. NFCSam McCall2017-12-011-1/+5
| | | | llvm-svn: 319579
* [clangd] Fuzzy match scorerSam McCall2017-12-011-0/+373
Summary: This will be used for rescoring code completion results based on partial identifiers. Short-term use: - we want to limit the number of code completion results returned to improve performance of global completion. The scorer will be used to rerank the results to return when the user has applied a filter. Long-term use case: - ranking of completion results from in-memory index - merging of completion results from multiple sources (merging usually works best when done at the component-score level, rescoring the fuzzy-match quality avoids different backends needing to have comparable scores) Reviewers: ilya-biryukov Subscribers: cfe-commits, mgorny Differential Revision: https://reviews.llvm.org/D40060 llvm-svn: 319557
OpenPOWER on IntegriCloud