# lineinfos

Theme:

- Index

Search:
Group by:
Source Edit

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

# Imports

ropes, pathutils

# 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

    TErrorOutputs = set[TErrorOutput]

  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, errRstMissingClosing, errRstGridTableNotImplemented,
      errRstMarkdownIllformedTable, errRstIllformedTable, errRstNewSectionExpected,
      errRstGeneralParseError, errRstInvalidDirectiveX, errRstInvalidField,
      errRstFootnoteMismatch, errRstSandboxedDirective, errProveInit, errGenerated,
      errFailedMove, errUser, warnCannotOpenFile = "CannotOpenFile",
      warnOctalEscape = "OctalEscape", warnXIsNeverRead = "XIsNeverRead",
      warnXmightNotBeenInit = "XmightNotBeenInit", warnDeprecated = "Deprecated",
      warnConfigDeprecated = "ConfigDeprecated", warnDotLikeOps = "DotLikeOps",
      warnSmallLshouldNotBeUsed = "SmallLshouldNotBeUsed",
      warnUnknownMagic = "UnknownMagic",
      warnRstRedefinitionOfLabel = "RedefinitionOfLabel",
      warnRstUnknownSubstitutionX = "UnknownSubstitutionX",
      warnRstAmbiguousLink = "AmbiguousLink", warnRstBrokenLink = "BrokenLink",
      warnRstLanguageXNotSupported = "LanguageXNotSupported",
      warnRstFieldXNotSupported = "FieldXNotSupported",
      warnRstUnusedImportdoc = "UnusedImportdoc", 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",
      warnPtrToCstringConv = "PtrToCstringConv", warnEffect = "Effect",
      warnCastSizes = "CastSizes", warnAboveMaxSizeSet = "AboveMaxSizeSet",
      warnImplicitTemplateRedefinition = "ImplicitTemplateRedefinition",
      warnUnnamedBreak = "UnnamedBreak", warnStmtListLambda = "StmtListLambda",
      warnBareExcept = "BareExcept",
      warnImplicitDefaultValue = "ImplicitDefaultValue",
      warnGenericsIgnoredInjection = "GenericsIgnoredInjection", warnUser = "User",
      hintSuccess = "Success", hintSuccessX = "SuccessX", hintCC = "CC",
      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", hintAmbiguousEnum = "AmbiguousEnum",
      hintUser = "User", hintUserRaw = "UserRaw",
      hintExtendedContext = "ExtendedContext", hintMsgOrigin = "MsgOrigin",
      hintDeclaredLoc = "DeclaredLoc", hintUnknownHint = "UnknownHint"

  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 = hintUnknownHint

  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", "$1", "grid table is not implemented",
        "illformed delimiter row of a markdown table", "Illformed table: $1",
        "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", "$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\'",
        "ambiguous doc link $1", "broken link \'$1\'",
        "language \'$1\' not supported", "field \'$1\' not supported",
        "importdoc for \'$1\' is not used", "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", "unsafe conversion to \'cstring\' from \'$1\'; Use a `cast` operation like `cast[cstring](x)`; this will become a compile time error in the future",
        "$1", "$1", "$1", "template \'$1\' is implicitly redefined; this is deprecated, add an explicit .redefine pragma", "Using an unnamed break in a block is deprecated; Use a named block with a named break instead", "statement list expression assumed to be anonymous proc; this is deprecated, use `do (): ...` or `proc () = ...` instead",
        "$1", "$1", "$1", "$1", "operation successful: $#",
        "$build\n$loc lines; ${sec}s; $mem; proj: $project; out: $output", "CC: $1",
        "\'$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", "$1", "unknown hint: $1"]

  Source Edit

    NotesVerbosity = [{warnCannotOpenFile..warnProveInit,
                       warnUnreachableElse..warnStaticIndexCheck,
                       warnGcUnsafe2..warnCycleCreated, warnStrictNotNil,
                       warnCannotOpen..warnSuspiciousEnumConv,
                       warnHoleEnumConv..warnStmtListLambda,
                       warnImplicitDefaultValue..warnUser,
                       hintXDeclaredButNotUsed..hintQuitCalled,
                       hintConditionAlwaysTrue..hintName,
                       hintExpandMacro..hintUserRaw, hintUnknownHint}, {
        warnCannotOpenFile..warnProveInit,
        warnUnreachableElse..warnStaticIndexCheck, warnGcUnsafe2..warnCycleCreated,
        warnStrictNotNil, warnCannotOpen..warnSuspiciousEnumConv,
        warnHoleEnumConv..warnStmtListLambda,
        warnImplicitDefaultValue..hintProcessing, hintConf,
        hintConditionAlwaysTrue..hintLinking, hintExpandMacro..hintUserRaw,
        hintUnknownHint}, {warnCannotOpenFile..warnCycleCreated, warnStrictNotNil,
                           warnCannotOpen..warnSuspiciousEnumConv,
                           warnHoleEnumConv..warnStmtListLambda,
                           warnImplicitDefaultValue..hintProcessing,
                           hintCodeBegin..hintPerformance, hintGCStats..hintUserRaw,
                           hintMsgOrigin, hintUnknownHint},
                      {20..62, warnStrictNotNil, 66..68, 70..78, 80..118}]

  Source Edit

    rstWarnings = {warnRstRedefinitionOfLabel..warnRstStyle}

  Source Edit

    trackPosInvalidFileIdx = -2'i32

  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: [], forbids: [].}

  Source Edit

    proc createDocLink(urlSuffix: string): string {....raises: [], tags: [],
        forbids: [].}

  Source Edit

    proc hash(i: TLineInfo): Hash {....raises: [], tags: [], forbids: [].}

  Source Edit

    proc initMsgConfig(): MsgConfig {....raises: [], tags: [], forbids: [].}

  Source Edit

    proc raiseRecoverableError(msg: string) {.noinline, ...raises: [ERecoverableError],
        tags: [], forbids: [].}

  Source Edit