-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
refactor(graphqlsp): Add getDeclarationOfIdentifier
helper
#351
base: main
Are you sure you want to change the base?
Conversation
|
85fea55
to
8841f43
Compare
8841f43
to
99e5ba5
Compare
b249940
to
5b0de48
Compare
This mirrors the
getDefinitionAtPosition
method in TypeScript's language service — specifically theGoToDefinition
component — to create agetDeclarationOfIdentifier
helper.Since we're only looking up definitions of identifiers, we can actually cut out a lot of special cases and end up with a relatively lean implementation of looking up declarations for identifiers. Specifically, if we were to switch over to an implementation like this, it would cut out a lot of extra wrappers, namely positional values that require is to look up file positions. It also saves us some look up work of cases that are impossible, since we're always jumping to declarations (fewer AST cases to account for)
Additionally, the returned AST node is a lot more limited in the locations it can be in, since it's guaranteed to only ever be a declaration.
To further help with this, a few modifications have been added to prevent us from jumping to type declarations, ambient declarations, and import/export/module specifiers (Although that's an artificial limitation)
The helpers also include: