correctly honor cmdline --hint:conf:on/off ; correctly show Conf hints in order
This commit is contained in:
parent
96bffadf60
commit
ce36fdc897
6 changed files with 18 additions and 3 deletions
|
|
@ -27,7 +27,9 @@ proc initDefinesProg*(self: NimProg, conf: ConfigRef, name: string) =
|
||||||
defineSymbol conf.symbols, name
|
defineSymbol conf.symbols, name
|
||||||
|
|
||||||
proc processCmdLineAndProjectPath*(self: NimProg, conf: ConfigRef) =
|
proc processCmdLineAndProjectPath*(self: NimProg, conf: ConfigRef) =
|
||||||
|
conf.isCmdLine = true
|
||||||
self.processCmdLine(passCmd1, "", conf)
|
self.processCmdLine(passCmd1, "", conf)
|
||||||
|
conf.isCmdLine = false
|
||||||
if self.supportsStdinFile and conf.projectName == "-":
|
if self.supportsStdinFile and conf.projectName == "-":
|
||||||
handleStdinInput(conf)
|
handleStdinInput(conf)
|
||||||
elif conf.projectName != "":
|
elif conf.projectName != "":
|
||||||
|
|
|
||||||
|
|
@ -204,11 +204,17 @@ proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass,
|
||||||
incl(conf.notes, n)
|
incl(conf.notes, n)
|
||||||
incl(conf.mainPackageNotes, n)
|
incl(conf.mainPackageNotes, n)
|
||||||
incl(conf.enableNotes, n)
|
incl(conf.enableNotes, n)
|
||||||
|
if conf.isCmdLine:
|
||||||
|
incl(conf.cmdLineNotes, n)
|
||||||
|
excl(conf.cmdLineDisabledNotes, n)
|
||||||
of "off":
|
of "off":
|
||||||
excl(conf.notes, n)
|
excl(conf.notes, n)
|
||||||
excl(conf.mainPackageNotes, n)
|
excl(conf.mainPackageNotes, n)
|
||||||
incl(conf.disableNotes, n)
|
incl(conf.disableNotes, n)
|
||||||
excl(conf.foreignPackageNotes, n)
|
excl(conf.foreignPackageNotes, n)
|
||||||
|
if conf.isCmdLine:
|
||||||
|
incl(conf.cmdLineDisabledNotes, n)
|
||||||
|
excl(conf.cmdLineNotes, n)
|
||||||
else: localError(conf, info, errOnOrOffExpectedButXFound % arg)
|
else: localError(conf, info, errOnOrOffExpectedButXFound % arg)
|
||||||
|
|
||||||
proc processCompile(conf: ConfigRef; filename: string) =
|
proc processCompile(conf: ConfigRef; filename: string) =
|
||||||
|
|
|
||||||
|
|
@ -418,7 +418,10 @@ proc rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) =
|
||||||
inc(conf.warnCounter)
|
inc(conf.warnCounter)
|
||||||
of hintMin..hintMax:
|
of hintMin..hintMax:
|
||||||
sev = Severity.Hint
|
sev = Severity.Hint
|
||||||
if not conf.hasHint(msg): return
|
if msg in conf.cmdLineDisabledNotes: return # eg: `--hints:conf:off` passed on cmdline
|
||||||
|
# handle `--hints:off` (regardless of cmdline/cfg file)
|
||||||
|
# handle `--hints:conf:on` on cmdline
|
||||||
|
if not conf.hasHint(msg) and not (optHints in conf.options and msg in conf.cmdLineNotes)): return
|
||||||
title = HintTitle
|
title = HintTitle
|
||||||
color = HintColor
|
color = HintColor
|
||||||
if msg != hintUserRaw: kind = HintsToStr[ord(msg) - ord(hintMin)]
|
if msg != hintUserRaw: kind = HintsToStr[ord(msg) - ord(hintMin)]
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,7 @@ proc loadConfigs*(cfg: RelativeFile; cache: IdentCache; conf: ConfigRef) =
|
||||||
template runNimScriptIfExists(path: AbsoluteFile) =
|
template runNimScriptIfExists(path: AbsoluteFile) =
|
||||||
let p = path # eval once
|
let p = path # eval once
|
||||||
if fileExists(p):
|
if fileExists(p):
|
||||||
|
configFiles.add(p)
|
||||||
runNimScript(cache, p, freshDefines = false, conf)
|
runNimScript(cache, p, freshDefines = false, conf)
|
||||||
|
|
||||||
if optSkipSystemConfigFile notin conf.globalOptions:
|
if optSkipSystemConfigFile notin conf.globalOptions:
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,8 @@ type
|
||||||
foreignPackageNotes*: TNoteKinds
|
foreignPackageNotes*: TNoteKinds
|
||||||
notes*: TNoteKinds
|
notes*: TNoteKinds
|
||||||
mainPackageNotes*: TNoteKinds
|
mainPackageNotes*: TNoteKinds
|
||||||
|
cmdLineNotes*: TNoteKinds
|
||||||
|
cmdLineDisabledNotes*: TNoteKinds
|
||||||
mainPackageId*: int
|
mainPackageId*: int
|
||||||
errorCounter*: int
|
errorCounter*: int
|
||||||
hintCounter*: int
|
hintCounter*: int
|
||||||
|
|
@ -286,6 +288,7 @@ type
|
||||||
structuredErrorHook*: proc (config: ConfigRef; info: TLineInfo; msg: string;
|
structuredErrorHook*: proc (config: ConfigRef; info: TLineInfo; msg: string;
|
||||||
severity: Severity) {.closure, gcsafe.}
|
severity: Severity) {.closure, gcsafe.}
|
||||||
cppCustomNamespace*: string
|
cppCustomNamespace*: string
|
||||||
|
isCmdLine*: bool # whether we are currently processing cmdline args, not cfg files
|
||||||
|
|
||||||
proc hasHint*(conf: ConfigRef, note: TNoteKind): bool =
|
proc hasHint*(conf: ConfigRef, note: TNoteKind): bool =
|
||||||
optHints in conf.options and note in conf.notes
|
optHints in conf.options and note in conf.notes
|
||||||
|
|
@ -391,6 +394,7 @@ proc newConfigRef*(): ConfigRef =
|
||||||
arguments: "",
|
arguments: "",
|
||||||
suggestMaxResults: 10_000,
|
suggestMaxResults: 10_000,
|
||||||
maxLoopIterationsVM: 10_000_000,
|
maxLoopIterationsVM: 10_000_000,
|
||||||
|
isCmdLine: false,
|
||||||
)
|
)
|
||||||
setTargetFromSystem(result.target)
|
setTargetFromSystem(result.target)
|
||||||
# enable colors by default on terminals
|
# enable colors by default on terminals
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,6 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
|
||||||
|
|
||||||
proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
|
proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
|
||||||
freshDefines=true; conf: ConfigRef) =
|
freshDefines=true; conf: ConfigRef) =
|
||||||
rawMessage(conf, hintConf, scriptName.string)
|
|
||||||
let oldSymbolFiles = conf.symbolFiles
|
let oldSymbolFiles = conf.symbolFiles
|
||||||
conf.symbolFiles = disabledSf
|
conf.symbolFiles = disabledSf
|
||||||
|
|
||||||
|
|
@ -224,7 +223,7 @@ proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
|
||||||
incl(m.flags, sfMainModule)
|
incl(m.flags, sfMainModule)
|
||||||
graph.vm = setupVM(m, cache, scriptName.string, graph)
|
graph.vm = setupVM(m, cache, scriptName.string, graph)
|
||||||
|
|
||||||
graph.compileSystemModule() # TODO: see why this unsets hintConf in conf.notes
|
graph.compileSystemModule()
|
||||||
discard graph.processModule(m, llStreamOpen(scriptName, fmRead))
|
discard graph.processModule(m, llStreamOpen(scriptName, fmRead))
|
||||||
|
|
||||||
# watch out, "newruntime" can be set within NimScript itself and then we need
|
# watch out, "newruntime" can be set within NimScript itself and then we need
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue