www.mooseframework.org
Public Member Functions | Public Attributes | Private Attributes | List of all members
UnusedWalker Class Reference
Inheritance diagram for UnusedWalker:
[legend]

Public Member Functions

 UnusedWalker (std::string fname, std::set< std::string > used, Parser &p)
 
void walk (const std::string &fullpath, const std::string &nodename, hit::Node *n) override
 

Public Attributes

std::vector< std::string > errors
 

Private Attributes

std::string _fname
 
std::set< std::string > _used
 
Parser_parser
 

Detailed Description

Definition at line 177 of file Parser.C.

Constructor & Destructor Documentation

◆ UnusedWalker()

UnusedWalker::UnusedWalker ( std::string  fname,
std::set< std::string >  used,
Parser p 
)
inline

Definition at line 180 of file Parser.C.

181  : _fname(fname), _used(used), _parser(p)
182  {
183  }
std::set< std::string > _used
Definition: Parser.C:214
Parser & _parser
Definition: Parser.C:215
std::string _fname
Definition: Parser.C:213

Member Function Documentation

◆ walk()

void UnusedWalker::walk ( const std::string &  fullpath,
const std::string &  nodename,
hit::Node *  n 
)
inlineoverride

Definition at line 185 of file Parser.C.

186  {
187  // the line() > 0 check allows us to skip nodes that were merged into this tree (i.e. CLI
188  // args) because their unused params are checked+reported independently of the ones in the
189  // main tree.
190  if (!_used.count(fullpath) && nodename != "active" && nodename != "inactive" &&
191  isSectionActive(fullpath, n->root()) && n->line() > 0)
192  {
193  auto section_name = fullpath.substr(0, fullpath.rfind("/"));
194  auto paramlist = _parser.listValidParams(section_name);
195  auto candidates = findSimilar(nodename, paramlist);
196  if (candidates.size() > 0)
197  errors.push_back(errormsg(_fname,
198  n,
199  "unused parameter '",
200  fullpath,
201  "'\n",
202  " Did you mean '",
203  candidates[0],
204  "'?"));
205  else
206  errors.push_back(errormsg(_fname, n, "unused parameter '", fullpath, "'"));
207  }
208  }
std::set< std::string > _used
Definition: Parser.C:214
Parser & _parser
Definition: Parser.C:215
bool isSectionActive(std::string path, hit::Node *root)
Definition: Parser.C:68
std::vector< std::string > listValidParams(std::string &section_name)
Definition: Parser.C:161
std::vector< std::string > errors
Definition: Parser.C:210
PetscInt n
std::string errormsg(std::string, hit::Node *)
Definition: Parser.h:34
std::vector< std::string > findSimilar(std::string param, std::vector< std::string > options)
Definition: Parser.C:135
std::string _fname
Definition: Parser.C:213

Member Data Documentation

◆ _fname

std::string UnusedWalker::_fname
private

Definition at line 213 of file Parser.C.

Referenced by walk().

◆ _parser

Parser& UnusedWalker::_parser
private

Definition at line 215 of file Parser.C.

Referenced by walk().

◆ _used

std::set<std::string> UnusedWalker::_used
private

Definition at line 214 of file Parser.C.

Referenced by walk().

◆ errors

std::vector<std::string> UnusedWalker::errors

Definition at line 210 of file Parser.C.

Referenced by Parser::errorCheck(), and walk().


The documentation for this class was generated from the following file: