[clang-tools-extra] [llvm] [Clangd] Add AST search capabilities from clang-query (PR #156090)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 1 04:43:35 PST 2025
Fabian =?utf-8?q?Keßler?= <fabian_kessler at gmx.de>,
Fabian =?utf-8?q?Keßler?= <fabian_kessler at gmx.de>,
Fabian =?utf-8?q?Keßler?= <fabian_kessler at gmx.de>,
Fabian =?utf-8?q?Keßler?= <fabian_kessler at gmx.de>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/156090 at github.com>
Febbe wrote:
> > My plan was just to move the existing "ast view" treeview widget to a new menu, add a text bar above, and allow it to show multiple matches for a first prototype.
>
> I'm wondering, what is the use case for showing the entire AST subtree (and indeed, the protocol sending an entire `ASTNode`) for each match?
>
> Might it be sufficient to just send a text file range for each match (much like ordinary search results), and then if the user wants to see the AST for a particular result they can select the range and invoke "Show AST"?
Interesting question, the tree of ASTNode's contain your search result and should also contain the source code range. For the most cases, just the source code range might be sufficient. But, you explicitly searched for a matching AST, so you might also view that AST result.
It was also an idea, to fullfill the last point of https://github.com/clangd/clangd/issues/1945#issue-2149756432 :
> * Optionally replace them with a sub AST
This would only work, if you can modify parts of the AST. Whether this is text based in the end might not matter, but in the intermediate state, e.g. while replacing static_cast's with a specific custom cast function, you need the subranges of each node.
https://github.com/llvm/llvm-project/pull/156090
More information about the cfe-commits
mailing list