Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggest: symToSuggest limit data per IdeCmd #908

Merged
merged 4 commits into from
Sep 21, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions compiler/tools/suggest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,17 @@ proc symToSuggest(g: ModuleGraph; s: PSym, isLocal: bool, section: IdeCmd, info:
result.quality = quality
result.isGlobal = sfGlobal in s.flags
result.prefix = prefix
result.contextFits = inTypeContext == (s.kind in {skType, skGenericParam})
if section in {ideSug, ideCon}:
result.contextFits = inTypeContext == (s.kind in {skType, skGenericParam})
result.scope = scope
result.name = addr s.name.s
when defined(nimsuggest):
result.globalUsages = s.allUsages.len
var c = 0
for u in s.allUsages:
if u.fileIndex == info.fileIndex: inc c
result.localUsages = c
if section in {ideSug, ideCon}:
result.globalUsages = s.allUsages.len
var c = 0
for u in s.allUsages:
if u.fileIndex == info.fileIndex: inc c
result.localUsages = c
result.symkind = byte s.kind
result.qualifiedPath = @[]
if not isLocal and s.kind != skModule:
Expand All @@ -191,7 +193,8 @@ proc symToSuggest(g: ModuleGraph; s: PSym, isLocal: bool, section: IdeCmd, info:
else:
result.forth = ""
when defined(nimsuggest) and not defined(noDocgen) and not defined(leanCompiler):
result.doc = extractDocComment(g, s)
if section in {ideSug, ideCon, ideDef, ideChk}:
bung87 marked this conversation as resolved.
Show resolved Hide resolved
result.doc = extractDocComment(g, s)
let infox =
if useSuppliedInfo or section in {ideUse, ideHighlight, ideOutline}:
info
Expand All @@ -200,10 +203,10 @@ proc symToSuggest(g: ModuleGraph; s: PSym, isLocal: bool, section: IdeCmd, info:
result.filePath = toFullPath(g.config, infox)
result.line = toLinenumber(infox)
result.column = toColumn(infox)
result.tokenLen = if section != ideHighlight:
s.name.s.len
else:
getTokenLenFromSource(g.config, s.name.s, infox)
if section in {ideHighlight}:
result.tokenLen = getTokenLenFromSource(g.config, s.name.s, infox)
else:
result.tokenLen = s.name.s.len
bung87 marked this conversation as resolved.
Show resolved Hide resolved

proc `$`*(suggest: Suggest): string =
result = $suggest.section
Expand Down
Loading