bugfix: suggest feature

This commit is contained in:
Araq
2011-12-22 20:15:02 +01:00
parent cc490b35b0
commit 4012517d6d
2 changed files with 23 additions and 28 deletions

View File

@@ -263,15 +263,16 @@ proc exprList(p: var TParser, endTok: TTokType, result: PNode) =
optInd(p, a)
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 =
result = parseSymbol(p) #optInd(p, result);
if p.tok.tokType == tkDot:
getTok(p)
optInd(p, result)
var a = result
result = newNodeI(nkDotExpr, a.info)
addSon(result, a)
addSon(result, parseSymbol(p))
if p.tok.tokType == tkDot: result = newDotExpr(p, result)
proc qualifiedIdentListAux(p: var TParser, endTok: TTokType, result: PNode) =
getTok(p)
@@ -465,13 +466,8 @@ proc primary(p: var TParser): PNode =
result = newNodeP(nkCall, p)
addSon(result, a)
exprColonEqExprListAux(p, nkExprEqExpr, tkParRi, tkEquals, result)
of tkDot:
var a = result
result = newNodeP(nkDotExpr, p)
addSon(result, a)
getTok(p) # skip '.'
optInd(p, result)
addSon(result, parseSymbol(p))
of tkDot:
result = newDotExpr(p, result)
result = parseGStrLit(p, result)
of tkBracketLe:
result = indexExprList(p, result, nkBracketExpr, tkBracketRi)

View File

@@ -10,7 +10,8 @@
## This file implements features required for IDE support.
import
lexer, idents, ast, astalgo, semdata, msgs, types, sigmatch, options
lexer, idents, ast, astalgo, semdata, msgs, types, sigmatch, options,
renderer
const
sep = '\t'
@@ -150,27 +151,25 @@ proc suggestFieldAccess(c: PContext, n: PNode) =
else:
suggestOperations(c, n, typ)
proc findClosestDot(n: PNode): PNode =
if msgs.inCheckpoint(n.info) == cpExact:
proc findClosestDot(n: PNode): PNode =
if n.kind == nkDotExpr and msgs.inCheckpoint(n.info) == cpExact:
result = n
elif n.kind notin {nkNone..nkNilLit}:
for i in 0.. <sonsLen(n):
if n.sons[i].kind == nkDotExpr:
result = findClosestDot(n.sons[i])
if result != nil: return
else:
for i in 0.. <safeLen(n):
result = findClosestDot(n.sons[i])
if result != nil: return
const
CallNodes = {nkCall, nkInfix, nkPrefix, nkPostfix, nkCommand, nkCallStrLit,
nkMacroStmt}
proc findClosestCall(n: PNode): PNode =
if msgs.inCheckpoint(n.info) == cpExact:
if n.kind in callNodes and msgs.inCheckpoint(n.info) == cpExact:
result = n
elif n.kind notin {nkNone..nkNilLit}:
for i in 0.. <sonsLen(n):
if n.sons[i].kind in callNodes:
result = findClosestCall(n.sons[i])
if result != nil: return
else:
for i in 0.. <safeLen(n):
result = findClosestCall(n.sons[i])
if result != nil: return
proc findClosestSym(n: PNode): PNode =
if n.kind == nkSym and msgs.inCheckpoint(n.info) == cpExact: