================ @@ -490,6 +491,13 @@ bool eligibleForExtraction(const SelectionTree::Node *N) { BO->getRHS() == OuterImplicit.ASTNode.get<Expr>()) return false; } + if (const auto *Decl = Parent->ASTNode.get<VarDecl>()) { + if (!Decl->isInitCapture() && ---------------- kadircet wrote:
thanks for the example! I guess one conceptual thing to note here is, clangd doesn't run it's refactorings on the exact selection user provided. instead it figures out an AST node that's "relevant" to this selection, and everything else is performed on that AST node, mostly independent of the selection. So this approach is surely not always what the user means/wants, but let's us reason about the refactoring going on. For this case in particular, even if you said the refactoring is available for selection of `x = 1 + [[2 + 3]]` through these heuristics, clangd will still end up extracting the full RHS, because that's the AST node we associated with that selection. Hence I'd actually lean towards not special casing it here, just to do the thing we're trying to prevent later on. Any particular reason why we should say extraction is available for such cases (and then still perform the extraction we're trying to avoid)? https://github.com/llvm/llvm-project/pull/69477 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits