bugfix: suggest feature
This commit is contained in:
parent
cc490b35b0
commit
4012517d6d
2 changed files with 23 additions and 28 deletions
|
|
@ -263,15 +263,16 @@ proc exprList(p: var TParser, endTok: TTokType, result: PNode) =
|
||||||
optInd(p, a)
|
optInd(p, a)
|
||||||
eat(p, endTok)
|
eat(p, endTok)
|
||||||
|
|
||||||
|
proc newDotExpr(p: var TParser, a: PNode): PNode =
|
||||||
|
getTok(p)
|
||||||
|
optInd(p, a)
|
||||||
|
result = newNodeI(nkDotExpr, a.info)
|
||||||
|
addSon(result, a)
|
||||||
|
addSon(result, parseSymbol(p))
|
||||||
|
|
||||||
proc qualifiedIdent(p: var TParser): PNode =
|
proc qualifiedIdent(p: var TParser): PNode =
|
||||||
result = parseSymbol(p) #optInd(p, result);
|
result = parseSymbol(p) #optInd(p, result);
|
||||||
if p.tok.tokType == tkDot:
|
if p.tok.tokType == tkDot: result = newDotExpr(p, result)
|
||||||
getTok(p)
|
|
||||||
optInd(p, result)
|
|
||||||
var a = result
|
|
||||||
result = newNodeI(nkDotExpr, a.info)
|
|
||||||
addSon(result, a)
|
|
||||||
addSon(result, parseSymbol(p))
|
|
||||||
|
|
||||||
proc qualifiedIdentListAux(p: var TParser, endTok: TTokType, result: PNode) =
|
proc qualifiedIdentListAux(p: var TParser, endTok: TTokType, result: PNode) =
|
||||||
getTok(p)
|
getTok(p)
|
||||||
|
|
@ -465,13 +466,8 @@ proc primary(p: var TParser): PNode =
|
||||||
result = newNodeP(nkCall, p)
|
result = newNodeP(nkCall, p)
|
||||||
addSon(result, a)
|
addSon(result, a)
|
||||||
exprColonEqExprListAux(p, nkExprEqExpr, tkParRi, tkEquals, result)
|
exprColonEqExprListAux(p, nkExprEqExpr, tkParRi, tkEquals, result)
|
||||||
of tkDot:
|
of tkDot:
|
||||||
var a = result
|
result = newDotExpr(p, result)
|
||||||
result = newNodeP(nkDotExpr, p)
|
|
||||||
addSon(result, a)
|
|
||||||
getTok(p) # skip '.'
|
|
||||||
optInd(p, result)
|
|
||||||
addSon(result, parseSymbol(p))
|
|
||||||
result = parseGStrLit(p, result)
|
result = parseGStrLit(p, result)
|
||||||
of tkBracketLe:
|
of tkBracketLe:
|
||||||
result = indexExprList(p, result, nkBracketExpr, tkBracketRi)
|
result = indexExprList(p, result, nkBracketExpr, tkBracketRi)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@
|
||||||
## This file implements features required for IDE support.
|
## This file implements features required for IDE support.
|
||||||
|
|
||||||
import
|
import
|
||||||
lexer, idents, ast, astalgo, semdata, msgs, types, sigmatch, options
|
lexer, idents, ast, astalgo, semdata, msgs, types, sigmatch, options,
|
||||||
|
renderer
|
||||||
|
|
||||||
const
|
const
|
||||||
sep = '\t'
|
sep = '\t'
|
||||||
|
|
@ -150,27 +151,25 @@ proc suggestFieldAccess(c: PContext, n: PNode) =
|
||||||
else:
|
else:
|
||||||
suggestOperations(c, n, typ)
|
suggestOperations(c, n, typ)
|
||||||
|
|
||||||
proc findClosestDot(n: PNode): PNode =
|
proc findClosestDot(n: PNode): PNode =
|
||||||
if msgs.inCheckpoint(n.info) == cpExact:
|
if n.kind == nkDotExpr and msgs.inCheckpoint(n.info) == cpExact:
|
||||||
result = n
|
result = n
|
||||||
elif n.kind notin {nkNone..nkNilLit}:
|
else:
|
||||||
for i in 0.. <sonsLen(n):
|
for i in 0.. <safeLen(n):
|
||||||
if n.sons[i].kind == nkDotExpr:
|
result = findClosestDot(n.sons[i])
|
||||||
result = findClosestDot(n.sons[i])
|
if result != nil: return
|
||||||
if result != nil: return
|
|
||||||
|
|
||||||
const
|
const
|
||||||
CallNodes = {nkCall, nkInfix, nkPrefix, nkPostfix, nkCommand, nkCallStrLit,
|
CallNodes = {nkCall, nkInfix, nkPrefix, nkPostfix, nkCommand, nkCallStrLit,
|
||||||
nkMacroStmt}
|
nkMacroStmt}
|
||||||
|
|
||||||
proc findClosestCall(n: PNode): PNode =
|
proc findClosestCall(n: PNode): PNode =
|
||||||
if msgs.inCheckpoint(n.info) == cpExact:
|
if n.kind in callNodes and msgs.inCheckpoint(n.info) == cpExact:
|
||||||
result = n
|
result = n
|
||||||
elif n.kind notin {nkNone..nkNilLit}:
|
else:
|
||||||
for i in 0.. <sonsLen(n):
|
for i in 0.. <safeLen(n):
|
||||||
if n.sons[i].kind in callNodes:
|
result = findClosestCall(n.sons[i])
|
||||||
result = findClosestCall(n.sons[i])
|
if result != nil: return
|
||||||
if result != nil: return
|
|
||||||
|
|
||||||
proc findClosestSym(n: PNode): PNode =
|
proc findClosestSym(n: PNode): PNode =
|
||||||
if n.kind == nkSym and msgs.inCheckpoint(n.info) == cpExact:
|
if n.kind == nkSym and msgs.inCheckpoint(n.info) == cpExact:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue