compiler/front/cli_reporter

    Dark Mode
Search:
  Source   Edit

This module provides default implementation of message reporting hook. Default compiler message formatting is done here.

Implementation is split into several layers

  1. reportHook - does the necessary message filtering
  2. reportFull - convert given report to string. Main Report overload dispatches into per-cateogory ones. Full report adds required prefix and suffix (location information, severity, message kind for hints)
  3. reportBody - generate main report body. Most of the error formatting is done in this proc.

Procs

proc addPragmaAndCallConvMismatch(message: var string; formal, actual: PType;
                                  conf: ConfigRef) {....raises: [ValueError],
    tags: [].}
Add pragma and calling convention mismatch for the formal (aka expected) and actual (aka provided) types.   Source   Edit
proc formatTrace(conf: ConfigRef; trace: seq[StackTraceEntry]): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
Format stack trace entries for reporting   Source   Edit
proc getSymRepr(conf: ConfigRef; s: PSym; getDeclarationPath = true): string {.
    ...raises: [Exception, KeyError, ValueError], tags: [RootEffect, ReadDirEffect].}
  Source   Edit
proc legacyReportBridge(conf: ConfigRef; diag: PAstDiag): Report {.
    ...raises: [ValueError, ERecoverableError], tags: [].}
Converts AST Diagnostics to legacy reports; meant to be assigned to a ConfigRef as a procedural value and act as a callback.   Source   Edit
proc presentSpellingCandidates(conf: ConfigRef;
                               candidates: seq[SemSpellCandidate]): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
Format potential spelling candidates   Source   Edit
proc renderAsType(vals: IntSet; t: PType): string {....raises: [ValueError],
    tags: [].}
Render integer values as type. For integer no representation conversion is done, for char convert to characters, for enums use enum symbols.   Source   Edit
proc reportBody(conf: ConfigRef; r: BackendReport): string {.
    ...raises: [ValueError], tags: [].}
  Source   Edit
proc reportBody(conf: ConfigRef; r: CmdReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportBody(conf: ConfigRef; r: DebugReport): string {.
    ...raises: [ValueError, KeyError, Exception],
    tags: [ReadDirEffect, RootEffect, ReadIOEffect].}
  Source   Edit
proc reportBody(conf: ConfigRef; r: ExternalReport): string {....raises: [],
    tags: [].}
  Source   Edit
proc reportBody(conf: ConfigRef; r: InternalReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportBody(conf: ConfigRef; r: LexerReport): string {....raises: [], tags: [].}
  Source   Edit
proc reportBody(conf: ConfigRef; r: ParserReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportBody(conf: ConfigRef; r: Report): string {.
    ...raises: [ValueError, KeyError, Exception, ERecoverableError],
    tags: [ReadDirEffect, RootEffect, ReadIOEffect].}
Generate main body of the report. Dispatches into implementations for specific report categories.   Source   Edit
proc reportBody(conf: ConfigRef; r: SemReport): string {.
    ...raises: [ValueError, KeyError, Exception, ERecoverableError],
    tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportBody(conf: ConfigRef; r: VMReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportFull(conf: ConfigRef; r: BackendReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportFull(conf: ConfigRef; r: CmdReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportFull(conf: ConfigRef; r: DebugReport): string {.
    ...raises: [ValueError, KeyError, Exception],
    tags: [ReadDirEffect, RootEffect, ReadIOEffect].}
  Source   Edit
proc reportFull(conf: ConfigRef; r: ExternalReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportFull(conf: ConfigRef; r: InternalReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportFull(conf: ConfigRef; r: LexerReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportFull(conf: ConfigRef; r: ParserReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportFull(conf: ConfigRef; r: Report): string {.
    ...raises: [ValueError, KeyError, Exception, ERecoverableError],
    tags: [ReadDirEffect, RootEffect, ReadIOEffect].}
Generate full version of the report (location, severity, body, optional suffix)   Source   Edit
proc reportFull(conf: ConfigRef; r: SemReport): string {.
    ...raises: [ValueError, KeyError, Exception, ERecoverableError],
    tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportFull(conf: ConfigRef; r: VMReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportHook(conf: ConfigRef; r: Report): TErrorHandling {.
    ...raises: [Exception, ValueError, KeyError, ERecoverableError],
    tags: [RootEffect, ReadDirEffect, ReadIOEffect].}
Default implementation of the report hook. Dispatches into reportBody for report, which then calls respective (for each report category) reportBody overloads defined above   Source   Edit
proc reportShort(conf: ConfigRef; r: BackendReport): string {.
    ...raises: [ValueError], tags: [].}
  Source   Edit
proc reportShort(conf: ConfigRef; r: CmdReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportShort(conf: ConfigRef; r: DebugReport): string {.
    ...raises: [ValueError, KeyError, Exception],
    tags: [ReadDirEffect, RootEffect, ReadIOEffect].}
  Source   Edit
proc reportShort(conf: ConfigRef; r: ExternalReport): string {.inline,
    ...raises: [], tags: [].}
  Source   Edit
proc reportShort(conf: ConfigRef; r: InternalReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportShort(conf: ConfigRef; r: LexerReport): string {....raises: [], tags: [].}
  Source   Edit
proc reportShort(conf: ConfigRef; r: ParserReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportShort(conf: ConfigRef; r: Report): string {.
    ...raises: [ValueError, KeyError, Exception, ERecoverableError],
    tags: [ReadDirEffect, RootEffect, ReadIOEffect].}
Generate short report version of the report   Source   Edit
proc reportShort(conf: ConfigRef; r: SemReport): string {.
    ...raises: [ValueError, KeyError, Exception, ERecoverableError],
    tags: [ReadDirEffect, RootEffect].}
  Source   Edit
proc reportShort(conf: ConfigRef; r: VMReport): string {.
    ...raises: [ValueError, KeyError, Exception], tags: [ReadDirEffect, RootEffect].}
  Source   Edit
func wrap(conf: ConfigRef; str: string; color: ForegroundColor;
          style: set[Style] = {}): string {....raises: [], tags: [].}
Optionally wrap text in ansi color formatting, if conf has coloring enabled   Source   Edit