IC navigator: added support for include files (#17784)
* ic fixed navigator crash when track wrong/missed Also fixed an issue with getNimcacheDir not observing the outDir. * closer, but not sure how to test[skip ci][ci skip] * IC navigator: added support for include files * update * make posix happy via expandFilename * update Co-authored-by: Saem Ghani <saemghani+github@gmail.com>
This commit is contained in:
parent
24abe10aa8
commit
3b80f0dc8e
9 changed files with 111 additions and 33 deletions
|
|
@ -28,7 +28,7 @@ bootSwitch(usedNoGC, defined(nogc), "--gc:none")
|
|||
import
|
||||
os, msgs, options, nversion, condsyms, strutils, extccomp, platform,
|
||||
wordrecg, parseutils, nimblecmd, parseopt, sequtils, lineinfos,
|
||||
pathutils, strtabs
|
||||
pathutils, strtabs, pathnorm
|
||||
|
||||
from ast import eqTypeFlags, tfGcSafe, tfNoSideEffect
|
||||
|
||||
|
|
@ -359,31 +359,52 @@ proc processCfgPath(conf: ConfigRef; path: string, info: TLineInfo): AbsoluteDir
|
|||
const
|
||||
errInvalidNumber = "$1 is not a valid number"
|
||||
|
||||
proc makeAbsolute(s: string): AbsoluteFile =
|
||||
if isAbsolute(s):
|
||||
AbsoluteFile pathnorm.normalizePath(s)
|
||||
else:
|
||||
AbsoluteFile pathnorm.normalizePath(os.getCurrentDir() / s)
|
||||
|
||||
proc setTrackingInfo(conf: ConfigRef; dirty, file, line, column: string,
|
||||
info: TLineInfo) =
|
||||
## set tracking info, common code for track, trackDirty, & ideTrack
|
||||
var ln, col: int
|
||||
if parseUtils.parseInt(line, ln) <= 0:
|
||||
localError(conf, info, errInvalidNumber % line)
|
||||
if parseUtils.parseInt(column, col) <= 0:
|
||||
localError(conf, info, errInvalidNumber % column)
|
||||
|
||||
let a = makeAbsolute(file)
|
||||
if dirty == "":
|
||||
conf.m.trackPos = newLineInfo(conf, a, ln, col)
|
||||
else:
|
||||
let dirtyOriginalIdx = fileInfoIdx(conf, a)
|
||||
if dirtyOriginalIdx.int32 >= 0:
|
||||
msgs.setDirtyFile(conf, dirtyOriginalIdx, makeAbsolute(dirty))
|
||||
conf.m.trackPos = newLineInfo(dirtyOriginalIdx, ln, col)
|
||||
|
||||
proc trackDirty(conf: ConfigRef; arg: string, info: TLineInfo) =
|
||||
var a = arg.split(',')
|
||||
if a.len != 4: localError(conf, info,
|
||||
"DIRTY_BUFFER,ORIGINAL_FILE,LINE,COLUMN expected")
|
||||
var line, column: int
|
||||
if parseUtils.parseInt(a[2], line) <= 0:
|
||||
localError(conf, info, errInvalidNumber % a[1])
|
||||
if parseUtils.parseInt(a[3], column) <= 0:
|
||||
localError(conf, info, errInvalidNumber % a[2])
|
||||
|
||||
let dirtyOriginalIdx = fileInfoIdx(conf, AbsoluteFile a[1])
|
||||
if dirtyOriginalIdx.int32 >= 0:
|
||||
msgs.setDirtyFile(conf, dirtyOriginalIdx, AbsoluteFile a[0])
|
||||
|
||||
conf.m.trackPos = newLineInfo(dirtyOriginalIdx, line, column)
|
||||
setTrackingInfo(conf, a[0], a[1], a[2], a[3], info)
|
||||
|
||||
proc track(conf: ConfigRef; arg: string, info: TLineInfo) =
|
||||
var a = arg.split(',')
|
||||
if a.len != 3: localError(conf, info, "FILE,LINE,COLUMN expected")
|
||||
var line, column: int
|
||||
if parseUtils.parseInt(a[1], line) <= 0:
|
||||
localError(conf, info, errInvalidNumber % a[1])
|
||||
if parseUtils.parseInt(a[2], column) <= 0:
|
||||
localError(conf, info, errInvalidNumber % a[2])
|
||||
conf.m.trackPos = newLineInfo(conf, AbsoluteFile a[0], line, column)
|
||||
setTrackingInfo(conf, "", a[0], a[1], a[2], info)
|
||||
|
||||
proc trackIde(conf: ConfigRef; cmd: IdeCmd, arg: string, info: TLineInfo) =
|
||||
## set the tracking info related to an ide cmd, supports optional dirty file
|
||||
var a = arg.split(',')
|
||||
case a.len
|
||||
of 4:
|
||||
setTrackingInfo(conf, a[0], a[1], a[2], a[3], info)
|
||||
of 3:
|
||||
setTrackingInfo(conf, "", a[0], a[1], a[2], info)
|
||||
else:
|
||||
localError(conf, info, "[DIRTY_BUFFER,]ORIGINAL_FILE,LINE,COLUMN expected")
|
||||
conf.ideCmd = cmd
|
||||
|
||||
proc dynlibOverride(conf: ConfigRef; switch, arg: string, pass: TCmdLinePass, info: TLineInfo) =
|
||||
if pass in {passCmd2, passPP}:
|
||||
|
|
@ -851,17 +872,17 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
|||
expectNoArg(conf, switch, arg, pass, info)
|
||||
conf.ideCmd = ideSug
|
||||
of "def":
|
||||
expectNoArg(conf, switch, arg, pass, info)
|
||||
conf.ideCmd = ideDef
|
||||
expectArg(conf, switch, arg, pass, info)
|
||||
trackIde(conf, ideDef, arg, info)
|
||||
of "context":
|
||||
expectNoArg(conf, switch, arg, pass, info)
|
||||
conf.ideCmd = ideCon
|
||||
of "usages":
|
||||
expectNoArg(conf, switch, arg, pass, info)
|
||||
conf.ideCmd = ideUse
|
||||
expectArg(conf, switch, arg, pass, info)
|
||||
trackIde(conf, ideUse, arg, info)
|
||||
of "defusages":
|
||||
expectNoArg(conf, switch, arg, pass, info)
|
||||
conf.ideCmd = ideDus
|
||||
expectArg(conf, switch, arg, pass, info)
|
||||
trackIde(conf, ideDus, arg, info)
|
||||
of "stdout":
|
||||
processOnOffSwitchG(conf, {optStdout}, arg, pass, info)
|
||||
of "listfullpaths":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue