This module implements the signature matching for resolving the call to overloaded procs, generic procs and operators.
This file implements features required for IDE support.
Due to Nim's nature and the fact that system.nim is always imported, there are lots of potential symbols. Furthermore thanks to templates and macros even context based analysis does not help much: In a context like let x: | where a type has to follow, that type might be constructed from a template like extractField(MyObject, fieldName). We deal with this problem by smart sorting so that the likely symbols come first. This sorting is done this way:
- If there is a prefix (foo|), symbols starting with this prefix come first.
 - If the prefix is part of the name (but the name doesn't start with it), these symbols come second.
 - If we have a prefix, only symbols matching this prefix are returned and nothing else.
 - If we have no prefix, consider the context. We currently distinguish between type and non-type contexts.
 - Finally, sort matches by relevance. The relevance is determined by the number of usages, so strutils.replace comes before strutils.wordWrap.
 - In any case, sorting also considers scoping information. Local variables get high priority.
 
Types
CandidateError = object sym*: PSym firstMismatch*: MismatchInfo diagnostics*: seq[string] enabled*: bool
- Source Edit
 CandidateErrors = seq[CandidateError]
- Source Edit
 MismatchInfo = object kind*: MismatchKind arg*: int formal*: PSym
- Source Edit
 MismatchKind = enum kUnknown, kAlreadyGiven, kUnknownNamedParam, kTypeMismatch, kVarNeeded, kMissingParam, kExtraArg, kPositionalAlreadyGiven
- Source Edit
 TCandidate = object c*: PContext exactMatches*: int genericMatches: int subtypeMatches: int intConvMatches: int convMatches: int state*: TCandidateState callee*: PType calleeSym*: PSym calleeScope*: int call*: PNode bindings*: TIdTable magic*: TMagic baseTypeMatch: bool fauxMatch*: TTypeKind genericConverter*: bool coerceDistincts*: bool typedescMatched*: bool isNoCall*: bool inferredTypes: seq[PType] diagnostics*: seq[string] inheritancePenalty: int firstMismatch*: MismatchInfo diagnosticsEnabled*: bool
- Source Edit
 TCandidateState = enum csEmpty, csMatch, csNoMatch
- Source Edit
 TCheckPointResult = enum cpNone, cpFuzzy, cpExact
- Source Edit
 TTypeRelFlag = enum trDontBind, trNoCovariance, trBindGenericParam
- Source Edit
 TTypeRelFlags = set[TTypeRelFlag]
- Source Edit
 
Procs
proc `$`(suggest: SuggestInlayHint): string {....raises: [], tags: [].}
- Source Edit
 proc argtypeMatches(c: PContext; f, a: PType; fromHlo = false): bool {....raises: [ Exception, KeyError, ValueError, OSError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect].}
- Source Edit
 proc cmpCandidates(a, b: TCandidate): int {....raises: [Exception], tags: [RootEffect].}
- Source Edit
 proc cmpTypes(c: PContext; f, a: PType): TTypeRelation {....raises: [KeyError, Exception, ValueError, OSError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect].}
- Source Edit
 proc describeArgs(c: PContext; n: PNode; startIdx = 1; prefer = preferName): string {. ...raises: [Exception, KeyError, ValueError], tags: [RootEffect].}
- Source Edit
 proc fieldVisible(c: PContext; f: PSym): bool {.inline, ...raises: [], tags: [].}
- Source Edit
 proc inCheckpoint(current, trackPos: TLineInfo): TCheckPointResult {....raises: [], tags: [].}
- Source Edit
 proc inferStaticParam(c: var TCandidate; lhs: PNode; rhs: BiggestInt): bool {. ...raises: [], tags: [].}
- Source Edit
 proc initCandidate(ctx: PContext; c: var TCandidate; callee: PSym; binding: PNode; calleeScope = -1; diagnosticsEnabled = false) {. ...raises: [], tags: [].}
- Source Edit
 proc initCandidate(ctx: PContext; c: var TCandidate; callee: PType) {. ...raises: [], tags: [].}
- Source Edit
 proc instTypeBoundOp(c: PContext; dc: PSym; t: PType; info: TLineInfo; op: TTypeAttachedOp; col: int): PSym {.nosinks, ...raises: [ Exception, ValueError, KeyError, OSError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect].}
- Source Edit
 proc isTracked(current, trackPos: TLineInfo; tokenLen: int): bool {....raises: [], tags: [].}
- Source Edit
 proc markOwnerModuleAsUsed(c: PContext; s: PSym) {....raises: [], tags: [].}
- Source Edit
 proc markUsed(c: PContext; info: TLineInfo; s: PSym) {....raises: [Exception, ValueError, KeyError, OSError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect].}
- Source Edit
 proc matches(c: PContext; n, nOrig: PNode; m: var TCandidate) {....raises: [ KeyError, Exception, ValueError, OSError, IOError, ERecoverableError], tags: [ ReadDirEffect, RootEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect].}
- Source Edit
 proc matchUserTypeClass(m: var TCandidate; ff, a: PType): PType {....raises: [ Exception, ValueError, KeyError, OSError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect].}
- Source Edit
 proc newCandidate(ctx: PContext; callee: PSym; binding: PNode; calleeScope = -1): TCandidate {. ...raises: [], tags: [].}
- Source Edit
 proc newCandidate(ctx: PContext; callee: PType): TCandidate {....raises: [], tags: [].}
- Source Edit
 proc paramTypesMatch(m: var TCandidate; f, a: PType; arg, argOrig: PNode): PNode {....raises: [ Exception, KeyError, ValueError, OSError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect].}
- Source Edit
 proc partialMatch(c: PContext; n, nOrig: PNode; m: var TCandidate) {....raises: [ KeyError, Exception, ValueError, OSError, IOError, ERecoverableError], tags: [ ReadDirEffect, RootEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect].}
- Source Edit
 proc safeSemExpr(c: PContext; n: PNode): PNode {....raises: [Exception], tags: [RootEffect].}
- Source Edit
 proc semFinishOperands(c: PContext; n: PNode) {....raises: [Exception], tags: [RootEffect].}
- Source Edit
 proc suggestDecl(c: PContext; n: PNode; s: PSym) {....raises: [Exception, KeyError, ValueError, OSError, IOError, ERecoverableError, ESuggestDone], tags: [ RootEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect, ReadEnvEffect].}
- Source Edit
 proc suggestEnum(c: PContext; n: PNode; t: PType) {. ...raises: [Exception, KeyError, ValueError, IOError, ESuggestDone], tags: [RootEffect, ReadIOEffect, WriteIOEffect].}
- Source Edit
 proc suggestExpr(c: PContext; n: PNode) {....raises: [Exception, KeyError, ValueError, OSError, IOError, ERecoverableError, ESuggestDone], tags: [ RootEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect, ReadEnvEffect].}
- Source Edit
 proc suggestExprNoCheck(c: PContext; n: PNode) {....raises: [Exception, KeyError, ValueError, OSError, IOError, ERecoverableError, ESuggestDone], tags: [ RootEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect, ReadEnvEffect].}
- Source Edit
 proc suggestResult(conf: ConfigRef; s: Suggest) {....raises: [Exception, IOError], tags: [RootEffect, WriteIOEffect].}
- Source Edit
 proc suggestSentinel(c: PContext) {....raises: [KeyError, Exception, ValueError, IOError], tags: [ReadDirEffect, RootEffect, ReadIOEffect, WriteIOEffect].}
- Source Edit
 proc suggestStmt(c: PContext; n: PNode) {....raises: [Exception, KeyError, ValueError, OSError, IOError, ERecoverableError, ESuggestDone], tags: [ RootEffect, ReadIOEffect, ReadDirEffect, WriteIOEffect, ReadEnvEffect].}
- Source Edit
 proc suggestSym(g: ModuleGraph; info: TLineInfo; s: PSym; usageSym: var PSym; isDecl = true) {.inline, ...raises: [], tags: [].}
- misnamed: should be 'symDeclared' Source Edit
 proc suggestToSuggestInlayHint(sug: Suggest): SuggestInlayHint {....raises: [], tags: [].}
- Source Edit
 proc symToSuggest(g: ModuleGraph; s: PSym; isLocal: bool; section: IdeCmd; info: TLineInfo; quality: range[0 .. 100]; prefix: PrefixMatch; inTypeContext: bool; scope: int; useSuppliedInfo = false; endLine: uint16 = 0; endCol = 0): Suggest {. ...raises: [Exception, KeyError, ValueError], tags: [RootEffect, ReadIOEffect].}
- Source Edit
 proc typeRel(c: var TCandidate; f, aOrig: PType; flags: TTypeRelFlags = {}): TTypeRelation {....raises: [ KeyError, Exception, ValueError, OSError, IOError, ERecoverableError], tags: [ RootEffect, ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect].}
- Source Edit
 proc writeMatches(c: TCandidate) {....raises: [Exception, KeyError, OSError], tags: [RootEffect, ReadDirEffect].}
- Source Edit
 
Templates
template hasFauxMatch(c: TCandidate): bool
- Source Edit