summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/unittests/RenameTests.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix issues reported by -Wrange-loop-analysis when building with latest Clang ↵Alexandre Ganea2020-01-071-1/+1
| | | | | | (trunk). NFC. Fixes warning: loop variable 'E' of type 'const llvm::StringRef' creates a copy from type 'const llvm::StringRef' [-Wrange-loop-analysis]
* NFC: Fix trivial typos in commentsKazuaki Ishizaki2020-01-041-3/+3
|
* [clangd] Rename constructors and destructors in cross-file caseKirill Bobyrev2019-12-121-46/+81
| | | | | | | | | | | * Use ad-hoc Decl canonicalization from Clang-Rename to allow renaming constructors and destructors while using cross-file rename. * Manually handle the destructor selection * Add unit tests to prevent regressions and ensure the correct behaviour Reviewed by: sammccall Differential Revision: https://reviews.llvm.org/D71247
* [clangd] Deduplicate refs from index for cross-file rename.Haojian Wu2019-12-111-11/+63
| | | | | | | | | | | | | | | | | | | | | | Summary: If the index returns duplicated refs, it will trigger the assertion in BuildRenameEdit (we expect the processing position is always larger the the previous one, but it is not true if we have duplication), and also breaks our heuristics. This patch make the code robost enough to handle duplications, also save some cost of redundnat llvm::sort. Though clangd's index doesn't return duplications, our internal index kythe will. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, mgrang, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71300
* [clangd] Fix an incorrect expectedResult usage in rename test.Haojian Wu2019-12-101-4/+5
| | | | | | expectedResult(Code, expectedResult(T, "abc")) => should be expectedResult(T, "abc") The test was passed by coincidence.
* [clangd] Implement range patching heuristics for cross-file rename.Haojian Wu2019-12-091-0/+298
| | | | | | | | | | | | Reviewers: sammccall, ilya-biryukov Reviewed By: sammccall Subscribers: merge_guards_bot, MaskRay, jkorous, mgrang, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70594
* [clangd] More unittests for cross-file rename.Haojian Wu2019-12-051-1/+152
| | | | | | | | | | | | | | | | | Summary: The previous unittests for cross-file rename was kind of weak. With this patch, we should have more test coverage, and it is easy to add more tests in the future. Reviewers: ilya-biryukov, kbobyrev Reviewed By: ilya-biryukov Subscribers: merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71050
* [clangd] Fix an incorrect comment, NFC.Haojian Wu2019-12-051-1/+1
|
* [clangd] Fix a regression issue in local rename.Haojian Wu2019-12-021-1/+8
| | | | | | | | | | | | | | Summary: The regression is that we can't rename symbols in annonymous namespaces. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70853
* [clangd] Correct the file path in Edit::replacements when generating the ↵Haojian Wu2019-11-291-3/+5
| | | | | | | | | | | | | | | | | rename edit. Summary: The file path was set to the file content previously, and it isn't covered by normal clangd & unittest code path (as we only uses the offset, length, replacement text). Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70828
* [clangd] Don't perform rename when the refs result from index is incomplete.Haojian Wu2019-11-281-0/+28
| | | | | | | | | | | | | | Summary: Also do an early return if the number of affected files > limit to save some unnecessary FileURI computations. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70811
* [clangd] Speed up when building rename edit.Haojian Wu2019-11-261-0/+27
| | | | | | | | | | | | | | Summary: We used to scan the code everytime when computing the LSP position to the offset (respect the LSP encoding). Now we only scan the source code once. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70441
* [clangd] Implement cross-file rename.Haojian Wu2019-11-261-18/+127
| | | | | | | | | | | | | | | | | 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] Fix ps4 buildbot failure.Haojian Wu2019-11-191-2/+0
| | | | | dynamic_cast on ps4 buildbot seems relying on rtti flag which is off by default. Remove the dynamic_cast in the tests.
* Reland "[clangd] Implement rename by using SelectionTree and ↵Haojian Wu2019-11-191-16/+356
| | | | | | | | | findExplicitReferences." this reland the commit 4f80fc2491cc35730a9a84b86975278b7daa8522 which has been reverted at f805c60a093325c16ce4200d2615ef48555d9cb8. Fixed windows buildbot failure (by adding -fno-delayed-template-parsing flag).
* Revert "[clangd] Implement rename by using SelectionTree and ↵Wolfgang Pieb2019-11-181-359/+14
| | | | | | | | | findExplicitReferences." This reverts commit 4f80fc2491cc35730a9a84b86975278b7daa8522. Caused buildbot failure at http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/58251
* [clangd] Implement rename by using SelectionTree and findExplicitReferences.Haojian Wu2019-11-181-14/+359
| | | | | | | | | | | | | | | | | | | | | | | Summary: With the new implemenation, we will have better coverage of various AST nodes, and fix some known/potential bugs. Also added the existing clang-renamae tests. Known changed behavior: - "~Fo^o()" will not trigger the rename, will fix afterwards - references in macro bodies are not renamed now This fixes: - https://github.com/clangd/clangd/issues/167 - https://github.com/clangd/clangd/issues/169 - https://github.com/clangd/clangd/issues/171 Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69934
* [clangd] Fix diagnostic warnings in the RenameTests, NFC.Haojian Wu2019-11-181-2/+4
|
* [clangd] Improve the output of rename tests where there are failures.Haojian Wu2019-11-061-64/+54
| | | | | | | | | | | | | | | Summary: Previously, we match ranges, which is hard to spot the difference. Now, we diff the code after rename against the expected result, it produces much nicer output. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69890
* [clangd] Bail out early if we are sure that the symbol is used outside of ↵Haojian Wu2019-10-021-18/+26
| | | | | | | | | | | | | | | | | | the file. Summary: This would reduce the false positive when the static index is in an unavailable state, e.g. background index is not finished. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68325 llvm-svn: 373444
* [clangd] Fix a crash when renaming operator.Haojian Wu2019-09-161-0/+7
| | | | | | | | | | | | | | | | | | | | Summary: The renamelib uses a tricky way to calculate the end location by relying on decl name, this is incorrect for the overloaded operator (the name is "operator++" instead of "++"), which will cause out-of-file offset. We also disable renaming operator symbol, this case is tricky, and renamelib doesnt handle it properly. Reviewers: ilya-biryukov Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67607 llvm-svn: 371971
* [clangd] Show better message when we rename macros.Haojian Wu2019-07-011-0/+7
| | | | | | | | | | | | | | | | | | Summary: Previously, when we rename a macro, we get an error message of "there is no symbol found". This patch improves the message of this case (as we don't support macros). Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63922 llvm-svn: 364735
* [clangd] Fix a case where we fail to detect a header-declared symbol in rename.Haojian Wu2019-06-271-16/+25
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Failing case: ``` #include "foo.h" void fo^o() {} ``` getRenameDecl() returns the decl of the symbol under the cursor (which is in the current main file), instead, we use the canonical decl to determine whether a symbol is declared in #included header. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63872 llvm-svn: 364537
* [clangd] Don't rename the namespace.Haojian Wu2019-06-261-9/+25
| | | | | | | | | | | | | | | | | 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] 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 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-071-0/+47
Reviewers: kadircet Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, jfb, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61596 llvm-svn: 360116
OpenPOWER on IntegriCloud