MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / isEmptyParenExpression

Method isEmptyParenExpression

src/CLI2.cpp:1711–1730  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Detects if the bracket at iterator it is a start or end of an empty paren expression Examples: ( status = pending ) ( ) ^ it -----| => true ( status = pending ) ( project = Home ) ^ it -----| => false

Source from the content-addressed store, hash-verified

1709// ^
1710// it -----| => false
1711bool CLI2::isEmptyParenExpression(std::vector<A2>::iterator it, bool forward /* = true */) const {
1712 int open = 0;
1713 int closed = 0;
1714
1715 for (auto a = it; a != (forward ? _args.end() : _args.begin()); (forward ? ++a : --a)) {
1716 if (a->attribute("raw") == "(")
1717 open++;
1718 else if (a->attribute("raw") == ")")
1719 closed++;
1720 else
1721 // Encountering a non-paren token means there is something between parenthees
1722 return false;
1723
1724 // Getting balanced parentheses means we have an empty paren expression
1725 if (open == closed && open != 0) return true;
1726 }
1727
1728 // Should not end here.
1729 return false;
1730}
1731
1732////////////////////////////////////////////////////////////////////////////////
1733// Two consecutive FILTER, non-OP arguments that are not "(" or ")" need an

Callers

nothing calls this directly

Calls 1

attributeMethod · 0.80

Tested by

no test coverage detected