change the [Processing] messages into dots (#14418)
* change the [Processing] messages into dots * better implementation * maybe I should work on something else...
This commit is contained in:
parent
063229a301
commit
ddee8a362a
5 changed files with 38 additions and 10 deletions
|
|
@ -112,7 +112,7 @@ const
|
||||||
warnUser: "$1",
|
warnUser: "$1",
|
||||||
hintSuccess: "operation successful: $#",
|
hintSuccess: "operation successful: $#",
|
||||||
# keep in sync with `testament.isSuccess`
|
# keep in sync with `testament.isSuccess`
|
||||||
hintSuccessX: "$loc LOC; $sec sec; $mem; $build build; proj: $project; out: $output",
|
hintSuccessX: "${loc} lines; ${sec}s; $mem; $build build; proj: $project; out: $output",
|
||||||
hintCC: "CC: $1",
|
hintCC: "CC: $1",
|
||||||
hintLineTooLong: "line too long",
|
hintLineTooLong: "line too long",
|
||||||
hintXDeclaredButNotUsed: "'$1' is declared but not used",
|
hintXDeclaredButNotUsed: "'$1' is declared but not used",
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,11 @@ type
|
||||||
msgSkipHook ## skip message hook even if it is present
|
msgSkipHook ## skip message hook even if it is present
|
||||||
MsgFlags* = set[MsgFlag]
|
MsgFlags* = set[MsgFlag]
|
||||||
|
|
||||||
|
template flushDot(stdorr) =
|
||||||
|
if conf.lastMsgWasDot:
|
||||||
|
write(stdorr, "\n")
|
||||||
|
conf.lastMsgWasDot = false
|
||||||
|
|
||||||
proc msgWriteln*(conf: ConfigRef; s: string, flags: MsgFlags = {}) =
|
proc msgWriteln*(conf: ConfigRef; s: string, flags: MsgFlags = {}) =
|
||||||
## Writes given message string to stderr by default.
|
## Writes given message string to stderr by default.
|
||||||
## If ``--stdout`` option is given, writes to stdout instead. If message hook
|
## If ``--stdout`` option is given, writes to stdout instead. If message hook
|
||||||
|
|
@ -286,15 +291,16 @@ proc msgWriteln*(conf: ConfigRef; s: string, flags: MsgFlags = {}) =
|
||||||
## This is used for 'nim dump' etc. where we don't have nimsuggest
|
## This is used for 'nim dump' etc. where we don't have nimsuggest
|
||||||
## support.
|
## support.
|
||||||
#if conf.cmd == cmdIdeTools and optCDebug notin gGlobalOptions: return
|
#if conf.cmd == cmdIdeTools and optCDebug notin gGlobalOptions: return
|
||||||
|
|
||||||
if not isNil(conf.writelnHook) and msgSkipHook notin flags:
|
if not isNil(conf.writelnHook) and msgSkipHook notin flags:
|
||||||
conf.writelnHook(s)
|
conf.writelnHook(s)
|
||||||
elif optStdout in conf.globalOptions or msgStdout in flags:
|
elif optStdout in conf.globalOptions or msgStdout in flags:
|
||||||
if eStdOut in conf.m.errorOutputs:
|
if eStdOut in conf.m.errorOutputs:
|
||||||
|
flushDot(stdout)
|
||||||
writeLine(stdout, s)
|
writeLine(stdout, s)
|
||||||
flushFile(stdout)
|
flushFile(stdout)
|
||||||
else:
|
else:
|
||||||
if eStdErr in conf.m.errorOutputs:
|
if eStdErr in conf.m.errorOutputs:
|
||||||
|
flushDot(stderr)
|
||||||
writeLine(stderr, s)
|
writeLine(stderr, s)
|
||||||
# On Windows stderr is fully-buffered when piped, regardless of C std.
|
# On Windows stderr is fully-buffered when piped, regardless of C std.
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
|
|
@ -330,15 +336,27 @@ macro callStyledWriteLineStderr(args: varargs[typed]): untyped =
|
||||||
template callWritelnHook(args: varargs[string, `$`]) =
|
template callWritelnHook(args: varargs[string, `$`]) =
|
||||||
conf.writelnHook concat(args)
|
conf.writelnHook concat(args)
|
||||||
|
|
||||||
|
proc msgWrite(conf: ConfigRef; s: string) =
|
||||||
|
if conf.m.errorOutputs != {}:
|
||||||
|
let stdOrr =
|
||||||
|
if optStdout in conf.globalOptions:
|
||||||
|
stdout
|
||||||
|
else:
|
||||||
|
stderr
|
||||||
|
write(stdOrr, s)
|
||||||
|
flushFile(stdOrr)
|
||||||
|
|
||||||
template styledMsgWriteln*(args: varargs[typed]) =
|
template styledMsgWriteln*(args: varargs[typed]) =
|
||||||
if not isNil(conf.writelnHook):
|
if not isNil(conf.writelnHook):
|
||||||
callIgnoringStyle(callWritelnHook, nil, args)
|
callIgnoringStyle(callWritelnHook, nil, args)
|
||||||
elif optStdout in conf.globalOptions:
|
elif optStdout in conf.globalOptions:
|
||||||
if eStdOut in conf.m.errorOutputs:
|
if eStdOut in conf.m.errorOutputs:
|
||||||
|
flushDot(stdout)
|
||||||
callIgnoringStyle(writeLine, stdout, args)
|
callIgnoringStyle(writeLine, stdout, args)
|
||||||
flushFile(stdout)
|
flushFile(stdout)
|
||||||
else:
|
else:
|
||||||
if eStdErr in conf.m.errorOutputs:
|
if eStdErr in conf.m.errorOutputs:
|
||||||
|
flushDot(stderr)
|
||||||
if optUseColors in conf.globalOptions:
|
if optUseColors in conf.globalOptions:
|
||||||
callStyledWriteLineStderr(args)
|
callStyledWriteLineStderr(args)
|
||||||
else:
|
else:
|
||||||
|
|
@ -450,11 +468,18 @@ proc rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) =
|
||||||
s & (if kind.len > 0: KindFormat % kind else: ""), sev)
|
s & (if kind.len > 0: KindFormat % kind else: ""), sev)
|
||||||
|
|
||||||
if not ignoreMsgBecauseOfIdeTools(conf, msg):
|
if not ignoreMsgBecauseOfIdeTools(conf, msg):
|
||||||
if kind.len > 0:
|
if msg == hintProcessing:
|
||||||
styledMsgWriteln(color, title, resetStyle, s,
|
msgWrite(conf, ".")
|
||||||
KindColor, `%`(KindFormat, kind))
|
conf.lastMsgWasDot = true
|
||||||
else:
|
else:
|
||||||
styledMsgWriteln(color, title, resetStyle, s)
|
if conf.lastMsgWasDot:
|
||||||
|
msgWrite(conf, "\n")
|
||||||
|
conf.lastMsgWasDot = false
|
||||||
|
if kind.len > 0:
|
||||||
|
styledMsgWriteln(color, title, resetStyle, s,
|
||||||
|
KindColor, `%`(KindFormat, kind))
|
||||||
|
else:
|
||||||
|
styledMsgWriteln(color, title, resetStyle, s)
|
||||||
handleError(conf, msg, doAbort, s)
|
handleError(conf, msg, doAbort, s)
|
||||||
|
|
||||||
proc rawMessage*(conf: ConfigRef; msg: TMsgKind, arg: string) =
|
proc rawMessage*(conf: ConfigRef; msg: TMsgKind, arg: string) =
|
||||||
|
|
@ -539,7 +564,10 @@ proc liMessage(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
|
||||||
if conf.hasHint(hintSource):
|
if conf.hasHint(hintSource):
|
||||||
conf.writeSurroundingSrc(info)
|
conf.writeSurroundingSrc(info)
|
||||||
if conf.hasHint(hintMsgOrigin):
|
if conf.hasHint(hintMsgOrigin):
|
||||||
styledMsgWriteln(styleBright, toFileLineCol(info2), resetStyle, " compiler msg initiated here", KindColor, KindFormat % HintsToStr[ord(hintMsgOrigin) - ord(hintMin)], resetStyle)
|
styledMsgWriteln(styleBright, toFileLineCol(info2), resetStyle,
|
||||||
|
" compiler msg initiated here", KindColor,
|
||||||
|
KindFormat % HintsToStr[ord(hintMsgOrigin) - ord(hintMin)],
|
||||||
|
resetStyle)
|
||||||
|
|
||||||
handleError(conf, msg, eh, s)
|
handleError(conf, msg, eh, s)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -279,6 +279,7 @@ type
|
||||||
projectPath*: AbsoluteDir # holds a path like /home/alice/projects/nim/compiler/
|
projectPath*: AbsoluteDir # holds a path like /home/alice/projects/nim/compiler/
|
||||||
projectFull*: AbsoluteFile # projectPath/projectName
|
projectFull*: AbsoluteFile # projectPath/projectName
|
||||||
projectIsStdin*: bool # whether we're compiling from stdin
|
projectIsStdin*: bool # whether we're compiling from stdin
|
||||||
|
lastMsgWasDot*: bool # the last compiler message was a single '.'
|
||||||
projectMainIdx*: FileIndex # the canonical path id of the main module
|
projectMainIdx*: FileIndex # the canonical path id of the main module
|
||||||
command*: string # the main command (e.g. cc, check, scan, etc)
|
command*: string # the main command (e.g. cc, check, scan, etc)
|
||||||
commandArgs*: seq[string] # any arguments after the main command
|
commandArgs*: seq[string] # any arguments after the main command
|
||||||
|
|
|
||||||
|
|
@ -742,7 +742,7 @@ proc matchUserTypeClass*(m: var TCandidate; ff, a: PType): PType =
|
||||||
addDecl(c, param)
|
addDecl(c, param)
|
||||||
|
|
||||||
var
|
var
|
||||||
oldWriteHook: type(m.c.config.writelnHook)
|
oldWriteHook: typeof(m.c.config.writelnHook)
|
||||||
diagnostics: seq[string]
|
diagnostics: seq[string]
|
||||||
errorPrefix: string
|
errorPrefix: string
|
||||||
flags: TExprFlags = {}
|
flags: TExprFlags = {}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
nimout: '''
|
nimout: '''
|
||||||
compile start
|
compile start
|
||||||
Hint: warn_module [Processing]
|
..
|
||||||
Hint: hashes [Processing]
|
|
||||||
warn_module.nim(6, 6) Hint: 'test' is declared but not used [XDeclaredButNotUsed]
|
warn_module.nim(6, 6) Hint: 'test' is declared but not used [XDeclaredButNotUsed]
|
||||||
compile end
|
compile end
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue