refactoring: move DB model to incremental.nim
This commit is contained in:
parent
688c54d8f1
commit
ddc6cec69e
10 changed files with 410 additions and 163 deletions
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
## This module implements the module graph data structure. The module graph
|
||||
## represents a complete Nim project. Single modules can either be kept in RAM
|
||||
## or stored in a ROD file. The ROD file mechanism is not yet integrated here.
|
||||
## or stored in a Sqlite database.
|
||||
##
|
||||
## The caching of modules is critical for 'nimsuggest' and is tricky to get
|
||||
## right. If module E is being edited, we need autocompletion (and type
|
||||
|
|
@ -25,7 +25,8 @@
|
|||
## - Its dependent module stays the same.
|
||||
##
|
||||
|
||||
import ast, intsets, tables, options, rod, lineinfos, hashes, idents
|
||||
import ast, intsets, tables, options, lineinfos, hashes, idents,
|
||||
incremental
|
||||
|
||||
type
|
||||
ModuleGraph* = ref object
|
||||
|
|
@ -54,6 +55,7 @@ type
|
|||
intTypeCache*: array[-5..64, PType]
|
||||
opContains*, opNot*: PSym
|
||||
emptyNode*: PNode
|
||||
incr*: IncrementalCtx
|
||||
|
||||
proc hash*(x: FileIndex): Hash {.borrow.}
|
||||
|
||||
|
|
@ -82,6 +84,7 @@ proc newModuleGraph*(cache: IdentCache; config: ConfigRef): ModuleGraph =
|
|||
result.opNot = createMagic(result, "not", mNot)
|
||||
result.opContains = createMagic(result, "contains", mInSet)
|
||||
result.emptyNode = newNode(nkEmpty)
|
||||
init(result.incr)
|
||||
|
||||
proc resetAllModules*(g: ModuleGraph) =
|
||||
initStrTable(packageSyms)
|
||||
|
|
@ -103,7 +106,7 @@ proc dependsOn(a, b: int): int {.inline.} = (a shl 15) + b
|
|||
|
||||
proc addDep*(g: ModuleGraph; m: PSym, dep: FileIndex) =
|
||||
assert m.position == m.info.fileIndex.int32
|
||||
addModuleDep(m.info.fileIndex, dep, isIncludeFile = false)
|
||||
addModuleDep(g.incr, g.config, m.info.fileIndex, dep, isIncludeFile = false)
|
||||
if suggestMode:
|
||||
deps.incl m.position.dependsOn(dep.int)
|
||||
# we compute the transitive closure later when quering the graph lazily.
|
||||
|
|
@ -111,7 +114,7 @@ proc addDep*(g: ModuleGraph; m: PSym, dep: FileIndex) =
|
|||
#invalidTransitiveClosure = true
|
||||
|
||||
proc addIncludeDep*(g: ModuleGraph; module, includeFile: FileIndex) =
|
||||
addModuleDep(module, includeFile, isIncludeFile = true)
|
||||
addModuleDep(g.incr, g.config, module, includeFile, isIncludeFile = true)
|
||||
discard hasKeyOrPut(inclToMod, includeFile, module)
|
||||
|
||||
proc parentModule*(g: ModuleGraph; fileIdx: FileIndex): FileIndex =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue