mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 07:57:20 +02:00
CLI2: Added ::desugarFilterTags
This commit is contained in:
parent
040f990bd1
commit
a21767aa15
2 changed files with 17 additions and 32 deletions
47
src/CLI2.cpp
47
src/CLI2.cpp
|
@ -511,15 +511,13 @@ void CLI2::prepareFilter (bool applyContext)
|
||||||
context.config.getInteger ("debug.parser") >= 3)
|
context.config.getInteger ("debug.parser") >= 3)
|
||||||
context.debug (dump ("CLI2::prepareFilter categorize"));
|
context.debug (dump ("CLI2::prepareFilter categorize"));
|
||||||
|
|
||||||
// TODO This is from the old CLI::analyze method, but need to be replicated here.
|
|
||||||
|
|
||||||
// Remove all the syntactic sugar for FILTERs.
|
// Remove all the syntactic sugar for FILTERs.
|
||||||
changes = false;
|
changes = false;
|
||||||
findIDs ();
|
findIDs ();
|
||||||
findUUIDs ();
|
findUUIDs ();
|
||||||
insertIDExpr ();
|
insertIDExpr ();
|
||||||
/*
|
|
||||||
desugarFilterTags ();
|
desugarFilterTags ();
|
||||||
|
/*
|
||||||
findStrayModifications ();
|
findStrayModifications ();
|
||||||
desugarFilterAttributes ();
|
desugarFilterAttributes ();
|
||||||
desugarFilterAttributeModifiers ();
|
desugarFilterAttributeModifiers ();
|
||||||
|
@ -905,46 +903,32 @@ bool CLI2::exactMatch (
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// +tag --> tags _hastag_ tag
|
// +tag --> tags _hastag_ tag
|
||||||
// -tag --> tags _notag_ tag
|
// -tag --> tags _notag_ tag
|
||||||
void CLI2::desugarFilterTags ()
|
void CLI2::desugarFilterTags ()
|
||||||
{
|
{
|
||||||
bool changes = false;
|
bool changes = false;
|
||||||
std::vector <A> reconstructed;
|
std::vector <A2> reconstructed;
|
||||||
for (auto& a : _args)
|
for (auto& a : _args)
|
||||||
{
|
{
|
||||||
if (a.hasTag ("FILTER"))
|
if (a._lextype == Lexer::Type::tag)
|
||||||
{
|
{
|
||||||
Nibbler n (a.attribute ("raw"));
|
changes = true;
|
||||||
std::string tag;
|
|
||||||
std::string sign;
|
|
||||||
|
|
||||||
if (n.getN (1, sign) &&
|
A2 left ("tags", Lexer::Type::dom);
|
||||||
(sign == "+" || sign == "-") &&
|
left.tag ("FILTER");
|
||||||
n.getUntilEOS (tag) &&
|
reconstructed.push_back (left);
|
||||||
tag.find (' ') == std::string::npos)
|
|
||||||
{
|
|
||||||
A left ("argTag", "tags");
|
|
||||||
left.tag ("ATTRIBUTE");
|
|
||||||
left.tag ("FILTER");
|
|
||||||
reconstructed.push_back (left);
|
|
||||||
|
|
||||||
A op ("argTag", sign == "+" ? "_hastag_" : "_notag_");
|
std::string raw = a.attribute ("raw");
|
||||||
op.tag ("OP");
|
|
||||||
op.tag ("FILTER");
|
|
||||||
reconstructed.push_back (op);
|
|
||||||
|
|
||||||
A right ("argTag", "'" + tag + "'");
|
A2 op (raw[0] == '+' ? "_hastag_" : "_notag_", Lexer::Type::op);
|
||||||
right.tag ("LITERAL");
|
op.tag ("FILTER");
|
||||||
right.tag ("FILTER");
|
reconstructed.push_back (op);
|
||||||
reconstructed.push_back (right);
|
|
||||||
|
|
||||||
changes = true;
|
A2 right ("" + raw.substr (1) + "", Lexer::Type::string);
|
||||||
}
|
right.tag ("FILTER");
|
||||||
else
|
reconstructed.push_back (right);
|
||||||
reconstructed.push_back (a);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
reconstructed.push_back (a);
|
reconstructed.push_back (a);
|
||||||
|
@ -955,10 +939,11 @@ void CLI2::desugarFilterTags ()
|
||||||
_args = reconstructed;
|
_args = reconstructed;
|
||||||
|
|
||||||
if (context.config.getInteger ("debug.parser") >= 3)
|
if (context.config.getInteger ("debug.parser") >= 3)
|
||||||
context.debug (dump ("CLI2::analyze desugarFilterTags"));
|
context.debug (dump ("CLI2::prepareFilter desugarFilterTags"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CLI2::findStrayModifications ()
|
void CLI2::findStrayModifications ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -100,8 +100,8 @@ private:
|
||||||
void findOverrides ();
|
void findOverrides ();
|
||||||
bool findCommand ();
|
bool findCommand ();
|
||||||
bool exactMatch (const std::string&, const std::string&) const;
|
bool exactMatch (const std::string&, const std::string&) const;
|
||||||
/*
|
|
||||||
void desugarFilterTags ();
|
void desugarFilterTags ();
|
||||||
|
/*
|
||||||
void findStrayModifications ();
|
void findStrayModifications ();
|
||||||
void desugarFilterAttributes ();
|
void desugarFilterAttributes ();
|
||||||
void desugarFilterAttributeModifiers ();
|
void desugarFilterAttributeModifiers ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue