mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-07 21:43:33 +00:00
@@ -919,6 +919,8 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||
excl(conf.notes, hintProcessing)
|
||||
excl(conf.mainPackageNotes, hintProcessing)
|
||||
else: localError(conf, info, "expected: dots|filenames|off, got: $1" % arg)
|
||||
of "unitsep":
|
||||
conf.unitSep = if switchOn(arg): "\31" else: ""
|
||||
of "listfullpaths":
|
||||
# xxx in future work, use `warningDeprecated`
|
||||
conf.filenameOption = if switchOn(arg): foAbs else: foCanonical
|
||||
|
||||
@@ -289,10 +289,6 @@ proc `??`* (conf: ConfigRef; info: TLineInfo, filename: string): bool =
|
||||
# only for debugging purposes
|
||||
result = filename in toFilename(conf, info)
|
||||
|
||||
const
|
||||
UnitSep = "\31"
|
||||
# this needs care to avoid issues similar to https://github.com/nim-lang/Nim/issues/17853
|
||||
|
||||
type
|
||||
MsgFlag* = enum ## flags altering msgWriteln behavior
|
||||
msgStdout, ## force writing to stdout, even stderr is default
|
||||
@@ -309,7 +305,7 @@ 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
|
||||
let sep = if msgNoUnitSep notin flags: UnitSep else: ""
|
||||
let sep = if msgNoUnitSep notin flags: conf.unitSep else: ""
|
||||
if not isNil(conf.writelnHook) and msgSkipHook notin flags:
|
||||
conf.writelnHook(s & sep)
|
||||
elif optStdout in conf.globalOptions or msgStdout in flags:
|
||||
@@ -409,7 +405,7 @@ proc quit(conf: ConfigRef; msg: TMsgKind) {.gcsafe.} =
|
||||
styledMsgWriteln(fgRed, """
|
||||
No stack traceback available
|
||||
To create a stacktrace, rerun compilation with './koch temp $1 <file>', see $2 for details""" %
|
||||
[conf.command, "intern.html#debugging-the-compiler".createDocLink], UnitSep)
|
||||
[conf.command, "intern.html#debugging-the-compiler".createDocLink], conf.unitSep)
|
||||
quit 1
|
||||
|
||||
proc handleError(conf: ConfigRef; msg: TMsgKind, eh: TErrorHandling, s: string) =
|
||||
@@ -550,13 +546,13 @@ proc liMessage*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
|
||||
msgWrite(conf, ".")
|
||||
else:
|
||||
styledMsgWriteln(styleBright, loc, resetStyle, color, title, resetStyle, s, KindColor, kindmsg,
|
||||
resetStyle, conf.getSurroundingSrc(info), UnitSep)
|
||||
resetStyle, conf.getSurroundingSrc(info), conf.unitSep)
|
||||
if hintMsgOrigin in conf.mainPackageNotes:
|
||||
# xxx needs a bit of refactoring to honor `conf.filenameOption`
|
||||
styledMsgWriteln(styleBright, toFileLineCol(info2), resetStyle,
|
||||
" compiler msg initiated here", KindColor,
|
||||
KindFormat % $hintMsgOrigin,
|
||||
resetStyle, UnitSep)
|
||||
resetStyle, conf.unitSep)
|
||||
handleError(conf, msg, eh, s)
|
||||
|
||||
template rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) =
|
||||
|
||||
@@ -283,6 +283,7 @@ type
|
||||
arcToExpand*: StringTableRef
|
||||
m*: MsgConfig
|
||||
filenameOption*: FilenameOption # how to render paths in compiler messages
|
||||
unitSep*: string
|
||||
evalTemplateCounter*: int
|
||||
evalMacroCounter*: int
|
||||
exitcode*: int8
|
||||
|
||||
@@ -41,6 +41,8 @@ Advanced options:
|
||||
defaults to `abs` (absolute)
|
||||
--processing:dots|filenames|off
|
||||
show files as they're being processed by nim compiler
|
||||
--unitsep:on|off use the ASCII unit separator (31) between error
|
||||
messages, useful for IDE-like tooling
|
||||
--declaredLocs:on|off show declaration locations in messages
|
||||
--spellSuggest|:num show at most `num >= 0` spelling suggestions on typos.
|
||||
if `num` is not specified (or `auto`), return
|
||||
|
||||
@@ -249,7 +249,7 @@ tests/newconfig/bar/mfoo.nims""".splitLines
|
||||
var expected = ""
|
||||
for a in files:
|
||||
let b = dir / a
|
||||
expected.add &"Hint: used config file '{b}' [Conf]\31\n"
|
||||
expected.add &"Hint: used config file '{b}' [Conf]\n"
|
||||
doAssert outp.endsWith expected, outp & "\n" & expected
|
||||
|
||||
block: # mfoo2.customext
|
||||
@@ -257,7 +257,7 @@ tests/newconfig/bar/mfoo.nims""".splitLines
|
||||
let cmd = fmt"{nim} e --hint:conf {filename}"
|
||||
let (outp, exitCode) = execCmdEx(cmd, options = {poStdErrToStdOut})
|
||||
doAssert exitCode == 0
|
||||
var expected = &"Hint: used config file '{filename}' [Conf]\31\n"
|
||||
var expected = &"Hint: used config file '{filename}' [Conf]\n"
|
||||
doAssert outp.endsWith "123" & "\n" & expected
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
discard """
|
||||
output: '''
|
||||
Error: cannot open 'a.nim'\31
|
||||
Error: cannot open 'b.nim'\31
|
||||
Error: cannot open 'a.nim'
|
||||
Error: cannot open 'b.nim'
|
||||
'''
|
||||
targets: "c"
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user