mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-16 16:14:20 +00:00
some improvements for nimfix
This commit is contained in:
@@ -376,3 +376,13 @@ proc nextOverloadIter*(o: var TOverloadIter, c: PContext, n: PNode): PSym =
|
||||
n.sons[0].sym.name, o.inSymChoice).skipAlias(n)
|
||||
|
||||
if result != nil and result.kind == skStub: loadStub(result)
|
||||
|
||||
proc pickSym*(c: PContext, n: PNode; kind: TSymKind;
|
||||
flags: TSymFlags = {}): PSym =
|
||||
var o: TOverloadIter
|
||||
var a = initOverloadIter(o, c, n)
|
||||
while a != nil:
|
||||
if a.kind == kind and flags <= a.flags:
|
||||
incl(a.flags, sfUsed)
|
||||
return a
|
||||
a = nextOverloadIter(o, c, n)
|
||||
|
||||
@@ -306,9 +306,6 @@ proc mainCommand* =
|
||||
CommandCompileToLLVM()
|
||||
else:
|
||||
rawMessage(errInvalidCommandX, command)
|
||||
of "pretty":
|
||||
gCmd = cmdPretty
|
||||
commandPretty()
|
||||
of "doc":
|
||||
gCmd = cmdDoc
|
||||
loadConfigs(DocConfig)
|
||||
|
||||
@@ -41,7 +41,7 @@ proc overwriteFiles*() =
|
||||
f.write line.strip(leading = false, trailing = true)
|
||||
else:
|
||||
f.write line
|
||||
f.write("\L")
|
||||
f.write(gSourceFiles[i].newline)
|
||||
f.close
|
||||
except IOError:
|
||||
rawMessage(errCannotOpenFile, newFile)
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
import ast, msgs, strutils, idents
|
||||
import ast, msgs, strutils, idents, lexbase, streams
|
||||
from os import splitFile
|
||||
|
||||
type
|
||||
TSourceFile* = object
|
||||
lines*: seq[string]
|
||||
dirty*, isNimfixFile*: bool
|
||||
fullpath*: string
|
||||
fullpath*, newline*: string
|
||||
|
||||
var
|
||||
gSourceFiles*: seq[TSourceFile] = @[]
|
||||
@@ -27,10 +27,24 @@ proc loadFile*(info: TLineInfo) =
|
||||
gSourceFiles[i].lines = @[]
|
||||
let path = info.toFullPath
|
||||
gSourceFiles[i].fullpath = path
|
||||
gSourceFiles[i].isNimfixFile = path.splitFile.ext == "nimfix"
|
||||
gSourceFiles[i].isNimfixFile = path.splitFile.ext == ".nimfix"
|
||||
# we want to die here for IOError:
|
||||
for line in lines(path):
|
||||
gSourceFiles[i].lines.add(line)
|
||||
# extract line ending of the file:
|
||||
var lex: BaseLexer
|
||||
open(lex, newFileStream(path))
|
||||
var pos = lex.bufpos
|
||||
while true:
|
||||
case lex.buf[pos]
|
||||
of '\c':
|
||||
gSourceFiles[i].newline = "\c\L"
|
||||
break
|
||||
of '\L', '\0':
|
||||
gSourceFiles[i].newline = "\L"
|
||||
break
|
||||
inc pos
|
||||
close(lex)
|
||||
|
||||
const
|
||||
Letters* = {'a'..'z', 'A'..'Z', '0'..'9', '\x80'..'\xFF', '_'}
|
||||
|
||||
@@ -2014,9 +2014,9 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
checkMinSonsLen(n, 1)
|
||||
let mode = if nfDotField in n.flags: {} else: {checkUndeclared}
|
||||
var s = qualifiedLookUp(c, n.sons[0], mode)
|
||||
if s != nil:
|
||||
if gCmd == cmdPretty and n.sons[0].kind == nkDotExpr:
|
||||
pretty.checkUse(n.sons[0].sons[1].info, s)
|
||||
if s != nil:
|
||||
#if gCmd == cmdPretty and n.sons[0].kind == nkDotExpr:
|
||||
# pretty.checkUse(n.sons[0].sons[1].info, s)
|
||||
case s.kind
|
||||
of skMacro:
|
||||
if sfImmediate notin s.flags:
|
||||
|
||||
@@ -279,7 +279,12 @@ proc semTypeIdent(c: PContext, n: PNode): PSym =
|
||||
if n.kind == nkSym:
|
||||
result = n.sym
|
||||
else:
|
||||
result = qualifiedLookUp(c, n, {checkAmbiguity, checkUndeclared})
|
||||
when defined(nimfix):
|
||||
result = pickSym(c, n, skType)
|
||||
if result.isNil:
|
||||
result = qualifiedLookUp(c, n, {checkAmbiguity, checkUndeclared})
|
||||
else:
|
||||
result = qualifiedLookUp(c, n, {checkAmbiguity, checkUndeclared})
|
||||
if result != nil:
|
||||
markUsed(n.info, result)
|
||||
if result.kind == skParam and result.typ.kind == tyTypeDesc:
|
||||
|
||||
@@ -12,7 +12,6 @@ Advanced commands:
|
||||
module dependency graph
|
||||
//dump dump all defined conditionals and search paths
|
||||
//check checks the project for syntax and semantic
|
||||
//pretty homogenizes source code style
|
||||
//idetools compiler support for IDEs: possible options:
|
||||
--track:FILE,LINE,COL track a file/cursor position
|
||||
--trackDirty:DIRTY_FILE,ORIG_FILE,LINE,COL
|
||||
|
||||
@@ -690,7 +690,7 @@ proc getQueuedCompletionStatus*(CompletionPort: THandle,
|
||||
dwMilliseconds: DWORD): WINBOOL{.stdcall,
|
||||
dynlib: "kernel32", importc: "GetQueuedCompletionStatus".}
|
||||
|
||||
proc getOverlappedResult*(hFile: THandle, lpOverlapped: TOverlapped,
|
||||
proc getOverlappedResult*(hFile: THandle, lpOverlapped: TOVERLAPPED,
|
||||
lpNumberOfBytesTransferred: var DWORD, bWait: WINBOOL): WINBOOL{.
|
||||
stdcall, dynlib: "kernel32", importc: "GetOverlappedResult".}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user