Rename SyntaxShape::Custom to CompleterWrapper (#10548)

# Description
The description `Custom` doesn't really reflect meaning in the set of
`SyntaxShape`. Makes it a bit more verbose but explicit


# User-Facing Changes
Only hypothetically breaking as plugins can not effectively use a
requirement on `SyntaxShape::Custom`.

# Tests + Formatting
(-)
This commit is contained in:
Stefan Holderbach 2023-09-29 19:22:58 +02:00 committed by GitHub
parent cc4f8bbd82
commit 9e445fd4c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View File

@ -321,7 +321,7 @@ fn get_documentation(
// document shape helps showing more useful information // document shape helps showing more useful information
pub fn document_shape(shape: SyntaxShape) -> SyntaxShape { pub fn document_shape(shape: SyntaxShape) -> SyntaxShape {
match shape { match shape {
SyntaxShape::Custom(inner_shape, _) => *inner_shape, SyntaxShape::CompleterWrapper(inner_shape, _) => *inner_shape,
_ => shape, _ => shape,
} }
} }

View File

@ -573,7 +573,7 @@ impl<'e, 's> ScopeData<'e, 's> {
fn extract_custom_completion_from_arg(engine_state: &EngineState, shape: &SyntaxShape) -> String { fn extract_custom_completion_from_arg(engine_state: &EngineState, shape: &SyntaxShape) -> String {
return match shape { return match shape {
SyntaxShape::Custom(_, custom_completion_decl_id) => { SyntaxShape::CompleterWrapper(_, custom_completion_decl_id) => {
let custom_completion_command = engine_state.get_decl(*custom_completion_decl_id); let custom_completion_command = engine_state.get_decl(*custom_completion_decl_id);
let custom_completion_command_name: &str = custom_completion_command.name(); let custom_completion_command_name: &str = custom_completion_command.name();
custom_completion_command_name.to_string() custom_completion_command_name.to_string()

View File

@ -2759,7 +2759,7 @@ pub fn parse_shape_name(
let decl_id = working_set.find_decl(command_name); let decl_id = working_set.find_decl(command_name);
if let Some(decl_id) = decl_id { if let Some(decl_id) = decl_id {
return SyntaxShape::Custom(Box::new(shape), decl_id); return SyntaxShape::CompleterWrapper(Box::new(shape), decl_id);
} else { } else {
working_set.error(ParseError::UnknownCommand(cmd_span)); working_set.error(ParseError::UnknownCommand(cmd_span));
return shape; return shape;
@ -4666,7 +4666,7 @@ pub fn parse_value(
} }
match shape { match shape {
SyntaxShape::Custom(shape, custom_completion) => { SyntaxShape::CompleterWrapper(shape, custom_completion) => {
let mut expression = parse_value(working_set, span, shape); let mut expression = parse_value(working_set, span, shape);
expression.custom_completion = Some(*custom_completion); expression.custom_completion = Some(*custom_completion);
expression expression

View File

@ -29,8 +29,8 @@ pub enum SyntaxShape {
/// A closure is allowed, eg `{|| start this thing}` /// A closure is allowed, eg `{|| start this thing}`
Closure(Option<Vec<SyntaxShape>>), Closure(Option<Vec<SyntaxShape>>),
/// A custom shape with custom completion logic /// A [`SyntaxShape`] with custom completion logic
Custom(Box<SyntaxShape>, DeclId), CompleterWrapper(Box<SyntaxShape>, DeclId),
/// A datetime value, eg `2022-02-02` or `2019-10-12T07:20:50.52+00:00` /// A datetime value, eg `2022-02-02` or `2019-10-12T07:20:50.52+00:00`
DateTime, DateTime,
@ -144,7 +144,7 @@ impl SyntaxShape {
SyntaxShape::Closure(_) => Type::Closure, SyntaxShape::Closure(_) => Type::Closure,
SyntaxShape::Binary => Type::Binary, SyntaxShape::Binary => Type::Binary,
SyntaxShape::CellPath => Type::Any, SyntaxShape::CellPath => Type::Any,
SyntaxShape::Custom(custom, _) => custom.to_type(), SyntaxShape::CompleterWrapper(inner, _) => inner.to_type(),
SyntaxShape::DateTime => Type::Date, SyntaxShape::DateTime => Type::Date,
SyntaxShape::Duration => Type::Duration, SyntaxShape::Duration => Type::Duration,
SyntaxShape::Expression => Type::Any, SyntaxShape::Expression => Type::Any,
@ -245,7 +245,7 @@ impl Display for SyntaxShape {
SyntaxShape::Expression => write!(f, "expression"), SyntaxShape::Expression => write!(f, "expression"),
SyntaxShape::Boolean => write!(f, "bool"), SyntaxShape::Boolean => write!(f, "bool"),
SyntaxShape::Error => write!(f, "error"), SyntaxShape::Error => write!(f, "error"),
SyntaxShape::Custom(x, _) => write!(f, "custom<{x}>"), SyntaxShape::CompleterWrapper(x, _) => write!(f, "completable<{x}>"),
SyntaxShape::OneOf(list) => { SyntaxShape::OneOf(list) => {
let arg_vec: Vec<_> = list.iter().map(|x| x.to_string()).collect(); let arg_vec: Vec<_> = list.iter().map(|x| x.to_string()).collect();
let arg_string = arg_vec.join(", "); let arg_string = arg_vec.join(", ");