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

Find References #3

Open
Tracked by #1
z80dev opened this issue Sep 18, 2023 · 0 comments
Open
Tracked by #1

Find References #3

z80dev opened this issue Sep 18, 2023 · 0 comments

Comments

@z80dev
Copy link
Collaborator

z80dev commented Sep 18, 2023

For any given symbol definition/declaration, we want to be able to find all references to this symbol in the project.

With Vyper's (current) lack of modules, this is simplified given that we only have to search the current file being edited.

LSP API Methods

  • textDocument/references

Variations of Reference Lookups

Variable Names

x: uint256

@external
def foo() -> uint256:
    return self.x

Looking up references of x should give us a list of every usage of self.x in the contract.

Constants and immutables will be referenced without the self prefix.

User-Defined "Types"

"Types" isn't quite the right word, but is useful here to cover both struct and event declarations.

event Foo:
    x: uint256
    y: uint256
    
struct Bar:
    z: uint256

@external
def baz() -> Bar:
    log Foo(1, 2)
    return Bar({z: 3})

Looking up references of Foo should bring up the line where we log Foo.

Looking up references of Bar should bring up both the line where we declare the return type of baz() to be Bar, as well as the line where we create a new instance of Bar to be returned

@z80dev z80dev mentioned this issue Sep 18, 2023
6 tasks
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

No branches or pull requests

1 participant