diff options
Diffstat (limited to 'compiler/modulegraphs.nim')
-rw-r--r-- | compiler/modulegraphs.nim | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/compiler/modulegraphs.nim b/compiler/modulegraphs.nim index 932f5a0b0..0df72c43b 100644 --- a/compiler/modulegraphs.nim +++ b/compiler/modulegraphs.nim @@ -53,6 +53,10 @@ type concreteTypes*: seq[FullId] inst*: PInstantiation + SymInfoPair* = object + sym*: PSym + info*: TLineInfo + ModuleGraph* {.acyclic.} = ref object ifaces*: seq[Iface] ## indexed by int32 fileIdx packed*: PackedModuleGraph @@ -83,7 +87,7 @@ type doStopCompile*: proc(): bool {.closure.} usageSym*: PSym # for nimsuggest owners*: seq[PSym] - suggestSymbols*: Table[FileIndex, seq[tuple[sym: PSym, info: TLineInfo]]] + suggestSymbols*: Table[FileIndex, seq[SymInfoPair]] suggestErrors*: Table[FileIndex, seq[Suggest]] methods*: seq[tuple[methods: seq[PSym], dispatcher: PSym]] # needs serialization! systemModule*: PSym @@ -374,12 +378,6 @@ template getPContext(): untyped = 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: - suggestSym(c.graph, info, s, c.graph.usageSym) - template onDefResolveForward*(info: TLineInfo; s: PSym) = discard else: template onUse*(info: TLineInfo; s: PSym) = discard @@ -442,7 +440,7 @@ proc initModuleGraphFields(result: ModuleGraph) = result.importStack = @[] result.inclToMod = initTable[FileIndex, FileIndex]() result.owners = @[] - result.suggestSymbols = initTable[FileIndex, seq[tuple[sym: PSym, info: TLineInfo]]]() + result.suggestSymbols = initTable[FileIndex, seq[SymInfoPair]]() result.suggestErrors = initTable[FileIndex, seq[Suggest]]() result.methods = @[] initStrTable(result.compilerprocs) @@ -641,7 +639,13 @@ func belongsToStdlib*(graph: ModuleGraph, sym: PSym): bool = ## Check if symbol belongs to the 'stdlib' package. sym.getPackageSymbol.getPackageId == graph.systemModule.getPackageId -iterator suggestSymbolsIter*(g: ModuleGraph): tuple[sym: PSym, info: TLineInfo] = +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 + +iterator suggestSymbolsIter*(g: ModuleGraph): SymInfoPair = for xs in g.suggestSymbols.values: for x in xs.deduplicate: yield x |