mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
correctly honor cmdline --hint:conf:on/off ; correctly show Conf hints in order
This commit is contained in:
committed by
Andreas Rumpf
parent
96bffadf60
commit
ce36fdc897
@@ -27,7 +27,9 @@ proc initDefinesProg*(self: NimProg, conf: ConfigRef, name: string) =
|
||||
defineSymbol conf.symbols, name
|
||||
|
||||
proc processCmdLineAndProjectPath*(self: NimProg, conf: ConfigRef) =
|
||||
conf.isCmdLine = true
|
||||
self.processCmdLine(passCmd1, "", conf)
|
||||
conf.isCmdLine = false
|
||||
if self.supportsStdinFile and conf.projectName == "-":
|
||||
handleStdinInput(conf)
|
||||
elif conf.projectName != "":
|
||||
|
||||
@@ -204,11 +204,17 @@ proc processSpecificNote*(arg: string, state: TSpecialWord, pass: TCmdLinePass,
|
||||
incl(conf.notes, n)
|
||||
incl(conf.mainPackageNotes, n)
|
||||
incl(conf.enableNotes, n)
|
||||
if conf.isCmdLine:
|
||||
incl(conf.cmdLineNotes, n)
|
||||
excl(conf.cmdLineDisabledNotes, n)
|
||||
of "off":
|
||||
excl(conf.notes, n)
|
||||
excl(conf.mainPackageNotes, n)
|
||||
incl(conf.disableNotes, n)
|
||||
excl(conf.foreignPackageNotes, n)
|
||||
if conf.isCmdLine:
|
||||
incl(conf.cmdLineDisabledNotes, n)
|
||||
excl(conf.cmdLineNotes, n)
|
||||
else: localError(conf, info, errOnOrOffExpectedButXFound % arg)
|
||||
|
||||
proc processCompile(conf: ConfigRef; filename: string) =
|
||||
|
||||
@@ -418,7 +418,10 @@ proc rawMessage*(conf: ConfigRef; msg: TMsgKind, args: openArray[string]) =
|
||||
inc(conf.warnCounter)
|
||||
of hintMin..hintMax:
|
||||
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
|
||||
color = HintColor
|
||||
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) =
|
||||
let p = path # eval once
|
||||
if fileExists(p):
|
||||
configFiles.add(p)
|
||||
runNimScript(cache, p, freshDefines = false, conf)
|
||||
|
||||
if optSkipSystemConfigFile notin conf.globalOptions:
|
||||
|
||||
@@ -231,6 +231,8 @@ type
|
||||
foreignPackageNotes*: TNoteKinds
|
||||
notes*: TNoteKinds
|
||||
mainPackageNotes*: TNoteKinds
|
||||
cmdLineNotes*: TNoteKinds
|
||||
cmdLineDisabledNotes*: TNoteKinds
|
||||
mainPackageId*: int
|
||||
errorCounter*: int
|
||||
hintCounter*: int
|
||||
@@ -286,6 +288,7 @@ type
|
||||
structuredErrorHook*: proc (config: ConfigRef; info: TLineInfo; msg: string;
|
||||
severity: Severity) {.closure, gcsafe.}
|
||||
cppCustomNamespace*: string
|
||||
isCmdLine*: bool # whether we are currently processing cmdline args, not cfg files
|
||||
|
||||
proc hasHint*(conf: ConfigRef, note: TNoteKind): bool =
|
||||
optHints in conf.options and note in conf.notes
|
||||
@@ -391,6 +394,7 @@ proc newConfigRef*(): ConfigRef =
|
||||
arguments: "",
|
||||
suggestMaxResults: 10_000,
|
||||
maxLoopIterationsVM: 10_000_000,
|
||||
isCmdLine: false,
|
||||
)
|
||||
setTargetFromSystem(result.target)
|
||||
# enable colors by default on terminals
|
||||
|
||||
@@ -199,7 +199,6 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string;
|
||||
|
||||
proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
|
||||
freshDefines=true; conf: ConfigRef) =
|
||||
rawMessage(conf, hintConf, scriptName.string)
|
||||
let oldSymbolFiles = conf.symbolFiles
|
||||
conf.symbolFiles = disabledSf
|
||||
|
||||
@@ -224,7 +223,7 @@ proc runNimScript*(cache: IdentCache; scriptName: AbsoluteFile;
|
||||
incl(m.flags, sfMainModule)
|
||||
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))
|
||||
|
||||
# watch out, "newruntime" can be set within NimScript itself and then we need
|
||||
|
||||
Reference in New Issue
Block a user