Whenever a code-completion is triggered within a class/struct/union looks at
base classes and figures out non-overriden virtual functions. Than suggests
completions for those.
Details
- Reviewers
ilya-biryukov hokein ioeric - Commits
- rGf8b85a3d6bf7: [clangd] Suggest code-completions for overriding base class virtual methods.
rL340530: [clangd] Suggest code-completions for overriding base class virtual methods.
rCTE340530: [clangd] Suggest code-completions for overriding base class virtual methods.
Diff Detail
- Repository
- rCTE Clang Tools Extra
- Build Status
Buildable 21787 Build 21787: arc lint + arc unit
Event Timeline
I think it is reasonable to make Sema support suggesting override methods, instead of implementing it in clangd side?
clangd/CodeComplete.cpp | ||
---|---|---|
206 | nit: CR->methods(). | |
210 | nit: we can simplify the code like Overrides[Name].push_back(Method). | |
219 | I think we should check whether BR == nullptr here. | |
1247 | It seems that we treat it as a special case, the code path here runs out of the ranking path. |
clangd/CodeComplete.cpp | ||
---|---|---|
1247 | Put override suggestions to ranking system. |
After today's offline discussion I suppose we are not going to implement it within Sema. And also I think getVirtualNonOverridenMethods is a pretty generic function that has no ties to clangd, so it can be easily moved into Sema. Should we still move it into a separate file or leave it there?
Looks good mostly, a few nits. We should make sure all related comments are updated accordingly
clangd/CodeComplete.cpp | ||
---|---|---|
198 | Since we are returning CodeCompletionResult, maybe naming it like getNonOverridenCompleteionResults is clearer? | |
222 | nit: Can't we use Overrides.find(Method->getName()) and the other places as well? | |
224 | nit: use {} around the body of if -- the one-line for statement is across line, adding {} around it will improve the readability. | |
1237–1238 | nit: we need to update the comment accordingly. | |
1280–1283 | here as well. | |
1324 | IIUC, we are treating the override results the same SemaResult, it is safe as long as Sema doesn't provide these overrides in its code completion results, otherwise we will have duplicated completion items? I think we probably need a proper comment explaining what's going on here. |
Thanks, LGTM.
clangd/CodeComplete.cpp | ||
---|---|---|
210 | nit: here as well, use Overrides[Method->getName()].push_back... |
- Resolve discussions.
- Move override generation logic from render to item generation so that internal clients can use it as well, also use a boolean for checking override status of a bundle to be more efficient.
- Change unittests accordingly, get rid of unused IsOverride field.
Since we are returning CodeCompletionResult, maybe naming it like getNonOverridenCompleteionResults is clearer?