diff options
author | Simon Hafner <hafnersimon@gmail.com> | 2015-04-22 06:15:52 +0500 |
---|---|---|
committer | Simon Hafner <hafnersimon@gmail.com> | 2015-04-22 06:15:52 +0500 |
commit | b01b7675abdbf9814b8c1b05a7df4c05b113e6e6 (patch) | |
tree | 297b72938280989fdc06f311abf694b88a168955 /compiler | |
parent | 766b7ea61d74532ede74e0aea59b2cda3400cfed (diff) | |
download | Nim-b01b7675abdbf9814b8c1b05a7df4c05b113e6e6.tar.gz |
parseEnum ftw
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/suggest.nim | 44 |
1 files changed, 4 insertions, 40 deletions
diff --git a/compiler/suggest.nim b/compiler/suggest.nim index 072145a70..97d0b51c2 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -11,7 +11,7 @@ # included from sigmatch.nim -import algorithm, sequtils +import algorithm, sequtils, strutils const sep = '\t' @@ -39,50 +39,14 @@ var template origModuleName(m: PSym): string = m.name.s -proc parseSection(s: string): Section = - case s: - of "sug": result = sug - of "con": result = con - of "use": result = use - of "def": result = def - else: raise newException(ERecoverableError, "Answer type incorrect") - -proc parseSymKind(s: string): TSymKind = - case s: - of "skDynLib": result = skDynLib - of "skParam": result = skParam - of "skGenericParam": result = skGenericParam - of "skTemp": result = skTemp - of "skModule": result = skModule - of "skType": result = skType - of "skVar": result = skVar - of "skLet": result = skLet - of "skConst": result = skConst - of "skResult": result = skResult - of "skProc": result = skProc - of "skMethod": result = skMethod - of "skIterator": result = skIterator - of "skClosureIterator": result = skClosureIterator - of "skConverter": result = skConverter - of "skMacro": result = skMacro - of "skTemplate": result = skTemplate - of "skField": result = skField - of "skEnumField": result = skEnumField - of "skForVar": result = skForVar - of "skLabel": result = skLabel - of "skStub": result = skStub - of "skPackage": result = skPackage - of "skAlias": result = skAlias - else: raise newException(ERecoverableError, "TSymKind not found") - proc symToSuggest(s: PSym, isLocal: bool, section: string, li: TLineInfo): Suggest = - result.section = parseSection(section) + result.section = parseEnum[Section](section) if optIdeTerse in gGlobalOptions: if s.kind in routineKinds: - result.symkind = parseSymKind(renderTree(s.ast, {renderNoBody, renderNoComments, + result.symkind = parseEnum[TSymKind](renderTree(s.ast, {renderNoBody, renderNoComments, renderDocComments, renderNoPragmas})) else: - result.symkind = parseSymKind(s.name.s) + result.symkind = parseEnum[TSymKind](s.name.s) result.filePath = toFullPath(li) result.line = toLinenumber(li) result.column = toColumn(li) |