<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/66365>66365</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clangd] feature request: Add ast matcher API to clangd

I would love to have a feature in clangd, which enables editor plugins to extend the search capabilities of that editor with an AST search. 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Febbe
      </td>
    </tr>
</table>

<pre>
    While refactoring or reviewing code I often find problematic code, which occurs in similar forms in the complete codebase. Searching for those via a regex ist cumbersome and does not work for all cases.

My preferred workflow would be:
1. Activate AST matching
1. Select code
2. Press Ctrl+F / Ctrl+H to retrieve the current AST in the search field
3. Edit Ast to be more generic
4. Replace AST with other AST (In case of replacement)

In order to implement this in clangd-plugins, clangd itself requires the functionality to 
1. Gain the AST from a code selection
2. Gain a view of sourcecode-location-range objects from an AST
3. Allow AST replacements for a sourcecode-location-range object.


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEU82OpDYQfhpzKTUCQ3cPBw7sbjqZQ6RVJlLOxi7AibE75aJ75-0jG3Z3bjkh46rP9f2UitHOHrEX50_i_KVQGy-B-huOIxZjMO_9X4t1CIST0hzI-hkCAeHD4jMddDAIrxAmRg-T9QbuFEaHq2Kr862Qn-G5WL1A0HqjCNZDtKt1imAKtOYfvCDosN4dMuauUUUs4Q0V6SW9MwUCXkJEeFgFCghn_AY2MuhtHZFiWBGUN2ACRvCB4Rnon9ymnAOtIsZSVIOoht_f4U44IRGaXDW58IRn2JyBEUWTauoSBs32oRhhePsTVsV5jv3qDR1q3tlVgyzhK2GM8JnJCfnpBkLevh9-Aw5AyGTxgTvNjQg9Z9iDecw0YbLojKiGpoRfjGUYIqfuEWENhDCjR7JaVENbwh94d0rvwz0tLxB4QcpHIV9efWYMYQLaC1f0LGS3K_DqIZBBSug2iZ5ugRebvdBO-dmc7m6brY_Jvv0PWI7oEuK_myWMefRp85pt8MpZfk94u0K_qoNaGmiisILaoxKzdDb4XbhcpyClKQ0bw0YaU-HJBa1S3YmUnxHC-DdqjgeWT7i7UoNL7qVnPjCNu_H_i3ckojB9Y7qmUwX29aVrL137UlfF0jfmKk1bq7a5mqupsWvb6Spfqmrs5FnqrrC9rGRTdXVby6ZpqrK7th3WlWnVta3PYyXaCldlXencYy0DzYWNccP-cmku58KpEV3MyyelxyfkSyFl2kXqU89p3OYo2srZyPEnClt2eWt3b8T5C0yoeCPM_mBk0QwwGAMq8h7fFI-vr8mjo2fPwpF8F1I-AyzqgaB-gP3Iw881Rq9GhxHQWA4ER05SL35j9OZjpLW6q9E6yxZjMpgXxd8bc2x3K4_yEoqNXL8w32PaQ3kT8jZbXrax1GEV8pb4H5_TnULyUMhbVi0Kecuq_hcAAP__YJyjAQ">