relative paths: show {code} properly when there are relative paths
This commit is contained in:
parent
e8ac45a5a7
commit
982f7dc2b3
|
@ -506,7 +506,7 @@ std::string ErrorLogger::ErrorMessage::toString(bool verbose, const std::string
|
||||||
endl = "\r\n";
|
endl = "\r\n";
|
||||||
else
|
else
|
||||||
endl = "\r";
|
endl = "\r";
|
||||||
findAndReplace(result, "{code}", readCode(_callStack.back().getfile(), _callStack.back().line, _callStack.back().col, endl));
|
findAndReplace(result, "{code}", readCode(_callStack.back().getOrigFile(), _callStack.back().line, _callStack.back().col, endl));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
findAndReplace(result, "{file}", "nofile");
|
findAndReplace(result, "{file}", "nofile");
|
||||||
|
@ -587,12 +587,12 @@ std::string ErrorLogger::callStackToString(const std::list<ErrorLogger::ErrorMes
|
||||||
|
|
||||||
|
|
||||||
ErrorLogger::ErrorMessage::FileLocation::FileLocation(const Token* tok, const TokenList* tokenList)
|
ErrorLogger::ErrorMessage::FileLocation::FileLocation(const Token* tok, const TokenList* tokenList)
|
||||||
: fileIndex(tok->fileIndex()), line(tok->linenr()), col(tok->col()), mFileName(tokenList->file(tok))
|
: fileIndex(tok->fileIndex()), line(tok->linenr()), col(tok->col()), mOrigFileName(tokenList->getOrigFile(tok)), mFileName(tokenList->file(tok))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorLogger::ErrorMessage::FileLocation::FileLocation(const Token* tok, const std::string &info, const TokenList* tokenList)
|
ErrorLogger::ErrorMessage::FileLocation::FileLocation(const Token* tok, const std::string &info, const TokenList* tokenList)
|
||||||
: fileIndex(tok->fileIndex()), line(tok->linenr()), col(tok->col()), mFileName(tokenList->file(tok)), mInfo(info)
|
: fileIndex(tok->fileIndex()), line(tok->linenr()), col(tok->col()), mOrigFileName(tokenList->getOrigFile(tok)), mFileName(tokenList->file(tok)), mInfo(info)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,6 +603,13 @@ std::string ErrorLogger::ErrorMessage::FileLocation::getfile(bool convert) const
|
||||||
return mFileName;
|
return mFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string ErrorLogger::ErrorMessage::FileLocation::getOrigFile(bool convert) const
|
||||||
|
{
|
||||||
|
if (convert)
|
||||||
|
return Path::toNativeSeparators(mOrigFileName);
|
||||||
|
return mOrigFileName;
|
||||||
|
}
|
||||||
|
|
||||||
void ErrorLogger::ErrorMessage::FileLocation::setfile(const std::string &file)
|
void ErrorLogger::ErrorMessage::FileLocation::setfile(const std::string &file)
|
||||||
{
|
{
|
||||||
mFileName = file;
|
mFileName = file;
|
||||||
|
|
|
@ -194,11 +194,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
FileLocation(const std::string &file, unsigned int aline)
|
FileLocation(const std::string &file, unsigned int aline)
|
||||||
: fileIndex(0), line(aline), col(0), mFileName(file) {
|
: fileIndex(0), line(aline), col(0), mOrigFileName(file), mFileName(file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileLocation(const std::string &file, const std::string &info, unsigned int aline)
|
FileLocation(const std::string &file, const std::string &info, unsigned int aline)
|
||||||
: fileIndex(0), line(aline), col(0), mFileName(file), mInfo(info) {
|
: fileIndex(0), line(aline), col(0), mOrigFileName(file), mFileName(file), mInfo(info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileLocation(const Token* tok, const TokenList* tokenList);
|
FileLocation(const Token* tok, const TokenList* tokenList);
|
||||||
|
@ -211,6 +211,8 @@ public:
|
||||||
*/
|
*/
|
||||||
std::string getfile(bool convert = true) const;
|
std::string getfile(bool convert = true) const;
|
||||||
|
|
||||||
|
std::string getOrigFile(bool convert = true) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the filename.
|
* Set the filename.
|
||||||
* @param file Filename to set.
|
* @param file Filename to set.
|
||||||
|
@ -234,6 +236,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::string mOrigFileName;
|
||||||
std::string mFileName;
|
std::string mFileName;
|
||||||
std::string mInfo;
|
std::string mInfo;
|
||||||
};
|
};
|
||||||
|
|
|
@ -266,7 +266,7 @@ bool TokenList::createTokens(std::istream &code, const std::string& file0)
|
||||||
void TokenList::createTokens(const simplecpp::TokenList *tokenList)
|
void TokenList::createTokens(const simplecpp::TokenList *tokenList)
|
||||||
{
|
{
|
||||||
if (tokenList->cfront())
|
if (tokenList->cfront())
|
||||||
mFiles = tokenList->cfront()->location.files;
|
mOrigFiles = mFiles = tokenList->cfront()->location.files;
|
||||||
else
|
else
|
||||||
mFiles.clear();
|
mFiles.clear();
|
||||||
|
|
||||||
|
@ -1249,6 +1249,11 @@ void TokenList::validateAst() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string TokenList::getOrigFile(const Token *tok) const
|
||||||
|
{
|
||||||
|
return mOrigFiles.at(tok->fileIndex());
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& TokenList::file(const Token *tok) const
|
const std::string& TokenList::file(const Token *tok) const
|
||||||
{
|
{
|
||||||
return mFiles.at(tok->fileIndex());
|
return mFiles.at(tok->fileIndex());
|
||||||
|
|
|
@ -128,6 +128,8 @@ public:
|
||||||
return mFiles;
|
return mFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string getOrigFile(const Token *tok) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get filename for given token
|
* get filename for given token
|
||||||
* @param tok The given token
|
* @param tok The given token
|
||||||
|
@ -187,6 +189,9 @@ private:
|
||||||
/** filenames for the tokenized source code (source + included) */
|
/** filenames for the tokenized source code (source + included) */
|
||||||
std::vector<std::string> mFiles;
|
std::vector<std::string> mFiles;
|
||||||
|
|
||||||
|
/** Original filenames for the tokenized source code (source + included) */
|
||||||
|
std::vector<std::string> mOrigFiles;
|
||||||
|
|
||||||
/** settings */
|
/** settings */
|
||||||
const Settings* mSettings;
|
const Settings* mSettings;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue