From 29832b8c3db509dea8da9164e980ccac4bccf47d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 16 Jul 2020 18:07:53 +0200 Subject: Reduce visibility --- .../ra_ide/src/completion/complete_trait_impl.rs | 2 +- crates/ra_ide/src/completion/presentation.rs | 2 +- crates/ra_ide/src/display.rs | 5 ++- crates/ra_ide/src/display/function_signature.rs | 40 ++++++++++------------ crates/ra_ide/src/inlay_hints.rs | 4 +-- crates/ra_ide/src/lib.rs | 2 +- 6 files changed, 26 insertions(+), 29 deletions(-) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs index a610fd6d1..90f5b1c25 100644 --- a/crates/ra_ide/src/completion/complete_trait_impl.rs +++ b/crates/ra_ide/src/completion/complete_trait_impl.rs @@ -43,7 +43,7 @@ use crate::{ completion::{ CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions, }, - display::FunctionSignature, + display::function_signature::FunctionSignature, }; pub(crate) fn complete_trait_impl(acc: &mut Completions, ctx: &CompletionContext) { diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs index e6b4737aa..e29b82017 100644 --- a/crates/ra_ide/src/completion/presentation.rs +++ b/crates/ra_ide/src/completion/presentation.rs @@ -11,7 +11,7 @@ use crate::{ completion_item::Builder, CompletionContext, CompletionItem, CompletionItemKind, CompletionKind, Completions, }, - display::{const_label, macro_label, type_label, FunctionSignature}, + display::{const_label, function_signature::FunctionSignature, macro_label, type_label}, CompletionScore, RootDatabase, }; diff --git a/crates/ra_ide/src/display.rs b/crates/ra_ide/src/display.rs index 70d2a2dd1..b59d4bbdf 100644 --- a/crates/ra_ide/src/display.rs +++ b/crates/ra_ide/src/display.rs @@ -1,7 +1,7 @@ //! This module contains utilities for turning SyntaxNodes and HIR types //! into types that may be used to render in a UI. -mod function_signature; +pub(crate) mod function_signature; mod navigation_target; mod structure; mod short_label; @@ -11,7 +11,6 @@ use ra_syntax::{ SyntaxKind::{ATTR, COMMENT}, }; -pub use function_signature::FunctionSignature; pub use navigation_target::NavigationTarget; pub use structure::{file_structure, StructureNode}; @@ -19,7 +18,7 @@ pub(crate) use navigation_target::{ToNav, TryToNav}; pub(crate) use short_label::ShortLabel; pub(crate) fn function_label(node: &ast::FnDef) -> String { - FunctionSignature::from(node).to_string() + function_signature::FunctionSignature::from(node).to_string() } pub(crate) fn const_label(node: &ast::ConstDef) -> String { diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs index 709a85f65..9b7220d1f 100644 --- a/crates/ra_ide/src/display/function_signature.rs +++ b/crates/ra_ide/src/display/function_signature.rs @@ -15,49 +15,48 @@ use stdx::{split_delim, SepBy}; use crate::display::{generic_parameters, where_predicates}; #[derive(Debug)] -pub enum CallableKind { +pub(crate) enum CallableKind { Function, StructConstructor, VariantConstructor, - Macro, } /// Contains information about a function signature #[derive(Debug)] -pub struct FunctionSignature { - pub kind: CallableKind, +pub(crate) struct FunctionSignature { + pub(crate) kind: CallableKind, /// Optional visibility - pub visibility: Option, + pub(crate) visibility: Option, /// Qualifiers like `async`, `unsafe`, ... - pub qualifier: FunctionQualifier, + pub(crate) qualifier: FunctionQualifier, /// Name of the function - pub name: Option, + pub(crate) name: Option, /// Documentation for the function - pub doc: Option, + pub(crate) doc: Option, /// Generic parameters - pub generic_parameters: Vec, + pub(crate) generic_parameters: Vec, /// Parameters of the function - pub parameters: Vec, + pub(crate) parameters: Vec, /// Parameter names of the function - pub parameter_names: Vec, + pub(crate) parameter_names: Vec, /// Parameter types of the function - pub parameter_types: Vec, + pub(crate) parameter_types: Vec, /// Optional return type - pub ret_type: Option, + pub(crate) ret_type: Option, /// Where predicates - pub where_predicates: Vec, + pub(crate) where_predicates: Vec, /// Self param presence - pub has_self_param: bool, + pub(crate) has_self_param: bool, } #[derive(Debug, Default)] -pub struct FunctionQualifier { +pub(crate) struct FunctionQualifier { // `async` and `const` are mutually exclusive. Do we need to enforcing it here? - pub is_async: bool, - pub is_const: bool, - pub is_unsafe: bool, + pub(crate) is_async: bool, + pub(crate) is_const: bool, + pub(crate) is_unsafe: bool, /// The string `extern ".."` - pub extern_abi: Option, + pub(crate) extern_abi: Option, } impl FunctionSignature { @@ -277,7 +276,6 @@ impl Display for FunctionSignature { CallableKind::Function => write!(f, "fn {}", name)?, CallableKind::StructConstructor => write!(f, "struct {}", name)?, CallableKind::VariantConstructor => write!(f, "{}", name)?, - CallableKind::Macro => write!(f, "{}!", name)?, } } diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 2e021f032..ae5695f61 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs @@ -5,10 +5,10 @@ use ra_syntax::{ ast::{self, ArgListOwner, AstNode, TypeAscriptionOwner}, match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange, T, }; - -use crate::{FileId, FunctionSignature}; use stdx::to_lower_snake_case; +use crate::{display::function_signature::FunctionSignature, FileId}; + #[derive(Clone, Debug, PartialEq, Eq)] pub struct InlayHintsConfig { pub type_hints: bool, diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 5d1f64e19..6810c1c6a 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -65,7 +65,7 @@ pub use crate::{ CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat, }, diagnostics::Severity, - display::{file_structure, FunctionSignature, NavigationTarget, StructureNode}, + display::{file_structure, NavigationTarget, StructureNode}, expand_macro::ExpandedMacro, folding_ranges::{Fold, FoldKind}, hover::{HoverAction, HoverConfig, HoverGotoTypeData, HoverResult}, -- cgit v1.2.3