nimsuggest: added 'dus' command that combines 'def' and 'use'
This commit is contained in:
parent
4705cf2308
commit
ca75985fc1
2 changed files with 8 additions and 2 deletions
|
|
@ -86,7 +86,7 @@ type # please make sure we have under 32 options
|
||||||
gcNone, gcBoehm, gcGo, gcMarkAndSweep, gcRefc, gcV2, gcGenerational
|
gcNone, gcBoehm, gcGo, gcMarkAndSweep, gcRefc, gcV2, gcGenerational
|
||||||
|
|
||||||
IdeCmd* = enum
|
IdeCmd* = enum
|
||||||
ideNone, ideSug, ideCon, ideDef, ideUse
|
ideNone, ideSug, ideCon, ideDef, ideUse, ideDus
|
||||||
|
|
||||||
var
|
var
|
||||||
gIdeCmd*: IdeCmd
|
gIdeCmd*: IdeCmd
|
||||||
|
|
@ -421,6 +421,7 @@ proc parseIdeCmd*(s: string): IdeCmd =
|
||||||
of "con": ideCon
|
of "con": ideCon
|
||||||
of "def": ideDef
|
of "def": ideDef
|
||||||
of "use": ideUse
|
of "use": ideUse
|
||||||
|
of "dus": ideDus
|
||||||
else: ideNone
|
else: ideNone
|
||||||
|
|
||||||
proc `$`*(c: IdeCmd): string =
|
proc `$`*(c: IdeCmd): string =
|
||||||
|
|
@ -429,4 +430,5 @@ proc `$`*(c: IdeCmd): string =
|
||||||
of ideCon: "con"
|
of ideCon: "con"
|
||||||
of ideDef: "def"
|
of ideDef: "def"
|
||||||
of ideUse: "use"
|
of ideUse: "use"
|
||||||
|
of ideDus: "dus"
|
||||||
of ideNone: "none"
|
of ideNone: "none"
|
||||||
|
|
|
||||||
|
|
@ -309,6 +309,10 @@ proc suggestSym*(info: TLineInfo; s: PSym) {.inline.} =
|
||||||
findUsages(info, s)
|
findUsages(info, s)
|
||||||
elif gIdeCmd == ideDef:
|
elif gIdeCmd == ideDef:
|
||||||
findDefinition(info, s)
|
findDefinition(info, s)
|
||||||
|
elif gIdeCmd == ideDus and s != nil:
|
||||||
|
if isTracked(info, s.name.s.len):
|
||||||
|
suggestResult(symToSuggest(s, isLocal=false, $ideDef))
|
||||||
|
findUsages(info, s)
|
||||||
|
|
||||||
proc markUsed(info: TLineInfo; s: PSym) =
|
proc markUsed(info: TLineInfo; s: PSym) =
|
||||||
incl(s.flags, sfUsed)
|
incl(s.flags, sfUsed)
|
||||||
|
|
@ -366,7 +370,7 @@ proc suggestExpr*(c: PContext, node: PNode) =
|
||||||
suggestCall(c, a, n, outputs)
|
suggestCall(c, a, n, outputs)
|
||||||
|
|
||||||
dec(c.compilesContextId)
|
dec(c.compilesContextId)
|
||||||
if outputs > 0 and gIdeCmd != ideUse: suggestQuit()
|
if outputs > 0 and gIdeCmd notin {ideUse, ideDus}: suggestQuit()
|
||||||
|
|
||||||
proc suggestStmt*(c: PContext, n: PNode) =
|
proc suggestStmt*(c: PContext, n: PNode) =
|
||||||
suggestExpr(c, n)
|
suggestExpr(c, n)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue