diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-09-07 01:53:09 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-09-07 19:21:16 +0200 |
commit | 86556ebfdbbd4b8e9edc9d3085ea21d6c0bae2e2 (patch) | |
tree | 9f8b4b752ed728ceff82dceef2f5605cb2a846a0 /nimsuggest/nimsuggest.nim | |
parent | b5730ec01f02e542eb06161430aa5a7c2ede775f (diff) | |
download | Nim-86556ebfdbbd4b8e9edc9d3085ea21d6c0bae2e2.tar.gz |
compiler refactoring; use typesafe path handing; docgen: render symbols between modules
Diffstat (limited to 'nimsuggest/nimsuggest.nim')
-rw-r--r-- | nimsuggest/nimsuggest.nim | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index b20572b0e..34b1cc4f7 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -20,7 +20,8 @@ import compiler / [options, commands, modules, sem, passes, passaux, msgs, nimconf, extccomp, condsyms, sigmatch, ast, scriptconfig, - idents, modulegraphs, vm, prefixmatches, lineinfos, cmdlinehelper] + idents, modulegraphs, vm, prefixmatches, lineinfos, cmdlinehelper, + pathutils] when defined(windows): import winlean @@ -158,10 +159,11 @@ proc symFromInfo(graph: ModuleGraph; trackPos: TLineInfo): PSym = if m != nil and m.ast != nil: result = findNode(m.ast, trackPos) -proc execute(cmd: IdeCmd, file, dirtyfile: string, line, col: int; +proc execute(cmd: IdeCmd, file, dirtyfile: AbsoluteFile, line, col: int; graph: ModuleGraph) = let conf = graph.config - myLog("cmd: " & $cmd & ", file: " & file & ", dirtyFile: " & dirtyfile & + myLog("cmd: " & $cmd & ", file: " & file.string & + ", dirtyFile: " & dirtyfile.string & "[" & $line & ":" & $col & "]") conf.ideCmd = cmd if cmd == ideChk: @@ -175,8 +177,8 @@ proc execute(cmd: IdeCmd, file, dirtyfile: string, line, col: int; var isKnownFile = true let dirtyIdx = fileInfoIdx(conf, file, isKnownFile) - if dirtyfile.len != 0: msgs.setDirtyFile(conf, dirtyIdx, dirtyfile) - else: msgs.setDirtyFile(conf, dirtyIdx, "") + if not dirtyfile.isEmpty: msgs.setDirtyFile(conf, dirtyIdx, dirtyfile) + else: msgs.setDirtyFile(conf, dirtyIdx, AbsoluteFile"") conf.m.trackPos = newLineInfo(dirtyIdx, line, col) conf.m.trackPosAttached = false @@ -186,7 +188,7 @@ proc execute(cmd: IdeCmd, file, dirtyfile: string, line, col: int; if not isKnownFile: graph.compileProject() if conf.suggestVersion == 0 and conf.ideCmd in {ideUse, ideDus} and - dirtyfile.len == 0: + dirtyfile.isEmpty: discard "no need to recompile anything" else: let modIdx = graph.parentModule(dirtyIdx) @@ -204,12 +206,12 @@ proc execute(cmd: IdeCmd, file, dirtyfile: string, line, col: int; proc executeEpc(cmd: IdeCmd, args: SexpNode; graph: ModuleGraph) = let - file = args[0].getStr + file = AbsoluteFile args[0].getStr line = args[1].getNum column = args[2].getNum - var dirtyfile = "" + var dirtyfile = AbsoluteFile"" if len(args) > 3: - dirtyfile = args[3].getStr("") + dirtyfile = AbsoluteFile args[3].getStr("") execute(cmd, file, dirtyfile, int(line), int(column), graph) proc returnEpc(socket: Socket, uid: BiggestInt, s: SexpNode|string, @@ -431,11 +433,11 @@ proc execCmd(cmd: string; graph: ModuleGraph; cachedMsgs: CachedMsgs) = i += parseInt(cmd, col, i) if conf.ideCmd == ideKnown: - results.send(Suggest(section: ideKnown, quality: ord(fileInfoKnown(conf, orig)))) + results.send(Suggest(section: ideKnown, quality: ord(fileInfoKnown(conf, AbsoluteFile orig)))) else: if conf.ideCmd == ideChk: for cm in cachedMsgs: errorHook(conf, cm.info, cm.msg, cm.sev) - execute(conf.ideCmd, orig, dirtyfile, line, col, graph) + execute(conf.ideCmd, AbsoluteFile orig, AbsoluteFile dirtyfile, line, col, graph) sentinel() proc recompileFullProject(graph: ModuleGraph) = @@ -451,7 +453,7 @@ proc mainThread(graph: ModuleGraph) = let conf = graph.config if gLogging: for it in conf.searchPaths: - log(it) + log(it.string) proc wrHook(line: string) {.closure.} = if gMode == mepc: @@ -496,7 +498,7 @@ proc mainCommand(graph: ModuleGraph) = wantMainModule(conf) if not fileExists(conf.projectFull): - quit "cannot find file: " & conf.projectFull + quit "cannot find file: " & conf.projectFull.string add(conf.searchPaths, conf.libpath) @@ -518,9 +520,9 @@ proc mainCommand(graph: ModuleGraph) = of mtcp: createThread(inputThread, replTcp, (gPort, gAddress)) of mepc: createThread(inputThread, replEpc, (gPort, gAddress)) of mcmdsug: createThread(inputThread, replCmdline, - (gPort, "sug \"" & conf.projectFull & "\":" & gAddress)) + (gPort, "sug \"" & conf.projectFull.string & "\":" & gAddress)) of mcmdcon: createThread(inputThread, replCmdline, - (gPort, "con \"" & conf.projectFull & "\":" & gAddress)) + (gPort, "con \"" & conf.projectFull.string & "\":" & gAddress)) mainThread(graph) joinThread(inputThread) close(requests) @@ -602,11 +604,12 @@ proc handleCmdLine(cache: IdentCache; conf: ConfigRef) = if binaryPath == "": raise newException(IOError, "Cannot find Nim standard library: Nim compiler not in PATH") - conf.prefixDir = binaryPath.splitPath().head.parentDir() - if not dirExists(conf.prefixDir / "lib"): conf.prefixDir = "" + conf.prefixDir = AbsoluteDir binaryPath.splitPath().head.parentDir() + if not dirExists(conf.prefixDir / RelativeDir"lib"): + conf.prefixDir = AbsoluteDir"" #msgs.writelnHook = proc (line: string) = log(line) - myLog("START " & conf.projectFull) + myLog("START " & conf.projectFull.string) discard self.loadConfigsAndRunMainCommand(cache, conf) |