Details
- Reviewers
hokein - Commits
- rG9ef11616b228: Add foldings for multi-line comment.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/SemanticSelection.cpp | ||
---|---|---|
176–177 | nit: update the fixme, comment is supported now. | |
239 | we can save some cost if we first get the final End comment, and calculate the offset from it. | |
243 | since LSP defines 3 kinds (region, comment, import), I'd suggest defining these string literals in the Protocol.h, rather than using the magic string here. | |
clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp | ||
351 | For this case, my personal preference would be to have 3 different foldings, rather than a union one. If you think about cases like below, it makes more sense to have individual folding per comment. /* comment 1 */ /* comment 2 */ /* comment 1 */ // comment 2 |
Addressed comments.
clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp | ||
---|---|---|
351 | In the cases mentioned, I think these comments would be about the same context. If I want to fold (possibly long) comments with interleaved new lines, I would be interested in folding all the related comments to look at the code clearly. |
clang-tools-extra/clangd/Protocol.h | ||
---|---|---|
1779 | sorry for not being clear on my previous comment, I think the current string kind; is good, and it aligns with the LSP one. what I suggest was adding string literals to FoldingRange, something like struct FoldingRange { const static llvm::StringLiteral REGION_KIND; const static llvm::StringLiteral COMMENT_KIND; const static llvm::StringLiteral IMPORT_KIND; // other fields keep as-is. ... } we're diverging from the LSP structure. | |
clang-tools-extra/clangd/SemanticSelection.cpp | ||
239 | this seems incorrect -- the LastComment->Line == T->Line + 1 condition is not true initially (because LastComment == T), so we will never run into this loop, then I'm confused, why the unittest are passed (premerge test is green). | |
clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp | ||
351 |
I'm not sure this is true. I could image a case like below, these comments are not about the same context. I think for cases where these comments are about the same context, they are generally separated by // <blankline> rather than <blankline>. btw, Kirill has a patch (https://reviews.llvm.org/D83914) for proposed folding behaviors, see the comments part (which seems reasonable to me). //===-- This is a file comment ------------------------------------------===// // // ... // //===----------------------------------------------------------------------===// // This is a doc comment of `foo` class class Foo {}; |
clang-tools-extra/clangd/Protocol.h | ||
---|---|---|
1779 | +1, we already have the same pattern for code action kinds, i was also referring to this in our offline discussion. |
Addressed comments.
clang-tools-extra/clangd/SemanticSelection.cpp | ||
---|---|---|
239 | I think I missed to update the patch last time I fixed this. |
clang-tools-extra/clangd/SemanticSelection.cpp | ||
---|---|---|
177–179 | nit: there is an extra space (I'd rather just use FIXME:) | |
224–226 | nit: add a comment explaining the +1 offset (skipping the bracket). | |
239 | nit: the <= seems to do much --I think we care about = LastCommentEnd.line and = LastCommentEnd.line + 1 cases, < LastCommentEnd.line should be impossible, right? |
sorry for not being clear on my previous comment, I think the current string kind; is good, and it aligns with the LSP one.
what I suggest was adding string literals to FoldingRange, something like
we're diverging from the LSP structure.