From 3680200df4e0b7a434f5e3c3cee20a228383cd32 Mon Sep 17 00:00:00 2001 From: Nikolay Nikolov Date: Wed, 15 Nov 2023 19:41:58 +0200 Subject: [PATCH] nimsuggest: Instead of checking for protocol version 3 exactly, check for version 3 or later. (#22945) Refactored the way nimsuggest checks for protocol version 3. Instead of checking for version 3 exactly, it now checks for version 3 or later. This way, once a version 4 is introduced, it will use version 3 as a base line, and then extra changes to the protocol can be added on top. No functional changes are introduced in this commit. --- compiler/suggest.nim | 4 ++-- nimsuggest/nimsuggest.nim | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/suggest.nim b/compiler/suggest.nim index 3f98060108..aa8709b16b 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -557,7 +557,7 @@ proc findDefinition(g: ModuleGraph; info: TLineInfo; s: PSym; usageSym: var PSym if s.isNil: return if isTracked(info, g.config.m.trackPos, s.name.s.len) or (s == usageSym and sfForward notin s.flags): suggestResult(g.config, symToSuggest(g, s, isLocal=false, ideDef, info, 100, PrefixMatch.None, false, 0, useSuppliedInfo = s == usageSym)) - if sfForward notin s.flags and g.config.suggestVersion != 3: + if sfForward notin s.flags and g.config.suggestVersion < 3: suggestQuit() else: usageSym = s @@ -761,7 +761,7 @@ proc suggestSentinel*(c: PContext) = when defined(nimsuggest): proc onDef(graph: ModuleGraph, s: PSym, info: TLineInfo) = - if graph.config.suggestVersion == 3 and info.exactEquals(s.info): + if graph.config.suggestVersion >= 3 and info.exactEquals(s.info): suggestSym(graph, info, s, graph.usageSym) template getPContext(): untyped = diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index ecfb9875aa..b483846ad9 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -219,7 +219,7 @@ proc executeNoHooks(cmd: IdeCmd, file, dirtyfile: AbsoluteFile, line, col: int, graph: ModuleGraph) = let conf = graph.config - if conf.suggestVersion == 3: + if conf.suggestVersion >= 3: let command = fmt "cmd = {cmd} {file}:{line}:{col}" benchmark command: executeNoHooksV3(cmd, file, dirtyfile, line, col, tag, graph) @@ -575,7 +575,7 @@ proc mainThread(graph: ModuleGraph) = else: os.sleep 250 idle += 1 - if idle == 20 and gRefresh and conf.suggestVersion != 3: + if idle == 20 and gRefresh and conf.suggestVersion < 3: # we use some nimsuggest activity to enable a lazy recompile: conf.ideCmd = ideChk conf.writelnHook = proc (s: string) = discard @@ -606,7 +606,7 @@ proc mainCommand(graph: ModuleGraph) = # do not print errors, but log them conf.writelnHook = proc (msg: string) = discard - if graph.config.suggestVersion == 3: + if graph.config.suggestVersion >= 3: graph.config.structuredErrorHook = proc (conf: ConfigRef; info: TLineInfo; msg: string; sev: Severity) = let suggest = Suggest(section: ideChk, filePath: toFullPath(conf, info), line: toLinenumber(info), column: toColumn(info), doc: msg, forth: $sev)