Skip to main content

Class: DocumentValidator

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:79

Constructors

Constructor

new DocumentValidator(doc, options, settings): DocumentValidator

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:108

Parameters

doc

TextDocument

Document to validate

options

DocumentValidatorOptions

settings

CSpellSettings

Returns

DocumentValidator

Properties

errors

readonly errors: Error[] = []

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:82


options

readonly options: DocumentValidatorOptions

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:87


perfTiming

readonly perfTiming: PerfTimings = {}

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:88


settings

readonly settings: CSpellSettings

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:111


skipValidation

skipValidation: boolean

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:89

Accessors

document

Get Signature

get document(): TextDocument

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:361

Returns

TextDocument


prepTime

Get Signature

get prepTime(): number

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:242

The amount of time in ms to prepare for validation.

Returns

number


ready

Get Signature

get ready(): boolean

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:123

Returns

boolean


validateDirectives

Get Signature

get validateDirectives(): boolean

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:246

Returns

boolean

Methods

_getPreparations()

_getPreparations(): undefined | Preparations

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:489

Internal cspell-lib use.

Returns

undefined | Preparations


check()

check(parsedText): ValidationIssue[]

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:263

Parameters

parsedText

ParsedText

Returns

ValidationIssue[]


checkDocument()

checkDocument(forceCheck): ValidationIssue[]

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:321

Check a Document for Validation Issues.

Note: The validator must be prepared before calling this method.

Parameters

forceCheck

boolean = false

force a check even if the document would normally be excluded.

Returns

ValidationIssue[]

the validation issues.


checkDocumentAsync()

checkDocumentAsync(forceCheck?): Promise<ValidationIssue[]>

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:309

Check a Document for Validation Issues.

Parameters

forceCheck?

boolean

force a check even if the document would normally be excluded.

Returns

Promise<ValidationIssue[]>

the validation issues.


checkDocumentDirectives()

checkDocumentDirectives(forceCheck): ValidationIssue[]

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:339

Parameters

forceCheck

boolean = false

Returns

ValidationIssue[]


checkText()

checkText(range, _text, scope?): ValidationIssue[]

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:257

Check a range of text for validation issues.

Parameters

range

SimpleRange

the range of text to check.

_text

the text to check. If not given, the text will be taken from the document.

undefined | string

scope?

the scope to use for validation. If not given, the default scope will be used.

string | string[]

Returns

ValidationIssue[]

the validation issues.


getCheckedTextRanges()

getCheckedTextRanges(): MatchRange[]

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:374

Get the calculated ranges of text that should be included in the spell checking.

Returns

MatchRange[]

MatchRanges of text to include.


getFinalizedDocSettings()

getFinalizedDocSettings(): CSpellSettingsInternal

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:468

Returns

CSpellSettingsInternal


prepare()

prepare(): Promise<void>

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:127

Returns

Promise<void>


shouldCheckDocument()

shouldCheckDocument(): boolean

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:481

Returns true if the final result of the configuration calculation results in the document being enabled. Note: in some cases, checking the document might still make sense, for example, the @cspell/eslint-plugin relies on eslint configuration to make that determination.

Returns

boolean

true if the document settings have resolved to be enabled


traceWord()

traceWord(word): TraceResult

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:379

Parameters

word

string

Returns

TraceResult


updateDocumentText()

updateDocumentText(text): Promise<void>

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:365

Parameters

text

string

Returns

Promise<void>


create()

static create(doc, options, settingsOrConfigFile): Promise<DocumentValidator>

Defined in: packages/cspell-lib/src/lib/textValidation/docValidator.ts:91

Parameters

doc

TextDocument

options

DocumentValidatorOptions

settingsOrConfigFile

CSpellSettings | ICSpellConfigFile

Returns

Promise<DocumentValidator>