[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG5ad6bbacf091: [clangd] Start using SyntaxTrees for folding ranges feature (authored by kbobyrev). Repository: rG LLVM Github Monorepo CHANGES SIN

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 301009. kbobyrev added a comment. Resolve merge conflict. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D88553/new/ https://reviews.llvm.org/D88553 Files: clang-tools-extra/clangd/SemanticSelection.cpp cla

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-27 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 301008. kbobyrev added a comment. Address post-LGTM comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D88553/new/ https://reviews.llvm.org/D88553 Files: clang-tools-extra/clangd/SemanticSelection.cpp

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision. sammccall added inline comments. This revision is now accepted and ready to land. Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:42 + +llvm::Optional toFoldingRange(LocInfo Begin, LocInfo End, +

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments. Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:60 + *RBrace = cast_or_null( + Stmt->findChild(syntax::NodeRole::CloseParen)); +if (!LBrace || !RBrace) sammccall wrote: > strictly this

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-24 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 300479. kbobyrev marked 3 inline comments as done. kbobyrev added a comment. Decompose locations and add checks for FileID == MainFileID. Also, rebase on top of master. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments. Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:40 -// Recursively collects FoldingRange from a symbol and its children. -void collectFoldingRanges(DocumentSymbol Symbol, - std::vector &Result) { +llvm::Option

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-21 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments. Comment at: clang/include/clang/Tooling/Syntax/Tree.h:172-174 /// Find the first node with a corresponding role. Node *findChild(NodeRole R); + const Node *findChild(NodeRole R) const; eduucaldas wrote: > I think that make

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-21 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 299620. kbobyrev added a comment. Fix a typo and remove invalid const-ness. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D88553/new/ https://reviews.llvm.org/D88553 Files: clang-tools-extra/clangd/SemanticS

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-21 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 299619. kbobyrev marked an inline comment as done. kbobyrev added a comment. Prevent code duplication for const-nonconst versions of the same function. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D88553/new/

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-21 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments. Comment at: clang/include/clang/Tooling/Syntax/Tree.h:172-174 /// Find the first node with a corresponding role. Node *findChild(NodeRole R); + const Node *findChild(NodeRole R) const; I think that makes sense, since all t

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-21 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments. Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:52-55 +const syntax::Token *FirstToken = Tree->findFirstLeaf()->getToken(), +*LastToken = Tree->findLastLeaf()->getToken(); +assert(FirstToken->kind() == t

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 299449. kbobyrev added a comment. Resolve comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D88553/new/ https://reviews.llvm.org/D88553 Files: clang-tools-extra/clangd/SemanticSelection.cpp clang-too

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments. Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:52-55 +const syntax::Token *FirstToken = Tree->findFirstLeaf()->getToken(), +*LastToken = Tree->findLastLeaf()->getToken(); +assert(FirstToken->kind() == to

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments. Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:52-55 +const syntax::Token *FirstToken = Tree->findFirstLeaf()->getToken(), +*LastToken = Tree->findLastLeaf()->getToken(); +assert(FirstToken->kind() == tok

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 299438. kbobyrev marked 9 inline comments as done. kbobyrev added a comment. Resolve review comments. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D88553/new/ https://reviews.llvm.org/D88553 Files: clang-to

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments. Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:39 FoldingRange Range; - Range.startLine = Symbol.range.start.line; - Range.startCharacter = Symbol.range.start.character; - Range.endLine = Symbol.range.end.line; - Range.endCharac

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-20 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments. Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:37 -// Recursively collects FoldingRange from a symbol and its children. -void collectFoldingRanges(DocumentSymbol Symbol, - std::vector &Result) { +FoldingRang

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-20 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments. Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:49-51 + if (Node->getKind() == syntax::NodeKind::CompoundStatement) { +const auto *Tree = dyn_cast(Node); +assert(Tree); Comment at: clang-to

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment. @sammccall I've reduced the patch to the bare minimum (compound statements) as I've had some issues with couple of other kinds of folding ranges and I'll be adding support for the node kinds one by one. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION