'nimfix' improvements; FdSet is TFdSet again

This commit is contained in:
Araq 2014-09-08 08:46:35 +02:00
commit 7333237be6
11 changed files with 46 additions and 54 deletions

View file

@ -22,10 +22,8 @@ Options:
--overwriteFiles:on|off overwrite the original nim files.
DEFAULT is ON!
--checkExtern:on|off style check also extern names
--styleCheck:none|confirm|auto performs style checking for identifiers
and suggests an alternative spelling. If
'auto', it automatically corrects the
spelling. If 'confirm' it asks the user.
--styleCheck:on|off performs style checking for identifiers
and suggests an alternative spelling.
In addition, all command line options of Nim are supported.
"""
@ -65,11 +63,9 @@ proc processCmdLine*(pass: TCmdLinePass, cmd: string) =
else: localError(gCmdLineInfo, errOnOrOffExpected)
of "stylecheck":
case p.val.normalize
of "none": gStyleCheck = StyleCheck.None
of "confirm": gStyleCheck = StyleCheck.Confirm
of "auto": gStyleCheck = StyleCheck.Auto
else: localError(gCmdLineInfo, errGenerated,
"'none', 'confirm' or 'auto' expected")
of "off": gStyleCheck = StyleCheck.None
of "on": gStyleCheck = StyleCheck.Auto
else: localError(gCmdLineInfo, errOnOrOffExpected)
else:
processSwitch(pass, p)
of cmdArgument:

View file

@ -29,11 +29,10 @@ type
PGen = ref TGen
proc overwriteFiles*() =
let overWrite = options.getConfigVar("pretty.overwrite").normalize != "off"
let doStrip = options.getConfigVar("pretty.strip").normalize == "on"
for i in 0 .. high(gSourceFiles):
if not gSourceFiles[i].dirty: continue
let newFile = if overWrite: gSourceFiles[i].fullpath
let newFile = if gOverWrite: gSourceFiles[i].fullpath
else: gSourceFiles[i].fullpath.changeFileExt(".pretty.nim")
try:
var f = open(newFile, fmWrite)
@ -102,6 +101,7 @@ proc checkStyle(info: TLineInfo, s: string, k: TSymKind) =
message(info, hintName, beau)
proc checkDef*(n: PNode; s: PSym) =
if gStyleCheck == StyleCheck.None: return
# operators stay as they are:
if s.kind in {skResult, skTemp} or s.name.s[0] notin prettybase.Letters:
return
@ -184,7 +184,6 @@ proc myOpen(module: PSym): PPassContext =
var g: PGen
new(g)
g.module = module
gCheckExtern = options.getConfigVar("pretty.checkextern").normalize == "on"
result = g
const prettyPass* = makePass(open = myOpen, process = processSym)