[refactor] compiler/[msgs, reorder, semstmts]: use toMsgFilename where appropriate (#11595)
* compiler/msgs: toMsgFilename now operates on FileIndex * compiler/reorder: use toMsgFilename for compiler messages * compiler/semstmts: respect listFullPaths for recursive deps error
This commit is contained in:
parent
b7f8031e98
commit
993b3909a8
3 changed files with 9 additions and 8 deletions
|
|
@ -195,12 +195,10 @@ template toFullPath*(conf: ConfigRef; info: TLineInfo): string =
|
||||||
template toFullPathConsiderDirty*(conf: ConfigRef; info: TLineInfo): string =
|
template toFullPathConsiderDirty*(conf: ConfigRef; info: TLineInfo): string =
|
||||||
string toFullPathConsiderDirty(conf, info.fileIndex)
|
string toFullPathConsiderDirty(conf, info.fileIndex)
|
||||||
|
|
||||||
proc toMsgFilename*(conf: ConfigRef; info: TLineInfo): string =
|
proc toMsgFilename*(conf: ConfigRef; info: FileIndex): string =
|
||||||
if info.fileIndex.int32 < 0:
|
|
||||||
return "???"
|
|
||||||
let
|
let
|
||||||
absPath = conf.m.fileInfos[info.fileIndex.int32].fullPath.string
|
absPath = toFullPath(conf, info)
|
||||||
relPath = conf.m.fileInfos[info.fileIndex.int32].projPath.string
|
relPath = toFilename(conf, info)
|
||||||
result = if (optListFullPaths in conf.globalOptions) or
|
result = if (optListFullPaths in conf.globalOptions) or
|
||||||
(relPath.len > absPath.len) or
|
(relPath.len > absPath.len) or
|
||||||
(relPath.count("..") > 2):
|
(relPath.count("..") > 2):
|
||||||
|
|
@ -208,6 +206,9 @@ proc toMsgFilename*(conf: ConfigRef; info: TLineInfo): string =
|
||||||
else:
|
else:
|
||||||
relPath
|
relPath
|
||||||
|
|
||||||
|
template toMsgFilename*(conf: ConfigRef; info: TLineInfo): string =
|
||||||
|
toMsgFilename(conf, info.fileIndex)
|
||||||
|
|
||||||
proc toLinenumber*(info: TLineInfo): int {.inline.} =
|
proc toLinenumber*(info: TLineInfo): int {.inline.} =
|
||||||
result = int info.line
|
result = int info.line
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ proc expandIncludes(graph: ModuleGraph, module: PSym, n: PNode,
|
||||||
if f != InvalidFileIDX:
|
if f != InvalidFileIDX:
|
||||||
if containsOrIncl(includedFiles, f.int):
|
if containsOrIncl(includedFiles, f.int):
|
||||||
localError(graph.config, a.info, "recursive dependency: '$1'" %
|
localError(graph.config, a.info, "recursive dependency: '$1'" %
|
||||||
toFilename(graph.config, f))
|
toMsgFilename(graph.config, f))
|
||||||
else:
|
else:
|
||||||
let nn = includeModule(graph, module, f)
|
let nn = includeModule(graph, module, f)
|
||||||
let nnn = expandIncludes(graph, module, nn, modulePath,
|
let nnn = expandIncludes(graph, module, nn, modulePath,
|
||||||
|
|
|
||||||
|
|
@ -1288,7 +1288,7 @@ proc semAllTypeSections(c: PContext; n: PNode): PNode =
|
||||||
var f = checkModuleName(c.config, n.sons[i])
|
var f = checkModuleName(c.config, n.sons[i])
|
||||||
if f != InvalidFileIDX:
|
if f != InvalidFileIDX:
|
||||||
if containsOrIncl(c.includedFiles, f.int):
|
if containsOrIncl(c.includedFiles, f.int):
|
||||||
localError(c.config, n.info, errRecursiveDependencyX % toFilename(c.config, f))
|
localError(c.config, n.info, errRecursiveDependencyX % toMsgFilename(c.config, f))
|
||||||
else:
|
else:
|
||||||
let code = c.graph.includeFileCallback(c.graph, c.module, f)
|
let code = c.graph.includeFileCallback(c.graph, c.module, f)
|
||||||
gatherStmts c, code, result
|
gatherStmts c, code, result
|
||||||
|
|
@ -2023,7 +2023,7 @@ proc incMod(c: PContext, n: PNode, it: PNode, includeStmtResult: PNode) =
|
||||||
var f = checkModuleName(c.config, it)
|
var f = checkModuleName(c.config, it)
|
||||||
if f != InvalidFileIDX:
|
if f != InvalidFileIDX:
|
||||||
if containsOrIncl(c.includedFiles, f.int):
|
if containsOrIncl(c.includedFiles, f.int):
|
||||||
localError(c.config, n.info, errRecursiveDependencyX % toFilename(c.config, f))
|
localError(c.config, n.info, errRecursiveDependencyX % toMsgFilename(c.config, f))
|
||||||
else:
|
else:
|
||||||
addSon(includeStmtResult, semStmt(c, c.graph.includeFileCallback(c.graph, c.module, f), {}))
|
addSon(includeStmtResult, semStmt(c, c.graph.includeFileCallback(c.graph, c.module, f), {}))
|
||||||
excl(c.includedFiles, f.int)
|
excl(c.includedFiles, f.int)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue