mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
CLI
- Implemented ::decomposeModTags.
This commit is contained in:
parent
f2e533d013
commit
5dcc415057
2 changed files with 56 additions and 50 deletions
101
src/CLI.cpp
101
src/CLI.cpp
|
@ -303,6 +303,7 @@ void CLI::analyze ()
|
||||||
// Decompose the elements for MODIFICATIONs.
|
// Decompose the elements for MODIFICATIONs.
|
||||||
decomposeModAttributes ();
|
decomposeModAttributes ();
|
||||||
decomposeModAttributeModifiers ();
|
decomposeModAttributeModifiers ();
|
||||||
|
decomposeModTags ();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1185,7 +1186,6 @@ void CLI::decomposeModAttributes ()
|
||||||
if (a->hasTag ("MODIFICATION"))
|
if (a->hasTag ("MODIFICATION"))
|
||||||
{
|
{
|
||||||
// Look for a valid attribute name.
|
// Look for a valid attribute name.
|
||||||
bool found = false;
|
|
||||||
Nibbler n (a->attribute ("raw"));
|
Nibbler n (a->attribute ("raw"));
|
||||||
std::string name;
|
std::string name;
|
||||||
if (n.getName (name) &&
|
if (n.getName (name) &&
|
||||||
|
@ -1205,43 +1205,31 @@ void CLI::decomposeModAttributes ()
|
||||||
std::string canonical;
|
std::string canonical;
|
||||||
if (canonicalize (canonical, "uda", name))
|
if (canonicalize (canonical, "uda", name))
|
||||||
{
|
{
|
||||||
A attr ("argUDA", name);
|
a->attribute ("name", canonical);
|
||||||
attr.attribute ("name", canonical);
|
a->attribute ("value", value);
|
||||||
attr.attribute ("value", value);
|
a->tag ("UDA");
|
||||||
attr.tag ("UDA");
|
a->tag ("MODIFIABLE");
|
||||||
attr.tag ("MODIFIABLE");
|
|
||||||
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->attribute ("name", canonical);
|
||||||
attr.attribute ("name", canonical);
|
a->attribute ("value", value);
|
||||||
attr.attribute ("value", value);
|
a->tag ("ATTRIBUTE");
|
||||||
attr.tag ("ATTRIBUTE");
|
|
||||||
attr.tag ("MODIFICATION");
|
|
||||||
|
|
||||||
std::map <std::string, Column*>::const_iterator col;
|
std::map <std::string, Column*>::const_iterator col;
|
||||||
col = context.columns.find (canonical);
|
col = context.columns.find (canonical);
|
||||||
if (col != context.columns.end () &&
|
if (col != context.columns.end () &&
|
||||||
col->second->modifiable ())
|
col->second->modifiable ())
|
||||||
{
|
{
|
||||||
attr.tag ("MODIFIABLE");
|
a->tag ("MODIFIABLE");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reconstructed.push_back (attr);
|
|
||||||
found = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
|
||||||
reconstructed.push_back (*a);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
reconstructed.push_back (*a);
|
reconstructed.push_back (*a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1258,7 +1246,6 @@ void CLI::decomposeModAttributeModifiers ()
|
||||||
if (a->hasTag ("MODIFICATION"))
|
if (a->hasTag ("MODIFICATION"))
|
||||||
{
|
{
|
||||||
// Look for a valid attribute name.
|
// Look for a valid attribute name.
|
||||||
bool found = false;
|
|
||||||
Nibbler n (a->attribute ("raw"));
|
Nibbler n (a->attribute ("raw"));
|
||||||
std::string name;
|
std::string name;
|
||||||
if (n.getUntil (".", name) &&
|
if (n.getUntil (".", name) &&
|
||||||
|
@ -1292,38 +1279,30 @@ void CLI::decomposeModAttributeModifiers ()
|
||||||
std::string canonical;
|
std::string canonical;
|
||||||
if (canonicalize (canonical, "uda", name))
|
if (canonicalize (canonical, "uda", name))
|
||||||
{
|
{
|
||||||
A attmod ("argUDA", name);
|
a->attribute ("name", canonical);
|
||||||
attmod.attribute ("name", canonical);
|
a->attribute ("modifier", modifier);
|
||||||
attmod.attribute ("modifier", modifier);
|
a->attribute ("sense", sense);
|
||||||
attmod.attribute ("sense", sense);
|
a->attribute ("value", value);
|
||||||
attmod.attribute ("value", value);
|
a->tag ("UDA");
|
||||||
attmod.tag ("UDA");
|
a->tag ("MODIFIABLE");
|
||||||
attmod.tag ("MODIFIABLE");
|
|
||||||
attmod.tag ("MODIFICATION");
|
|
||||||
reconstructed.push_back (attmod);
|
|
||||||
found = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (canonicalize (canonical, "attribute", name))
|
else if (canonicalize (canonical, "attribute", name))
|
||||||
{
|
{
|
||||||
A attmod ("argAtt", name);
|
a->attribute ("name", canonical);
|
||||||
attmod.attribute ("name", canonical);
|
a->attribute ("modifier", modifier);
|
||||||
attmod.attribute ("modifier", modifier);
|
a->attribute ("sense", sense);
|
||||||
attmod.attribute ("sense", sense);
|
a->attribute ("value", value);
|
||||||
attmod.attribute ("value", value);
|
a->tag ("ATTMOD");
|
||||||
attmod.tag ("ATTMOD");
|
|
||||||
attmod.tag ("MODIFICATION");
|
|
||||||
|
|
||||||
std::map <std::string, Column*>::const_iterator col;
|
std::map <std::string, Column*>::const_iterator col;
|
||||||
col = context.columns.find (canonical);
|
col = context.columns.find (canonical);
|
||||||
if (col != context.columns.end () &&
|
if (col != context.columns.end () &&
|
||||||
col->second->modifiable ())
|
col->second->modifiable ())
|
||||||
{
|
{
|
||||||
attmod.tag ("MODIFIABLE");
|
a->tag ("MODIFIABLE");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reconstructed.push_back (attmod);
|
|
||||||
found = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1331,10 +1310,36 @@ void CLI::decomposeModAttributeModifiers ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
reconstructed.push_back (*a);
|
||||||
reconstructed.push_back (*a);
|
}
|
||||||
}
|
|
||||||
else
|
_args = reconstructed;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void CLI::decomposeModTags ()
|
||||||
|
{
|
||||||
|
std::vector <A> reconstructed;
|
||||||
|
std::vector <A>::iterator a;
|
||||||
|
for (a = _args.begin (); a != _args.end (); ++a)
|
||||||
|
{
|
||||||
|
if (a->hasTag ("MODIFICATION"))
|
||||||
|
{
|
||||||
|
Nibbler n (a->attribute ("raw"));
|
||||||
|
std::string tag;
|
||||||
|
std::string sign;
|
||||||
|
|
||||||
|
if (n.getN (1, sign) &&
|
||||||
|
(sign == "+" || sign == "-") &&
|
||||||
|
n.getUntilEOS (tag) &&
|
||||||
|
tag.find (' ') == std::string::npos)
|
||||||
|
{
|
||||||
|
a->attribute ("name", tag);
|
||||||
|
a->attribute ("sign", sign);
|
||||||
|
a->tag ("TAG");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reconstructed.push_back (*a);
|
reconstructed.push_back (*a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,7 @@ private:
|
||||||
void desugarUUIDs ();
|
void desugarUUIDs ();
|
||||||
void decomposeModAttributes ();
|
void decomposeModAttributes ();
|
||||||
void decomposeModAttributeModifiers ();
|
void decomposeModAttributeModifiers ();
|
||||||
|
void decomposeModTags ();
|
||||||
|
|
||||||
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