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

Emit definitions and references for included files #67

Description

@varungandhi-src

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions