Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a "references" relationship kind and referenceLocation mixin #59

Merged

Conversation

QuietMisdreavus
Copy link
Contributor

Bug/issue #, if applicable: rdar://108470705

Summary

This PR adds a new relationship kind, references, that describes a relationship where one symbol references another one in its implementation. It also introduces a referenceLocation mixin for relationships that describes the source range where the reference occurs.

The idea behind adding this information to a symbol graph would be to allow for more semantic analyses to be made on projects, for example to find unused symbols within a project. Including the source range also allows for a sort of "offline language server", by providing a data source for a "jump to definition" and "find references" functionality.

The JSON for these relationships would look like this:

{
  "kind": "references",
  "source": "source",
  "target": "target",
  "referenceLocation": {
    "uri": "file://file.swift",
    "range": {
      "start": {
        "line": 14,
        "character": 0
      },
      "end": {
        "line": 14,
        "character": 6
      }
    }
  }
}

Dependencies

None

Testing

This PR is being used as a baseline specification for future implementations, so demonstration symbol graphs need to be synthesized from whole cloth and cannot be tested in a straightforward manner.

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

Copy link

@daniel-grumberg daniel-grumberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@QuietMisdreavus QuietMisdreavus merged commit 1d5aba8 into swiftlang:main Apr 25, 2023
@QuietMisdreavus QuietMisdreavus deleted the reference-relationship branch April 25, 2023 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants