From b803c20c16dd78f5ffcfd84fe1f462fdb54d3327 Mon Sep 17 00:00:00 2001 From: Ivan Yonchovski Date: Tue, 24 May 2022 22:29:41 +0300 Subject: [PATCH 1/7] Initial implementation of nimsuggest v3 Rework `nimsuggest` to use caching to make usage of ide commands more efficient. Previously, all commands no matter what the state of the process is were causing clean build. In the context of Language Server Protocol(LSP) and lsp clients this was causing perf issues and overall instability. Overall, the goal of v3 is to fit to LSP Server needs - added two new commands: - `recompile` to do clean compilation - `changed` which can be used by the IDEs to notify that a particular file has been changed. The later can be utilized when using LSP file watches. - `globalSymbols` - searching global references - added `segfaults` dependency to allow fallback to clean build when incremental fails. I wish the error to be propagated to the client so we can work on fixing the incremental build failures (typically hitting pointer) - more efficient rebuild flow. ATM incremental rebuild is triggered when the command needs that(i. e. it is global) while the commands that work on the current source rebuild only it Things missing in this PR: - Documentation - Extensive unit testing. Although functional I still see this more as a POC that this approach can work. Next steps: - Implement `sug` request. - Rework/extend the protocol to allow better client/server communication. Ideally we will need push events, diagnostics should be restructored to allow per file notifications, etc. - implement v3 test suite. - better logging --- compiler/modulegraphs.nim | 81 ++++++-- compiler/options.nim | 9 +- compiler/passes.nim | 7 +- compiler/suggest.nim | 11 +- nimsuggest/nimsuggest.nim | 185 +++++++++++++++++- nimsuggest/tester.nim | 5 +- nimsuggest/tests/fixtures/nimble.nim | 7 + .../tests/fixtures/packageinfotypes.nim | 3 + .../tests/tuse_def_struct_two_files.nim | 9 + 9 files changed, 292 insertions(+), 25 deletions(-) create mode 100644 nimsuggest/tests/fixtures/nimble.nim create mode 100644 nimsuggest/tests/fixtures/packageinfotypes.nim create mode 100644 nimsuggest/tests/tuse_def_struct_two_files.nim diff --git a/compiler/modulegraphs.nim b/compiler/modulegraphs.nim index 1473819104aab..38053aec0190c 100644 --- a/compiler/modulegraphs.nim +++ b/compiler/modulegraphs.nim @@ -11,7 +11,7 @@ ## represents a complete Nim project. Single modules can either be kept in RAM ## or stored in a rod-file. -import intsets, tables, hashes, md5_old +import intsets, tables, hashes, md5_old, sequtils import ast, astalgo, options, lineinfos,idents, btrees, ropes, msgs, pathutils, packages import ic / [packed_ast, ic] @@ -83,6 +83,8 @@ type doStopCompile*: proc(): bool {.closure.} usageSym*: PSym # for nimsuggest owners*: seq[PSym] + suggestSymbols*: Table[FileIndex, seq[tuple[sym: PSym, info: TLineInfo]]] + suggestErrors*: Table[FileIndex, seq[Suggest]] methods*: seq[tuple[methods: seq[PSym], dispatcher: PSym]] # needs serialization! systemModule*: PSym sysTypes*: array[TTypeKind, PType] @@ -385,9 +387,20 @@ when defined(nimfind): c.graph.onDefinitionResolveForward(c.graph, s, info) else: - template onUse*(info: TLineInfo; s: PSym) = discard - template onDef*(info: TLineInfo; s: PSym) = discard - template onDefResolveForward*(info: TLineInfo; s: PSym) = discard + when defined(nimsuggest): + template onUse*(info: TLineInfo; s: PSym) = discard + + template onDef*(info: TLineInfo; s: PSym) = + let c = getPContext() + if c.graph.config.suggestVersion == 3 and + not c.graph.suggestSymbols.getOrDefault(info.fileIndex, @[]).contains (s, info): + suggestSym(c.graph, info, s, c.graph.usageSym) + + template onDefResolveForward*(info: TLineInfo; s: PSym) = discard + else: + template onUse*(info: TLineInfo; s: PSym) = discard + template onDef*(info: TLineInfo; s: PSym) = discard + template onDefResolveForward*(info: TLineInfo; s: PSym) = discard proc stopCompile*(g: ModuleGraph): bool {.inline.} = result = g.doStopCompile != nil and g.doStopCompile() @@ -434,8 +447,7 @@ proc initOperators*(g: ModuleGraph): Operators = result.opNot = createMagic(g, "not", mNot) result.opContains = createMagic(g, "contains", mInSet) -proc newModuleGraph*(cache: IdentCache; config: ConfigRef): ModuleGraph = - result = ModuleGraph() +proc initModuleGraphFields(result: ModuleGraph) = # A module ID of -1 means that the symbol is not attached to a module at all, # but to the module graph: result.idgen = IdGenerator(module: -1'i32, symId: 0'i32, typeId: 0'i32) @@ -445,9 +457,9 @@ proc newModuleGraph*(cache: IdentCache; config: ConfigRef): ModuleGraph = result.ifaces = @[] result.importStack = @[] result.inclToMod = initTable[FileIndex, FileIndex]() - result.config = config - result.cache = cache result.owners = @[] + result.suggestSymbols = initTable[FileIndex, seq[tuple[sym: PSym, info: TLineInfo]]]() + result.suggestErrors = initTable[FileIndex, seq[Suggest]]() result.methods = @[] initStrTable(result.compilerprocs) initStrTable(result.exposed) @@ -461,6 +473,12 @@ proc newModuleGraph*(cache: IdentCache; config: ConfigRef): ModuleGraph = result.operators = initOperators(result) result.emittedTypeInfo = initTable[string, FileIndex]() +proc newModuleGraph*(cache: IdentCache; config: ConfigRef): ModuleGraph = + result = ModuleGraph() + result.config = config + result.cache = cache + initModuleGraphFields(result) + proc resetAllModules*(g: ModuleGraph) = initStrTable(g.packageSyms) g.deps = initIntSet() @@ -472,6 +490,7 @@ proc resetAllModules*(g: ModuleGraph) = g.methods = @[] initStrTable(g.compilerprocs) initStrTable(g.exposed) + initModuleGraphFields(g) proc getModule*(g: ModuleGraph; fileIdx: FileIndex): PSym = if fileIdx.int32 >= 0: @@ -550,7 +569,19 @@ proc transitiveClosure(g: var IntSet; n: int) = proc markDirty*(g: ModuleGraph; fileIdx: FileIndex) = let m = g.getModule fileIdx - if m != nil: incl m.flags, sfDirty + if m != nil: + g.suggestSymbols.del(fileIdx) + g.suggestErrors.del(fileIdx) + incl m.flags, sfDirty + +proc unmarkAllDirty*(g: ModuleGraph) = + for i in 0i32.. 100: + break + else: + # TODO ideSug + discard + +# v3 end when isMainModule: handleCmdLine(newIdentCache(), newConfigRef()) else: diff --git a/nimsuggest/tester.nim b/nimsuggest/tester.nim index 1db33706ab7a3..fea0a8d45b7e2 100644 --- a/nimsuggest/tester.nim +++ b/nimsuggest/tester.nim @@ -252,7 +252,10 @@ proc runEpcTest(filename: string): int = for cmd in s.startup: if not runCmd(cmd, s.dest): quit "invalid command: " & cmd - let epccmd = s.cmd.replace("--tester", "--epc --v2 --log") + let epccmd = if s.cmd.contains("--v3"): + s.cmd.replace("--tester", "--epc --log") + else: + s.cmd.replace("--tester", "--epc --v2 --log") let cl = parseCmdLine(epccmd) var p = startProcess(command=cl[0], args=cl[1 .. ^1], options={poStdErrToStdOut, poUsePath, diff --git a/nimsuggest/tests/fixtures/nimble.nim b/nimsuggest/tests/fixtures/nimble.nim new file mode 100644 index 0000000000000..d147909318bdf --- /dev/null +++ b/nimsuggest/tests/fixtures/nimble.nim @@ -0,0 +1,7 @@ +import packageinfotypes +import options + +proc a(nnnnnnnnn: Option[PackageInfo]) = + echo nnnnnnnnn.get.isMinimal + let b = nnnnnnnnn.get.isMinimal + echo b diff --git a/nimsuggest/tests/fixtures/packageinfotypes.nim b/nimsuggest/tests/fixtures/packageinfotypes.nim new file mode 100644 index 0000000000000..dd1d62f8422d1 --- /dev/null +++ b/nimsuggest/tests/fixtures/packageinfotypes.nim @@ -0,0 +1,3 @@ +type + PackageInfo* = object + isMinimal*: string diff --git a/nimsuggest/tests/tuse_def_struct_two_files.nim b/nimsuggest/tests/tuse_def_struct_two_files.nim new file mode 100644 index 0000000000000..a8e04dd346493 --- /dev/null +++ b/nimsuggest/tests/tuse_def_struct_two_files.nim @@ -0,0 +1,9 @@ +# Test def with type definition in separate file + +discard """ +$nimsuggest --v3 --tester /home/yyoncho/Sources/nim/Nim/nimsuggest/tests/fixtures/nimble.nim +>use /home/yyoncho/Sources/nim/Nim/nimsuggest/tests/fixtures/packageinfotypes.nim:3:4 +def skField packageinfotypes.PackageInfo.isMinimal string /home/yyoncho/Sources/nim/Nim/nimsuggest/tests/fixtures/packageinfotypes.nim 3 4 "" 100 +use skField packageinfotypes.PackageInfo.isMinimal string /home/yyoncho/Sources/nim/Nim/nimsuggest/tests/fixtures/nimble.nim 5 21 "" 100 +use skField packageinfotypes.PackageInfo.isMinimal string /home/yyoncho/Sources/nim/Nim/nimsuggest/tests/fixtures/nimble.nim 6 24 "" 100 +""" From 66ef857373975f5716cfab3bb88c014e89ab8ad9 Mon Sep 17 00:00:00 2001 From: Ivan Yonchovski Date: Tue, 31 May 2022 09:36:28 +0300 Subject: [PATCH 2/7] Add tests for v3 and implement ideSug --- compiler/modulegraphs.nim | 7 +- compiler/suggest.nim | 4 +- nimsuggest/nimsuggest.nim | 174 +++++++++++------- nimsuggest/tests/fixtures/nimble.nim | 7 - .../tests/fixtures/packageinfotypes.nim | 3 - .../tests/tuse_def_struct_two_files.nim | 9 - nimsuggest/tests/tv3.nim | 25 +++ 7 files changed, 134 insertions(+), 95 deletions(-) delete mode 100644 nimsuggest/tests/fixtures/nimble.nim delete mode 100644 nimsuggest/tests/fixtures/packageinfotypes.nim delete mode 100644 nimsuggest/tests/tuse_def_struct_two_files.nim create mode 100644 nimsuggest/tests/tv3.nim diff --git a/compiler/modulegraphs.nim b/compiler/modulegraphs.nim index 38053aec0190c..fc3df4dfe56d3 100644 --- a/compiler/modulegraphs.nim +++ b/compiler/modulegraphs.nim @@ -392,8 +392,7 @@ else: template onDef*(info: TLineInfo; s: PSym) = let c = getPContext() - if c.graph.config.suggestVersion == 3 and - not c.graph.suggestSymbols.getOrDefault(info.fileIndex, @[]).contains (s, info): + if c.graph.config.suggestVersion == 3: suggestSym(c.graph, info, s, c.graph.usageSym) template onDefResolveForward*(info: TLineInfo; s: PSym) = discard @@ -605,8 +604,8 @@ proc needsCompilation*(g: ModuleGraph): bool = return true proc needsCompilation*(g: ModuleGraph, fileIdx: FileIndex): bool = - let module = g.ifaces[fileIdx.int32].module - if module == nil or g.isDirty(module): + let module = g.getModule(fileIdx) + if module != nil and g.isDirty(module): return true for i in 0i32.. 100: break else: - # TODO ideSug - discard + myLog fmt "Discarding {cmd}" # v3 end when isMainModule: diff --git a/nimsuggest/tests/fixtures/nimble.nim b/nimsuggest/tests/fixtures/nimble.nim deleted file mode 100644 index d147909318bdf..0000000000000 --- a/nimsuggest/tests/fixtures/nimble.nim +++ /dev/null @@ -1,7 +0,0 @@ -import packageinfotypes -import options - -proc a(nnnnnnnnn: Option[PackageInfo]) = - echo nnnnnnnnn.get.isMinimal - let b = nnnnnnnnn.get.isMinimal - echo b diff --git a/nimsuggest/tests/fixtures/packageinfotypes.nim b/nimsuggest/tests/fixtures/packageinfotypes.nim deleted file mode 100644 index dd1d62f8422d1..0000000000000 --- a/nimsuggest/tests/fixtures/packageinfotypes.nim +++ /dev/null @@ -1,3 +0,0 @@ -type - PackageInfo* = object - isMinimal*: string diff --git a/nimsuggest/tests/tuse_def_struct_two_files.nim b/nimsuggest/tests/tuse_def_struct_two_files.nim deleted file mode 100644 index a8e04dd346493..0000000000000 --- a/nimsuggest/tests/tuse_def_struct_two_files.nim +++ /dev/null @@ -1,9 +0,0 @@ -# Test def with type definition in separate file - -discard """ -$nimsuggest --v3 --tester /home/yyoncho/Sources/nim/Nim/nimsuggest/tests/fixtures/nimble.nim ->use /home/yyoncho/Sources/nim/Nim/nimsuggest/tests/fixtures/packageinfotypes.nim:3:4 -def skField packageinfotypes.PackageInfo.isMinimal string /home/yyoncho/Sources/nim/Nim/nimsuggest/tests/fixtures/packageinfotypes.nim 3 4 "" 100 -use skField packageinfotypes.PackageInfo.isMinimal string /home/yyoncho/Sources/nim/Nim/nimsuggest/tests/fixtures/nimble.nim 5 21 "" 100 -use skField packageinfotypes.PackageInfo.isMinimal string /home/yyoncho/Sources/nim/Nim/nimsuggest/tests/fixtures/nimble.nim 6 24 "" 100 -""" diff --git a/nimsuggest/tests/tv3.nim b/nimsuggest/tests/tv3.nim new file mode 100644 index 0000000000000..99caa987bbd63 --- /dev/null +++ b/nimsuggest/tests/tv3.nim @@ -0,0 +1,25 @@ +# tests v3 + +type + Foo* = ref object of RootObj + bar*: string + +proc test(f: Foo) = + echo f.ba#[!]#r + +discard """ +$nimsuggest --v3 --tester $file +>use $1 +def skField tv3.Foo.bar string $file 5 4 "" 100 +use skField tv3.Foo.bar string $file 8 9 "" 100 +>def $1 +def skField tv3.Foo.bar string $file 5 4 "" 100 +>outline $1 +outline skType tv3.Foo Foo $file 4 2 "" 100 +outline skField tv3.Foo.bar string $file 5 4 "" 100 +outline skProc tv3.test proc (f: Foo){.gcsafe, locks: 0.} $file 7 5 "" 100 +>sug $1 +sug skField bar string $file 5 4 "" 100 Prefix +>globalSymbols test +def skProc tv3.test proc (f: Foo){.gcsafe, locks: 0.} $file 7 5 "" 100 +""" From 66e3aa6c0587e3633710e4bbd7cb02c36b841642 Mon Sep 17 00:00:00 2001 From: Ivan Yonchovski Date: Wed, 1 Jun 2022 13:05:19 +0300 Subject: [PATCH 3/7] Remove typeInstCache/procInstCache cleanup --- nimsuggest/nimsuggest.nim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index 5d7c9aa47bad2..41260610b86c1 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -693,9 +693,10 @@ proc recompilePartially(graph: ModuleGraph, projectFileIdx = InvalidFileIdx) = myLog fmt "Recompiling partially starting from {graph.getModule(projectFileIdx)}" # inst caches are breaking incremental compilation when the cache caches stuff - # from changed buffer - graph.typeInstCache.clear() - graph.procInstCache.clear() + # from dirty buffer + # TODO: investigate more efficient way to achieve the same + # graph.typeInstCache.clear() + # graph.procInstCache.clear() GC_fullCollect() @@ -935,8 +936,9 @@ else: if self.loadConfigsAndProcessCmdLine(cache, conf, graph): mockCommand(graph) if gLogging: + log("Search paths:") for it in conf.searchPaths: - log(it.string) + log(" " & it.string) retval.doStopCompile = proc (): bool = false return NimSuggest(graph: retval, idle: 0, cachedMsgs: @[]) From dc6f3e734e20c15ab238307068d0ee9a379019de Mon Sep 17 00:00:00 2001 From: Ivan Yonchovski Date: Thu, 2 Jun 2022 10:22:46 +0300 Subject: [PATCH 4/7] Add ideChkFile command --- compiler/options.nim | 4 +++- nimsuggest/nimsuggest.nim | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compiler/options.nim b/compiler/options.nim index 0b2ddbc0c1c9e..792f15d58e0bb 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -188,7 +188,7 @@ type # as far as usesWriteBarrier() is concerned IdeCmd* = enum - ideNone, ideSug, ideCon, ideDef, ideUse, ideDus, ideChk, ideMod, + ideNone, ideSug, ideCon, ideDef, ideUse, ideDus, ideChk, ideChkFile, ideMod, ideHighlight, ideOutline, ideKnown, ideMsg, ideProject, ideGlobalSymbols, ideRecompile, ideChanged @@ -994,6 +994,7 @@ proc parseIdeCmd*(s: string): IdeCmd = of "use": ideUse of "dus": ideDus of "chk": ideChk + of "chkFile": ideChkFile of "mod": ideMod of "highlight": ideHighlight of "outline": ideOutline @@ -1013,6 +1014,7 @@ proc `$`*(c: IdeCmd): string = of ideUse: "use" of ideDus: "dus" of ideChk: "chk" + of ideChkFile: "chkFile" of ideMod: "mod" of ideNone: "none" of ideHighlight: "highlight" diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index 41260610b86c1..02baa17fe4f34 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -150,7 +150,7 @@ proc listEpc(): SexpNode = argspecs = sexp("file line column dirtyfile".split(" ").map(newSSymbol)) docstring = sexp("line starts at 1, column at 0, dirtyfile is optional") result = newSList() - for command in ["sug", "con", "def", "use", "dus", "chk", "mod", "globalSymbols", "recompile", "saved"]: + for command in ["sug", "con", "def", "use", "dus", "chk", "mod", "globalSymbols", "recompile", "saved", "chkFile"]: let cmd = sexp(command) methodDesc = newSList() @@ -456,6 +456,7 @@ proc execCmd(cmd: string; graph: ModuleGraph; cachedMsgs: CachedMsgs) = of "project": conf.ideCmd = ideProject of "changed": conf.ideCmd = ideChanged of "globalsymbols": conf.ideCmd = ideGlobalSymbols + of "chkfile": conf.ideCmd = ideChkFile of "recompile": conf.ideCmd = ideRecompile else: err() var dirtyfile = "" @@ -784,7 +785,7 @@ proc executeNoHooksV3(cmd: IdeCmd, file: AbsoluteFile, dirtyfile: AbsoluteFile, graph.unmarkAllDirty() # these commands require partially compiled project - elif cmd in {ideSug, ideOutline, ideHighlight, ideDef} and + elif cmd in {ideSug, ideOutline, ideHighlight, ideDef, ideChkFile} and (graph.needsCompilation(fileIndex) or cmd == ideSug): # for ideSug use v2 implementation if cmd == ideSug: @@ -838,9 +839,14 @@ proc executeNoHooksV3(cmd: IdeCmd, file: AbsoluteFile, dirtyfile: AbsoluteFile, symToSuggest(graph, sym, false, ideOutline, sym.info, 100, PrefixMatch.None, false, 0)) of ideChk: - myLog fmt "Reporting {graph.suggestErrors.len} error(s)" + myLog fmt "Reporting errors for {graph.suggestErrors.len} file(s)" for sug in graph.suggestErrorsIter: suggestResult(graph.config, sug) + of ideChkFile: + let errors = graph.suggestErrors.getOrDefault(fileIndex, @[]) + myLog fmt "Reporting {errors.len} error(s) for {file.string}" + for error in errors: + suggestResult(graph.config, error) of ideGlobalSymbols: var counter = 0 for (sym, info) in graph.suggestSymbolsIter: From e8789f1e3d217b31982976074da82e8f3c2137e1 Mon Sep 17 00:00:00 2001 From: Ivan Yonchovski Date: Wed, 8 Jun 2022 13:59:45 +0300 Subject: [PATCH 5/7] Avoid contains call when adding symbol info --- compiler/modulegraphs.nim | 2 +- compiler/suggest.nim | 3 +-- nimsuggest/nimsuggest.nim | 13 ++++++------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/compiler/modulegraphs.nim b/compiler/modulegraphs.nim index fc3df4dfe56d3..8294d863e1d5d 100644 --- a/compiler/modulegraphs.nim +++ b/compiler/modulegraphs.nim @@ -658,7 +658,7 @@ func belongsToStdlib*(graph: ModuleGraph, sym: PSym): bool = iterator suggestSymbolsIter*(g: ModuleGraph): tuple[sym: PSym, info: TLineInfo] = for xs in g.suggestSymbols.values: - for x in xs: + for x in xs.deduplicate: yield x iterator suggestErrorsIter*(g: ModuleGraph): Suggest = diff --git a/compiler/suggest.nim b/compiler/suggest.nim index 400974e705f5d..38751fcc726f0 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -497,8 +497,7 @@ proc suggestSym*(g: ModuleGraph; info: TLineInfo; s: PSym; usageSym: var PSym; i ## misnamed: should be 'symDeclared' let conf = g.config when defined(nimsuggest): - if not g.suggestSymbols.getOrDefault(info.fileIndex, @[]).contains (s, info): - g.suggestSymbols.mgetOrPut(info.fileIndex, @[]).add (s, info) + g.suggestSymbols.mgetOrPut(info.fileIndex, @[]).add (s, info) if conf.suggestVersion == 0: if s.allUsages.len == 0: diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index 02baa17fe4f34..e774590607d94 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -711,12 +711,15 @@ proc recompilePartially(graph: ModuleGraph, projectFileIdx = InvalidFileIdx) = except Exception as e: myLog fmt "Failed clean recompilation:\n {e.msg} \n\n {e.getStackTrace()}" +proc fileSymbols(graph: ModuleGraph, fileIdx: FileIndex): seq[tuple[sym: PSym, info: TLineInfo]] = + result = graph.suggestSymbols.getOrDefault(fileIdx, @[]).deduplicate + proc findSymData(graph: ModuleGraph, file: AbsoluteFile; line, col: int): tuple[sym: PSym, info: TLineInfo] = let fileIdx = fileInfoIdx(graph.config, file) trackPos = newLineInfo(fileIdx, line, col) - for (sym, info) in graph.suggestSymbolsIter: + for (sym, info) in graph.fileSymbols(fileIdx): if isTracked(info, trackPos, sym.name.s.len): return (sym, info) @@ -810,10 +813,7 @@ proc executeNoHooksV3(cmd: IdeCmd, file: AbsoluteFile, dirtyfile: AbsoluteFile, of ideHighlight: let sym = graph.findSymData(file, line, col).sym if sym != nil: - let usages = graph - .suggestSymbols - .getOrDefault(fileIndex, @[]) - .filterIt(it.sym == sym) + let usages = graph.fileSymbols(fileIndex).filterIt(it.sym == sym) myLog fmt "Found {usages.len} usages in {file.string}" for (sym, info) in usages: graph.suggestResult(sym, info) @@ -828,8 +828,7 @@ proc executeNoHooksV3(cmd: IdeCmd, file: AbsoluteFile, dirtyfile: AbsoluteFile, of ideOutline: let module = graph.getModule fileIndex - symbols = graph.suggestSymbols - .getOrDefault(fileIndex, @[]) + symbols = graph.fileSymbols(fileIndex) .filterIt(it.sym.info == it.info and (it.sym.owner == module or it.sym.kind in searchableSymKinds)) From 0552591fdb9eb86e41a3280700f7c6582780f55c Mon Sep 17 00:00:00 2001 From: Ivan Yonchovski Date: Wed, 8 Jun 2022 14:56:29 +0300 Subject: [PATCH 6/7] Remove log --- nimsuggest/nimsuggest.nim | 1 - 1 file changed, 1 deletion(-) diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index e774590607d94..0578403ddd2a7 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -769,7 +769,6 @@ proc executeNoHooksV3(cmd: IdeCmd, file: AbsoluteFile, dirtyfile: AbsoluteFile, return fileIndex = fileInfoIdx(conf, file) - myLog fmt "File {file} mapped to {fileIndex.int}, module = {graph.getModule(fileIndex)}" msgs.setDirtyFile( conf, fileIndex, From 97f22b9e6e5df037d92dc15268b1b2b9690ff0d3 Mon Sep 17 00:00:00 2001 From: Ivan Yonchovski Date: Mon, 13 Jun 2022 09:58:53 +0300 Subject: [PATCH 7/7] Remove segfaults --- nimsuggest/nimsuggest.nim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index 0578403ddd2a7..a18b2f960c275 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -11,7 +11,6 @@ import compiler/renderer import strformat import tables import std/sha1 -import segfaults import times ## Nimsuggest is a tool that helps to give editors IDE like capabilities. @@ -499,8 +498,8 @@ proc recompileFullProject(graph: ModuleGraph) = graph.resetForBackend() graph.resetSystemArtifacts() graph.vm = nil - GC_fullCollect() graph.resetAllModules() + GC_fullCollect() graph.compileProject() proc mainThread(graph: ModuleGraph) =