diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-05-21 22:36:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-21 22:36:34 +0200 |
commit | ddee8a362a6590d8e590e6804e31b79bdb9ab7e6 (patch) | |
tree | 70b4ecdd077594a17b1786cda70a285ef788263f /compiler | |
parent | 063229a301837484699fb2b8cdd02c16f9c37781 (diff) | |
download | Nim-ddee8a362a6590d8e590e6804e31b79bdb9ab7e6.tar.gz |
change the [Processing] messages into dots (#14418)
* change the [Processing] messages into dots * better implementation * maybe I should work on something else...
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/lineinfos.nim | 2 | ||||
-rw-r--r-- | compiler/msgs.nim | 40 | ||||
-rw-r--r-- | compiler/options.nim | 1 | ||||
-rw-r--r-- | compiler/sigmatch.nim | 2 |
4 files changed, 37 insertions, 8 deletions
diff --git a/compiler/lineinfos.nim b/compiler/lineinfos.nim index 2fd5a5a60..331268d6a 100644 --- a/compiler/lineinfos.nim +++ b/compiler/lineinfos.nim @@ -112,7 +112,7 @@ const warnUser: "$1", hintSuccess: "operation successful: $#", # 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", hintLineTooLong: "line too long", hintXDeclaredButNotUsed: "'$1' is declared but not used", diff --git a/compiler/msgs.nim b/compiler/msgs.nim index a43977606..7523d2d8b 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -277,6 +277,11 @@ type msgSkipHook ## skip message hook even if it is present MsgFlags* = set[MsgFlag] +template flushDot(stdorr) = + if conf.lastMsgWasDot: + write(stdorr, "\n") + conf.lastMsgWasDot = false + proc msgWriteln*(conf: ConfigRef; s: string, flags: MsgFlags = {}) = ## Writes given message string to stderr by default. ## 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 ## support. #if conf.cmd == cmdIdeTools and optCDebug notin gGlobalOptions: return - if not isNil(conf.writelnHook) and msgSkipHook notin flags: conf.writelnHook(s) elif optStdout in conf.globalOptions or msgStdout in flags: if eStdOut in conf.m.errorOutputs: + flushDot(stdout) writeLine(stdout, s) flushFile(stdout) else: if eStdErr in conf.m.errorOutputs: + flushDot(stderr) writeLine(stderr, s) # On Windows stderr is fully-buffered when piped, regardless of C std. when defined(windows): @@ -330,15 +336,27 @@ macro callStyledWriteLineStderr(args: varargs[typed]): untyped = template callWritelnHook(args: varargs[string, `$`]) = 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]) = if not isNil(conf.writelnHook): callIgnoringStyle(callWritelnHook, nil, args) elif optStdout in conf.globalOptions: if eStdOut in conf.m.errorOutputs: + flushDot(stdout) callIgnoringStyle(writeLine, stdout, args) flushFile(stdout) else: if eStdErr in conf.m.errorOutputs: + flushDot(stderr) if optUseColors in conf.globalOptions: callStyledWriteLineStderr(args) else: @@ -450,11 +468,18 @@ proc rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) = s & (if kind.len > 0: KindFormat % kind else: ""), sev) if not ignoreMsgBecauseOfIdeTools(conf, msg): - if kind.len > 0: - styledMsgWriteln(color, title, resetStyle, s, - KindColor, `%`(KindFormat, kind)) + if msg == hintProcessing: + msgWrite(conf, ".") + conf.lastMsgWasDot = true 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) 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): conf.writeSurroundingSrc(info) 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) diff --git a/compiler/options.nim b/compiler/options.nim index 194d635b1..1418fff63 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -279,6 +279,7 @@ type projectPath*: AbsoluteDir # holds a path like /home/alice/projects/nim/compiler/ projectFull*: AbsoluteFile # projectPath/projectName 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 command*: string # the main command (e.g. cc, check, scan, etc) commandArgs*: seq[string] # any arguments after the main command diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 077b4b269..401d160fa 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -742,7 +742,7 @@ proc matchUserTypeClass*(m: var TCandidate; ff, a: PType): PType = addDecl(c, param) var - oldWriteHook: type(m.c.config.writelnHook) + oldWriteHook: typeof(m.c.config.writelnHook) diagnostics: seq[string] errorPrefix: string flags: TExprFlags = {} |