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

Fix goto references for TerseRelayResolver #4587

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions compiler/crates/relay-lsp/src/docblock_resolution_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,21 @@ pub fn create_docblock_resolution_info(
}
};

// Root fragment
if let Some(root_fragment) = resolver_ir.root_fragment {
if root_fragment.location.contains(position_span) {
return Some(DocblockResolutionInfo::RootFragment(root_fragment.item));
}
}

// Field name
if resolver_ir.field.name.span.contains(position_span) {
return Some(DocblockResolutionInfo::FieldName(
resolver_ir.field.name.value,
));
}

// Return type
if let Some(output_type) = &resolver_ir.output_type {
if output_type.inner().location.contains(position_span) {
return Some(DocblockResolutionInfo::Type(
Expand All @@ -57,6 +60,7 @@ pub fn create_docblock_resolution_info(
}
}

// @deprecated key
if let Some(deprecated) = resolver_ir.deprecated {
if deprecated.key_location().contains(position_span) {
return Some(DocblockResolutionInfo::Deprecated);
Expand Down Expand Up @@ -89,6 +93,13 @@ pub fn create_docblock_resolution_info(
}
}

// Field name
if resolver_ir.field.name.span.contains(position_span) {
return Some(DocblockResolutionInfo::FieldName(
resolver_ir.field.name.value,
));
}

// @deprecated key
if let Some(deprecated) = resolver_ir.deprecated {
if deprecated.key_location().contains(position_span) {
Expand Down
5 changes: 1 addition & 4 deletions compiler/crates/relay-lsp/src/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ fn get_references_response(
On::Type(type_) => type_.value.item,
On::Interface(interface) => interface.value.item,
},
DocblockIr::TerseRelayResolver(_) => {
// TODO: Implement support for terse relay resolvers.
return Err(LSPRuntimeError::ExpectedError);
}
DocblockIr::TerseRelayResolver(terse_resolver) => terse_resolver.type_.item,
DocblockIr::StrongObjectResolver(_) => {
// TODO: Implement support for strong object.
return Err(LSPRuntimeError::ExpectedError);
Expand Down
Loading