sourcegraph / lsif-clang

Language Server Indexing Format (LSIF) generator for C, C++ and Objective C
https://lsif.dev/
35 stars 8 forks source link

Emit definitions and references for included files #67

Open varungandhi-src opened 2 years ago

varungandhi-src commented 2 years ago

We should emit:

Together, these would make Go to Definition from the #include to the included file work.

Note that you can't get a Code Intel popover with Find References for a file if we don't pick a source range (or use an empty range); you'd have to do a text search like #include .*MyFile\.myext, which is a little unfortunate. As an approximate solution, perhaps we should use the first line if it is blank or a comment?

Supporting Go to Definition from #include directives was flagged as a customer issue. They didn't flag Find References specifically.

For context, we do support this functionality for imports in Go today.

Code Intel Popover showing Go to Definition for import in Go.

Go has explicit package declarations, which nicely resolves the issue of Find References.