fixes nimsuggest issue #44
This commit is contained in:
parent
ca0b16fd33
commit
0b93db5a7c
2 changed files with 19 additions and 3 deletions
|
|
@ -268,6 +268,7 @@ proc suggestFieldAccess(c: PContext, n: PNode, outputs: var int) =
|
||||||
t = t.sons[0]
|
t = t.sons[0]
|
||||||
suggestOperations(c, n, typ, outputs)
|
suggestOperations(c, n, typ, outputs)
|
||||||
else:
|
else:
|
||||||
|
let orig = skipTypes(typ, {tyGenericInst, tyAlias})
|
||||||
typ = skipTypes(typ, {tyGenericInst, tyVar, tyPtr, tyRef, tyAlias})
|
typ = skipTypes(typ, {tyGenericInst, tyVar, tyPtr, tyRef, tyAlias})
|
||||||
if typ.kind == tyObject:
|
if typ.kind == tyObject:
|
||||||
var t = typ
|
var t = typ
|
||||||
|
|
@ -275,11 +276,10 @@ proc suggestFieldAccess(c: PContext, n: PNode, outputs: var int) =
|
||||||
suggestObject(c, t.n, outputs)
|
suggestObject(c, t.n, outputs)
|
||||||
if t.sons[0] == nil: break
|
if t.sons[0] == nil: break
|
||||||
t = skipTypes(t.sons[0], skipPtrs)
|
t = skipTypes(t.sons[0], skipPtrs)
|
||||||
suggestOperations(c, n, typ, outputs)
|
|
||||||
elif typ.kind == tyTuple and typ.n != nil:
|
elif typ.kind == tyTuple and typ.n != nil:
|
||||||
suggestSymList(c, typ.n, outputs)
|
suggestSymList(c, typ.n, outputs)
|
||||||
suggestOperations(c, n, typ, outputs)
|
suggestOperations(c, n, orig, outputs)
|
||||||
else:
|
if typ != orig:
|
||||||
suggestOperations(c, n, typ, outputs)
|
suggestOperations(c, n, typ, outputs)
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -331,6 +331,8 @@ when defined(nimsuggest):
|
||||||
info.fileIndex + info.line.int64 shl 32 + info.col.int64 shl 48
|
info.fileIndex + info.line.int64 shl 32 + info.col.int64 shl 48
|
||||||
|
|
||||||
proc addNoDup(s: PSym; info: TLineInfo) =
|
proc addNoDup(s: PSym; info: TLineInfo) =
|
||||||
|
# ensure nothing gets too slow:
|
||||||
|
if s.allUsages.len > 500: return
|
||||||
let infoAsInt = info.infoToInt
|
let infoAsInt = info.infoToInt
|
||||||
for infoB in s.allUsages:
|
for infoB in s.allUsages:
|
||||||
if infoB.infoToInt == infoAsInt: return
|
if infoB.infoToInt == infoAsInt: return
|
||||||
|
|
|
||||||
14
tools/nimsuggest/tests/tno_deref.nim
Normal file
14
tools/nimsuggest/tests/tno_deref.nim
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
var x: ptr int
|
||||||
|
|
||||||
|
proc foo(y: ptr int) =
|
||||||
|
discard
|
||||||
|
|
||||||
|
x.#[!]#
|
||||||
|
|
||||||
|
discard """
|
||||||
|
$nimsuggest --tester $file
|
||||||
|
>sug $1
|
||||||
|
sug;;skProc;;tno_deref.foo;;proc (y: ptr int)*;;$file;;4;;5;;"";;100
|
||||||
|
*
|
||||||
|
"""
|
||||||
Loading…
Add table
Add a link
Reference in a new issue