mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-24 18:06:42 +02:00
CLI
- Implemented ::decomposeModAttribute.
This commit is contained in:
parent
b484abea4a
commit
626354999c
2 changed files with 89 additions and 1 deletions
89
src/CLI.cpp
89
src/CLI.cpp
|
@ -292,13 +292,16 @@ void CLI::analyze ()
|
|||
findOverrides ();
|
||||
categorize ();
|
||||
|
||||
// Remove all the syntactic sugar.
|
||||
// Remove all the syntactic sugar for FILTERs..
|
||||
desugarTags ();
|
||||
desugarAttributes ();
|
||||
desugarAttributeModifiers ();
|
||||
desugarPatterns ();
|
||||
desugarIDs ();
|
||||
desugarUUIDs ();
|
||||
|
||||
// Decompose the elements for MODIFICATIONs.
|
||||
decomposeModAttributes ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1172,3 +1175,87 @@ void CLI::desugarUUIDs ()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void CLI::decomposeModAttributes ()
|
||||
{
|
||||
std::vector <A> reconstructed;
|
||||
std::vector <A>::iterator a;
|
||||
for (a = _args.begin (); a != _args.end (); ++a)
|
||||
{
|
||||
if (a->hasTag ("MODIFICATION"))
|
||||
{
|
||||
// Look for a valid attribute name.
|
||||
bool found = false;
|
||||
Nibbler n (a->attribute ("raw"));
|
||||
std::string name;
|
||||
if (n.getName (name) &&
|
||||
name.length ())
|
||||
{
|
||||
if (n.skip (':'))
|
||||
{
|
||||
std::string value;
|
||||
if (n.getQuoted ('"', value) ||
|
||||
n.getQuoted ('\'', value) ||
|
||||
n.getUntilEOS (value) ||
|
||||
n.depleted ())
|
||||
{
|
||||
if (value == "")
|
||||
value = "''";
|
||||
|
||||
std::string canonical;
|
||||
if (canonicalize (canonical, "uda", name))
|
||||
{
|
||||
A attr ("argUDA", name);
|
||||
attr.attribute ("name", canonical);
|
||||
attr.attribute ("value", value);
|
||||
attr.tag ("UDA");
|
||||
attr.tag ("MODIFIABLE");
|
||||
attr.tag ("MODIFICATION");
|
||||
reconstructed.push_back (attr);
|
||||
found = true;
|
||||
}
|
||||
|
||||
else if (canonicalize (canonical, "pseudo", name))
|
||||
{
|
||||
A attr ("argUDA", name);
|
||||
attr.attribute ("name", canonical);
|
||||
attr.attribute ("value", value);
|
||||
attr.tag ("PSEUDO");
|
||||
attr.tag ("MODIFICATION");
|
||||
reconstructed.push_back (attr);
|
||||
found = true;
|
||||
}
|
||||
|
||||
else if (canonicalize (canonical, "attribute", name))
|
||||
{
|
||||
A attr ("argAtt", name);
|
||||
attr.attribute ("name", canonical);
|
||||
attr.attribute ("value", value);
|
||||
attr.tag ("ATTRIBUTE");
|
||||
attr.tag ("MODIFICATION");
|
||||
|
||||
std::map <std::string, Column*>::const_iterator col;
|
||||
col = context.columns.find (canonical);
|
||||
if (col != context.columns.end () &&
|
||||
col->second->modifiable ())
|
||||
{
|
||||
attr.tag ("MODIFIABLE");
|
||||
}
|
||||
|
||||
reconstructed.push_back (attr);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
reconstructed.push_back (*a);
|
||||
}
|
||||
else
|
||||
reconstructed.push_back (*a);
|
||||
}
|
||||
|
||||
_args = reconstructed;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -86,6 +86,7 @@ private:
|
|||
void desugarPatterns ();
|
||||
void desugarIDs ();
|
||||
void desugarUUIDs ();
|
||||
void decomposeModAttributes ();
|
||||
|
||||
public:
|
||||
std::multimap <std::string, std::string> _entities;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue