diff options
author | Ivan Yonchovski <yyoncho@users.noreply.github.com> | 2022-10-06 08:18:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-06 07:18:46 +0200 |
commit | 7caa0379366a500b5db11922d3ac1e739dd5dea1 (patch) | |
tree | b62734791211da5a56fda007d7965e5c6e1661bf /compiler | |
parent | 723a71bd229cad3498f01c3095a10cf9f6c3255d (diff) | |
download | Nim-7caa0379366a500b5db11922d3ac1e739dd5dea1.tar.gz |
Fix/improve handling of forward declarations in nimsuggest (#20493)
* Fix/improve handling of forward declarations in nimsuggest - ideUse now works fine when invoked on the implementation - implemented ideDeclaration to make cover lsp feature textDocument/declaration - fixed performance issue related to deduplicating symbols. Now the deduplication happens after the symbols are filtered. As a alternative we might change the way cached symbols are stored(e. g. use set). - I also fixed the way globalSymbols work. Now it will sort the responses based on the match location to make sure that the results are sorted in user friendly way. * Update nimsuggest/nimsuggest.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de> Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/modulegraphs.nim | 4 | ||||
-rw-r--r-- | compiler/options.nim | 3 | ||||
-rw-r--r-- | compiler/suggest.nim | 2 |
3 files changed, 5 insertions, 4 deletions
diff --git a/compiler/modulegraphs.nim b/compiler/modulegraphs.nim index 0df72c43b..9fa530a47 100644 --- a/compiler/modulegraphs.nim +++ b/compiler/modulegraphs.nim @@ -643,11 +643,11 @@ proc `==`*(a, b: SymInfoPair): bool = result = a.sym == b.sym and a.info.exactEquals(b.info) proc fileSymbols*(graph: ModuleGraph, fileIdx: FileIndex): seq[SymInfoPair] = - result = graph.suggestSymbols.getOrDefault(fileIdx, @[]).deduplicate + result = graph.suggestSymbols.getOrDefault(fileIdx, @[]) iterator suggestSymbolsIter*(g: ModuleGraph): SymInfoPair = for xs in g.suggestSymbols.values: - for x in xs.deduplicate: + for x in xs: yield x iterator suggestErrorsIter*(g: ModuleGraph): Suggest = diff --git a/compiler/options.nim b/compiler/options.nim index d52b1cdef..94776cc59 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -192,7 +192,7 @@ type IdeCmd* = enum ideNone, ideSug, ideCon, ideDef, ideUse, ideDus, ideChk, ideChkFile, ideMod, ideHighlight, ideOutline, ideKnown, ideMsg, ideProject, ideGlobalSymbols, - ideRecompile, ideChanged, ideType + ideRecompile, ideChanged, ideType, ideDeclaration Feature* = enum ## experimental features; DO NOT RENAME THESE! implicitDeref, @@ -1026,6 +1026,7 @@ proc `$`*(c: IdeCmd): string = of ideMsg: "msg" of ideProject: "project" of ideGlobalSymbols: "globalSymbols" + of ideDeclaration: "declaration" of ideRecompile: "recompile" of ideChanged: "changed" of ideType: "type" diff --git a/compiler/suggest.nim b/compiler/suggest.nim index 9d4089707..b5f787296 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -164,7 +164,7 @@ proc symToSuggest*(g: ModuleGraph; s: PSym, isLocal: bool, section: IdeCmd, info result.tokenLen = 0 else: let infox = - if useSuppliedInfo or section in {ideUse, ideHighlight, ideOutline}: + if useSuppliedInfo or section in {ideUse, ideHighlight, ideOutline, ideDeclaration}: info else: s.info |