Adds code completion support to clangd.
Details
Diff Detail
- Build Status
Buildable 5054 Build 5054: arc lint + arc unit
Event Timeline
clangd/ASTManager.cpp | ||
---|---|---|
263 | CompletionItem::unparse should do the escaping. It's weird to have YAML stuff here. | |
266 | std::move | |
275 | I think returning by reference and moving out of CodeCompletionInfo in codeComplete() is safe. | |
clangd/ASTManager.h | ||
78 | Some documentation on the lock would be useful. I'm a bit worried about the priorities here, code completion should always have priority over parsing for diagnostics. But we can address that later. | |
clangd/Protocol.cpp | ||
635 | Os.flush(); | |
640 | Os.flush(); | |
clangd/Protocol.h | ||
289 | Just use C++11 inline initialization, no need to spell out the constructor. |
Urg, I was working on this too :) I'll compare implementations and provide comments if I find anything good to suggest.
test/clangd/formatting.test | ||
---|---|---|
14 | It would be good eventually to trigger on "::" (static members, etc) |
Ideas/Observations:
- One thing I has done in my version is to introduce "ASTUnitRunnable", a lambda function type that has an ASTUnit as parameter and is executed by the ASTManager. So the ASTManager takes care of locking the AST but the actual code using the AST is kept in the ProtocolHandlers. I think this can be refactored later if this is seen as a good approach.
- I have noticed while testing that there is some wrong escaping happening. I had typed "ù" by mistake (french keyboard layout!) and it threw an error about unexpected \x. I think using yaml::escape is not entirely correct. This can be addressed in a different patch because it affects other protocol handlers as well (diagnostics, etc).
- I noticed that "file://" is stripped from file:///path but not "file:" in file:/path, I think it's the Eclipse client that's wrong here.
But I don't see any immediate need to change anything in this patch.
clangd/Protocol.cpp | ||
---|---|---|
613 | if kind is actually provided there will be a trailing quote, as in ("kind": 4"). |
Some documentation on the lock would be useful.
I'm a bit worried about the priorities here, code completion should always have priority over parsing for diagnostics. But we can address that later.