mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
CLI
- Implemented ::decomposeModAttributeModifiers.
This commit is contained in:
parent
626354999c
commit
f2e533d013
2 changed files with 95 additions and 11 deletions
105
src/CLI.cpp
105
src/CLI.cpp
|
@ -302,6 +302,7 @@ void CLI::analyze ()
|
||||||
|
|
||||||
// Decompose the elements for MODIFICATIONs.
|
// Decompose the elements for MODIFICATIONs.
|
||||||
decomposeModAttributes ();
|
decomposeModAttributes ();
|
||||||
|
decomposeModAttributeModifiers ();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1214,17 +1215,6 @@ void CLI::decomposeModAttributes ()
|
||||||
found = true;
|
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))
|
else if (canonicalize (canonical, "attribute", name))
|
||||||
{
|
{
|
||||||
A attr ("argAtt", name);
|
A attr ("argAtt", name);
|
||||||
|
@ -1259,3 +1249,96 @@ void CLI::decomposeModAttributes ()
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CLI::decomposeModAttributeModifiers ()
|
||||||
|
{
|
||||||
|
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.getUntil (".", name) &&
|
||||||
|
name.length ())
|
||||||
|
{
|
||||||
|
std::string canonical;
|
||||||
|
if (canonicalize (canonical, "attribute", name) ||
|
||||||
|
canonicalize (canonical, "uda", name))
|
||||||
|
{
|
||||||
|
if (n.skip ('.'))
|
||||||
|
{
|
||||||
|
std::string sense = "+";
|
||||||
|
if (n.skip ('~'))
|
||||||
|
sense = "-";
|
||||||
|
|
||||||
|
std::string modifier;
|
||||||
|
n.getUntilOneOf (":=", modifier);
|
||||||
|
|
||||||
|
if (n.skip (':') ||
|
||||||
|
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 attmod ("argUDA", name);
|
||||||
|
attmod.attribute ("name", canonical);
|
||||||
|
attmod.attribute ("modifier", modifier);
|
||||||
|
attmod.attribute ("sense", sense);
|
||||||
|
attmod.attribute ("value", value);
|
||||||
|
attmod.tag ("UDA");
|
||||||
|
attmod.tag ("MODIFIABLE");
|
||||||
|
attmod.tag ("MODIFICATION");
|
||||||
|
reconstructed.push_back (attmod);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (canonicalize (canonical, "attribute", name))
|
||||||
|
{
|
||||||
|
A attmod ("argAtt", name);
|
||||||
|
attmod.attribute ("name", canonical);
|
||||||
|
attmod.attribute ("modifier", modifier);
|
||||||
|
attmod.attribute ("sense", sense);
|
||||||
|
attmod.attribute ("value", value);
|
||||||
|
attmod.tag ("ATTMOD");
|
||||||
|
attmod.tag ("MODIFICATION");
|
||||||
|
|
||||||
|
std::map <std::string, Column*>::const_iterator col;
|
||||||
|
col = context.columns.find (canonical);
|
||||||
|
if (col != context.columns.end () &&
|
||||||
|
col->second->modifiable ())
|
||||||
|
{
|
||||||
|
attmod.tag ("MODIFIABLE");
|
||||||
|
}
|
||||||
|
|
||||||
|
reconstructed.push_back (attmod);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
reconstructed.push_back (*a);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
reconstructed.push_back (*a);
|
||||||
|
}
|
||||||
|
|
||||||
|
_args = reconstructed;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -87,6 +87,7 @@ private:
|
||||||
void desugarIDs ();
|
void desugarIDs ();
|
||||||
void desugarUUIDs ();
|
void desugarUUIDs ();
|
||||||
void decomposeModAttributes ();
|
void decomposeModAttributes ();
|
||||||
|
void decomposeModAttributeModifiers ();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::multimap <std::string, std::string> _entities;
|
std::multimap <std::string, std::string> _entities;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue