nimsuggest: special rule for 'of' completion in case statements
This commit is contained in:
parent
c5566f7c37
commit
2430fc7d82
3 changed files with 28 additions and 1 deletions
|
|
@ -205,7 +205,8 @@ proc semCase(c: PContext, n: PNode): PNode =
|
|||
var typ = commonTypeBegin
|
||||
var hasElse = false
|
||||
var notOrdinal = false
|
||||
case skipTypes(n.sons[0].typ, abstractVarRange-{tyTypeDesc}).kind
|
||||
let caseTyp = skipTypes(n.sons[0].typ, abstractVarRange-{tyTypeDesc})
|
||||
case caseTyp.kind
|
||||
of tyInt..tyInt64, tyChar, tyEnum, tyUInt..tyUInt32, tyBool:
|
||||
chckCovered = true
|
||||
of tyFloat..tyFloat128, tyString, tyError:
|
||||
|
|
@ -215,6 +216,9 @@ proc semCase(c: PContext, n: PNode): PNode =
|
|||
return
|
||||
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:
|
||||
suggestEnum(c, x, caseTyp)
|
||||
case x.kind
|
||||
of nkOfBranch:
|
||||
checkMinSonsLen(x, 2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue