summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-07-30 15:19:58 +0200
committerAraq <rumpf_a@web.de>2011-07-30 15:19:58 +0200
commit2d62738bbb5e7a664fab3f7a49313b5fb839a47c (patch)
tree5da1e6689d4ce081b9c1b9e621cdaff4d3552358 /compiler
parent086f0d34dbcd6e2333a8f25d313f2431ad5acaa3 (diff)
downloadNim-2d62738bbb5e7a664fab3f7a49313b5fb839a47c.tar.gz
attempt to improve 'suggest' feature
Diffstat (limited to 'compiler')
-rwxr-xr-xcompiler/semstmts.nim8
-rwxr-xr-xcompiler/suggest.nim11
2 files changed, 11 insertions, 8 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 553989c40..52fc2ea31 100755
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -499,8 +499,8 @@ proc typeSectionFinalPass(c: PContext, n: PNode) =
   for i in countup(0, sonsLen(n) - 1): 
     var a = n.sons[i]
     if a.kind == nkCommentStmt: continue 
-    if (a.sons[0].kind != nkSym): IllFormedAst(a)
-    var s = a.sons[0].sym         
+    if a.sons[0].kind != nkSym: IllFormedAst(a)
+    var s = a.sons[0].sym
     # compute the type's size and check for illegal recursions:
     if a.sons[1].kind == nkEmpty: 
       if a.sons[2].kind in {nkSym, nkIdent, nkAccQuoted}:
@@ -563,7 +563,7 @@ proc semLambda(c: PContext, n: PNode): PNode =
   n.sons[namePos] = newSymNode(s)
   pushOwner(s)
   openScope(c.tab)
-  if (n.sons[genericParamsPos].kind != nkEmpty): 
+  if n.sons[genericParamsPos].kind != nkEmpty:
     illFormedAst(n)           # process parameters:
   if n.sons[paramsPos].kind != nkEmpty: 
     semParamList(c, n.sons[ParamsPos], nil, s)
@@ -651,7 +651,7 @@ proc semProcAux(c: PContext, n: PNode, kind: TSymKind,
     s = proto
     n.sons[genericParamsPos] = proto.ast.sons[genericParamsPos]
     n.sons[paramsPos] = proto.ast.sons[paramsPos]
-    if (n.sons[namePos].kind != nkSym): InternalError(n.info, "semProcAux")
+    if n.sons[namePos].kind != nkSym: InternalError(n.info, "semProcAux")
     n.sons[namePos].sym = proto
     proto.ast = n             # needed for code generation
     popOwner()
diff --git a/compiler/suggest.nim b/compiler/suggest.nim
index b16c4eba7..86d91bc1c 100755
--- a/compiler/suggest.nim
+++ b/compiler/suggest.nim
@@ -102,8 +102,12 @@ proc suggestOperations(c: PContext, n: PNode, typ: PType) =
   assert typ != nil
   wholeSymTab(filterSym(it) and typeFits(c, it, typ), sectionSuggest)
 
-proc suggestEverything(c: PContext, n: PNode) = 
-  wholeSymTab(filterSym(it), sectionSuggest)
+proc suggestEverything(c: PContext, n: PNode) =
+  # do not produce too many symbols:
+  for i in countdown(c.tab.tos-1, 1):
+    for it in items(c.tab.stack[i]):
+      if filterSym(it):
+        OutWriteln(SymToStr(it, isLocal = i > ModuleTablePos, sectionSuggest))
 
 proc suggestFieldAccess(c: PContext, n: PNode) =
   # special code that deals with ``myObj.``. `n` is NOT the nkDotExpr-node, but
@@ -144,8 +148,7 @@ proc suggestFieldAccess(c: PContext, n: PNode) =
       suggestSymList(typ.n)
       suggestOperations(c, n, typ)
     else:
-      # fallback: 
-      suggestEverything(c, n)
+      suggestOperations(c, n, typ)
 
 proc findClosestDot(n: PNode): PNode = 
   if msgs.inCheckpoint(n.info) == cpExact: