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 178 of file Parser.C.

Constructor & Destructor Documentation

◆ UnusedWalker()

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

Definition at line 181 of file Parser.C.

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

Member Function Documentation

◆ walk()

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

Definition at line 186 of file Parser.C.

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

Member Data Documentation

◆ _fname

std::string UnusedWalker::_fname
private

Definition at line 214 of file Parser.C.

Referenced by walk().

◆ _parser

Parser& UnusedWalker::_parser
private

Definition at line 216 of file Parser.C.

Referenced by walk().

◆ _used

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

Definition at line 215 of file Parser.C.

Referenced by walk().

◆ errors

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

Definition at line 211 of file Parser.C.

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


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