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,
|
||||
.name = "Info name",
|
||||
.description = "Info description",
|
||||
});
|
||||
});
|
||||
|
||||
logger->logEI(
|
||||
ErrorInfo { .level = lvlTalkative,
|
||||
.name = "Talkative name",
|
||||
.description = "Talkative description",
|
||||
});
|
||||
});
|
||||
|
||||
logger->logEI(
|
||||
ErrorInfo { .level = lvlChatty,
|
||||
.name = "Chatty name",
|
||||
.description = "Chatty description",
|
||||
});
|
||||
});
|
||||
|
||||
logger->logEI(
|
||||
ErrorInfo { .level = lvlDebug,
|
||||
.name = "Debug name",
|
||||
.description = "Debug description",
|
||||
});
|
||||
});
|
||||
|
||||
logger->logEI(
|
||||
ErrorInfo { .level = lvlVomit,
|
||||
.name = "Vomit name",
|
||||
.description = "Vomit description",
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Error in a program; no hint and no nix code.
|
||||
logError(
|
||||
ErrorInfo { .name = "name",
|
||||
.description = "error description",
|
||||
});
|
||||
});
|
||||
|
||||
// Warning with name, description, and hint.
|
||||
// The hintfmt function makes all the substituted text yellow.
|
||||
|
@ -68,7 +68,7 @@ int main()
|
|||
ErrorInfo { .name = "name",
|
||||
.description = "error description",
|
||||
.hint = hintfmt("there was a %1%", "warning"),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Warning with nix file, line number, column, and the lines of
|
||||
|
@ -80,28 +80,28 @@ int main()
|
|||
ErrorInfo { .name = "warning name",
|
||||
.description = "warning description",
|
||||
.hint = hintfmt("this hint has %1% templated %2%!!",
|
||||
"yellow",
|
||||
"values"),
|
||||
"yellow",
|
||||
"values"),
|
||||
.nixCode = NixCode {
|
||||
.errPos = Pos(problem_file, 40, 13),
|
||||
.prevLineOfCode = std::nullopt,
|
||||
.errLineOfCode = "this is the problem line of code",
|
||||
.nextLineOfCode = std::nullopt
|
||||
}});
|
||||
}});
|
||||
|
||||
// Error with previous and next lines of code.
|
||||
logError(
|
||||
ErrorInfo { .name = "error name",
|
||||
.description = "error description",
|
||||
.hint = hintfmt("this hint has %1% templated %2%!!",
|
||||
"yellow",
|
||||
"values"),
|
||||
"yellow",
|
||||
"values"),
|
||||
.nixCode = NixCode {
|
||||
.errPos = Pos(problem_file, 40, 13),
|
||||
.prevLineOfCode = std::optional("previous line of code"),
|
||||
.errLineOfCode = "this is the problem line of code",
|
||||
.nextLineOfCode = std::optional("next line of code"),
|
||||
}});
|
||||
}});
|
||||
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -234,7 +234,8 @@ struct ExprLambda : Expr
|
|||
: pos(pos), arg(arg), matchAttrs(matchAttrs), formals(formals), body(body)
|
||||
{
|
||||
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);
|
||||
string showNamePos() const;
|
||||
COMMON_METHODS
|
||||
|
|
|
@ -45,17 +45,17 @@ void printCodeLines(const string &prefix, const NixCode &nixCode)
|
|||
// previous line of code.
|
||||
if (nixCode.prevLineOfCode.has_value()) {
|
||||
std::cout << fmt("%1% %|2$5d|| %3%",
|
||||
prefix,
|
||||
(nixCode.errPos.line - 1),
|
||||
*nixCode.prevLineOfCode)
|
||||
prefix,
|
||||
(nixCode.errPos.line - 1),
|
||||
*nixCode.prevLineOfCode)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
// line of code containing the error.%2$+5d%
|
||||
std::cout << fmt("%1% %|2$5d|| %3%",
|
||||
prefix,
|
||||
(nixCode.errPos.line),
|
||||
nixCode.errLineOfCode)
|
||||
prefix,
|
||||
(nixCode.errPos.line),
|
||||
nixCode.errLineOfCode)
|
||||
<< std::endl;
|
||||
|
||||
// error arrows for the column range.
|
||||
|
@ -69,17 +69,17 @@ void printCodeLines(const string &prefix, const NixCode &nixCode)
|
|||
std::string arrows("^");
|
||||
|
||||
std::cout << fmt("%1% |%2%" ANSI_RED "%3%" ANSI_NORMAL,
|
||||
prefix,
|
||||
spaces,
|
||||
arrows) << std::endl;
|
||||
prefix,
|
||||
spaces,
|
||||
arrows) << std::endl;
|
||||
}
|
||||
|
||||
// next line of code.
|
||||
if (nixCode.nextLineOfCode.has_value()) {
|
||||
std::cout << fmt("%1% %|2$5d|| %3%",
|
||||
prefix,
|
||||
(nixCode.errPos.line + 1),
|
||||
*nixCode.nextLineOfCode)
|
||||
prefix,
|
||||
(nixCode.errPos.line + 1),
|
||||
*nixCode.nextLineOfCode)
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -149,18 +149,18 @@ std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
|
|||
// divider.
|
||||
if (einfo.name != "")
|
||||
out << fmt("%1%%2%" ANSI_BLUE " --- %3% %4% %5%" ANSI_NORMAL,
|
||||
prefix,
|
||||
levelString,
|
||||
einfo.name,
|
||||
dashes,
|
||||
einfo.programName.value_or(""))
|
||||
prefix,
|
||||
levelString,
|
||||
einfo.name,
|
||||
dashes,
|
||||
einfo.programName.value_or(""))
|
||||
<< std::endl;
|
||||
else
|
||||
out << fmt("%1%%2%" ANSI_BLUE " -----%3% %4%" ANSI_NORMAL,
|
||||
prefix,
|
||||
levelString,
|
||||
dashes,
|
||||
einfo.programName.value_or(""))
|
||||
prefix,
|
||||
levelString,
|
||||
dashes,
|
||||
einfo.programName.value_or(""))
|
||||
<< std::endl;
|
||||
|
||||
// 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,
|
||||
prefix,
|
||||
einfo.nixCode->errPos.file,
|
||||
eline) << std::endl;
|
||||
prefix,
|
||||
einfo.nixCode->errPos.file,
|
||||
eline) << std::endl;
|
||||
out << prefix << std::endl;
|
||||
} else {
|
||||
out << fmt("%1%from command line argument", prefix) << std::endl;
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
|
||||
void logEI(const ErrorInfo & ei) override
|
||||
{
|
||||
std::stringstream oss;
|
||||
std::stringstream oss;
|
||||
oss << ei;
|
||||
|
||||
log(ei.level, oss.str());
|
||||
|
@ -68,7 +68,7 @@ public:
|
|||
|
||||
void startActivity(ActivityId act, Verbosity lvl, ActivityType type,
|
||||
const std::string & s, const Fields & fields, ActivityId parent)
|
||||
override
|
||||
override
|
||||
{
|
||||
if (lvl <= verbosity && !s.empty())
|
||||
log(lvl, s + "...");
|
||||
|
@ -111,8 +111,7 @@ Activity::Activity(Logger & logger, Verbosity lvl, ActivityType type,
|
|||
logger.startActivity(id, lvl, type, s, fields, parent);
|
||||
}
|
||||
|
||||
struct JSONLogger : Logger
|
||||
{
|
||||
struct JSONLogger : Logger {
|
||||
Logger & prevLogger;
|
||||
|
||||
JSONLogger(Logger & prevLogger) : prevLogger(prevLogger) { }
|
||||
|
@ -155,28 +154,26 @@ struct JSONLogger : Logger
|
|||
json["level"] = ei.level;
|
||||
json["msg"] = oss.str();
|
||||
|
||||
// Extra things that COULD go into json. Useful?
|
||||
// Extra things that COULD go into json. Useful?
|
||||
// TODO: decide if useful.
|
||||
// TODO: make a json obj that goes into json["msg"]?
|
||||
json["name"] = ei.name;
|
||||
json["description"] = ei.description;
|
||||
if (ei.hint.has_value())
|
||||
{
|
||||
json["hint"] = ei.hint->str();
|
||||
if (ei.hint.has_value()) {
|
||||
json["hint"] = ei.hint->str();
|
||||
}
|
||||
if (ei.nixCode.has_value())
|
||||
{
|
||||
if (ei.nixCode->errPos.line != 0)
|
||||
json["line"] = ei.nixCode->errPos.line;
|
||||
if (ei.nixCode->errPos.column != 0)
|
||||
json["column"] = ei.nixCode->errPos.column;
|
||||
if (ei.nixCode->errPos.file != "")
|
||||
json["file"] = ei.nixCode->errPos.file;
|
||||
if (ei.nixCode->prevLineOfCode.has_value())
|
||||
json["prevLineOfCode"] = *ei.nixCode->prevLineOfCode;
|
||||
json["errLineOfCode"] = ei.nixCode->errLineOfCode;
|
||||
if (ei.nixCode->nextLineOfCode.has_value())
|
||||
json["nextLineOfCode"] = *ei.nixCode->nextLineOfCode;
|
||||
if (ei.nixCode.has_value()) {
|
||||
if (ei.nixCode->errPos.line != 0)
|
||||
json["line"] = ei.nixCode->errPos.line;
|
||||
if (ei.nixCode->errPos.column != 0)
|
||||
json["column"] = ei.nixCode->errPos.column;
|
||||
if (ei.nixCode->errPos.file != "")
|
||||
json["file"] = ei.nixCode->errPos.file;
|
||||
if (ei.nixCode->prevLineOfCode.has_value())
|
||||
json["prevLineOfCode"] = *ei.nixCode->prevLineOfCode;
|
||||
json["errLineOfCode"] = ei.nixCode->errLineOfCode;
|
||||
if (ei.nixCode->nextLineOfCode.has_value())
|
||||
json["nextLineOfCode"] = *ei.nixCode->nextLineOfCode;
|
||||
}
|
||||
|
||||
write(json);
|
||||
|
@ -278,7 +275,8 @@ bool handleJSONLogMessage(const std::string & msg,
|
|||
return true;
|
||||
}
|
||||
|
||||
Activity::~Activity() {
|
||||
Activity::~Activity()
|
||||
{
|
||||
try {
|
||||
logger.stopActivity(id);
|
||||
} catch (...) {
|
||||
|
|
|
@ -62,12 +62,12 @@ public:
|
|||
|
||||
virtual void logEI(const ErrorInfo &ei) = 0;
|
||||
|
||||
void logEI(Verbosity lvl, ErrorInfo ei)
|
||||
void logEI(Verbosity lvl, ErrorInfo ei)
|
||||
{
|
||||
ei.level = lvl;
|
||||
logEI(ei);
|
||||
}
|
||||
|
||||
|
||||
virtual void warn(const std::string & msg);
|
||||
|
||||
virtual void startActivity(ActivityId act, Verbosity lvl, ActivityType type,
|
||||
|
|
Loading…
Reference in a new issue