Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
We have some logic in AddUsing tweak to determine insertion point based on AST. i think it makes sense to migrate it to these helpers too. There's some more logic in extract variable/function too. Extract variable seems too elaborate as it actually looks at statements, rather than decls and extract function is quite simple already as we already figure out current function's range and whatnot, but having another usage might help.
(thinking out loud)
We've got some helpers in SourceCode.h to determine insertion point in the absence of ASTs. Concepts here and there around an "insertion point" seems to be quite different (it's just a sourcelocation here and a set of locations + a namespace in SourceCode.h).
I suppose those two are somewhat hard to merge and serve different purposes, so It's better to keep them separate.
Thanks, I'd forgotten about those. I might tackle those next?
There's some more logic in extract variable/function too. Extract variable seems too elaborate as it actually looks at statements, rather than decls and extract function is quite simple already as we already figure out current function's range and whatnot, but having another usage might help.
Yeah I wasn't sure I could do a good job of generalizing these ones yet (and we haven't needed it yet).
We've got some helpers in SourceCode.h to determine insertion point in the absence of ASTs. Concepts here and there around an "insertion point" seems to be quite different (it's just a sourcelocation here and a set of locations + a namespace in SourceCode.h).
I suppose those two are somewhat hard to merge and serve different purposes, so It's better to keep them separate.
For sure ast-based and pseudoparsing-based cases are going to be different APIs, but I would like to move those into this header too.
The problem I hit was they share private infrastructure (in SourceCode.cpp) with other functionality (the namespace pseudoparsing for completion, I think). So it's a bit of work to extract.
clang-tools-extra/clangd/refactor/InsertionPoint.cpp | ||
---|---|---|
135 | Oops, good catch. In that particular case, you could make a case for inserting at the very top of the class (no access specifier needed). But some coding styles want the opposite. |
Thanks, LGTM!
SGTM.
We've got some helpers in SourceCode.h to determine insertion point in the absence of ASTs. Concepts here and there around an "insertion point" seems to be quite different (it's just a sourcelocation here and a set of locations + a namespace in SourceCode.h).
I suppose those two are somewhat hard to merge and serve different purposes, so It's better to keep them separate.For sure ast-based and pseudoparsing-based cases are going to be different APIs, but I would like to move those into this header too.
Makes sense.
The problem I hit was they share private infrastructure (in SourceCode.cpp) with other functionality (the namespace pseudoparsing for completion, I think). So it's a bit of work to extract.
Ah I see :/
nit: use a switch?