parent
d31cbfd167
commit
06232b7f2e
6 changed files with 13 additions and 12 deletions
|
|
@ -919,6 +919,8 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||||
excl(conf.notes, hintProcessing)
|
excl(conf.notes, hintProcessing)
|
||||||
excl(conf.mainPackageNotes, hintProcessing)
|
excl(conf.mainPackageNotes, hintProcessing)
|
||||||
else: localError(conf, info, "expected: dots|filenames|off, got: $1" % arg)
|
else: localError(conf, info, "expected: dots|filenames|off, got: $1" % arg)
|
||||||
|
of "unitsep":
|
||||||
|
conf.unitSep = if switchOn(arg): "\31" else: ""
|
||||||
of "listfullpaths":
|
of "listfullpaths":
|
||||||
# xxx in future work, use `warningDeprecated`
|
# xxx in future work, use `warningDeprecated`
|
||||||
conf.filenameOption = if switchOn(arg): foAbs else: foCanonical
|
conf.filenameOption = if switchOn(arg): foAbs else: foCanonical
|
||||||
|
|
|
||||||
|
|
@ -289,10 +289,6 @@ proc `??`* (conf: ConfigRef; info: TLineInfo, filename: string): bool =
|
||||||
# only for debugging purposes
|
# only for debugging purposes
|
||||||
result = filename in toFilename(conf, info)
|
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
|
type
|
||||||
MsgFlag* = enum ## flags altering msgWriteln behavior
|
MsgFlag* = enum ## flags altering msgWriteln behavior
|
||||||
msgStdout, ## force writing to stdout, even stderr is default
|
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
|
## 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
|
||||||
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:
|
if not isNil(conf.writelnHook) and msgSkipHook notin flags:
|
||||||
conf.writelnHook(s & sep)
|
conf.writelnHook(s & sep)
|
||||||
elif optStdout in conf.globalOptions or msgStdout in flags:
|
elif optStdout in conf.globalOptions or msgStdout in flags:
|
||||||
|
|
@ -409,7 +405,7 @@ proc quit(conf: ConfigRef; msg: TMsgKind) {.gcsafe.} =
|
||||||
styledMsgWriteln(fgRed, """
|
styledMsgWriteln(fgRed, """
|
||||||
No stack traceback available
|
No stack traceback available
|
||||||
To create a stacktrace, rerun compilation with './koch temp $1 <file>', see $2 for details""" %
|
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
|
quit 1
|
||||||
|
|
||||||
proc handleError(conf: ConfigRef; msg: TMsgKind, eh: TErrorHandling, s: string) =
|
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, ".")
|
msgWrite(conf, ".")
|
||||||
else:
|
else:
|
||||||
styledMsgWriteln(styleBright, loc, resetStyle, color, title, resetStyle, s, KindColor, kindmsg,
|
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:
|
if hintMsgOrigin in conf.mainPackageNotes:
|
||||||
# xxx needs a bit of refactoring to honor `conf.filenameOption`
|
# xxx needs a bit of refactoring to honor `conf.filenameOption`
|
||||||
styledMsgWriteln(styleBright, toFileLineCol(info2), resetStyle,
|
styledMsgWriteln(styleBright, toFileLineCol(info2), resetStyle,
|
||||||
" compiler msg initiated here", KindColor,
|
" compiler msg initiated here", KindColor,
|
||||||
KindFormat % $hintMsgOrigin,
|
KindFormat % $hintMsgOrigin,
|
||||||
resetStyle, UnitSep)
|
resetStyle, conf.unitSep)
|
||||||
handleError(conf, msg, eh, s)
|
handleError(conf, msg, eh, s)
|
||||||
|
|
||||||
template rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) =
|
template rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) =
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,7 @@ type
|
||||||
arcToExpand*: StringTableRef
|
arcToExpand*: StringTableRef
|
||||||
m*: MsgConfig
|
m*: MsgConfig
|
||||||
filenameOption*: FilenameOption # how to render paths in compiler messages
|
filenameOption*: FilenameOption # how to render paths in compiler messages
|
||||||
|
unitSep*: string
|
||||||
evalTemplateCounter*: int
|
evalTemplateCounter*: int
|
||||||
evalMacroCounter*: int
|
evalMacroCounter*: int
|
||||||
exitcode*: int8
|
exitcode*: int8
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ Advanced options:
|
||||||
defaults to `abs` (absolute)
|
defaults to `abs` (absolute)
|
||||||
--processing:dots|filenames|off
|
--processing:dots|filenames|off
|
||||||
show files as they're being processed by nim compiler
|
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
|
--declaredLocs:on|off show declaration locations in messages
|
||||||
--spellSuggest|:num show at most `num >= 0` spelling suggestions on typos.
|
--spellSuggest|:num show at most `num >= 0` spelling suggestions on typos.
|
||||||
if `num` is not specified (or `auto`), return
|
if `num` is not specified (or `auto`), return
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,7 @@ tests/newconfig/bar/mfoo.nims""".splitLines
|
||||||
var expected = ""
|
var expected = ""
|
||||||
for a in files:
|
for a in files:
|
||||||
let b = dir / a
|
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
|
doAssert outp.endsWith expected, outp & "\n" & expected
|
||||||
|
|
||||||
block: # mfoo2.customext
|
block: # mfoo2.customext
|
||||||
|
|
@ -257,7 +257,7 @@ tests/newconfig/bar/mfoo.nims""".splitLines
|
||||||
let cmd = fmt"{nim} e --hint:conf {filename}"
|
let cmd = fmt"{nim} e --hint:conf {filename}"
|
||||||
let (outp, exitCode) = execCmdEx(cmd, options = {poStdErrToStdOut})
|
let (outp, exitCode) = execCmdEx(cmd, options = {poStdErrToStdOut})
|
||||||
doAssert exitCode == 0
|
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
|
doAssert outp.endsWith "123" & "\n" & expected
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''
|
output: '''
|
||||||
Error: cannot open 'a.nim'\31
|
Error: cannot open 'a.nim'
|
||||||
Error: cannot open 'b.nim'\31
|
Error: cannot open 'b.nim'
|
||||||
'''
|
'''
|
||||||
targets: "c"
|
targets: "c"
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue