nimfix supports specialized '.nimfix' modules
This commit is contained in:
parent
7333237be6
commit
c53a27f0dc
4 changed files with 31 additions and 18 deletions
|
|
@ -337,6 +337,16 @@ proc findFile*(f: string): string {.procvar.} =
|
||||||
|
|
||||||
proc findModule*(modulename, currentModule: string): string =
|
proc findModule*(modulename, currentModule: string): string =
|
||||||
# returns path to module
|
# returns path to module
|
||||||
|
when defined(nimfix):
|
||||||
|
# '.nimfix' modules are preferred over '.nim' modules so that specialized
|
||||||
|
# versions can be kept for 'nimfix'.
|
||||||
|
block:
|
||||||
|
let m = addFileExt(modulename, "nimfix")
|
||||||
|
let currentPath = currentModule.splitFile.dir
|
||||||
|
result = currentPath / m
|
||||||
|
if not existsFile(result):
|
||||||
|
result = findFile(m)
|
||||||
|
if existsFile(result): return result
|
||||||
let m = addFileExt(modulename, NimExt)
|
let m = addFileExt(modulename, NimExt)
|
||||||
let currentPath = currentModule.splitFile.dir
|
let currentPath = currentModule.splitFile.dir
|
||||||
result = currentPath / m
|
result = currentPath / m
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ type
|
||||||
proc overwriteFiles*() =
|
proc overwriteFiles*() =
|
||||||
let doStrip = options.getConfigVar("pretty.strip").normalize == "on"
|
let doStrip = options.getConfigVar("pretty.strip").normalize == "on"
|
||||||
for i in 0 .. high(gSourceFiles):
|
for i in 0 .. high(gSourceFiles):
|
||||||
if not gSourceFiles[i].dirty: continue
|
if gSourceFiles[i].dirty and not gSourceFiles[i].isNimfixFile:
|
||||||
let newFile = if gOverWrite: gSourceFiles[i].fullpath
|
let newFile = if gOverWrite: gSourceFiles[i].fullpath
|
||||||
else: gSourceFiles[i].fullpath.changeFileExt(".pretty.nim")
|
else: gSourceFiles[i].fullpath.changeFileExt(".pretty.nim")
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,12 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
import ast, msgs, strutils, idents
|
import ast, msgs, strutils, idents
|
||||||
|
from os import splitFile
|
||||||
|
|
||||||
type
|
type
|
||||||
TSourceFile* = object
|
TSourceFile* = object
|
||||||
lines*: seq[string]
|
lines*: seq[string]
|
||||||
dirty*: bool
|
dirty*, isNimfixFile*: bool
|
||||||
fullpath*: string
|
fullpath*: string
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
@ -26,7 +27,8 @@ proc loadFile*(info: TLineInfo) =
|
||||||
gSourceFiles[i].lines = @[]
|
gSourceFiles[i].lines = @[]
|
||||||
let path = info.toFullPath
|
let path = info.toFullPath
|
||||||
gSourceFiles[i].fullpath = path
|
gSourceFiles[i].fullpath = path
|
||||||
# we want to die here for EIO:
|
gSourceFiles[i].isNimfixFile = path.splitFile.ext == "nimfix"
|
||||||
|
# we want to die here for IOError:
|
||||||
for line in lines(path):
|
for line in lines(path):
|
||||||
gSourceFiles[i].lines.add(line)
|
gSourceFiles[i].lines.add(line)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ proc osErrorMsg*(): string {.rtl, extern: "nos$1", deprecated.} =
|
||||||
## On Windows ``GetLastError`` is checked before ``errno``.
|
## On Windows ``GetLastError`` is checked before ``errno``.
|
||||||
## Returns "" if no error occured.
|
## Returns "" if no error occured.
|
||||||
##
|
##
|
||||||
## **Deprecated since version 0.9.4**: use the other ``OSErrorMsg`` proc.
|
## **Deprecated since version 0.9.4**: use the other ``osErrorMsg`` proc.
|
||||||
|
|
||||||
result = ""
|
result = ""
|
||||||
when defined(Windows):
|
when defined(Windows):
|
||||||
|
|
@ -225,6 +225,7 @@ proc raiseOSError*(msg: string = "") {.noinline, rtl, extern: "nos$1",
|
||||||
raise newException(OSError, msg)
|
raise newException(OSError, msg)
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
||||||
|
when not defined(nimfix):
|
||||||
{.deprecated: [osError: raiseOSError].}
|
{.deprecated: [osError: raiseOSError].}
|
||||||
|
|
||||||
proc `==`*(err1, err2: OSErrorCode): bool {.borrow.}
|
proc `==`*(err1, err2: OSErrorCode): bool {.borrow.}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue