This improves the behavior related to type aliases, as well as cases of
typo correction.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp | ||
---|---|---|
268 | what about saving the full range here, and using it's start and length - name.size() as removal range in apply? similarly we can also use the range.text as text to insert. that way we can inline getNNSLAsString as it won't be needed elsewhere anymore. | |
274 | it is not that important, but I suppose NameRef is going to be alive during apply, so I suppose we can keep Name as a llvm::StringRef. | |
clang-tools-extra/clangd/unittests/TweakTests.cpp | ||
2828 | Tests don't seem to be covering something like: namespace foo { namespace bar { struct X {}; } } using namespace foo; bar::X^ x; |
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp | ||
---|---|---|
268 | We only have a range in this branch of the code. The other one (for DeclRefExpr) is not using TokenBuffers, so no range right now. We may change it in the future. Or would you prefer this changed now? | |
274 | Right, it used to be NameRef, then in some random version of the code pre-review it had to be a string and I never reverted that. Good point, thanks. | |
clang-tools-extra/clangd/unittests/TweakTests.cpp | ||
2828 | So this has the unfortunate side-effect of triggering a variation of https://github.com/clangd/clangd/issues/585 That's something I'm fixing in a later change (although this case is still not handled). For now, I'm putting an extra namespace scope to make this test correct, while still testing your example. |
thanks, lgtm!
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp | ||
---|---|---|
268 |
Ah right, I've forgot that one. My main concern was the extra getSpellingLoc in apply.
No hurries. | |
clang-tools-extra/clangd/unittests/TweakTests.cpp | ||
2828 | sorry for being confusing, I was actually suggesting putting: namespace foo { namespace bar { struct X {}; } } using namespace foo; into the header (to prevent that bug from triggering), and only having the usage in the CC file. but this works too. |
what about saving the full range here, and using it's start and length - name.size() as removal range in apply?
similarly we can also use the range.text as text to insert. that way we can inline getNNSLAsString as it won't be needed elsewhere anymore.