[nimsuggest] fix def call on identifier 2 times on the line (#20228)

- apparently TLineInfo's implementation of `==` ignores the column. After I fixed
the code to use exact TLineInfo comparison I fixed several other issues hidden
by that issue.

- Replaced `tuple[sym, info]` with `SymInfoPair`
This commit is contained in:
Ivan Yonchovski 2022-08-30 22:02:15 +03:00 • committed by GitHub
commit d4c0d35b32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 76 additions and 48 deletions

View file

@ -503,7 +503,7 @@ proc suggestSym*(g: ModuleGraph; info: TLineInfo; s: PSym; usageSym: var PSym; i
## misnamed: should be 'symDeclared'
let conf = g.config
when defined(nimsuggest):
g.suggestSymbols.mgetOrPut(info.fileIndex, @[]).add (s, info)
g.suggestSymbols.mgetOrPut(info.fileIndex, @[]).add SymInfoPair(sym: s, info: info)
if conf.suggestVersion == 0:
if s.allUsages.len == 0:
@ -699,3 +699,16 @@ proc suggestSentinel*(c: PContext) =
dec(c.compilesContextId)
produceOutput(outputs, c.config)
when defined(nimsuggest):
proc onDef(graph: ModuleGraph, s: PSym, info: TLineInfo) =
if graph.config.suggestVersion == 3 and info.exactEquals(s.info):
suggestSym(graph, info, s, graph.usageSym)
template getPContext(): untyped =
when c is PContext: c
else: c.c
template onDef*(info: TLineInfo; s: PSym) =
let c = getPContext()
onDef(c.graph, s, info)