removed a few consts and rewired to IdeCmd

This commit is contained in:
Simon Hafner 2015-04-26 08:54:46 +05:00
commit 33edba665d
2 changed files with 28 additions and 18 deletions

View file

@ -16,15 +16,10 @@ import algorithm, sequtils, strutils, ast, msgs, options, renderer,
const
sep = '\t'
sectionSuggest = "sug"
sectionDef = "def"
sectionContext = "con"
sectionUsage = "use"
type
Section* = enum sug, def, con, use
Suggest* = object
section*: Section
section*: IdeCmd
qualifiedPath*: seq[string]
filePath*: string
line*: int # Starts at 1
@ -41,7 +36,7 @@ var
template origModuleName(m: PSym): string = m.name.s
proc symToSuggest(s: PSym, isLocal: bool, section: string, li: TLineInfo): Suggest =
result.section = parseEnum[Section](section)
result.section = parseIdeCmd(section)
if optIdeTerse in gGlobalOptions:
if s.kind in routineKinds:
result.symkind = parseEnum[TSymKind](renderTree(s.ast, {renderNoBody, renderNoComments,
@ -116,7 +111,7 @@ proc fieldVisible*(c: PContext, f: PSym): bool {.inline.} =
proc suggestField(c: PContext, s: PSym, outputs: var int) =
if filterSym(s) and fieldVisible(c, s):
suggestResult(symToSuggest(s, isLocal=true, sectionSuggest))
suggestResult(symToSuggest(s, isLocal=true, $ideSug))
inc outputs
template wholeSymTab(cond, section: expr) {.immediate.} =
@ -172,7 +167,7 @@ proc argsFit(c: PContext, candidate: PSym, n, nOrig: PNode): bool =
proc suggestCall(c: PContext, n, nOrig: PNode, outputs: var int) =
wholeSymTab(filterSym(it) and nameFits(c, it, n) and argsFit(c, it, n, nOrig),
sectionContext)
$ideCon)
proc typeFits(c: PContext, s: PSym, firstArg: PType): bool {.inline.} =
if s.typ != nil and sonsLen(s.typ) > 1 and s.typ.sons[1] != nil:
@ -189,7 +184,7 @@ proc typeFits(c: PContext, s: PSym, firstArg: PType): bool {.inline.} =
proc suggestOperations(c: PContext, n: PNode, typ: PType, outputs: var int) =
assert typ != nil
wholeSymTab(filterSymNoOpr(it) and typeFits(c, it, typ), sectionSuggest)
wholeSymTab(filterSymNoOpr(it) and typeFits(c, it, typ), $ideSug)
proc suggestEverything(c: PContext, n: PNode, outputs: var int) =
# do not produce too many symbols:
@ -198,7 +193,7 @@ proc suggestEverything(c: PContext, n: PNode, outputs: var int) =
if scope == c.topLevelScope: isLocal = false
for it in items(scope.symbols):
if filterSym(it):
suggestResult(symToSuggest(it, isLocal = isLocal, sectionSuggest))
suggestResult(symToSuggest(it, isLocal = isLocal, $ideSug))
inc outputs
if scope == c.topLevelScope: break
@ -213,12 +208,12 @@ proc suggestFieldAccess(c: PContext, n: PNode, outputs: var int) =
# all symbols accessible, because we are in the current module:
for it in items(c.topLevelScope.symbols):
if filterSym(it):
suggestResult(symToSuggest(it, isLocal=false, sectionSuggest))
suggestResult(symToSuggest(it, isLocal=false, $ideSug))
inc outputs
else:
for it in items(n.sym.tab):
if filterSym(it):
suggestResult(symToSuggest(it, isLocal=false, sectionSuggest))
suggestResult(symToSuggest(it, isLocal=false, $ideSug))
inc outputs
else:
# fallback:
@ -295,16 +290,16 @@ var
proc findUsages(info: TLineInfo; s: PSym) =
if usageSym == nil and isTracked(info, s.name.s.len):
usageSym = s
suggestResult(symToSuggest(s, isLocal=false, sectionUsage))
suggestResult(symToSuggest(s, isLocal=false, $ideUse))
elif s == usageSym:
if lastLineInfo != info:
suggestResult(symToSuggest(s, isLocal=false, sectionUsage, info))
suggestResult(symToSuggest(s, isLocal=false, $ideUse, info))
lastLineInfo = info
proc findDefinition(info: TLineInfo; s: PSym) =
if s.isNil: return
if isTracked(info, s.name.s.len):
suggestResult(symToSuggest(s, isLocal=false, sectionDef))
suggestResult(symToSuggest(s, isLocal=false, $ideDef))
suggestQuit()
proc ensureIdx[T](x: var T, y: int) =