Token debug function printOut() can now print out filename instead of index
This commit is contained in:
parent
2c51542cf1
commit
0bdf63d864
|
@ -603,10 +603,22 @@ void Token::createMutualLinks(Token *begin, Token *end)
|
||||||
|
|
||||||
void Token::printOut(const char *title) const
|
void Token::printOut(const char *title) const
|
||||||
{
|
{
|
||||||
std::cout << stringifyList(true, title) << std::endl;
|
const std::vector<std::string> fileNames;
|
||||||
|
std::cout << stringifyList(true, title, fileNames) << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Token::printOut(const char *title, const std::vector<std::string> &fileNames) const
|
||||||
|
{
|
||||||
|
std::cout << stringifyList(true, title, fileNames) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Token::stringifyList(bool varid, const char *title) const
|
std::string Token::stringifyList(bool varid, const char *title) const
|
||||||
|
{
|
||||||
|
const std::vector<std::string> fileNames;
|
||||||
|
return stringifyList(varid, title, fileNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Token::stringifyList(bool varid, const char *title, const std::vector<std::string> &fileNames) const
|
||||||
{
|
{
|
||||||
std::ostringstream ret;
|
std::ostringstream ret;
|
||||||
if (title)
|
if (title)
|
||||||
|
@ -626,7 +638,11 @@ std::string Token::stringifyList(bool varid, const char *title) const
|
||||||
}
|
}
|
||||||
|
|
||||||
fileIndex = static_cast<int>(tok->_fileIndex);
|
fileIndex = static_cast<int>(tok->_fileIndex);
|
||||||
ret << "\n\n##file " << fileIndex << "";
|
ret << "\n\n##file ";
|
||||||
|
if (fileNames.size() > static_cast<unsigned int>(fileIndex))
|
||||||
|
ret << fileNames.at(fileIndex);
|
||||||
|
else
|
||||||
|
ret << fileIndex;
|
||||||
|
|
||||||
linenr = lineNumbers[fileIndex];
|
linenr = lineNumbers[fileIndex];
|
||||||
fileChange = true;
|
fileChange = true;
|
||||||
|
|
14
lib/token.h
14
lib/token.h
|
@ -20,6 +20,7 @@
|
||||||
#define TokenH
|
#define TokenH
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
/// @addtogroup Core
|
/// @addtogroup Core
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -220,6 +221,16 @@ public:
|
||||||
*/
|
*/
|
||||||
void printOut(const char *title = 0) const;
|
void printOut(const char *title = 0) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For debugging purposes, prints token and all tokens
|
||||||
|
* followed by it.
|
||||||
|
* @param title Title for the printout or use default parameter or 0
|
||||||
|
* for no title.
|
||||||
|
* @param fileNames Prints out file name instead of file index.
|
||||||
|
* File index should match the index of the string in this vector.
|
||||||
|
*/
|
||||||
|
void printOut(const char *title, const std::vector<std::string> &fileNames) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace token replaceThis with tokens between start and end,
|
* Replace token replaceThis with tokens between start and end,
|
||||||
* including start and end. The replaceThis token is deleted.
|
* including start and end. The replaceThis token is deleted.
|
||||||
|
@ -230,7 +241,8 @@ public:
|
||||||
static void replace(Token *replaceThis, Token *start, Token *end);
|
static void replace(Token *replaceThis, Token *start, Token *end);
|
||||||
|
|
||||||
/** Stringify a token list (with or without varId) */
|
/** Stringify a token list (with or without varId) */
|
||||||
std::string stringifyList(bool varid = true, const char *title = 0) const;
|
std::string stringifyList(bool varid = 0, const char *title = 0) const;
|
||||||
|
std::string stringifyList(bool varid, const char *title, const std::vector<std::string> &fileNames) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is intended to be used for the first token in the list
|
* This is intended to be used for the first token in the list
|
||||||
|
|
|
@ -2164,7 +2164,7 @@ bool Tokenizer::simplifyTokenList()
|
||||||
simplifyComma();
|
simplifyComma();
|
||||||
if (_settings && _settings->_debug)
|
if (_settings && _settings->_debug)
|
||||||
{
|
{
|
||||||
_tokens->printOut();
|
_tokens->printOut(0, _files);
|
||||||
}
|
}
|
||||||
|
|
||||||
return validate();
|
return validate();
|
||||||
|
|
Loading…
Reference in New Issue