summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2020-05-21 22:36:34 +0200
committerGitHub <noreply@github.com>2020-05-21 22:36:34 +0200
commitddee8a362a6590d8e590e6804e31b79bdb9ab7e6 (patch)
tree70b4ecdd077594a17b1786cda70a285ef788263f /compiler
parent063229a301837484699fb2b8cdd02c16f9c37781 (diff)
downloadNim-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.nim2
-rw-r--r--compiler/msgs.nim40
-rw-r--r--compiler/options.nim1
-rw-r--r--compiler/sigmatch.nim2
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 = {}
#n13'>13 14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161