<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Thanks <span>Ilya</span>! I'll try something like this. That was my initial idea before the index came in but I thought we could maximize code reuse by going the index way. My worry with using the AST approach is that
 it will duplicate not only some of the symbol collection code but also the some querying parts, i.e. matching prefixes, scoring, etc. Perhaps I'll be able to extract some common logic for that or perhaps we can do something simpler for this type of query.
 I'll let you know how it turns out.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Thanks again,<br>
</p>
<p style="margin-top:0;margin-bottom:0">Marc-Andr¨¦<br>
</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Ilya Biryukov <iu.biryukov@gmail.com><br>
<b>Sent:</b> Thursday, May 31, 2018 5:14:19 AM<br>
<b>To:</b> Marc-Andr¨¦ Laperle<br>
<b>Cc:</b> clangd-dev@lists.llvm.org<br>
<b>Subject:</b> Re: [clangd-dev] Implementing symbols in document (textDocument/documentSymbol)</font>
<div> </div>
</div>
<meta content="text/html; charset=utf-8">
<div>
<div dir="ltr">Hi Marc-Andr¨¦,
<div><br>
</div>
<div>I find that our index is just not suited for file-centric queries at this point. E.g. it aggregates all redecls and chooses just one when creating the symbol, has the logic to filter out non-local symbols, etc. Moreover, it was design with project-wide
 queries in mind and changing it is definitely a lot of work.</div>
<div><br>
</div>
<div>For file-major queries, we have the AST and I think we should use it instead. So I suggest we:</div>
<div>1. Traverse the AST of the current file to find all decls inside this file. The results will not contain everything, including local vars(do we need them BTW?), static functions, etc. We can also convert results to something more suitable for filtering,
 e.g. SymbolSlab. But I won't put them into the index.</div>
<div>2. Search through results from step 1 and filter out the ones that don't match the query.</div>
<div><br>
</div>
<div>If step 1 turns out to be slow, we can compute the results once and stash them somewhere as an optimization. But given that the current file is usually small enough, we can probably even get away without it.</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr" class="x_m_7747237279871862064gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>--</div>
Regards,</div>
<div>Ilya Biryukov</div>
</div>
</div>
</div>
</div>
<br>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr">§ã§â, 30 §Þ§Ñ§ñ 2018 §Ô. §Ó 23:24, Marc-Andr¨¦ Laperle via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a>>:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="x_m_7747237279871862064m_-434028872537890019divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0"></p>
<div>Hi,<br>
<br>
I've been thinking about how to implement the "symbols in document" feature. I think it would make a lot of sense to reuse the in-memory index for this. One problem is that there is no current way to do "file-major" queries, i.e. get all symbols within one
 file.<br>
<br>
I see a few options:<br>
1) Change the <span>YAML</span> format, in-memory model and index interface to allow file-major queries. This is the most work. On the other hand, I don't think it's worth investing a ton of effort in the YAML format.<br>
2) Change only the "in-memory" index and interface for file-major queries. Not sure how feasible that is, but perhaps a good solution.<br>
3) Run a new SymbolCollector every time on textDocument/documentSymbol, only on the needed file. That way there is a lot less symbol to filter out (only need the ones in the main file).<br>
4) Iterate through all symbols, keep only the ones in the correct file. This is basically workspace/symbol with another "file" parameter. This is likely the least amount of work.<br>
<br>
I tried #4 and it seems to work fine but is probably not the most scalable so I am not sure how acceptable that is as an interim implementation.<br>
<br>
Let me know what you think,<br>
Marc-Andr¨¦</div>
<p></p>
</div>
</div>
_______________________________________________<br>
clangd-dev mailing list<br>
<a href="mailto:clangd-dev@lists.llvm.org" target="_blank">clangd-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev</a><br>
</blockquote>
</div>
</div>
</div>
</body>
</html>