lix-website/themes/lix/assets/bootstrap/node_modules/cspell-lib/dist/spellCheckFile.d.ts

81 lines
3.9 KiB
TypeScript
Raw Normal View History

2024-04-27 03:39:10 +00:00
/// <reference types="node" />
import type { CSpellSettingsWithSourceTrace, CSpellUserSettings } from '@cspell/cspell-types';
import { URI } from 'vscode-uri';
import { ValidateTextOptions, ValidationIssue } from './validator';
export interface SpellCheckFileOptions extends ValidateTextOptions {
/**
* Optional path to a configuration file.
* If given, it will be used instead of searching for a configuration file.
*/
configFile?: string;
/**
* File encoding
* @defaultValue 'utf-8'
*/
encoding?: BufferEncoding;
/**
* Prevents searching for local configuration files
* By default the spell checker looks for configuration files
* starting at the location of given filename.
* If `configFile` is defined it will still be loaded instead of searching.
* `false` will override the value in `settings.noConfigSearch`.
* @defaultValue undefined
*/
noConfigSearch?: boolean;
}
export interface SpellCheckFileResult {
document: Document | DocumentWithText;
settingsUsed: CSpellSettingsWithSourceTrace;
localConfigFilepath: string | undefined;
options: SpellCheckFileOptions;
issues: ValidationIssue[];
checked: boolean;
errors: Error[] | undefined;
}
export declare type UriString = string;
export interface DocumentWithText extends Document {
text: string;
}
export interface Document {
uri: UriString;
text?: string;
languageId?: string;
locale?: string;
}
/**
* Spell Check a file
* @param file - absolute path to file to read and check.
* @param options - options to control checking
* @param settings - default settings to use.
*/
export declare function spellCheckFile(file: string, options: SpellCheckFileOptions, settings: CSpellUserSettings): Promise<SpellCheckFileResult>;
/**
* Spell Check a Document.
* @param document - document to be checked. If `document.text` is `undefined` the file will be loaded
* @param options - options to control checking
* @param settings - default settings to use.
*/
export declare function spellCheckDocument(document: Document | DocumentWithText, options: SpellCheckFileOptions, settings: CSpellUserSettings): Promise<SpellCheckFileResult>;
export interface DetermineFinalDocumentSettingsResult {
document: DocumentWithText;
settings: CSpellSettingsWithSourceTrace;
}
/**
* Combines all relevant setting values into a final configuration to be used for spell checking.
* It applies any overrides and appropriate language settings by taking into account the document type (languageId)
* the locale (natural language) and any in document settings.
*
* Note: this method will not search for configuration files. Configuration files should already be merged into `settings`.
* It is NOT necessary to include the cspell defaultSettings or globalSettings. They will be applied within this function.
* @param document - The document to be spell checked. Note: if the URI doesn't have a path, overrides cannot be applied.
* `locale` - if defined will be used unless it is overridden by an in-document setting.
* `languageId` - if defined will be used to select appropriate file type dictionaries.
* @param settings - The near final settings. Should already be the combination of all configuration files.
*/
export declare function determineFinalDocumentSettings(document: DocumentWithText, settings: CSpellUserSettings): DetermineFinalDocumentSettingsResult;
export declare function isBinaryDoc(document: Document): boolean;
export declare function isBinaryFile(filenameUri: URI, languageId?: string | string[]): boolean;
export declare function fileToDocument(file: string): Document;
export declare function fileToDocument(file: string, text: string, languageId?: string, locale?: string): DocumentWithText;
export declare function fileToDocument(file: string, text?: string, languageId?: string, locale?: string): Document | DocumentWithText;
//# sourceMappingURL=spellCheckFile.d.ts.map