10447: Add enum variant references CodeLens. r=Veykril a=ericsampson



Co-authored-by: Eric Sampson <esampson@eaze.com>
This commit is contained in:
bors[bot]
2021-10-05 22:03:23 +00:00
committed by GitHub
5 changed files with 61 additions and 13 deletions

View File

@@ -227,9 +227,12 @@ config_data! {
/// Whether to show `Method References` lens. Only applies when
/// `#rust-analyzer.lens.enable#` is set.
lens_methodReferences: bool = "false",
/// Whether to show `References` lens. Only applies when
/// `#rust-analyzer.lens.enable#` is set.
/// Whether to show `References` lens for Struct, Enum, Union and Trait.
/// Only applies when `#rust-analyzer.lens.enable#` is set.
lens_references: bool = "false",
/// Whether to show `References` lens for Enum Variants.
/// Only applies when `#rust-analyzer.lens.enable#` is set.
lens_enumVariantReferences: bool = "false",
/// Internal config: use custom client-side commands even when the
/// client doesn't set the corresponding capability.
lens_forceCustomCommands: bool = "true",
@@ -326,6 +329,7 @@ pub struct LensConfig {
pub implementations: bool,
pub method_refs: bool,
pub refs: bool, // for Struct, Enum, Union and Trait
pub enum_variant_refs: bool,
}
impl LensConfig {
@@ -342,7 +346,7 @@ impl LensConfig {
}
pub fn references(&self) -> bool {
self.method_refs || self.refs
self.method_refs || self.refs || self.enum_variant_refs
}
}
@@ -832,6 +836,7 @@ impl Config {
implementations: self.data.lens_enable && self.data.lens_implementations,
method_refs: self.data.lens_enable && self.data.lens_methodReferences,
refs: self.data.lens_enable && self.data.lens_references,
enum_variant_refs: self.data.lens_enable && self.data.lens_enumVariantReferences,
}
}
pub fn hover_actions(&self) -> HoverActionsConfig {

View File

@@ -1135,6 +1135,7 @@ pub(crate) fn handle_code_lens(
annotate_impls: lens_config.implementations,
annotate_references: lens_config.refs,
annotate_method_references: lens_config.method_refs,
annotate_enum_variant_references: lens_config.enum_variant_refs,
},
file_id,
)?;