<div dir="ltr">Sound great, thanks! <div><br></div><div>One interesting case in Chromium might be generated jni headers. I would be interested what the heuristic finds for these files:<div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">src/out/Android/gen/chrome/bro<wbr>wser/jni_headers/chrome/jni/<wbr>BrowsingDataBridge_jni.h</span></div><div><br></div><div>the implementation is in:<br></div><div><div>src/chrome/browser/android/bro<wbr>wsing_data/browsing_data_bridg<wbr>e.cc<br></div></div><div>I don't think that will get matched.</div><div><br></div><div></div></div></div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">I don't really care if code completion works in generated files but at least there shouldn't be incorrect error messages in vscode. Is it possible to exclude a folder from being analyzed by clangd?</span><div><br><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 29, 2018 at 1:50 AM, Sam McCall <span dir="ltr"><<a href="mailto:sammccall@google.com" target="_blank">sammccall@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Looks like our mail crossed :)<div>Cquery's success with this is another point in favor.</div><div><br></div><div>I have a prototype in <a href="https://reviews.llvm.org/D45006" target="_blank">https://reviews.llvm.org/<wbr>D45006</a> (+ 2-line patch to enable in clangd: <a href="https://reviews.llvm.org/D45007" target="_blank">https://reviews.llvm.<wbr>org/D45007</a>).</div><div>It seems to work pretty well at first glance, but it needs rigorous testing. If anyone's feeling this pain, feel free to try it out!</div><div><br></div><div>It does a little bit of indexing to avoid traversing all the entries every time, not sure if that's worth it.</div></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Wed, Mar 28, 2018 at 9:58 PM Fāng-ruì Sòng via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Another heuristic solution:<div><br></div><div>Enumerate all compilation database entries and calculate the matching score for each entry with the target file<br>Bonus for common leading components<br>Penalty for diverged path components<br>Bonus for common trailing characters sans filename extension (e.g. Match.cc Match.h are the same sans extension)<br><br>This heuristic is used in cquery.<br><br>Add another point for textDocument/didOpen on an unseen filename:<br>The inferred command line options are not authoritative, they should be overriden by other translation units when later it turns out the header file is included by some entry in the compilation database.</div></div><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Mar 28, 2018 at 7:12 AM Christian Dullweber via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I recently tried to use clangd for Chromium in vscode and hit the same issue. </div><div>I experimented a bit with generating a compile_commands.json file with valid rules for headers and came to this solution: <a href="https://gist.github.com/xchrdw/bfd2b3a5f765f4195a55d6351daf1b48" target="_blank">https://gist.github.<wbr>com/xchrdw/<wbr>bfd2b3a5f765f4195a55d6351daf1b<wbr>48</a></div><div>I sorted all .cc filenames and then looked up the index of the closest match<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span> </span>for each header </span>using binary search. As there were some edge cases like the first or last file in a directory, I additionally compared which file at the index has the largest prefix with the header.</div><div>I found a few issues with system headers and some generated protobuf headers but otherwise it works well.</div><div>Native support from clangd would be amazing :)</div><div><br></div><div>Thanks,</div><div>Christian</div></div>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-2071493688234920741m_-5510749033118636740gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">宋方睿</div></div>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</blockquote></div>
</div></div></blockquote></div><br></div>