made compiler more robust for idetools; implemented idetools.usages
This commit is contained in:
parent
b0c11d3efb
commit
674c05f426
11 changed files with 96 additions and 47 deletions
|
|
@ -455,6 +455,9 @@ proc processSwitch(switch, arg: string, pass: TCmdlinePass, info: TLineInfo) =
|
||||||
of "context":
|
of "context":
|
||||||
expectNoArg(switch, arg, pass, info)
|
expectNoArg(switch, arg, pass, info)
|
||||||
incl(gGlobalOptions, optContext)
|
incl(gGlobalOptions, optContext)
|
||||||
|
of "usages":
|
||||||
|
expectNoArg(switch, arg, pass, info)
|
||||||
|
incl(gGlobalOptions, optUsages)
|
||||||
of "stdout":
|
of "stdout":
|
||||||
expectNoArg(switch, arg, pass, info)
|
expectNoArg(switch, arg, pass, info)
|
||||||
incl(gGlobalOptions, optStdout)
|
incl(gGlobalOptions, optStdout)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,9 @@ proc cardSet*(s: PNode): BiggestInt
|
||||||
# implementation
|
# implementation
|
||||||
|
|
||||||
proc inSet(s: PNode, elem: PNode): bool =
|
proc inSet(s: PNode, elem: PNode): bool =
|
||||||
if s.kind != nkCurly: InternalError(s.info, "inSet")
|
if s.kind != nkCurly:
|
||||||
|
InternalError(s.info, "inSet")
|
||||||
|
return false
|
||||||
for i in countup(0, sonsLen(s) - 1):
|
for i in countup(0, sonsLen(s) - 1):
|
||||||
if s.sons[i].kind == nkRange:
|
if s.sons[i].kind == nkRange:
|
||||||
if leValue(s.sons[i].sons[0], elem) and
|
if leValue(s.sons[i].sons[0], elem) and
|
||||||
|
|
@ -58,7 +60,9 @@ proc overlap(a, b: PNode): bool =
|
||||||
|
|
||||||
proc SomeInSet(s: PNode, a, b: PNode): bool =
|
proc SomeInSet(s: PNode, a, b: PNode): bool =
|
||||||
# checks if some element of a..b is in the set s
|
# checks if some element of a..b is in the set s
|
||||||
if s.kind != nkCurly: InternalError(s.info, "SomeInSet")
|
if s.kind != nkCurly:
|
||||||
|
InternalError(s.info, "SomeInSet")
|
||||||
|
return false
|
||||||
for i in countup(0, sonsLen(s) - 1):
|
for i in countup(0, sonsLen(s) - 1):
|
||||||
if s.sons[i].kind == nkRange:
|
if s.sons[i].kind == nkRange:
|
||||||
if leValue(s.sons[i].sons[0], b) and leValue(b, s.sons[i].sons[1]) or
|
if leValue(s.sons[i].sons[0], b) and leValue(b, s.sons[i].sons[1]) or
|
||||||
|
|
@ -164,7 +168,9 @@ proc cardSet(s: PNode): BiggestInt =
|
||||||
Inc(result)
|
Inc(result)
|
||||||
|
|
||||||
proc SetHasRange(s: PNode): bool =
|
proc SetHasRange(s: PNode): bool =
|
||||||
if s.kind != nkCurly: InternalError(s.info, "SetHasRange")
|
if s.kind != nkCurly:
|
||||||
|
InternalError(s.info, "SetHasRange")
|
||||||
|
return false
|
||||||
for i in countup(0, sonsLen(s) - 1):
|
for i in countup(0, sonsLen(s) - 1):
|
||||||
if s.sons[i].kind == nkRange:
|
if s.sons[i].kind == nkRange:
|
||||||
return true
|
return true
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ type # please make sure we have under 32 options
|
||||||
optSuggest, # ideTools: 'suggest'
|
optSuggest, # ideTools: 'suggest'
|
||||||
optContext, # ideTools: 'context'
|
optContext, # ideTools: 'context'
|
||||||
optDef, # ideTools: 'def'
|
optDef, # ideTools: 'def'
|
||||||
|
optUsages, # ideTools: 'usages'
|
||||||
optThreadAnalysis, # thread analysis pass
|
optThreadAnalysis, # thread analysis pass
|
||||||
optTaintMode, # taint mode turned on
|
optTaintMode, # taint mode turned on
|
||||||
optTlsEmulation, # thread var emulation turned on
|
optTlsEmulation, # thread var emulation turned on
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,9 @@ proc atom(n: PNode): string =
|
||||||
of nkType:
|
of nkType:
|
||||||
if (n.typ != nil) and (n.typ.sym != nil): result = n.typ.sym.name.s
|
if (n.typ != nil) and (n.typ.sym != nil): result = n.typ.sym.name.s
|
||||||
else: result = "[type node]"
|
else: result = "[type node]"
|
||||||
else: InternalError("rnimsyn.atom " & $n.kind)
|
else:
|
||||||
|
InternalError("rnimsyn.atom " & $n.kind)
|
||||||
|
result = ""
|
||||||
|
|
||||||
proc lcomma(n: PNode, start: int = 0, theEnd: int = - 1): int =
|
proc lcomma(n: PNode, start: int = 0, theEnd: int = - 1): int =
|
||||||
assert(theEnd < 0)
|
assert(theEnd < 0)
|
||||||
|
|
|
||||||
|
|
@ -146,14 +146,16 @@ proc PushOwner(owner: PSym) =
|
||||||
|
|
||||||
proc PopOwner() =
|
proc PopOwner() =
|
||||||
var length = len(gOwners)
|
var length = len(gOwners)
|
||||||
if (length <= 0): InternalError("popOwner")
|
if length > 0: setlen(gOwners, length - 1)
|
||||||
setlen(gOwners, length - 1)
|
else: InternalError("popOwner")
|
||||||
|
|
||||||
proc lastOptionEntry(c: PContext): POptionEntry =
|
proc lastOptionEntry(c: PContext): POptionEntry =
|
||||||
result = POptionEntry(c.optionStack.tail)
|
result = POptionEntry(c.optionStack.tail)
|
||||||
|
|
||||||
proc pushProcCon*(c: PContext, owner: PSym) {.inline.} =
|
proc pushProcCon*(c: PContext, owner: PSym) {.inline.} =
|
||||||
if owner == nil: InternalError("owner is nil")
|
if owner == nil:
|
||||||
|
InternalError("owner is nil")
|
||||||
|
return
|
||||||
var x: PProcCon
|
var x: PProcCon
|
||||||
new(x)
|
new(x)
|
||||||
x.owner = owner
|
x.owner = owner
|
||||||
|
|
|
||||||
|
|
@ -118,8 +118,10 @@ proc semSym(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
||||||
LocalError(n.info, errIllegalCaptureX, s.name.s)
|
LocalError(n.info, errIllegalCaptureX, s.name.s)
|
||||||
result = newSymNode(s, n.info)
|
result = newSymNode(s, n.info)
|
||||||
of skGenericParam:
|
of skGenericParam:
|
||||||
if s.ast == nil: InternalError(n.info, "no default for")
|
if s.ast != nil: result = semExpr(c, s.ast)
|
||||||
result = semExpr(c, s.ast)
|
else:
|
||||||
|
InternalError(n.info, "no default for")
|
||||||
|
result = emptyNode
|
||||||
of skType:
|
of skType:
|
||||||
markUsed(n, s)
|
markUsed(n, s)
|
||||||
result = newSymNode(s, n.info)
|
result = newSymNode(s, n.info)
|
||||||
|
|
@ -322,14 +324,17 @@ proc changeType(n: PNode, newType: PType) =
|
||||||
of nkPar:
|
of nkPar:
|
||||||
if newType.kind != tyTuple:
|
if newType.kind != tyTuple:
|
||||||
InternalError(n.info, "changeType: no tuple type for constructor")
|
InternalError(n.info, "changeType: no tuple type for constructor")
|
||||||
if newType.n == nil: nil
|
elif newType.n == nil: nil
|
||||||
elif sonsLen(n) > 0 and n.sons[0].kind == nkExprColonExpr:
|
elif sonsLen(n) > 0 and n.sons[0].kind == nkExprColonExpr:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
var m = n.sons[i].sons[0]
|
var m = n.sons[i].sons[0]
|
||||||
if m.kind != nkSym:
|
if m.kind != nkSym:
|
||||||
internalError(m.info, "changeType(): invalid tuple constr")
|
internalError(m.info, "changeType(): invalid tuple constr")
|
||||||
|
return
|
||||||
var f = getSymFromList(newType.n, m.sym.name)
|
var f = getSymFromList(newType.n, m.sym.name)
|
||||||
if f == nil: internalError(m.info, "changeType(): invalid identifier")
|
if f == nil:
|
||||||
|
internalError(m.info, "changeType(): invalid identifier")
|
||||||
|
return
|
||||||
changeType(n.sons[i].sons[1], f.typ)
|
changeType(n.sons[i].sons[1], f.typ)
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
|
|
@ -485,7 +490,9 @@ proc analyseIfAddressTaken(c: PContext, n: PNode): PNode =
|
||||||
result = newHiddenAddrTaken(c, n)
|
result = newHiddenAddrTaken(c, n)
|
||||||
of nkDotExpr:
|
of nkDotExpr:
|
||||||
checkSonsLen(n, 2)
|
checkSonsLen(n, 2)
|
||||||
if n.sons[1].kind != nkSym: internalError(n.info, "analyseIfAddressTaken")
|
if n.sons[1].kind != nkSym:
|
||||||
|
internalError(n.info, "analyseIfAddressTaken")
|
||||||
|
return
|
||||||
if skipTypes(n.sons[1].sym.typ, abstractInst).kind != tyVar:
|
if skipTypes(n.sons[1].sym.typ, abstractInst).kind != tyVar:
|
||||||
incl(n.sons[1].sym.flags, sfAddrTaken)
|
incl(n.sons[1].sym.flags, sfAddrTaken)
|
||||||
result = newHiddenAddrTaken(c, n)
|
result = newHiddenAddrTaken(c, n)
|
||||||
|
|
@ -590,6 +597,7 @@ proc semOverloadedCallAnalyseEffects(c: PContext, n: PNode, nOrig: PNode,
|
||||||
if result != nil:
|
if result != nil:
|
||||||
if result.sons[0].kind != nkSym:
|
if result.sons[0].kind != nkSym:
|
||||||
InternalError("semDirectCallAnalyseEffects")
|
InternalError("semDirectCallAnalyseEffects")
|
||||||
|
return
|
||||||
let callee = result.sons[0].sym
|
let callee = result.sons[0].sym
|
||||||
case callee.kind
|
case callee.kind
|
||||||
of skMacro, skTemplate: nil
|
of skMacro, skTemplate: nil
|
||||||
|
|
@ -1225,8 +1233,8 @@ proc semIfExpr(c: PContext, n: PNode): PNode =
|
||||||
of nkElseExpr:
|
of nkElseExpr:
|
||||||
checkSonsLen(it, 1)
|
checkSonsLen(it, 1)
|
||||||
it.sons[0] = semExprWithType(c, it.sons[0])
|
it.sons[0] = semExprWithType(c, it.sons[0])
|
||||||
if typ == nil: InternalError(it.info, "semIfExpr")
|
if typ != nil: it.sons[0] = fitNode(c, typ, it.sons[0])
|
||||||
it.sons[0] = fitNode(c, typ, it.sons[0])
|
else: InternalError(it.info, "semIfExpr")
|
||||||
else: illFormedAst(n)
|
else: illFormedAst(n)
|
||||||
result.typ = typ
|
result.typ = typ
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ proc semWhen(c: PContext, n: PNode, semCheck = true): PNode =
|
||||||
checkSonsLen(it, 2)
|
checkSonsLen(it, 2)
|
||||||
var e = semConstExpr(c, it.sons[0])
|
var e = semConstExpr(c, it.sons[0])
|
||||||
if e.kind != nkIntLit: InternalError(n.info, "semWhen")
|
if e.kind != nkIntLit: InternalError(n.info, "semWhen")
|
||||||
if e.intVal != 0 and result == nil:
|
elif e.intVal != 0 and result == nil:
|
||||||
setResult(it.sons[1])
|
setResult(it.sons[1])
|
||||||
of nkElse, nkElseExpr:
|
of nkElse, nkElseExpr:
|
||||||
checkSonsLen(it, 1)
|
checkSonsLen(it, 1)
|
||||||
|
|
@ -514,8 +514,8 @@ proc addGenericParamListToScope(c: PContext, n: PNode) =
|
||||||
InternalError(n.info, "addGenericParamListToScope")
|
InternalError(n.info, "addGenericParamListToScope")
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in countup(0, sonsLen(n)-1):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind != nkSym: internalError(a.info, "addGenericParamListToScope")
|
if a.kind == nkSym: addDecl(c, a.sym)
|
||||||
addDecl(c, a.sym)
|
else: internalError(a.info, "addGenericParamListToScope")
|
||||||
|
|
||||||
proc typeSectionLeftSidePass(c: PContext, n: PNode) =
|
proc typeSectionLeftSidePass(c: PContext, n: PNode) =
|
||||||
# process the symbols on the left side for the whole type section, before
|
# process the symbols on the left side for the whole type section, before
|
||||||
|
|
@ -628,8 +628,8 @@ proc semParamList(c: PContext, n, genericParams: PNode, s: PSym) =
|
||||||
|
|
||||||
proc addParams(c: PContext, n: PNode, kind: TSymKind) =
|
proc addParams(c: PContext, n: PNode, kind: TSymKind) =
|
||||||
for i in countup(1, sonsLen(n)-1):
|
for i in countup(1, sonsLen(n)-1):
|
||||||
if (n.sons[i].kind != nkSym): InternalError(n.info, "addParams")
|
if n.sons[i].kind == nkSym: addParamOrResult(c, n.sons[i].sym, kind)
|
||||||
addParamOrResult(c, n.sons[i].sym, kind)
|
else: InternalError(n.info, "addParams")
|
||||||
|
|
||||||
proc semBorrow(c: PContext, n: PNode, s: PSym) =
|
proc semBorrow(c: PContext, n: PNode, s: PSym) =
|
||||||
# search for the correct alias:
|
# search for the correct alias:
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,7 @@ proc semRecordCase(c: PContext, n: PNode, check: var TIntSet, pos: var int,
|
||||||
checkMinSonsLen(n, 2)
|
checkMinSonsLen(n, 2)
|
||||||
semRecordNodeAux(c, n.sons[0], check, pos, a, rectype)
|
semRecordNodeAux(c, n.sons[0], check, pos, a, rectype)
|
||||||
if a.sons[0].kind != nkSym:
|
if a.sons[0].kind != nkSym:
|
||||||
internalError("semRecordCase: dicriminant is no symbol")
|
internalError("semRecordCase: discriminant is no symbol")
|
||||||
return
|
return
|
||||||
incl(a.sons[0].sym.flags, sfDiscriminant)
|
incl(a.sons[0].sym.flags, sfDiscriminant)
|
||||||
var covered: biggestInt = 0
|
var covered: biggestInt = 0
|
||||||
|
|
@ -412,7 +412,7 @@ proc semRecordNodeAux(c: PContext, n: PNode, check: var TIntSet, pos: var int,
|
||||||
if c.InGenericContext == 0:
|
if c.InGenericContext == 0:
|
||||||
var e = semConstBoolExpr(c, it.sons[0])
|
var e = semConstBoolExpr(c, it.sons[0])
|
||||||
if e.kind != nkIntLit: InternalError(e.info, "semRecordNodeAux")
|
if e.kind != nkIntLit: InternalError(e.info, "semRecordNodeAux")
|
||||||
if e.intVal != 0 and branch == nil: branch = it.sons[1]
|
elif e.intVal != 0 and branch == nil: branch = it.sons[1]
|
||||||
else:
|
else:
|
||||||
it.sons[0] = forceBool(c, semExprWithType(c, it.sons[0]))
|
it.sons[0] = forceBool(c, semExprWithType(c, it.sons[0]))
|
||||||
of nkElse:
|
of nkElse:
|
||||||
|
|
@ -735,6 +735,7 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
|
||||||
isConcrete = false
|
isConcrete = false
|
||||||
elif s.typ.containerID == 0:
|
elif s.typ.containerID == 0:
|
||||||
InternalError(n.info, "semtypes.semGeneric")
|
InternalError(n.info, "semtypes.semGeneric")
|
||||||
|
return errorType(c)
|
||||||
elif sonsLen(n) != sonsLen(s.typ):
|
elif sonsLen(n) != sonsLen(s.typ):
|
||||||
LocalError(n.info, errWrongNumberOfArguments)
|
LocalError(n.info, errWrongNumberOfArguments)
|
||||||
return errorType(c)
|
return errorType(c)
|
||||||
|
|
@ -930,7 +931,9 @@ proc semGenericConstraints(c: PContext, n: PNode, result: PType) =
|
||||||
|
|
||||||
proc semGenericParamList(c: PContext, n: PNode, father: PType = nil): PNode =
|
proc semGenericParamList(c: PContext, n: PNode, father: PType = nil): PNode =
|
||||||
result = copyNode(n)
|
result = copyNode(n)
|
||||||
if n.kind != nkGenericParams: InternalError(n.info, "semGenericParamList")
|
if n.kind != nkGenericParams:
|
||||||
|
InternalError(n.info, "semGenericParamList")
|
||||||
|
return
|
||||||
for i in countup(0, sonsLen(n)-1):
|
for i in countup(0, sonsLen(n)-1):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
if a.kind != nkIdentDefs: illFormedAst(n)
|
if a.kind != nkIdentDefs: illFormedAst(n)
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,8 @@ proc tupleRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||||
for i in countup(0, sonsLen(f.n) - 1):
|
for i in countup(0, sonsLen(f.n) - 1):
|
||||||
# check field names:
|
# check field names:
|
||||||
if f.n.sons[i].kind != nkSym: InternalError(f.n.info, "tupleRel")
|
if f.n.sons[i].kind != nkSym: InternalError(f.n.info, "tupleRel")
|
||||||
if a.n.sons[i].kind != nkSym: InternalError(a.n.info, "tupleRel")
|
elif a.n.sons[i].kind != nkSym: InternalError(a.n.info, "tupleRel")
|
||||||
|
else:
|
||||||
var x = f.n.sons[i].sym
|
var x = f.n.sons[i].sym
|
||||||
var y = a.n.sons[i].sym
|
var y = a.n.sons[i].sym
|
||||||
if x.name.id != y.name.id: return isNone
|
if x.name.id != y.name.id: return isNone
|
||||||
|
|
@ -501,7 +502,7 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||||
for i in countup(1, sonsLen(f) - 1):
|
for i in countup(1, sonsLen(f) - 1):
|
||||||
if a.sons[i].kind == tyGenericParam:
|
if a.sons[i].kind == tyGenericParam:
|
||||||
InternalError("wrong instantiated type!")
|
InternalError("wrong instantiated type!")
|
||||||
if typeRel(c, f.sons[i], a.sons[i]) <= isSubtype: return
|
elif typeRel(c, f.sons[i], a.sons[i]) <= isSubtype: return
|
||||||
result = isGeneric
|
result = isGeneric
|
||||||
else:
|
else:
|
||||||
result = typeRel(c, f.sons[0], a)
|
result = typeRel(c, f.sons[0], a)
|
||||||
|
|
@ -539,7 +540,7 @@ proc typeRel(c: var TCandidate, f, a: PType): TTypeRelation =
|
||||||
result = isNone
|
result = isNone
|
||||||
of tyExpr, tyStmt:
|
of tyExpr, tyStmt:
|
||||||
result = isGeneric
|
result = isGeneric
|
||||||
else: internalError("typeRel(" & $f.kind & ')')
|
else: internalError("typeRel: " & $f.kind)
|
||||||
|
|
||||||
proc cmpTypes*(f, a: PType): TTypeRelation =
|
proc cmpTypes*(f, a: PType): TTypeRelation =
|
||||||
var c: TCandidate
|
var c: TCandidate
|
||||||
|
|
@ -551,7 +552,9 @@ proc getInstantiatedType(c: PContext, arg: PNode, m: TCandidate,
|
||||||
result = PType(idTableGet(m.bindings, f))
|
result = PType(idTableGet(m.bindings, f))
|
||||||
if result == nil:
|
if result == nil:
|
||||||
result = generateTypeInstance(c, m.bindings, arg, f)
|
result = generateTypeInstance(c, m.bindings, arg, f)
|
||||||
if result == nil: InternalError(arg.info, "getInstantiatedType")
|
if result == nil:
|
||||||
|
InternalError(arg.info, "getInstantiatedType")
|
||||||
|
result = errorType(c)
|
||||||
|
|
||||||
proc implicitConv(kind: TNodeKind, f: PType, arg: PNode, m: TCandidate,
|
proc implicitConv(kind: TNodeKind, f: PType, arg: PNode, m: TCandidate,
|
||||||
c: PContext): PNode =
|
c: PContext): PNode =
|
||||||
|
|
@ -794,6 +797,7 @@ proc matchesAux*(c: PContext, n, nOrig: PNode,
|
||||||
else:
|
else:
|
||||||
if m.callee.n.sons[f].kind != nkSym:
|
if m.callee.n.sons[f].kind != nkSym:
|
||||||
InternalError(n.sons[a].info, "matches")
|
InternalError(n.sons[a].info, "matches")
|
||||||
|
return
|
||||||
formal = m.callee.n.sons[f].sym
|
formal = m.callee.n.sons[f].sym
|
||||||
if ContainsOrIncl(marker, formal.position):
|
if ContainsOrIncl(marker, formal.position):
|
||||||
# already in namedParams:
|
# already in namedParams:
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ const
|
||||||
sectionDef = "def"
|
sectionDef = "def"
|
||||||
sectionContext = "con"
|
sectionContext = "con"
|
||||||
|
|
||||||
proc SymToStr(s: PSym, isLocal: bool, section: string): string =
|
proc SymToStr(s: PSym, isLocal: bool, section: string, li: TLineInfo): string =
|
||||||
result = section
|
result = section
|
||||||
result.add(sep)
|
result.add(sep)
|
||||||
result.add($s.kind)
|
result.add($s.kind)
|
||||||
|
|
@ -33,11 +33,14 @@ proc SymToStr(s: PSym, isLocal: bool, section: string): string =
|
||||||
if s.typ != nil:
|
if s.typ != nil:
|
||||||
result.add(typeToString(s.typ))
|
result.add(typeToString(s.typ))
|
||||||
result.add(sep)
|
result.add(sep)
|
||||||
result.add(toFilename(s.info))
|
result.add(toFilename(li))
|
||||||
result.add(sep)
|
result.add(sep)
|
||||||
result.add($ToLinenumber(s.info))
|
result.add($ToLinenumber(li))
|
||||||
result.add(sep)
|
result.add(sep)
|
||||||
result.add($ToColumn(s.info))
|
result.add($ToColumn(li))
|
||||||
|
|
||||||
|
proc SymToStr(s: PSym, isLocal: bool, section: string): string =
|
||||||
|
result = SymToStr(s, isLocal, section, s.info)
|
||||||
|
|
||||||
proc filterSym(s: PSym): bool {.inline.} =
|
proc filterSym(s: PSym): bool {.inline.} =
|
||||||
result = s.name.s[0] in lexer.SymChars
|
result = s.name.s[0] in lexer.SymChars
|
||||||
|
|
@ -196,6 +199,9 @@ proc fuzzySemCheck(c: PContext, n: PNode): PNode =
|
||||||
if n.kind notin {nkNone..nkNilLit}:
|
if n.kind notin {nkNone..nkNilLit}:
|
||||||
for i in 0 .. < sonsLen(n): result.addSon(fuzzySemCheck(c, n.sons[i]))
|
for i in 0 .. < sonsLen(n): result.addSon(fuzzySemCheck(c, n.sons[i]))
|
||||||
|
|
||||||
|
var
|
||||||
|
usageSym: PSym
|
||||||
|
|
||||||
proc suggestExpr*(c: PContext, node: PNode) =
|
proc suggestExpr*(c: PContext, node: PNode) =
|
||||||
var cp = msgs.inCheckpoint(node.info)
|
var cp = msgs.inCheckpoint(node.info)
|
||||||
if cp == cpNone: return
|
if cp == cpNone: return
|
||||||
|
|
@ -233,13 +239,26 @@ proc suggestExpr*(c: PContext, node: PNode) =
|
||||||
suggestCall(c, a, n, outputs)
|
suggestCall(c, a, n, outputs)
|
||||||
|
|
||||||
if optDef in gGlobalOptions:
|
if optDef in gGlobalOptions:
|
||||||
var n = findClosestSym(fuzzySemCheck(c, node))
|
let n = findClosestSym(fuzzySemCheck(c, node))
|
||||||
if n != nil:
|
if n != nil:
|
||||||
OutWriteln(SymToStr(n.sym, isLocal=false, sectionDef))
|
OutWriteln(SymToStr(n.sym, isLocal=false, sectionDef))
|
||||||
inc outputs
|
inc outputs
|
||||||
|
|
||||||
|
if optUsages in gGlobalOptions:
|
||||||
|
if usageSym == nil:
|
||||||
|
let n = findClosestSym(fuzzySemCheck(c, node))
|
||||||
|
if n != nil:
|
||||||
|
usageSym = n.sym
|
||||||
|
OutWriteln(SymToStr(n.sym, isLocal=false, sectionDef))
|
||||||
|
inc outputs
|
||||||
|
else:
|
||||||
|
let n = node
|
||||||
|
if n.kind == nkSym and n.sym == usageSym:
|
||||||
|
OutWriteln(SymToStr(n.sym, isLocal=false, sectionDef, n.info))
|
||||||
|
inc outputs
|
||||||
|
|
||||||
dec(c.InCompilesContext)
|
dec(c.InCompilesContext)
|
||||||
if outputs > 0: quit(0)
|
if outputs > 0 and optUsages notin gGlobalOptions: quit(0)
|
||||||
|
|
||||||
proc suggestStmt*(c: PContext, n: PNode) =
|
proc suggestStmt*(c: PContext, n: PNode) =
|
||||||
suggestExpr(c, n)
|
suggestExpr(c, n)
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,9 @@ Advanced commands:
|
||||||
//idetools compiler support for IDEs: possible options:
|
//idetools compiler support for IDEs: possible options:
|
||||||
--track:FILE,LINE,COL track a file/cursor position
|
--track:FILE,LINE,COL track a file/cursor position
|
||||||
--suggest suggest all possible symbols at position
|
--suggest suggest all possible symbols at position
|
||||||
--def list all possible symbols at position
|
--def list all possible definitions at position
|
||||||
--context list possible invokation context
|
--context list possible invokation context
|
||||||
|
--usages list all usages of the symbol at position
|
||||||
|
|
||||||
Advanced options:
|
Advanced options:
|
||||||
-m, --mainmodule:FILE set the project main module
|
-m, --mainmodule:FILE set the project main module
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue