Skip to content

Find references of included members from their root declaration #9524

In progress

Description

@cknitt

Follow-up to #9331.

#9331 finds the references of a member brought in by include by walking families of copies: the copies in a file, the other file of a .res/.resi pair, and the files the copies come from, with a visited set so each family is gathered once. Uses in other files are matched by their keys and, since #9329, by resolving their paths.

A simpler design would work from the declaration itself:

  • Follow the queried member back to its root declaration: through include_origin in its file, into other files, and from a .resi member to its .res counterpart.
  • In the one pass over the project, accept a use when its resolved member has the same root.
  • In each file, take the internal references of the copies whose root is that declaration.

This would replace include_family, families_in_file, alternate_stamps, the recursion and the visited set in analysis/src/references.ml. It would also find two kinds of uses that #9331 misses:

  • uses through the including file's path when Find References starts from the declaration in another file, such as Main.x for Lib.x after include Lib in Main.res;
  • uses through a sibling copy, such as S.x when another module also includes the functor result.

The cost per query needs measuring: finding the root of every candidate use and copy goes through resolve_global, so the resolutions should be cached per query as external_references does.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions