This is an helper for incoming move definition out-of-line action to
figure out possible insertion locations for definition of a qualified name.
Details
- Reviewers
hokein ilya-biryukov - Commits
- rGd62e3ed3f4b9: [clangd] Implement GetEligiblePoints
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 38577 Build 38576: arc lint + arc unit
Event Timeline
- Rename regions to points
- Return EOF if there are no shared namespaces with the target
A few go-by comments from me, Haojian should have better context here!
clang-tools-extra/clangd/SourceCode.cpp | ||
---|---|---|
655 | Yay! Thanks! Less templates, more type-checking! Could you rename 'A' to something more specific, though? | |
655 | why const Position and not const Position&? | |
674 | Should this be const Position& or Position? | |
996 | If we were to do this, I'd rather try matching brace structure and only report closing brace that is probably end of the top-level decl(function, struct, etc) events. Everything else seems super hard to get right. | |
clang-tools-extra/clangd/SourceCode.h | ||
270 | Do we ever name anonymous namespace here? How do we represent them? |
clang-tools-extra/clangd/SourceCode.cpp | ||
---|---|---|
996 | Actually, now I remembered that this should also work just fine. So LG |
The implementation looks good, just have some questions on the API.
clang-tools-extra/clangd/SourceCode.cpp | ||
---|---|---|
998 | If I understand the FIXME well, so we will extend the API to parse functions, so that we could get a more eligible point e.g. near the near the neighboring declaration. | |
clang-tools-extra/clangd/SourceCode.h | ||
270 | Current seems not clear enough, how about "MatchNamespace"? | |
273 | I'm curious how the caller use this, it seems that the caller has no/little information to distinguish all the positions, even for a simple case where we add a definition at the last eligible point (I assume just just using EligiblePoints.back()). |
clang-tools-extra/clangd/SourceCode.cpp | ||
---|---|---|
998 | yes that's the idea. we'll try to provide as many valid insertion points as possible in the closest namespace. | |
clang-tools-extra/clangd/SourceCode.h | ||
273 | for example a caller with access to AST and Index, could first look at the decls surrounding the target(fully qualified name), then check for their definition locations using index and find an eligible point between these two. |
clang-tools-extra/clangd/SourceCode.h | ||
---|---|---|
270 | what about enclosing? |
- Address comments
clang-tools-extra/clangd/SourceCode.h | ||
---|---|---|
270 |
No we don't, represents anonymous namespaces. I also updated docs to mention that FullyQualifiedName should not contain anon namespaces. |
looks good.
clang-tools-extra/clangd/unittests/SourceCodeTests.cpp | ||
---|---|---|
610 | nit: I'd use a struct, it is hard to infer the member by reading get<0>, get<1> (I have to go back to the top) |
Do we ever name anonymous namespace here? How do we represent them?