moved messages from Parser to SPF_message
This commit is contained in:
@@ -387,7 +387,50 @@ static string shiftLines(const string &in, const map<string, const FileInfo*> &m
|
|||||||
return newStr;
|
return newStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string>& errors)
|
static void addMessage(const string& in, const map<string, const FileInfo*>& mapOfFiles,
|
||||||
|
const FileInfo* currF, map<string, vector<Messages>>& messages, typeMessage type)
|
||||||
|
{
|
||||||
|
int byNum = 0;
|
||||||
|
|
||||||
|
auto it = in.find("on line ");
|
||||||
|
if (it != string::npos)
|
||||||
|
it += strlen("on line ");
|
||||||
|
|
||||||
|
int line = 0;
|
||||||
|
sscanf(in.c_str() + it, "%d", &line);
|
||||||
|
|
||||||
|
auto it1 = in.find("of", it + 1);
|
||||||
|
if (it1 == string::npos)
|
||||||
|
return;
|
||||||
|
it1 += 3;
|
||||||
|
|
||||||
|
string fileN = in.substr(it1, in.find(':', it1) - it1);
|
||||||
|
auto itF = mapOfFiles.find(fileN);
|
||||||
|
if (itF != mapOfFiles.end() && itF->second != currF)
|
||||||
|
{
|
||||||
|
byNum = itF->second->includesAdded;
|
||||||
|
if (byNum != 0)
|
||||||
|
{
|
||||||
|
if (line - byNum <= 0)
|
||||||
|
{
|
||||||
|
//return in;
|
||||||
|
printInternalError(convertFileName(__FILE__).c_str(), __LINE__);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
line -= byNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const string newStr = in.substr(0, it) + std::to_string(line) + in.substr(in.find(' ', it + 1));
|
||||||
|
|
||||||
|
wstring messageE, messageR;
|
||||||
|
__spf_printToLongBuf(messageE, L"%s", to_wstring(newStr).c_str());
|
||||||
|
__spf_printToLongBuf(messageR, L"%s", to_wstring(newStr).c_str());
|
||||||
|
|
||||||
|
messages[fileN].push_back(Messages(type, line, messageR, messageE, 6000));
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string>& errors, map<string, vector<Messages>>& messages)
|
||||||
{
|
{
|
||||||
int errorsCount = 0;
|
int errorsCount = 0;
|
||||||
map<string, const FileInfo*> mapOfFiles;
|
map<string, const FileInfo*> mapOfFiles;
|
||||||
@@ -420,9 +463,13 @@ static int dumpErrors(const vector<FileInfo>& listOfProject, const vector<string
|
|||||||
for (auto& elem : splited)
|
for (auto& elem : splited)
|
||||||
{
|
{
|
||||||
if (elem.find("Warning 308") != string::npos)
|
if (elem.find("Warning 308") != string::npos)
|
||||||
|
{
|
||||||
|
addMessage(elem, mapOfFiles, &file, messages, WARR);
|
||||||
outS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
outS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
||||||
|
}
|
||||||
else if (elem.find("Error") != string::npos)
|
else if (elem.find("Error") != string::npos)
|
||||||
{
|
{
|
||||||
|
addMessage(elem, mapOfFiles, &file, messages, ERROR);
|
||||||
errS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
errS += shiftLines(elem, mapOfFiles, &file) + "\n";
|
||||||
errorsCount++;
|
errorsCount++;
|
||||||
}
|
}
|
||||||
@@ -652,7 +699,7 @@ static int parseFiles(vector<string>& errors, vector<FileInfo>& listOfProject, v
|
|||||||
return rethrow;
|
return rethrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int parseForInlining)
|
int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int parseForInlining, map<string, vector<Messages>>& messages)
|
||||||
{
|
{
|
||||||
FILE* list = fopen(proj, "r");
|
FILE* list = fopen(proj, "r");
|
||||||
if (!list)
|
if (!list)
|
||||||
@@ -723,7 +770,7 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
|
|||||||
vector<string> errors;
|
vector<string> errors;
|
||||||
|
|
||||||
int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, parseForInlining);
|
int rethrow = parseFiles(errors, listOfProject, filesCompilationOrder, parseForInlining);
|
||||||
int errCount = dumpErrors(listOfProject, errors);
|
int errCount = dumpErrors(listOfProject, errors, messages);
|
||||||
|
|
||||||
if (rethrow != 0)
|
if (rethrow != 0)
|
||||||
throw rethrow;
|
throw rethrow;
|
||||||
@@ -732,6 +779,8 @@ int parseFiles(const char* proj, vector<string>& filesCompilationOrder, int pars
|
|||||||
|
|
||||||
void parseFiles(int argc, char** argv)
|
void parseFiles(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
map<string, vector<Messages>> messages;
|
||||||
|
|
||||||
bool isInline = false;
|
bool isInline = false;
|
||||||
auto result = splitCommandLineForParse(argv, argc, isInline);
|
auto result = splitCommandLineForParse(argv, argc, isInline);
|
||||||
if (result.second.size() == 0)
|
if (result.second.size() == 0)
|
||||||
|
|||||||
@@ -3,5 +3,5 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int parseFiles(const char* proj, std::vector<std::string>& filesCompilationOrder, int parseForInlining);
|
int parseFiles(const char* proj, std::vector<std::string>& filesCompilationOrder, int parseForInlining, std::map<std::string, std::vector<Messages>>& messages);
|
||||||
void parseFiles(int argc, char** argv);
|
void parseFiles(int argc, char** argv);
|
||||||
|
|||||||
@@ -2389,7 +2389,7 @@ void runPass(const int curr_regime, const char *proj_name, const char *folderNam
|
|||||||
break;
|
break;
|
||||||
case PARSE_FILES:
|
case PARSE_FILES:
|
||||||
{
|
{
|
||||||
int err = parseFiles(proj_name, filesCompilationOrder, parseForInlining);
|
int err = parseFiles(proj_name, filesCompilationOrder, parseForInlining, SPF_messages);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,6 +145,9 @@ enum typeMessage { WARR, ERROR, NOTE };
|
|||||||
// 06 "%s clause can be used only once."
|
// 06 "%s clause can be used only once."
|
||||||
// 07 "Variable '%s' can't be used in FILES and EXCEPT clauses at the same time."
|
// 07 "Variable '%s' can't be used in FILES and EXCEPT clauses at the same time."
|
||||||
|
|
||||||
|
// 6000 PARSER GROUP
|
||||||
|
//
|
||||||
|
|
||||||
extern int langOfMessages;
|
extern int langOfMessages;
|
||||||
struct Messages
|
struct Messages
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user