@@ -624,41 +624,43 @@ proc ensureIdx[T](x: var T, y: int) =
624624proc ensureSeq [T](x: var seq [T]) =
625625 if x == nil : newSeq (x, 0 )
626626
627- proc suggestSym * (g: ModuleGraph ; info: TLineInfo ; s: PSym ; usageSym: var PSym ; isDecl= true ) {.inline .} =
627+ proc suggestSym * (g: ModuleGraph ; info: TLineInfo ; s: PSym ; usageSym: var PSym ; isDecl= true ; isGenericInstance = false ) {.inline .} =
628628 # # misnamed: should be 'symDeclared'
629629 let conf = g.config
630630 when defined (nimsuggest):
631- g.suggestSymbols.add SymInfoPair (sym: s, info: info, isDecl: isDecl), optIdeExceptionInlayHints in g.config.globalOptions
631+ if optIdeExceptionInlayHints in conf.globalOptions or not isGenericInstance:
632+ g.suggestSymbols.add SymInfoPair (sym: s, info: info, isDecl: isDecl, isGenericInstance: isGenericInstance), optIdeExceptionInlayHints in g.config.globalOptions
632633
633- if conf.suggestVersion == 0 :
634- if s.allUsages.len == 0 :
635- s.allUsages = @ [info]
636- else :
637- s.addNoDup (info)
638-
639- if conf.ideCmd == ideUse:
640- findUsages (g, info, s, usageSym)
641- elif conf.ideCmd == ideDef:
642- findDefinition (g, info, s, usageSym)
643- elif conf.ideCmd == ideDus and s != nil :
644- if isTracked (info, conf.m.trackPos, s.name.s.len):
645- suggestResult (conf, symToSuggest (g, s, isLocal= false , ideDef, info, 100 , PrefixMatch .None , false , 0 ))
646- findUsages (g, info, s, usageSym)
647- elif conf.ideCmd == ideHighlight and info.fileIndex == conf.m.trackPos.fileIndex:
648- suggestResult (conf, symToSuggest (g, s, isLocal= false , ideHighlight, info, 100 , PrefixMatch .None , false , 0 ))
649- elif conf.ideCmd == ideOutline and isDecl:
650- # if a module is included then the info we have is inside the include and
651- # we need to walk up the owners until we find the outer most module,
652- # which will be the last skModule prior to an skPackage.
653- var
654- parentFileIndex = info.fileIndex # assume we're in the correct module
655- parentModule = s.owner
656- while parentModule != nil and parentModule.kind == skModule:
657- parentFileIndex = parentModule.info.fileIndex
658- parentModule = parentModule.owner
659-
660- if parentFileIndex == conf.m.trackPos.fileIndex:
661- suggestResult (conf, symToSuggest (g, s, isLocal= false , ideOutline, info, 100 , PrefixMatch .None , false , 0 ))
634+ if not isGenericInstance:
635+ if conf.suggestVersion == 0 :
636+ if s.allUsages.len == 0 :
637+ s.allUsages = @ [info]
638+ else :
639+ s.addNoDup (info)
640+
641+ if conf.ideCmd == ideUse:
642+ findUsages (g, info, s, usageSym)
643+ elif conf.ideCmd == ideDef:
644+ findDefinition (g, info, s, usageSym)
645+ elif conf.ideCmd == ideDus and s != nil :
646+ if isTracked (info, conf.m.trackPos, s.name.s.len):
647+ suggestResult (conf, symToSuggest (g, s, isLocal= false , ideDef, info, 100 , PrefixMatch .None , false , 0 ))
648+ findUsages (g, info, s, usageSym)
649+ elif conf.ideCmd == ideHighlight and info.fileIndex == conf.m.trackPos.fileIndex:
650+ suggestResult (conf, symToSuggest (g, s, isLocal= false , ideHighlight, info, 100 , PrefixMatch .None , false , 0 ))
651+ elif conf.ideCmd == ideOutline and isDecl:
652+ # if a module is included then the info we have is inside the include and
653+ # we need to walk up the owners until we find the outer most module,
654+ # which will be the last skModule prior to an skPackage.
655+ var
656+ parentFileIndex = info.fileIndex # assume we're in the correct module
657+ parentModule = s.owner
658+ while parentModule != nil and parentModule.kind == skModule:
659+ parentFileIndex = parentModule.info.fileIndex
660+ parentModule = parentModule.owner
661+
662+ if parentFileIndex == conf.m.trackPos.fileIndex:
663+ suggestResult (conf, symToSuggest (g, s, isLocal= false , ideOutline, info, 100 , PrefixMatch .None , false , 0 ))
662664
663665proc warnAboutDeprecated (conf: ConfigRef ; info: TLineInfo ; s: PSym ) =
664666 var pragmaNode: PNode
@@ -702,26 +704,28 @@ proc markOwnerModuleAsUsed(c: PContext; s: PSym) =
702704 else :
703705 inc i
704706
705- proc markUsed (c: PContext ; info: TLineInfo ; s: PSym ; checkStyle = true ) =
706- let conf = c.config
707- incl (s.flags, sfUsed)
708- if s.kind == skEnumField and s.owner != nil :
709- incl (s.owner.flags, sfUsed)
710- if sfDeprecated in s.owner.flags:
711- warnAboutDeprecated (conf, info, s)
712- if {sfDeprecated, sfError} * s.flags != {}:
713- if sfDeprecated in s.flags:
714- if not (c.lastTLineInfo.line == info.line and
715- c.lastTLineInfo.col == info.col):
707+ proc markUsed (c: PContext ; info: TLineInfo ; s: PSym ; checkStyle = true ; isGenericInstance = false ) =
708+ if not isGenericInstance:
709+ let conf = c.config
710+ incl (s.flags, sfUsed)
711+ if s.kind == skEnumField and s.owner != nil :
712+ incl (s.owner.flags, sfUsed)
713+ if sfDeprecated in s.owner.flags:
716714 warnAboutDeprecated (conf, info, s)
717- c.lastTLineInfo = info
718-
719- if sfError in s.flags: userError (conf, info, s)
715+ if {sfDeprecated, sfError} * s.flags != {}:
716+ if sfDeprecated in s.flags:
717+ if not (c.lastTLineInfo.line == info.line and
718+ c.lastTLineInfo.col == info.col):
719+ warnAboutDeprecated (conf, info, s)
720+ c.lastTLineInfo = info
721+
722+ if sfError in s.flags: userError (conf, info, s)
720723 when defined (nimsuggest):
721- suggestSym (c.graph, info, s, c.graph.usageSym, false )
722- if checkStyle:
723- styleCheckUse (c, info, s)
724- markOwnerModuleAsUsed (c, s)
724+ suggestSym (c.graph, info, s, c.graph.usageSym, isDecl = false , isGenericInstance = isGenericInstance)
725+ if not isGenericInstance:
726+ if checkStyle:
727+ styleCheckUse (c, info, s)
728+ markOwnerModuleAsUsed (c, s)
725729
726730proc safeSemExpr * (c: PContext , n: PNode ): PNode =
727731 # use only for idetools support!
0 commit comments