summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xcompiler/parser.nim24
-rwxr-xr-xcompiler/suggest.nim27
2 files changed, 23 insertions, 28 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim
index e3bf3a748..ab715f029 100755
--- a/compiler/parser.nim
+++ b/compiler/parser.nim
@@ -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)
diff --git a/compiler/suggest.nim b/compiler/suggest.nim
index 86d91bc1c..971ff4d32 100755
--- a/compiler/suggest.nim
+++ b/compiler/suggest.nim
@@ -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: