compiler/lineinfos

  Source   Edit

This module contains the TMsgKind enum as well as the TLineInfo object.

Types

ERecoverableError = object of ValueError
  Source   Edit
ESuggestDone = object of ValueError
  Source   Edit
FileIndex = distinct int32
  Source   Edit
MsgConfig = object
  trackPos*: TLineInfo
  trackPosAttached*: bool    ## whether the tracking position was attached to
                             ## some close token.
  errorOutputs*: TErrorOutputs
  msgContext*: seq[tuple[info: TLineInfo, detail: string]]
  lastError*: TLineInfo
  filenameToIndexTbl*: Table[string, FileIndex]
  fileInfos*: seq[TFileInfo]
  systemFileIdx*: FileIndex
does not need to be stored in the incremental cache   Source   Edit
Severity {.pure.} = enum
  Hint, Warning, Error
VS Code only supports these three   Source   Edit
TErrorOutput = enum
  eStdOut, eStdErr
  Source   Edit
TFileInfo = object
  fullPath*: AbsoluteFile
  projPath*: RelativeFile
  shortName*: string
  quotedName*: Rope
  quotedFullName*: Rope
  lines*: seq[string]
  dirtyFile*: AbsoluteFile
  hash*: string
  dirty*: bool
  when defined(nimpretty):
      fullContent*: string

  
  Source   Edit
TLineInfo = object
  line*: uint16
  col*: int16
  fileIndex*: FileIndex
  when defined(nimpretty):
      offsetA*, offsetB*: int
      commentOffsetA*, commentOffsetB*: int

  
  Source   Edit
TMsgKind = enum
  errUnknown, errFatal, errInternal, errIllFormedAstX, errCannotOpenFile,
  errXExpected, errRstGridTableNotImplemented, errRstMarkdownIllformedTable,
  errRstNewSectionExpected, errRstGeneralParseError, errRstInvalidDirectiveX,
  errRstInvalidField, errRstFootnoteMismatch, errRstSandboxedDirective,
  errProveInit, errGenerated, errUser, warnCannotOpenFile = "CannotOpenFile",
  warnOctalEscape = "OctalEscape", warnXIsNeverRead = "XIsNeverRead",
  warnXmightNotBeenInit = "XmightNotBeenInit", warnDeprecated = "Deprecated",
  warnConfigDeprecated = "ConfigDeprecated", warnDotLikeOps = "DotLikeOps",
  warnSmallLshouldNotBeUsed = "SmallLshouldNotBeUsed",
  warnUnknownMagic = "UnknownMagic",
  warnRstRedefinitionOfLabel = "RedefinitionOfLabel",
  warnRstUnknownSubstitutionX = "UnknownSubstitutionX",
  warnRstBrokenLink = "BrokenLink",
  warnRstLanguageXNotSupported = "LanguageXNotSupported",
  warnRstFieldXNotSupported = "FieldXNotSupported",
  warnRstStyle = "warnRstStyle", warnCommentXIgnored = "CommentXIgnored",
  warnTypelessParam = "TypelessParam", warnUseBase = "UseBase",
  warnWriteToForeignHeap = "WriteToForeignHeap", warnUnsafeCode = "UnsafeCode",
  warnUnusedImportX = "UnusedImport",
  warnInheritFromException = "InheritFromException",
  warnEachIdentIsTuple = "EachIdentIsTuple", warnUnsafeSetLen = "UnsafeSetLen",
  warnUnsafeDefault = "UnsafeDefault", warnProveInit = "ProveInit",
  warnProveField = "ProveField", warnProveIndex = "ProveIndex",
  warnUnreachableElse = "UnreachableElse",
  warnUnreachableCode = "UnreachableCode", warnStaticIndexCheck = "IndexCheck",
  warnGcUnsafe = "GcUnsafe", warnGcUnsafe2 = "GcUnsafe2", warnUninit = "Uninit",
  warnGcMem = "GcMem", warnDestructor = "Destructor",
  warnLockLevel = "LockLevel", warnResultShadowed = "ResultShadowed",
  warnInconsistentSpacing = "Spacing", warnCaseTransition = "CaseTransition",
  warnCycleCreated = "CycleCreated", warnObservableStores = "ObservableStores",
  warnStrictNotNil = "StrictNotNil", warnResultUsed = "ResultUsed",
  warnCannotOpen = "CannotOpen", warnFileChanged = "FileChanged",
  warnSuspiciousEnumConv = "EnumConv", warnAnyEnumConv = "AnyEnumConv",
  warnHoleEnumConv = "HoleEnumConv", warnCstringConv = "CStringConv",
  warnEffect = "Effect", warnUser = "User", hintSuccess = "Success",
  hintSuccessX = "SuccessX", hintCC = "CC", hintLineTooLong = "LineTooLong",
  hintXDeclaredButNotUsed = "XDeclaredButNotUsed",
  hintDuplicateModuleImport = "DuplicateModuleImport",
  hintXCannotRaiseY = "XCannotRaiseY",
  hintConvToBaseNotNeeded = "ConvToBaseNotNeeded",
  hintConvFromXtoItselfNotNeeded = "ConvFromXtoItselfNotNeeded",
  hintExprAlwaysX = "ExprAlwaysX", hintQuitCalled = "QuitCalled",
  hintProcessing = "Processing", hintProcessingStmt = "ProcessingStmt",
  hintCodeBegin = "CodeBegin", hintCodeEnd = "CodeEnd", hintConf = "Conf",
  hintPath = "Path", hintConditionAlwaysTrue = "CondTrue",
  hintConditionAlwaysFalse = "CondFalse", hintName = "Name",
  hintPattern = "Pattern", hintExecuting = "Exec", hintLinking = "Link",
  hintDependency = "Dependency", hintSource = "Source",
  hintPerformance = "Performance", hintStackTrace = "StackTrace",
  hintGCStats = "GCStats", hintGlobalVar = "GlobalVar",
  hintExpandMacro = "ExpandMacro", hintUser = "User", hintUserRaw = "UserRaw",
  hintExtendedContext = "ExtendedContext", hintMsgOrigin = "MsgOrigin",
  hintDeclaredLoc = "DeclaredLoc"
  Source   Edit
TNoteKind = range[warnMin .. hintMax]
  Source   Edit
TNoteKinds = set[TNoteKind]
  Source   Edit

Consts

commandLineIdx = -3'i32
  Source   Edit
errArgsNeedRunOption = "arguments can only be given if the \'--run\' option is selected"
  Source   Edit
errMax = errUser
  Source   Edit
errMin = errUnknown
  Source   Edit
errXMustBeCompileTime = "\'$1\' can only be used in compile-time context"
  Source   Edit
explanationsBaseUrl = "https://nim-lang.github.io/Nim"
  Source   Edit
fatalMsgs = {errUnknown..errInternal}
  Source   Edit
hintMax = hintDeclaredLoc
  Source   Edit
hintMin = hintSuccess
  Source   Edit
InvalidFileIdx = -1'i32
  Source   Edit
MsgKindToStr: array[TMsgKind, string] = ["unknown error", "fatal error: $1",
    "internal error: $1", "illformed AST: $1", "cannot open \'$1\'",
    "\'$1\' expected", "grid table is not implemented",
    "illformed delimiter row of a markdown table", "new section expected $1",
    "general parse error", "invalid directive: \'$1\'", "invalid field: $1",
    "number of footnotes and their references don\'t match: $1",
    "disabled directive: \'$1\'", "Cannot prove that \'$1\' is initialized.",
    "$1", "$1", "cannot open \'$1\'",
    "octal escape sequences do not exist; leading zero is ignored",
    "\'$1\' is never read", "\'$1\' might not have been initialized", "$1",
    "config file \'$1\' is deprecated", "$1",
    "\'l\' should not be used as an identifier; may look like \'1\' (one)",
    "unknown magic \'$1\' might crash the compiler",
    "redefinition of label \'$1\'", "unknown substitution \'$1\'",
    "broken link \'$1\'", "language \'$1\' not supported",
    "field \'$1\' not supported", "RST style: $1", "comment \'$1\' ignored", "",
    "use {.base.} for base methods; baseless methods are deprecated",
    "write to foreign heap", "unsafe code: \'$1\'",
    "imported and not used: \'$1\'", "inherit from a more precise exception type like ValueError, IOError or OSError. If these don\'t suit, inherit from CatchableError or Defect.",
    "each identifier is a tuple", "setLen can potentially expand the sequence, but the element type \'$1\' doesn\'t have a valid default value",
    "The \'$1\' type doesn\'t have a valid default value", "Cannot prove that \'$1\' is initialized. This will become a compile time error in the future.",
    "cannot prove that field \'$1\' is accessible",
    "cannot prove index \'$1\' is valid",
    "unreachable else, all cases are already covered",
    "unreachable code after \'return\' statement or \'{.noReturn.}\' proc",
    "$1", "not GC-safe: \'$1\'", "$1",
    "use explicit initialization of \'$1\' for clarity",
    "\'$1\' uses GC\'ed memory", "usage of a type with a destructor in a non destructible context. This will become a compile time error in the future.",
    "$1", "Special variable \'result\' is shadowed.",
    "Number of spaces around \'$#\' is not consistent",
    "Potential object case transition, instantiate new object instead", "$1",
    "observable stores to \'$1\'", "$1", "used \'result\' variable",
    "cannot open: $1", "file changed: $1", "$1", "$1", "$1", "$1", "$1", "$1",
    "operation successful: $#",
    "$build\n$loc lines; ${sec}s; $mem; proj: $project; out: $output", "CC: $1",
    "line too long", "\'$1\' is declared but not used", "$1", "$1",
    "conversion to base object is not needed",
    "conversion from $1 to itself is pointless",
    "expression evaluates always to \'$1\'", "quit() called", "$1", "$1",
    "generated code listing:", "end of listing", "used config file \'$1\'",
    "added path: \'$1\'", "condition is always true: \'$1\'",
    "condition is always false: \'$1\'", "$1", "$1", "$1", "$1", "$1", "$1",
    "$1", "$1", "$1", "global variable declared here", "expanded macro: $1",
    "$1", "$1", "$1", "$1", "$1"]
  Source   Edit
NotesVerbosity = [{warnCannotOpenFile..warnProveInit,
                   warnUnreachableElse..warnStaticIndexCheck, warnGcUnsafe2,
                   warnGcMem..warnCycleCreated, warnStrictNotNil,
                   warnCannotOpen..warnSuspiciousEnumConv,
                   warnHoleEnumConv..warnUser, hintLineTooLong..hintQuitCalled,
                   hintConditionAlwaysTrue..hintName,
                   hintExpandMacro..hintUserRaw}, {
    warnCannotOpenFile..warnProveInit,
    warnUnreachableElse..warnStaticIndexCheck, warnGcUnsafe2,
    warnGcMem..warnCycleCreated, warnStrictNotNil,
    warnCannotOpen..warnSuspiciousEnumConv, warnHoleEnumConv..hintProcessing,
    hintConf, hintConditionAlwaysTrue..hintLinking, hintExpandMacro..hintUserRaw}, {
    warnCannotOpenFile..warnGcUnsafe2, warnGcMem..warnCycleCreated,
    warnStrictNotNil, warnCannotOpen..warnSuspiciousEnumConv,
    warnHoleEnumConv..hintProcessing, hintCodeBegin..hintPerformance,
    hintGCStats..hintUserRaw, hintMsgOrigin},
                  {17..57, warnStrictNotNil, 61..63, 65..103}]
  Source   Edit
rstWarnings = {warnRstRedefinitionOfLabel..warnRstStyle}
  Source   Edit
unknownLineInfo = (line: 0'u, col: -1, fileIndex: -1)
  Source   Edit
warnMax = warnUser
  Source   Edit
warnMin = warnCannotOpenFile
  Source   Edit

Procs

proc `==`(a, b: FileIndex): bool {.borrow, ...raises: [], tags: [].}
  Source   Edit
proc createDocLink(urlSuffix: string): string {....raises: [], tags: [].}
  Source   Edit
proc hash(i: TLineInfo): Hash {....raises: [], tags: [].}
  Source   Edit
proc initMsgConfig(): MsgConfig {....raises: [], tags: [].}
  Source   Edit
proc raiseRecoverableError(msg: string) {.noinline, ...raises: [ERecoverableError],
    tags: [].}
  Source   Edit