mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-09 22:16:32 +00:00
fileset: implement expect_no_arguments() as method
This commit is contained in:
parent
c9b088c795
commit
7a230395c2
2 changed files with 12 additions and 10 deletions
|
@ -396,11 +396,11 @@ static BUILTIN_FUNCTION_MAP: Lazy<HashMap<&'static str, FilesetFunction>> = Lazy
|
||||||
// code completion inside macro is quite restricted.
|
// code completion inside macro is quite restricted.
|
||||||
let mut map: HashMap<&'static str, FilesetFunction> = HashMap::new();
|
let mut map: HashMap<&'static str, FilesetFunction> = HashMap::new();
|
||||||
map.insert("none", |_ctx, function| {
|
map.insert("none", |_ctx, function| {
|
||||||
fileset_parser::expect_no_arguments(function)?;
|
function.expect_no_arguments()?;
|
||||||
Ok(FilesetExpression::none())
|
Ok(FilesetExpression::none())
|
||||||
});
|
});
|
||||||
map.insert("all", |_ctx, function| {
|
map.insert("all", |_ctx, function| {
|
||||||
fileset_parser::expect_no_arguments(function)?;
|
function.expect_no_arguments()?;
|
||||||
Ok(FilesetExpression::all())
|
Ok(FilesetExpression::all())
|
||||||
});
|
});
|
||||||
map
|
map
|
||||||
|
|
|
@ -342,14 +342,16 @@ pub fn parse_program_or_bare_string(text: &str) -> FilesetParseResult<Expression
|
||||||
Ok(ExpressionNode::new(expr, span))
|
Ok(ExpressionNode::new(expr, span))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expect_no_arguments(function: &FunctionCallNode) -> FilesetParseResult<()> {
|
impl<'i> FunctionCallNode<'i> {
|
||||||
if function.args.is_empty() {
|
pub fn expect_no_arguments(&self) -> FilesetParseResult<()> {
|
||||||
Ok(())
|
if self.args.is_empty() {
|
||||||
} else {
|
Ok(())
|
||||||
Err(FilesetParseError::invalid_arguments(
|
} else {
|
||||||
function,
|
Err(FilesetParseError::invalid_arguments(
|
||||||
"Expected 0 arguments",
|
self,
|
||||||
))
|
"Expected 0 arguments",
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue