mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 01:44:37 +00:00
ugh, forgot to add rod/suggest.nim
This commit is contained in:
51
rod/suggest.nim
Normal file
51
rod/suggest.nim
Normal file
@@ -0,0 +1,51 @@
|
||||
#
|
||||
#
|
||||
# The Nimrod Compiler
|
||||
# (c) Copyright 2011 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## This file implements features required for IDE support.
|
||||
|
||||
import ast, astalgo, semdata, msgs, types
|
||||
|
||||
const
|
||||
sep = '\t'
|
||||
|
||||
proc SymToStr(s: PSym, isLocal: bool): string =
|
||||
result = ""
|
||||
result.add($s.kind)
|
||||
result.add(sep)
|
||||
if not isLocal:
|
||||
if s.kind != skModule and s.owner != nil:
|
||||
result.add(s.owner.name.s)
|
||||
result.add('.')
|
||||
result.add(s.name.s)
|
||||
result.add(sep)
|
||||
if s.typ != nil:
|
||||
result.add(typeToString(s.typ))
|
||||
result.add(sep)
|
||||
result.add(toFilename(s.info))
|
||||
result.add(sep)
|
||||
result.add($ToLinenumber(s.info))
|
||||
result.add(sep)
|
||||
result.add($ToColumn(s.info))
|
||||
|
||||
proc suggestExpr*(c: PContext, n: PNode) =
|
||||
if not msgs.inCheckpoint(n.info): return
|
||||
|
||||
for i in countdown(c.tab.tos-1, 0):
|
||||
for it in items(c.tab.stack[i]):
|
||||
MessageOut(SymToStr(it, i > ModuleTablePos))
|
||||
quit(0)
|
||||
|
||||
proc suggestStmt*(c: PContext, n: PNode) =
|
||||
suggestExpr(c, n)
|
||||
|
||||
|
||||
proc suggestFieldAccess*(c: PContext, n: PNode) =
|
||||
suggestExpr(c, n)
|
||||
# XXX provide a better implementation based on n[0].typ
|
||||
|
||||
Reference in New Issue
Block a user