nimsuggest: track type contexts
This commit is contained in:
parent
936ed9721b
commit
ee13c8014b
3 changed files with 12 additions and 2 deletions
|
|
@ -112,6 +112,7 @@ type
|
||||||
signatures*: TStrTable
|
signatures*: TStrTable
|
||||||
recursiveDep*: string
|
recursiveDep*: string
|
||||||
suggestionsMade*: bool
|
suggestionsMade*: bool
|
||||||
|
inTypeContext*: int
|
||||||
|
|
||||||
proc makeInstPair*(s: PSym, inst: PInstantiation): TInstantiationPair =
|
proc makeInstPair*(s: PSym, inst: PInstantiation): TInstantiationPair =
|
||||||
result.genericSym = s
|
result.genericSym = s
|
||||||
|
|
|
||||||
|
|
@ -1169,6 +1169,8 @@ proc fixupTypeOf(c: PContext, prev: PType, typExpr: PNode) =
|
||||||
|
|
||||||
proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||||
result = nil
|
result = nil
|
||||||
|
when defined(nimsuggest):
|
||||||
|
inc c.inTypeContext
|
||||||
|
|
||||||
if gCmd == cmdIdeTools: suggestExpr(c, n)
|
if gCmd == cmdIdeTools: suggestExpr(c, n)
|
||||||
case n.kind
|
case n.kind
|
||||||
|
|
@ -1374,6 +1376,8 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||||
localError(n.info, errTypeExpected)
|
localError(n.info, errTypeExpected)
|
||||||
result = newOrPrevType(tyError, prev, c)
|
result = newOrPrevType(tyError, prev, c)
|
||||||
n.typ = result
|
n.typ = result
|
||||||
|
when defined(nimsuggest):
|
||||||
|
dec c.inTypeContext
|
||||||
|
|
||||||
proc setMagicType(m: PSym, kind: TTypeKind, size: int) =
|
proc setMagicType(m: PSym, kind: TTypeKind, size: int) =
|
||||||
m.typ.kind = kind
|
m.typ.kind = kind
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,13 @@
|
||||||
## - If there is a prefix (foo|), symbols starting with this prefix come first.
|
## - If there is a prefix (foo|), symbols starting with this prefix come first.
|
||||||
## - If the prefix is part of the name (but the name doesn't start with it),
|
## - If the prefix is part of the name (but the name doesn't start with it),
|
||||||
## these symbols come second.
|
## these symbols come second.
|
||||||
## - Otherwise consider the context. We currently distinguish between type
|
## - If we have a prefix, only symbols matching this prefix are returned and
|
||||||
## and non-type contexts.
|
## nothing else.
|
||||||
|
## - If we have no prefix, consider the context. We currently distinguish
|
||||||
|
## between type and non-type contexts.
|
||||||
|
## - Finally, sort matches by relevance. The relevance is determined by the
|
||||||
|
## number of usages, so ``strutils.replace`` comes before
|
||||||
|
## ``strutils.wordWrap``.
|
||||||
|
|
||||||
# included from sigmatch.nim
|
# included from sigmatch.nim
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue