forked from lix-project/lix
uncrustify formatting
This commit is contained in:
parent
22e6490311
commit
e2f61263eb
2989
.uncrustify.cfg
Normal file
2989
.uncrustify.cfg
Normal file
File diff suppressed because it is too large
Load diff
|
@ -29,38 +29,38 @@ int main()
|
||||||
ErrorInfo { .level = lvlInfo,
|
ErrorInfo { .level = lvlInfo,
|
||||||
.name = "Info name",
|
.name = "Info name",
|
||||||
.description = "Info description",
|
.description = "Info description",
|
||||||
});
|
});
|
||||||
|
|
||||||
logger->logEI(
|
logger->logEI(
|
||||||
ErrorInfo { .level = lvlTalkative,
|
ErrorInfo { .level = lvlTalkative,
|
||||||
.name = "Talkative name",
|
.name = "Talkative name",
|
||||||
.description = "Talkative description",
|
.description = "Talkative description",
|
||||||
});
|
});
|
||||||
|
|
||||||
logger->logEI(
|
logger->logEI(
|
||||||
ErrorInfo { .level = lvlChatty,
|
ErrorInfo { .level = lvlChatty,
|
||||||
.name = "Chatty name",
|
.name = "Chatty name",
|
||||||
.description = "Chatty description",
|
.description = "Chatty description",
|
||||||
});
|
});
|
||||||
|
|
||||||
logger->logEI(
|
logger->logEI(
|
||||||
ErrorInfo { .level = lvlDebug,
|
ErrorInfo { .level = lvlDebug,
|
||||||
.name = "Debug name",
|
.name = "Debug name",
|
||||||
.description = "Debug description",
|
.description = "Debug description",
|
||||||
});
|
});
|
||||||
|
|
||||||
logger->logEI(
|
logger->logEI(
|
||||||
ErrorInfo { .level = lvlVomit,
|
ErrorInfo { .level = lvlVomit,
|
||||||
.name = "Vomit name",
|
.name = "Vomit name",
|
||||||
.description = "Vomit description",
|
.description = "Vomit description",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Error in a program; no hint and no nix code.
|
// Error in a program; no hint and no nix code.
|
||||||
logError(
|
logError(
|
||||||
ErrorInfo { .name = "name",
|
ErrorInfo { .name = "name",
|
||||||
.description = "error description",
|
.description = "error description",
|
||||||
});
|
});
|
||||||
|
|
||||||
// Warning with name, description, and hint.
|
// Warning with name, description, and hint.
|
||||||
// The hintfmt function makes all the substituted text yellow.
|
// The hintfmt function makes all the substituted text yellow.
|
||||||
|
@ -68,7 +68,7 @@ int main()
|
||||||
ErrorInfo { .name = "name",
|
ErrorInfo { .name = "name",
|
||||||
.description = "error description",
|
.description = "error description",
|
||||||
.hint = hintfmt("there was a %1%", "warning"),
|
.hint = hintfmt("there was a %1%", "warning"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Warning with nix file, line number, column, and the lines of
|
// Warning with nix file, line number, column, and the lines of
|
||||||
|
@ -80,28 +80,28 @@ int main()
|
||||||
ErrorInfo { .name = "warning name",
|
ErrorInfo { .name = "warning name",
|
||||||
.description = "warning description",
|
.description = "warning description",
|
||||||
.hint = hintfmt("this hint has %1% templated %2%!!",
|
.hint = hintfmt("this hint has %1% templated %2%!!",
|
||||||
"yellow",
|
"yellow",
|
||||||
"values"),
|
"values"),
|
||||||
.nixCode = NixCode {
|
.nixCode = NixCode {
|
||||||
.errPos = Pos(problem_file, 40, 13),
|
.errPos = Pos(problem_file, 40, 13),
|
||||||
.prevLineOfCode = std::nullopt,
|
.prevLineOfCode = std::nullopt,
|
||||||
.errLineOfCode = "this is the problem line of code",
|
.errLineOfCode = "this is the problem line of code",
|
||||||
.nextLineOfCode = std::nullopt
|
.nextLineOfCode = std::nullopt
|
||||||
}});
|
}});
|
||||||
|
|
||||||
// Error with previous and next lines of code.
|
// Error with previous and next lines of code.
|
||||||
logError(
|
logError(
|
||||||
ErrorInfo { .name = "error name",
|
ErrorInfo { .name = "error name",
|
||||||
.description = "error description",
|
.description = "error description",
|
||||||
.hint = hintfmt("this hint has %1% templated %2%!!",
|
.hint = hintfmt("this hint has %1% templated %2%!!",
|
||||||
"yellow",
|
"yellow",
|
||||||
"values"),
|
"values"),
|
||||||
.nixCode = NixCode {
|
.nixCode = NixCode {
|
||||||
.errPos = Pos(problem_file, 40, 13),
|
.errPos = Pos(problem_file, 40, 13),
|
||||||
.prevLineOfCode = std::optional("previous line of code"),
|
.prevLineOfCode = std::optional("previous line of code"),
|
||||||
.errLineOfCode = "this is the problem line of code",
|
.errLineOfCode = "this is the problem line of code",
|
||||||
.nextLineOfCode = std::optional("next line of code"),
|
.nextLineOfCode = std::optional("next line of code"),
|
||||||
}});
|
}});
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -234,7 +234,8 @@ struct ExprLambda : Expr
|
||||||
: pos(pos), arg(arg), matchAttrs(matchAttrs), formals(formals), body(body)
|
: pos(pos), arg(arg), matchAttrs(matchAttrs), formals(formals), body(body)
|
||||||
{
|
{
|
||||||
if (!arg.empty() && formals && formals->argNames.find(arg) != formals->argNames.end())
|
if (!arg.empty() && formals && formals->argNames.find(arg) != formals->argNames.end())
|
||||||
throw ParseError("duplicate formal function argument '%1%' at %2%", arg, pos); };
|
throw ParseError("duplicate formal function argument '%1%' at %2%", arg, pos);
|
||||||
|
};
|
||||||
void setName(Symbol & name);
|
void setName(Symbol & name);
|
||||||
string showNamePos() const;
|
string showNamePos() const;
|
||||||
COMMON_METHODS
|
COMMON_METHODS
|
||||||
|
|
|
@ -45,17 +45,17 @@ void printCodeLines(const string &prefix, const NixCode &nixCode)
|
||||||
// previous line of code.
|
// previous line of code.
|
||||||
if (nixCode.prevLineOfCode.has_value()) {
|
if (nixCode.prevLineOfCode.has_value()) {
|
||||||
std::cout << fmt("%1% %|2$5d|| %3%",
|
std::cout << fmt("%1% %|2$5d|| %3%",
|
||||||
prefix,
|
prefix,
|
||||||
(nixCode.errPos.line - 1),
|
(nixCode.errPos.line - 1),
|
||||||
*nixCode.prevLineOfCode)
|
*nixCode.prevLineOfCode)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// line of code containing the error.%2$+5d%
|
// line of code containing the error.%2$+5d%
|
||||||
std::cout << fmt("%1% %|2$5d|| %3%",
|
std::cout << fmt("%1% %|2$5d|| %3%",
|
||||||
prefix,
|
prefix,
|
||||||
(nixCode.errPos.line),
|
(nixCode.errPos.line),
|
||||||
nixCode.errLineOfCode)
|
nixCode.errLineOfCode)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
// error arrows for the column range.
|
// error arrows for the column range.
|
||||||
|
@ -69,17 +69,17 @@ void printCodeLines(const string &prefix, const NixCode &nixCode)
|
||||||
std::string arrows("^");
|
std::string arrows("^");
|
||||||
|
|
||||||
std::cout << fmt("%1% |%2%" ANSI_RED "%3%" ANSI_NORMAL,
|
std::cout << fmt("%1% |%2%" ANSI_RED "%3%" ANSI_NORMAL,
|
||||||
prefix,
|
prefix,
|
||||||
spaces,
|
spaces,
|
||||||
arrows) << std::endl;
|
arrows) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// next line of code.
|
// next line of code.
|
||||||
if (nixCode.nextLineOfCode.has_value()) {
|
if (nixCode.nextLineOfCode.has_value()) {
|
||||||
std::cout << fmt("%1% %|2$5d|| %3%",
|
std::cout << fmt("%1% %|2$5d|| %3%",
|
||||||
prefix,
|
prefix,
|
||||||
(nixCode.errPos.line + 1),
|
(nixCode.errPos.line + 1),
|
||||||
*nixCode.nextLineOfCode)
|
*nixCode.nextLineOfCode)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,18 +149,18 @@ std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
|
||||||
// divider.
|
// divider.
|
||||||
if (einfo.name != "")
|
if (einfo.name != "")
|
||||||
out << fmt("%1%%2%" ANSI_BLUE " --- %3% %4% %5%" ANSI_NORMAL,
|
out << fmt("%1%%2%" ANSI_BLUE " --- %3% %4% %5%" ANSI_NORMAL,
|
||||||
prefix,
|
prefix,
|
||||||
levelString,
|
levelString,
|
||||||
einfo.name,
|
einfo.name,
|
||||||
dashes,
|
dashes,
|
||||||
einfo.programName.value_or(""))
|
einfo.programName.value_or(""))
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
else
|
else
|
||||||
out << fmt("%1%%2%" ANSI_BLUE " -----%3% %4%" ANSI_NORMAL,
|
out << fmt("%1%%2%" ANSI_BLUE " -----%3% %4%" ANSI_NORMAL,
|
||||||
prefix,
|
prefix,
|
||||||
levelString,
|
levelString,
|
||||||
dashes,
|
dashes,
|
||||||
einfo.programName.value_or(""))
|
einfo.programName.value_or(""))
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
// filename.
|
// filename.
|
||||||
|
@ -171,9 +171,9 @@ std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
out << fmt("%1%in file: " ANSI_BLUE "%2%%3%" ANSI_NORMAL,
|
out << fmt("%1%in file: " ANSI_BLUE "%2%%3%" ANSI_NORMAL,
|
||||||
prefix,
|
prefix,
|
||||||
einfo.nixCode->errPos.file,
|
einfo.nixCode->errPos.file,
|
||||||
eline) << std::endl;
|
eline) << std::endl;
|
||||||
out << prefix << std::endl;
|
out << prefix << std::endl;
|
||||||
} else {
|
} else {
|
||||||
out << fmt("%1%from command line argument", prefix) << std::endl;
|
out << fmt("%1%from command line argument", prefix) << std::endl;
|
||||||
|
|
|
@ -68,7 +68,7 @@ public:
|
||||||
|
|
||||||
void startActivity(ActivityId act, Verbosity lvl, ActivityType type,
|
void startActivity(ActivityId act, Verbosity lvl, ActivityType type,
|
||||||
const std::string & s, const Fields & fields, ActivityId parent)
|
const std::string & s, const Fields & fields, ActivityId parent)
|
||||||
override
|
override
|
||||||
{
|
{
|
||||||
if (lvl <= verbosity && !s.empty())
|
if (lvl <= verbosity && !s.empty())
|
||||||
log(lvl, s + "...");
|
log(lvl, s + "...");
|
||||||
|
@ -111,8 +111,7 @@ Activity::Activity(Logger & logger, Verbosity lvl, ActivityType type,
|
||||||
logger.startActivity(id, lvl, type, s, fields, parent);
|
logger.startActivity(id, lvl, type, s, fields, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct JSONLogger : Logger
|
struct JSONLogger : Logger {
|
||||||
{
|
|
||||||
Logger & prevLogger;
|
Logger & prevLogger;
|
||||||
|
|
||||||
JSONLogger(Logger & prevLogger) : prevLogger(prevLogger) { }
|
JSONLogger(Logger & prevLogger) : prevLogger(prevLogger) { }
|
||||||
|
@ -160,23 +159,21 @@ struct JSONLogger : Logger
|
||||||
// TODO: make a json obj that goes into json["msg"]?
|
// TODO: make a json obj that goes into json["msg"]?
|
||||||
json["name"] = ei.name;
|
json["name"] = ei.name;
|
||||||
json["description"] = ei.description;
|
json["description"] = ei.description;
|
||||||
if (ei.hint.has_value())
|
if (ei.hint.has_value()) {
|
||||||
{
|
json["hint"] = ei.hint->str();
|
||||||
json["hint"] = ei.hint->str();
|
|
||||||
}
|
}
|
||||||
if (ei.nixCode.has_value())
|
if (ei.nixCode.has_value()) {
|
||||||
{
|
if (ei.nixCode->errPos.line != 0)
|
||||||
if (ei.nixCode->errPos.line != 0)
|
json["line"] = ei.nixCode->errPos.line;
|
||||||
json["line"] = ei.nixCode->errPos.line;
|
if (ei.nixCode->errPos.column != 0)
|
||||||
if (ei.nixCode->errPos.column != 0)
|
json["column"] = ei.nixCode->errPos.column;
|
||||||
json["column"] = ei.nixCode->errPos.column;
|
if (ei.nixCode->errPos.file != "")
|
||||||
if (ei.nixCode->errPos.file != "")
|
json["file"] = ei.nixCode->errPos.file;
|
||||||
json["file"] = ei.nixCode->errPos.file;
|
if (ei.nixCode->prevLineOfCode.has_value())
|
||||||
if (ei.nixCode->prevLineOfCode.has_value())
|
json["prevLineOfCode"] = *ei.nixCode->prevLineOfCode;
|
||||||
json["prevLineOfCode"] = *ei.nixCode->prevLineOfCode;
|
json["errLineOfCode"] = ei.nixCode->errLineOfCode;
|
||||||
json["errLineOfCode"] = ei.nixCode->errLineOfCode;
|
if (ei.nixCode->nextLineOfCode.has_value())
|
||||||
if (ei.nixCode->nextLineOfCode.has_value())
|
json["nextLineOfCode"] = *ei.nixCode->nextLineOfCode;
|
||||||
json["nextLineOfCode"] = *ei.nixCode->nextLineOfCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
write(json);
|
write(json);
|
||||||
|
@ -278,7 +275,8 @@ bool handleJSONLogMessage(const std::string & msg,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Activity::~Activity() {
|
Activity::~Activity()
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
logger.stopActivity(id);
|
logger.stopActivity(id);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
Loading…
Reference in a new issue