make nimsuggest compile again

This commit is contained in:
Andreas Rumpf 2018-05-13 09:53:00 +02:00
commit e4c088721a
7 changed files with 97 additions and 89 deletions

View file

@ -152,7 +152,7 @@ proc myImportModule(c: PContext, n: PNode): PSym =
message(c.config, n.info, warnDeprecated, result.constraint.strVal & "; " & result.name.s)
else:
message(c.config, n.info, warnDeprecated, result.name.s)
suggestSym(n.info, result, c.graph.usageSym, false)
suggestSym(c.config, n.info, result, c.graph.usageSym, false)
proc impMod(c: PContext; it: PNode) =
let m = myImportModule(c, it)

View file

@ -274,7 +274,7 @@ template tokenEnd(tok, pos) {.dirty.} =
when defined(nimsuggest):
let colB = getColNumber(L, pos)+1
if L.fileIdx == gTrackPos.fileIndex and gTrackPos.col in colA..colB and
L.lineNumber == gTrackPos.line.int and gIdeCmd in {ideSug, ideCon}:
L.lineNumber == gTrackPos.line.int and L.config.ideCmd in {ideSug, ideCon}:
L.cursor = CursorPosition.InToken
gTrackPos.col = colA.int16
colA = 0
@ -285,7 +285,7 @@ template tokenEndIgnore(tok, pos) =
when defined(nimsuggest):
let colB = getColNumber(L, pos)
if L.fileIdx == gTrackPos.fileIndex and gTrackPos.col in colA..colB and
L.lineNumber == gTrackPos.line.int and gIdeCmd in {ideSug, ideCon}:
L.lineNumber == gTrackPos.line.int and L.config.ideCmd in {ideSug, ideCon}:
gTrackPos.fileIndex = trackPosInvalidFileIdx
gTrackPos.line = 0'u16
colA = 0
@ -299,7 +299,7 @@ template tokenEndPrevious(tok, pos) =
# the cursor in a string literal or comment:
let colB = getColNumber(L, pos)
if L.fileIdx == gTrackPos.fileIndex and gTrackPos.col in colA..colB and
L.lineNumber == gTrackPos.line.int and gIdeCmd in {ideSug, ideCon}:
L.lineNumber == gTrackPos.line.int and L.config.ideCmd in {ideSug, ideCon}:
L.cursor = CursorPosition.BeforeToken
gTrackPos = L.previousToken
gTrackPosAttached = true
@ -1122,7 +1122,7 @@ proc rawGetTok*(L: var TLexer, tok: var TToken) =
tok.tokType = tkParLe
when defined(nimsuggest):
if L.fileIdx == gTrackPos.fileIndex and tok.col < gTrackPos.col and
tok.line == gTrackPos.line.int and gIdeCmd == ideCon:
tok.line == gTrackPos.line.int and L.config.ideCmd == ideCon:
gTrackPos.col = tok.col.int16
of ')':
tok.tokType = tkParRi
@ -1143,7 +1143,7 @@ proc rawGetTok*(L: var TLexer, tok: var TToken) =
of '.':
when defined(nimsuggest):
if L.fileIdx == gTrackPos.fileIndex and tok.col+1 == gTrackPos.col and
tok.line == gTrackPos.line.int and gIdeCmd == ideSug:
tok.line == gTrackPos.line.int and L.config.ideCmd == ideSug:
tok.tokType = tkDot
L.cursor = CursorPosition.InToken
gTrackPos.col = tok.col.int16

View file

@ -2154,7 +2154,7 @@ proc semBlock(c: PContext, n: PNode): PNode =
if sfGenSym notin labl.flags:
addDecl(c, labl)
n.sons[0] = newSymNode(labl, n.sons[0].info)
suggestSym(n.sons[0].info, labl, c.graph.usageSym)
suggestSym(c.config, n.sons[0].info, labl, c.graph.usageSym)
styleCheckDef(labl)
n.sons[1] = semExpr(c, n.sons[1])
n.typ = n.sons[1].typ

View file

@ -62,7 +62,7 @@ proc semBreakOrContinue(c: PContext, n: PNode): PNode =
x.info = n.info
incl(s.flags, sfUsed)
n.sons[0] = x
suggestSym(x.info, s, c.graph.usageSym)
suggestSym(c.config, x.info, s, c.graph.usageSym)
styleCheckUse(x.info, s)
else:
localError(c.config, n.info, errInvalidControlFlowX % s.name.s)
@ -203,7 +203,7 @@ proc semCase(c: PContext, n: PNode): PNode =
for i in countup(1, sonsLen(n) - 1):
var x = n.sons[i]
when defined(nimsuggest):
if gIdeCmd == ideSug and exactEquals(gTrackPos, x.info) and caseTyp.kind == tyEnum:
if c.config.ideCmd == ideSug and exactEquals(gTrackPos, x.info) and caseTyp.kind == tyEnum:
suggestEnum(c, x, caseTyp)
case x.kind
of nkOfBranch:
@ -365,7 +365,7 @@ proc semIdentDef(c: PContext, n: PNode, kind: TSymKind): PSym =
result = semIdentWithPragma(c, kind, n, {})
if result.owner.kind == skModule:
incl(result.flags, sfGlobal)
suggestSym(n.info, result, c.graph.usageSym)
suggestSym(c.config, n.info, result, c.graph.usageSym)
styleCheckDef(result)
proc checkNilable(c: PContext; v: PSym) =

View file

@ -672,7 +672,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var IntSet, pos: var int,
else: rectype.sym
for i in countup(0, sonsLen(n)-3):
var f = semIdentWithPragma(c, skField, n.sons[i], {sfExported})
suggestSym(n.sons[i].info, f, c.graph.usageSym)
suggestSym(c.config, n.sons[i].info, f, c.graph.usageSym)
f.typ = typ
f.position = pos
if fieldOwner != nil and

View file

@ -342,12 +342,12 @@ proc suggestFieldAccess(c: PContext, n, field: PNode, outputs: var Suggestions)
when defined(nimsuggest):
if n.kind == nkSym and n.sym.kind == skError and suggestVersion == 0:
# consider 'foo.|' where 'foo' is some not imported module.
let fullPath = findModule(n.sym.name.s, n.info.toFullPath)
let fullPath = findModule(c.config, n.sym.name.s, n.info.toFullPath)
if fullPath.len == 0:
# error: no known module name:
typ = nil
else:
let m = gImportModule(c.graph, c.module, fullpath.fileInfoIdx, c.cache)
let m = gImportModule(c.graph, c.module, fileInfoIdx(c.config, fullpath), c.cache)
if m == nil: typ = nil
else:
for it in items(n.sym.tab):
@ -457,7 +457,7 @@ proc ensureIdx[T](x: var T, y: int) =
proc ensureSeq[T](x: var seq[T]) =
if x == nil: newSeq(x, 0)
proc suggestSym*(info: TLineInfo; s: PSym; usageSym: var PSym; isDecl=true) {.inline.} =
proc suggestSym*(conf: ConfigRef; info: TLineInfo; s: PSym; usageSym: var PSym; isDecl=true) {.inline.} =
## misnamed: should be 'symDeclared'
when defined(nimsuggest):
if suggestVersion == 0:
@ -466,17 +466,17 @@ proc suggestSym*(info: TLineInfo; s: PSym; usageSym: var PSym; isDecl=true) {.in
else:
s.addNoDup(info)
if gIdeCmd == ideUse:
if conf.ideCmd == ideUse:
findUsages(info, s, usageSym)
elif gIdeCmd == ideDef:
elif conf.ideCmd == ideDef:
findDefinition(info, s)
elif gIdeCmd == ideDus and s != nil:
elif conf.ideCmd == ideDus and s != nil:
if isTracked(info, s.name.s.len):
suggestResult(symToSuggest(s, isLocal=false, ideDef, info, 100, PrefixMatch.None, false, 0))
findUsages(info, s, usageSym)
elif gIdeCmd == ideHighlight and info.fileIndex == gTrackPos.fileIndex:
elif conf.ideCmd == ideHighlight and info.fileIndex == gTrackPos.fileIndex:
suggestResult(symToSuggest(s, isLocal=false, ideHighlight, info, 100, PrefixMatch.None, false, 0))
elif gIdeCmd == ideOutline and info.fileIndex == gTrackPos.fileIndex and
elif conf.ideCmd == ideOutline and info.fileIndex == gTrackPos.fileIndex and
isDecl:
suggestResult(symToSuggest(s, isLocal=false, ideOutline, info, 100, PrefixMatch.None, false, 0))
@ -499,7 +499,7 @@ proc markUsed(conf: ConfigRef; info: TLineInfo; s: PSym; usageSym: var PSym) =
if sfDeprecated in s.flags: warnAboutDeprecated(conf, info, s)
if sfError in s.flags: localError(conf, info, "usage of '$1' is a user-defined error" % s.name.s)
when defined(nimsuggest):
suggestSym(info, s, usageSym, false)
suggestSym(conf, info, s, usageSym, false)
proc useSym*(conf: ConfigRef; sym: PSym; usageSym: var PSym): PNode =
result = newSymNode(sym)