Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Emit definitions and references for included files #67

Open
varungandhi-src opened this issue May 5, 2022 · 0 comments
Open

Emit definitions and references for included files #67

varungandhi-src opened this issue May 5, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@varungandhi-src
Copy link
Contributor

We should emit:

  • A reference for #include directives.
  • A definition for the included file.

Normally these are just headers, but in principle, one can include any files at all.

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

  • We should avoid emitting redundant definitions for the same file.
  • It's not super clear what the source location for the definition should be. I can't recall if there is a way to encode a reference to a file instead of a specific source range in the file.
    • If the former is possible, we should do that.
    • If a specific source range is needed, that makes it trickier; I can't think of a way to pick a non-empty range off the top of my head that works reliably and gives intuitive results. Picking an empty range is an option.

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.

@varungandhi-src varungandhi-src added the enhancement New feature or request label May 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant