mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
Fix nimsuggest def being different on proc definition/use (#23025)
Currently the documentation isn't shown when running `def` on the definition of a proc (Which works for things like variables). `gcsafe`/`noSideEffects` status also isn't showing up when running `def` on the definition Images of current behavior. After PR both look like "Usage" **Definition**  **Usage**  Issue was the symbol getting passed too early to nimsuggest so it didn't have all that info, now gets passed once proc is fully semmed
This commit is contained in:
@@ -2153,7 +2153,9 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
||||
result = n
|
||||
checkMinSonsLen(n, bodyPos + 1, c.config)
|
||||
|
||||
let isAnon = n[namePos].kind == nkEmpty
|
||||
let
|
||||
isAnon = n[namePos].kind == nkEmpty
|
||||
isHighlight = c.config.ideCmd == ideHighlight
|
||||
|
||||
var s: PSym
|
||||
|
||||
@@ -2166,7 +2168,10 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
||||
s = n[namePos].sym
|
||||
s.owner = c.getCurrOwner
|
||||
else:
|
||||
s = semIdentDef(c, n[namePos], kind)
|
||||
# Highlighting needs to be done early so the position for
|
||||
# name isn't changed (see taccent_highlight). We don't want to check if this is the
|
||||
# defintion yet since we are missing some info (comments, side effects)
|
||||
s = semIdentDef(c, n[namePos], kind, reportToNimsuggest=isHighlight)
|
||||
n[namePos] = newSymNode(s)
|
||||
when false:
|
||||
# disable for now
|
||||
@@ -2413,6 +2418,11 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
|
||||
elif isTopLevel(c) and s.kind != skIterator and s.typ.callConv == ccClosure:
|
||||
localError(c.config, s.info, "'.closure' calling convention for top level routines is invalid")
|
||||
|
||||
# Prevent double highlights. We already highlighted before.
|
||||
# When not highlighting we still need to allow for suggestions though
|
||||
if not isHighlight:
|
||||
suggestSym(c.graph, s.info, s, c.graph.usageSym)
|
||||
|
||||
proc determineType(c: PContext, s: PSym) =
|
||||
if s.typ != nil: return
|
||||
#if s.magic != mNone: return
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
discard """
|
||||
$nimsuggest --tester $file
|
||||
>def $1
|
||||
def;;skProc;;tdef1.hello;;proc (): string{.noSideEffect, gcsafe.};;$file;;9;;5;;"Return hello";;100
|
||||
>def $1
|
||||
def;;skProc;;tdef1.hello;;proc (): string{.noSideEffect, gcsafe.};;$file;;9;;5;;"Return hello";;100
|
||||
def;;skProc;;tdef1.hello;;proc (): string{.noSideEffect, gcsafe.};;$file;;11;;5;;"Return hello";;100
|
||||
>def $2
|
||||
def;;skProc;;tdef1.hello;;proc (): string{.noSideEffect, gcsafe.};;$file;;11;;5;;"Return hello";;100
|
||||
>def $2
|
||||
def;;skProc;;tdef1.hello;;proc (): string{.noSideEffect, gcsafe.};;$file;;11;;5;;"Return hello";;100
|
||||
"""
|
||||
|
||||
proc hello(): string =
|
||||
proc hel#[!]#lo(): string =
|
||||
## Return hello
|
||||
"Hello"
|
||||
|
||||
|
||||
8
nimsuggest/tests/tsug_recursive.nim
Normal file
8
nimsuggest/tests/tsug_recursive.nim
Normal file
@@ -0,0 +1,8 @@
|
||||
discard """
|
||||
$nimsuggest --tester $file
|
||||
>sug $1
|
||||
sug;;skProc;;tsug_recursive.fooBar;;proc ();;$file;;7;;5;;"";;100;;Prefix
|
||||
"""
|
||||
|
||||
proc fooBar() =
|
||||
fooBa#[!]#
|
||||
Reference in New Issue
Block a user