lineinfos

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

Imports

ropes, pathutils

Types

TMsgKind = enum
  errUnknown, errInternal, errIllFormedAstX, errCannotOpenFile, errXExpected,
  errGridTableNotImplemented, errGeneralParseError, errNewSectionExpected,
  errInvalidDirectiveX, errProveInit, errGenerated, errUser,
  warnCannotOpenFile = "CannotOpenFile", warnOctalEscape = "OctalEscape",
  warnXIsNeverRead = "XIsNeverRead",
  warnXmightNotBeenInit = "XmightNotBeenInit", warnDeprecated = "Deprecated",
  warnConfigDeprecated = "ConfigDeprecated",
  warnSmallLshouldNotBeUsed = "SmallLshouldNotBeUsed",
  warnUnknownMagic = "UnknownMagic",
  warnRedefinitionOfLabel = "RedefinitionOfLabel",
  warnUnknownSubstitutionX = "UnknownSubstitutionX",
  warnLanguageXNotSupported = "LanguageXNotSupported",
  warnFieldXNotSupported = "FieldXNotSupported",
  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",
  warnResultUsed = "ResultUsed", warnUser = "User", hintSuccess = "Success",
  hintSuccessX = "SuccessX", hintCC = "CC", hintLineTooLong = "LineTooLong",
  hintXDeclaredButNotUsed = "XDeclaredButNotUsed",
  hintXCannotRaiseY = "XCannotRaiseY",
  hintConvToBaseNotNeeded = "ConvToBaseNotNeeded",
  hintConvFromXtoItselfNotNeeded = "ConvFromXtoItselfNotNeeded",
  hintExprAlwaysX = "ExprAlwaysX", hintQuitCalled = "QuitCalled",
  hintProcessing = "Processing", 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"
Source Edit
TNoteKind = range[warnMin .. hintMax]
Source Edit
TNoteKinds = set[TNoteKind]
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
FileIndex = distinct int32
Source Edit
TLineInfo = object
  line*: uint16
  col*: int16
  fileIndex*: FileIndex
  when defined(nimpretty):
      offsetA*, offsetB*: int
      commentOffsetA*, commentOffsetB*: int
Source Edit
TErrorOutput = enum
  eStdOut, eStdErr
Source Edit
TErrorOutputs = set[TErrorOutput]
Source Edit
ERecoverableError = object of ValueError
Source Edit
ESuggestDone = object of ValueError
Source Edit
Severity {...}{.pure.} = enum
  Hint, Warning, Error
VS Code only supports these three 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

Consts

explanationsBaseUrl = "https://nim-lang.github.io/Nim"
Source Edit
MsgKindToStr: array[TMsgKind, string] = ["unknown error", "internal error: $1",
    "illformed AST: $1", "cannot open \'$1\'", "\'$1\' expected",
    "grid table is not implemented", "general parse error",
    "new section expected", "invalid 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",
    "\'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\'",
    "language \'$1\' not supported", "field \'$1\' not supported",
    "comment \'$1\' ignored", "\'$1\' has no type. Typeless parameters are deprecated; only allowed for \'template\'",
    "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\'", "used \'result\' variable", "$1",
    "operation successful: $#",
    "${loc} lines; ${sec}s; $mem; $build build; proj: $project; out: $output",
    "CC: $1", "line too long", "\'$1\' is declared but not used", "$1",
    "conversion to base object is not needed",
    "conversion from $1 to itself is pointless",
    "expression evaluates always to \'$1\'", "quit() called", "$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"]
Source Edit
fatalMin = errUnknown
Source Edit
fatalMax = errInternal
Source Edit
errMin = errUnknown
Source Edit
errMax = errUser
Source Edit
warnMin = warnCannotOpenFile
Source Edit
warnMax = warnUser
Source Edit
hintMin = hintSuccess
Source Edit
hintMax = hintMsgOrigin
Source Edit
NotesVerbosity = [{warnCannotOpenFile..warnProveInit,
                   warnUnreachableElse..warnStaticIndexCheck, warnGcUnsafe2,
                   warnGcMem..warnCycleCreated, warnUser,
                   hintLineTooLong..hintQuitCalled,
                   hintConditionAlwaysTrue..hintName, hintPerformance,
                   hintExpandMacro..hintUserRaw}, {
    warnCannotOpenFile..warnProveInit,
    warnUnreachableElse..warnStaticIndexCheck, warnGcUnsafe2,
    warnGcMem..warnCycleCreated, warnUser..hintProcessing, hintConf,
    hintConditionAlwaysTrue..hintLinking, hintPerformance,
    hintExpandMacro..hintUserRaw}, {warnCannotOpenFile..warnGcUnsafe2,
                                    warnGcMem..warnCycleCreated,
                                    warnUser..hintPerformance,
                                    hintGCStats..hintUserRaw, hintMsgOrigin},
                  {12..49, 52..84}]
Source Edit
errXMustBeCompileTime = "\'$1\' can only be used in compile-time context"
Source Edit
errArgsNeedRunOption = "arguments can only be given if the \'--run\' option is selected"
Source Edit
InvalidFileIdx = -1'i32
Source Edit
unknownLineInfo = (line: 0'u, col: -1, fileIndex: -1)
Source Edit
trackPosInvalidFileIdx = -2'i32
Source Edit
commandLineIdx = -3'i32
Source Edit

Procs

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

© 2006–2021 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/compiler/lineinfos.html