Skip to content

Commit

Permalink
Clean up go to definition for resolvers
Browse files Browse the repository at this point in the history
Reviewed By: alunyov

Differential Revision: D40355780

fbshipit-source-id: cff72a96d3d1943737e74a5a23fe8d66b0d5272a
  • Loading branch information
captbaritone authored and facebook-github-bot committed Oct 14, 2022
1 parent 85fc8e5 commit cb052fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
17 changes: 7 additions & 10 deletions compiler/crates/relay-lsp/src/docblock_resolution_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ use crate::LSPRuntimeError;
use crate::LSPRuntimeResult;

pub enum DocblockResolutionInfo {
OnType(StringKey),
OnInterface(StringKey),
Type(StringKey),
RootFragment(FragmentDefinitionName),
FieldName(StringKey),
OutputType(StringKey),
Deprecated,
}

Expand All @@ -32,15 +30,16 @@ pub fn create_docblock_resolution_info(
match resolver_ir.on {
On::Type(on_type) => {
if on_type.value.location.contains(position_span) {
return Ok(DocblockResolutionInfo::OnType(on_type.value.item));
return Ok(DocblockResolutionInfo::Type(on_type.value.item));
}
}
On::Interface(on_interface) => {
if on_interface.value.location.contains(position_span) {
return Ok(DocblockResolutionInfo::OnInterface(on_interface.value.item));
return Ok(DocblockResolutionInfo::Type(on_interface.value.item));
}
}
};

if let Some(root_fragment) = resolver_ir.root_fragment {
if root_fragment.location.contains(position_span) {
return Ok(DocblockResolutionInfo::RootFragment(root_fragment.item));
Expand All @@ -55,7 +54,7 @@ pub fn create_docblock_resolution_info(

if let Some(output_type) = &resolver_ir.output_type {
if output_type.inner().location.contains(position_span) {
return Ok(DocblockResolutionInfo::OutputType(
return Ok(DocblockResolutionInfo::Type(
output_type.inner().item.inner().name.value,
));
}
Expand All @@ -71,9 +70,7 @@ pub fn create_docblock_resolution_info(
}
DocblockIr::StrongObjectResolver(strong_object) => {
if strong_object.type_.value.location.contains(position_span) {
return Ok(DocblockResolutionInfo::OnType(
strong_object.type_.value.item,
));
return Ok(DocblockResolutionInfo::Type(strong_object.type_.value.item));
}

if let Some(deprecated) = strong_object.deprecated {
Expand All @@ -90,7 +87,7 @@ pub fn create_docblock_resolution_info(
.location
.contains(position_span)
{
return Ok(DocblockResolutionInfo::OnType(
return Ok(DocblockResolutionInfo::Type(
weak_type_ir.type_name.value.item,
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@ pub fn get_docblock_definition_description(
) -> LSPRuntimeResult<DefinitionDescription> {
let resolution = create_docblock_resolution_info(docblock_ir, position_span)?;
match resolution {
DocblockResolutionInfo::OnType(type_name) => Ok(DefinitionDescription::Type { type_name }),
DocblockResolutionInfo::OnInterface(interface_name) => Ok(DefinitionDescription::Type {
type_name: interface_name,
}),
DocblockResolutionInfo::OutputType(edge_type) => Ok(DefinitionDescription::Type {
type_name: edge_type,
}),
DocblockResolutionInfo::Type(type_name) => Ok(DefinitionDescription::Type { type_name }),
DocblockResolutionInfo::RootFragment(fragment_name) => {
Ok(DefinitionDescription::Fragment { fragment_name })
}
Expand Down

0 comments on commit cb052fc

Please sign in to comment.