bugfix: consider type contexts properly
This commit is contained in:
parent
0596c11775
commit
4d0d6c47bd
2 changed files with 42 additions and 33 deletions
|
|
@ -113,6 +113,7 @@ type
|
||||||
recursiveDep*: string
|
recursiveDep*: string
|
||||||
suggestionsMade*: bool
|
suggestionsMade*: bool
|
||||||
inTypeContext*: int
|
inTypeContext*: int
|
||||||
|
suggestionNode*: PNode
|
||||||
|
|
||||||
proc makeInstPair*(s: PSym, inst: PInstantiation): TInstantiationPair =
|
proc makeInstPair*(s: PSym, inst: PInstantiation): TInstantiationPair =
|
||||||
result.genericSym = s
|
result.genericSym = s
|
||||||
|
|
|
||||||
|
|
@ -525,16 +525,7 @@ proc safeSemExpr*(c: PContext, n: PNode): PNode =
|
||||||
except ERecoverableError:
|
except ERecoverableError:
|
||||||
result = ast.emptyNode
|
result = ast.emptyNode
|
||||||
|
|
||||||
proc suggestExpr*(c: PContext, node: PNode) =
|
proc sugExpr(c: PContext, node: PNode, outputs: var Suggestions; cp: TCheckPointResult) =
|
||||||
if gTrackPos.line < 0: return
|
|
||||||
var cp = inCheckpoint(node.info)
|
|
||||||
if cp == cpNone: return
|
|
||||||
# This keeps semExpr() from coming here recursively:
|
|
||||||
if c.compilesContextId > 0: return
|
|
||||||
inc(c.compilesContextId)
|
|
||||||
|
|
||||||
var outputs: Suggestions = @[]
|
|
||||||
if gIdeCmd == ideSug:
|
|
||||||
var n = findClosestDot(node)
|
var n = findClosestDot(node)
|
||||||
if n == nil: n = node
|
if n == nil: n = node
|
||||||
if n.kind == nkDotExpr:
|
if n.kind == nkDotExpr:
|
||||||
|
|
@ -556,6 +547,20 @@ proc suggestExpr*(c: PContext, node: PNode) =
|
||||||
let prefix = if cp == cpExact: n else: nil
|
let prefix = if cp == cpExact: n else: nil
|
||||||
suggestEverything(c, n, prefix, outputs)
|
suggestEverything(c, n, prefix, outputs)
|
||||||
|
|
||||||
|
proc suggestExpr*(c: PContext, node: PNode) =
|
||||||
|
if gTrackPos.line < 0: return
|
||||||
|
var cp = inCheckpoint(node.info)
|
||||||
|
if cp == cpNone: return
|
||||||
|
# This keeps semExpr() from coming here recursively:
|
||||||
|
if cp == cpFuzzy:
|
||||||
|
c.suggestionNode = node
|
||||||
|
return
|
||||||
|
|
||||||
|
if c.compilesContextId > 0: return
|
||||||
|
inc(c.compilesContextId)
|
||||||
|
var outputs: Suggestions = @[]
|
||||||
|
if gIdeCmd == ideSug:
|
||||||
|
sugExpr(c, node, outputs, cp)
|
||||||
elif gIdeCmd == ideCon:
|
elif gIdeCmd == ideCon:
|
||||||
var n = findClosestCall(node)
|
var n = findClosestCall(node)
|
||||||
if n == nil: n = node
|
if n == nil: n = node
|
||||||
|
|
@ -583,9 +588,12 @@ proc suggestSentinel*(c: PContext) =
|
||||||
if gIdeCmd != ideSug or c.module.position != gTrackPos.fileIndex: return
|
if gIdeCmd != ideSug or c.module.position != gTrackPos.fileIndex: return
|
||||||
if c.compilesContextId > 0: return
|
if c.compilesContextId > 0: return
|
||||||
inc(c.compilesContextId)
|
inc(c.compilesContextId)
|
||||||
|
var outputs: Suggestions = @[]
|
||||||
|
if c.suggestionNode != nil:
|
||||||
|
sugExpr(c, c.suggestionNode, outputs, cpExact)
|
||||||
|
else:
|
||||||
# suggest everything:
|
# suggest everything:
|
||||||
var isLocal = true
|
var isLocal = true
|
||||||
var outputs: Suggestions = @[]
|
|
||||||
var scopeN = 0
|
var scopeN = 0
|
||||||
for scope in walkScopes(c.currentScope):
|
for scope in walkScopes(c.currentScope):
|
||||||
if scope == c.topLevelScope: isLocal = false
|
if scope == c.topLevelScope: isLocal = false
|
||||||
|
|
@ -595,5 +603,5 @@ proc suggestSentinel*(c: PContext) =
|
||||||
if filterSymNoOpr(it, nil, pm):
|
if filterSymNoOpr(it, nil, pm):
|
||||||
outputs.add(symToSuggest(it, isLocal = isLocal, $ideSug, 0, PrefixMatch.None, false, scopeN))
|
outputs.add(symToSuggest(it, isLocal = isLocal, $ideSug, 0, PrefixMatch.None, false, scopeN))
|
||||||
|
|
||||||
produceOutput(outputs)
|
|
||||||
dec(c.compilesContextId)
|
dec(c.compilesContextId)
|
||||||
|
produceOutput(outputs)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue