mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-09 05:50:36 +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.
|
||||
let mut map: HashMap<&'static str, FilesetFunction> = HashMap::new();
|
||||
map.insert("none", |_ctx, function| {
|
||||
fileset_parser::expect_no_arguments(function)?;
|
||||
function.expect_no_arguments()?;
|
||||
Ok(FilesetExpression::none())
|
||||
});
|
||||
map.insert("all", |_ctx, function| {
|
||||
fileset_parser::expect_no_arguments(function)?;
|
||||
function.expect_no_arguments()?;
|
||||
Ok(FilesetExpression::all())
|
||||
});
|
||||
map
|
||||
|
|
|
@ -342,14 +342,16 @@ pub fn parse_program_or_bare_string(text: &str) -> FilesetParseResult<Expression
|
|||
Ok(ExpressionNode::new(expr, span))
|
||||
}
|
||||
|
||||
pub fn expect_no_arguments(function: &FunctionCallNode) -> FilesetParseResult<()> {
|
||||
if function.args.is_empty() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(FilesetParseError::invalid_arguments(
|
||||
function,
|
||||
"Expected 0 arguments",
|
||||
))
|
||||
impl<'i> FunctionCallNode<'i> {
|
||||
pub fn expect_no_arguments(&self) -> FilesetParseResult<()> {
|
||||
if self.args.is_empty() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(FilesetParseError::invalid_arguments(
|
||||
self,
|
||||
"Expected 0 arguments",
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue