cspell-lib 6.7.0 → 6.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LanguageIds.js +2 -0
- package/dist/Settings/CSpellSettingsServer.d.ts +0 -4
- package/dist/Settings/CSpellSettingsServer.js +6 -9
- package/dist/Settings/Controller/configLoader/configLoader.d.ts +137 -0
- package/dist/Settings/Controller/configLoader/configLoader.js +489 -0
- package/dist/Settings/Controller/configLoader/extractImportErrors.d.ts +7 -0
- package/dist/Settings/Controller/configLoader/extractImportErrors.js +26 -0
- package/dist/Settings/Controller/configLoader/index.d.ts +4 -0
- package/dist/Settings/Controller/configLoader/index.js +26 -0
- package/dist/Settings/Controller/configLoader/normalizeRawSettings.d.ts +50 -0
- package/dist/Settings/Controller/configLoader/normalizeRawSettings.js +136 -0
- package/dist/Settings/Controller/configLoader/readSettings.d.ts +23 -0
- package/dist/Settings/Controller/configLoader/readSettings.js +12 -0
- package/dist/Settings/Controller/configLoader/toGlobDef.d.ts +6 -0
- package/dist/Settings/Controller/configLoader/toGlobDef.js +23 -0
- package/dist/Settings/InDocSettings.d.ts +16 -0
- package/dist/Settings/InDocSettings.js +132 -15
- package/dist/Settings/RegExpPatterns.js +1 -1
- package/dist/Settings/constants.d.ts +5 -0
- package/dist/Settings/constants.js +8 -0
- package/dist/Settings/index.d.ts +2 -1
- package/dist/Settings/index.js +4 -3
- package/dist/SpellingDictionary/SpellingDictionary.d.ts +13 -0
- package/dist/SpellingDictionary/createSpellingDictionary.js +2 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -1
- package/dist/spellCheckFile.d.ts +3 -0
- package/dist/spellCheckFile.js +14 -3
- package/dist/textValidation/ValidationTypes.d.ts +2 -2
- package/dist/textValidation/checkText.d.ts +47 -0
- package/dist/textValidation/checkText.js +152 -0
- package/dist/textValidation/docValidator.d.ts +16 -1
- package/dist/textValidation/docValidator.js +43 -1
- package/dist/textValidation/index.d.ts +6 -4
- package/dist/textValidation/index.js +7 -5
- package/dist/textValidation/validator.d.ts +11 -19
- package/dist/textValidation/validator.js +25 -69
- package/dist/util/errors.js +0 -1
- package/dist/util/util.d.ts +1 -1
- package/dist/validator.d.ts +1 -1
- package/dist/validator.js +2 -1
- package/package.json +19 -19
- package/dist/Settings/Controller/configLoader.d.ts +0 -84
- package/dist/Settings/Controller/configLoader.js +0 -564
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.normalizeCacheSettings = exports.normalizeSettingsGlobs = exports.normalizeGitignoreRoot = exports.normalizeLanguageSettings = exports.normalizeReporters = exports.normalizeOverrides = exports.normalizeDictionaryDefs = exports.normalizeRawConfig = void 0;
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const resolveFile_1 = require("../../../util/resolveFile");
|
|
29
|
+
const util = __importStar(require("../../../util/util"));
|
|
30
|
+
const DictionarySettings_1 = require("../../DictionarySettings");
|
|
31
|
+
const toGlobDef_1 = require("./toGlobDef");
|
|
32
|
+
function normalizeRawConfig(config) {
|
|
33
|
+
if (typeof config.version === 'number') {
|
|
34
|
+
config.version = config.version.toString();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.normalizeRawConfig = normalizeRawConfig;
|
|
38
|
+
function normalizeDictionaryDefs(settings, pathToSettingsFile) {
|
|
39
|
+
const dictionaryDefinitions = (0, DictionarySettings_1.mapDictDefsToInternal)(settings.dictionaryDefinitions, pathToSettingsFile);
|
|
40
|
+
const languageSettings = settings.languageSettings?.map((langSetting) => util.clean({
|
|
41
|
+
...langSetting,
|
|
42
|
+
dictionaryDefinitions: (0, DictionarySettings_1.mapDictDefsToInternal)(langSetting.dictionaryDefinitions, pathToSettingsFile),
|
|
43
|
+
}));
|
|
44
|
+
return util.clean({
|
|
45
|
+
dictionaryDefinitions,
|
|
46
|
+
languageSettings,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
exports.normalizeDictionaryDefs = normalizeDictionaryDefs;
|
|
50
|
+
function normalizeOverrides(settings, pathToSettingsFile) {
|
|
51
|
+
const { globRoot = path.dirname(pathToSettingsFile) } = settings;
|
|
52
|
+
const overrides = settings.overrides?.map((override) => {
|
|
53
|
+
const filename = (0, toGlobDef_1.toGlobDef)(override.filename, globRoot, pathToSettingsFile);
|
|
54
|
+
const { dictionaryDefinitions, languageSettings } = normalizeDictionaryDefs(override, pathToSettingsFile);
|
|
55
|
+
return util.clean({
|
|
56
|
+
...override,
|
|
57
|
+
filename,
|
|
58
|
+
dictionaryDefinitions,
|
|
59
|
+
languageSettings: normalizeLanguageSettings(languageSettings),
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
return overrides ? { overrides } : {};
|
|
63
|
+
}
|
|
64
|
+
exports.normalizeOverrides = normalizeOverrides;
|
|
65
|
+
function normalizeReporters(settings, pathToSettingsFile) {
|
|
66
|
+
if (settings.reporters === undefined)
|
|
67
|
+
return {};
|
|
68
|
+
const folder = path.dirname(pathToSettingsFile);
|
|
69
|
+
function resolve(s) {
|
|
70
|
+
const r = (0, resolveFile_1.resolveFile)(s, folder);
|
|
71
|
+
if (!r.found) {
|
|
72
|
+
throw new Error(`Not found: "${s}"`);
|
|
73
|
+
}
|
|
74
|
+
return r.filename;
|
|
75
|
+
}
|
|
76
|
+
function resolveReporter(s) {
|
|
77
|
+
if (typeof s === 'string') {
|
|
78
|
+
return resolve(s);
|
|
79
|
+
}
|
|
80
|
+
if (!Array.isArray(s) || typeof s[0] !== 'string')
|
|
81
|
+
throw new Error('Invalid Reporter');
|
|
82
|
+
// Preserve the shape of Reporter Setting while resolving the reporter file.
|
|
83
|
+
const [r, ...rest] = s;
|
|
84
|
+
return [resolve(r), ...rest];
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
reporters: settings.reporters.map(resolveReporter),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
exports.normalizeReporters = normalizeReporters;
|
|
91
|
+
function normalizeLanguageSettings(languageSettings) {
|
|
92
|
+
if (!languageSettings)
|
|
93
|
+
return undefined;
|
|
94
|
+
function fixLocale(s) {
|
|
95
|
+
const { local: locale, ...rest } = s;
|
|
96
|
+
return util.clean({ locale, ...rest });
|
|
97
|
+
}
|
|
98
|
+
return languageSettings.map(fixLocale);
|
|
99
|
+
}
|
|
100
|
+
exports.normalizeLanguageSettings = normalizeLanguageSettings;
|
|
101
|
+
function normalizeGitignoreRoot(settings, pathToSettingsFile) {
|
|
102
|
+
const { gitignoreRoot } = settings;
|
|
103
|
+
if (!gitignoreRoot)
|
|
104
|
+
return {};
|
|
105
|
+
const dir = path.dirname(pathToSettingsFile);
|
|
106
|
+
const roots = Array.isArray(gitignoreRoot) ? gitignoreRoot : [gitignoreRoot];
|
|
107
|
+
return {
|
|
108
|
+
gitignoreRoot: roots.map((p) => path.resolve(dir, p)),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
exports.normalizeGitignoreRoot = normalizeGitignoreRoot;
|
|
112
|
+
function normalizeSettingsGlobs(settings, pathToSettingsFile) {
|
|
113
|
+
const { globRoot } = settings;
|
|
114
|
+
if (settings.ignorePaths === undefined)
|
|
115
|
+
return {};
|
|
116
|
+
const ignorePaths = (0, toGlobDef_1.toGlobDef)(settings.ignorePaths, globRoot, pathToSettingsFile);
|
|
117
|
+
return {
|
|
118
|
+
ignorePaths,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
exports.normalizeSettingsGlobs = normalizeSettingsGlobs;
|
|
122
|
+
function normalizeCacheSettings(settings, pathToSettingsDir) {
|
|
123
|
+
const { cache } = settings;
|
|
124
|
+
if (cache === undefined)
|
|
125
|
+
return {};
|
|
126
|
+
const { cacheLocation } = cache;
|
|
127
|
+
if (cacheLocation === undefined)
|
|
128
|
+
return { cache };
|
|
129
|
+
return { cache: { ...cache, cacheLocation: resolveFilePath(cacheLocation, pathToSettingsDir) } };
|
|
130
|
+
}
|
|
131
|
+
exports.normalizeCacheSettings = normalizeCacheSettings;
|
|
132
|
+
function resolveFilePath(filename, pathToSettingsFile) {
|
|
133
|
+
const cwd = process.cwd();
|
|
134
|
+
return path.resolve(pathToSettingsFile, filename.replace('${cwd}', cwd));
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=normalizeRawSettings.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CSpellSettingsI, CSpellSettingsWST } from './configLoader';
|
|
2
|
+
/**
|
|
3
|
+
* Read / import a cspell configuration file.
|
|
4
|
+
* @param filename - the path to the file.
|
|
5
|
+
* Supported types: json, yaml, js, and cjs. ES Modules are not supported.
|
|
6
|
+
* - absolute path `/absolute/path/to/file`
|
|
7
|
+
* - relative path `./path/to/file` (relative to the current working directory)
|
|
8
|
+
* - package `@cspell/dict-typescript/cspell-ext.json`
|
|
9
|
+
*/
|
|
10
|
+
export declare function readSettings(filename: string): CSpellSettingsI;
|
|
11
|
+
export declare function readSettings(filename: string, defaultValues: CSpellSettingsWST): CSpellSettingsI;
|
|
12
|
+
/**
|
|
13
|
+
* Read / import a cspell configuration file.
|
|
14
|
+
* @param filename - the path to the file.
|
|
15
|
+
* Supported types: json, yaml, js, and cjs. ES Modules are not supported.
|
|
16
|
+
* - absolute path `/absolute/path/to/file`
|
|
17
|
+
* - relative path `./path/to/file` (relative to `relativeTo`)
|
|
18
|
+
* - package `@cspell/dict-typescript/cspell-ext.json` searches for node_modules relative to `relativeTo`
|
|
19
|
+
* @param relativeTo - absolute path to start searching for relative files or node_modules.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readSettings(filename: string, relativeTo: string): CSpellSettingsI;
|
|
22
|
+
export declare function readSettings(filename: string, relativeTo: string, defaultValues: CSpellSettingsWST): CSpellSettingsI;
|
|
23
|
+
//# sourceMappingURL=readSettings.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readSettings = void 0;
|
|
4
|
+
const configLoader_1 = require("./configLoader");
|
|
5
|
+
function readSettings(filename, relativeToOrDefault, defaultValue) {
|
|
6
|
+
const loader = (0, configLoader_1.getDefaultConfigLoader)();
|
|
7
|
+
if (typeof relativeToOrDefault !== 'string' || defaultValue === undefined)
|
|
8
|
+
return loader.readSettings(filename, relativeToOrDefault);
|
|
9
|
+
return loader.readSettings(filename, relativeToOrDefault, defaultValue);
|
|
10
|
+
}
|
|
11
|
+
exports.readSettings = readSettings;
|
|
12
|
+
//# sourceMappingURL=readSettings.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Glob, GlobDef } from '@cspell/cspell-types';
|
|
2
|
+
export declare function toGlobDef(g: undefined, root: string | undefined, source: string | undefined): undefined;
|
|
3
|
+
export declare function toGlobDef(g: Glob, root: string | undefined, source: string | undefined): GlobDef;
|
|
4
|
+
export declare function toGlobDef(g: Glob[], root: string | undefined, source: string | undefined): GlobDef[];
|
|
5
|
+
export declare function toGlobDef(g: Glob | Glob[], root: string | undefined, source: string | undefined): GlobDef | GlobDef[];
|
|
6
|
+
//# sourceMappingURL=toGlobDef.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toGlobDef = void 0;
|
|
4
|
+
function toGlobDef(g, root, source) {
|
|
5
|
+
if (g === undefined)
|
|
6
|
+
return undefined;
|
|
7
|
+
if (Array.isArray(g)) {
|
|
8
|
+
return g.map((g) => toGlobDef(g, root, source));
|
|
9
|
+
}
|
|
10
|
+
if (typeof g === 'string') {
|
|
11
|
+
const glob = { glob: g };
|
|
12
|
+
if (root !== undefined) {
|
|
13
|
+
glob.root = root;
|
|
14
|
+
}
|
|
15
|
+
return toGlobDef(glob, root, source);
|
|
16
|
+
}
|
|
17
|
+
if (source) {
|
|
18
|
+
return { ...g, source };
|
|
19
|
+
}
|
|
20
|
+
return g;
|
|
21
|
+
}
|
|
22
|
+
exports.toGlobDef = toGlobDef;
|
|
23
|
+
//# sourceMappingURL=toGlobDef.js.map
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import type { CSpellUserSettings } from '@cspell/cspell-types';
|
|
2
2
|
import { Sequence } from 'gensequence';
|
|
3
3
|
export declare type CSpellUserSettingsKeys = keyof CSpellUserSettings;
|
|
4
|
+
export interface DirectiveIssue {
|
|
5
|
+
/**
|
|
6
|
+
* the start and end offsets within the document of the issue.
|
|
7
|
+
*/
|
|
8
|
+
range: [start: number, end: number];
|
|
9
|
+
/**
|
|
10
|
+
* The text causing the issue.
|
|
11
|
+
*/
|
|
12
|
+
text: string;
|
|
13
|
+
message: string;
|
|
14
|
+
suggestions: string[];
|
|
15
|
+
}
|
|
4
16
|
export declare function getInDocumentSettings(text: string): CSpellUserSettings;
|
|
17
|
+
export declare function validateInDocumentSettings(docText: string, _settings: CSpellUserSettings): Iterable<DirectiveIssue>;
|
|
18
|
+
export declare const regExSpellingGuardBlock: RegExp;
|
|
19
|
+
export declare const regExSpellingGuardNext: RegExp;
|
|
20
|
+
export declare const regExSpellingGuardLine: RegExp;
|
|
5
21
|
declare function parseCompoundWords(match: string): CSpellUserSettings;
|
|
6
22
|
declare function parseWords(match: string): CSpellUserSettings;
|
|
7
23
|
declare function parseIgnoreWords(match: string): CSpellUserSettings;
|
|
@@ -23,14 +23,70 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.internal = exports.getIgnoreRegExpFromDocument = exports.getIgnoreWordsFromDocument = exports.getInDocumentSettings = void 0;
|
|
26
|
+
exports.internal = exports.getIgnoreRegExpFromDocument = exports.getIgnoreWordsFromDocument = exports.regExSpellingGuardLine = exports.regExSpellingGuardNext = exports.regExSpellingGuardBlock = exports.validateInDocumentSettings = exports.getInDocumentSettings = void 0;
|
|
27
|
+
const cspell_pipe_1 = require("@cspell/cspell-pipe");
|
|
27
28
|
const gensequence_1 = require("gensequence");
|
|
29
|
+
const SpellingDictionary_1 = require("../SpellingDictionary");
|
|
28
30
|
const Text = __importStar(require("../util/text"));
|
|
29
31
|
const util_1 = require("../util/util");
|
|
30
32
|
const CSpellSettingsServer_1 = require("./CSpellSettingsServer");
|
|
31
33
|
// cspell:ignore gimuy
|
|
32
34
|
const regExMatchRegEx = /\/.*\/[gimuy]*/;
|
|
33
|
-
const
|
|
35
|
+
const regExCSpellInDocDirective = /(?:spell-?checker|c?spell)::?(.*)/gi;
|
|
36
|
+
const regExCSpellDirectiveKey = /(?<=(?:spell-?checker|c?spell)::?)(?!:)(.*)/i;
|
|
37
|
+
const regExInFileSettings = [regExCSpellInDocDirective, /(LocalWords:?.*)/g];
|
|
38
|
+
const officialDirectives = [
|
|
39
|
+
'enable',
|
|
40
|
+
'disable',
|
|
41
|
+
'disable-line',
|
|
42
|
+
'disable-next',
|
|
43
|
+
'disable-next-line',
|
|
44
|
+
'word',
|
|
45
|
+
'words',
|
|
46
|
+
'ignore',
|
|
47
|
+
'ignoreWord',
|
|
48
|
+
'ignoreWords',
|
|
49
|
+
'ignore-word',
|
|
50
|
+
'ignore-words',
|
|
51
|
+
'includeRegExp',
|
|
52
|
+
'ignoreRegExp',
|
|
53
|
+
'local',
|
|
54
|
+
'locale',
|
|
55
|
+
'language',
|
|
56
|
+
'dictionaries',
|
|
57
|
+
'dictionary',
|
|
58
|
+
'forbid',
|
|
59
|
+
'forbidWord',
|
|
60
|
+
'forbid-word',
|
|
61
|
+
'flag',
|
|
62
|
+
'flagWord',
|
|
63
|
+
'flag-word',
|
|
64
|
+
'enableCompoundWords',
|
|
65
|
+
'enableAllowCompoundWords',
|
|
66
|
+
'disableCompoundWords',
|
|
67
|
+
'disableAllowCompoundWords',
|
|
68
|
+
'enableCaseSensitive',
|
|
69
|
+
'disableCaseSensitive',
|
|
70
|
+
];
|
|
71
|
+
const noSuggestDirectives = new Set(['local']);
|
|
72
|
+
const preferredDirectives = [
|
|
73
|
+
'enable',
|
|
74
|
+
'disable',
|
|
75
|
+
'disable-line',
|
|
76
|
+
'disable-next-line',
|
|
77
|
+
'words',
|
|
78
|
+
'ignore',
|
|
79
|
+
'forbid',
|
|
80
|
+
'locale',
|
|
81
|
+
'dictionary',
|
|
82
|
+
'dictionaries',
|
|
83
|
+
'enableCaseSensitive',
|
|
84
|
+
'disableCaseSensitive',
|
|
85
|
+
];
|
|
86
|
+
const allDirectives = new Set(preferredDirectives.concat(officialDirectives));
|
|
87
|
+
const dictInDocSettings = (0, SpellingDictionary_1.createSpellingDictionary)(allDirectives, 'Directives', 'Directive List', {
|
|
88
|
+
supportNonStrictSearches: false,
|
|
89
|
+
});
|
|
34
90
|
const EmptyWords = [];
|
|
35
91
|
Object.freeze(EmptyWords);
|
|
36
92
|
function getInDocumentSettings(text) {
|
|
@@ -43,21 +99,66 @@ function getInDocumentSettings(text) {
|
|
|
43
99
|
return settings;
|
|
44
100
|
}
|
|
45
101
|
exports.getInDocumentSettings = getInDocumentSettings;
|
|
102
|
+
function validateInDocumentSettings(docText, _settings) {
|
|
103
|
+
return (0, cspell_pipe_1.pipeSync)(getPossibleInDocSettings(docText), (0, cspell_pipe_1.opMap)(parseSettingMatchValidation), (0, cspell_pipe_1.opFilter)(util_1.isDefined));
|
|
104
|
+
}
|
|
105
|
+
exports.validateInDocumentSettings = validateInDocumentSettings;
|
|
106
|
+
const settingParsers = [
|
|
107
|
+
[/^(?:enable|disable)(?:allow)?CompoundWords\b(?!-)/i, parseCompoundWords],
|
|
108
|
+
[/^(?:enable|disable)CaseSensitive\b(?!-)/i, parseCaseSensitive],
|
|
109
|
+
[/^enable\b(?!-)/i, parseEnable],
|
|
110
|
+
[/^disable(-line|-next(-line)?)?\b(?!-)/i, parseDisable],
|
|
111
|
+
[/^words?\b(?!-)/i, parseWords],
|
|
112
|
+
[/^ignore(?:-?words?)?\b(?!-)/i, parseIgnoreWords],
|
|
113
|
+
[/^(?:flag|forbid)(?:-?words?)?\b(?!-)/i, parseFlagWords],
|
|
114
|
+
[/^ignore_?Reg_?Exp\s+.+$/i, parseIgnoreRegExp],
|
|
115
|
+
[/^include_?Reg_?Exp\s+.+$/i, parseIncludeRegExp],
|
|
116
|
+
[/^locale?\b(?!-)/i, parseLocale],
|
|
117
|
+
[/^language\s\b(?!-)/i, parseLocale],
|
|
118
|
+
[/^dictionar(?:y|ies)\b(?!-)/i, parseDictionaries],
|
|
119
|
+
[/^LocalWords:/, (w) => parseWords(w.replace(/^LocalWords:?/gi, ' '))],
|
|
120
|
+
];
|
|
121
|
+
exports.regExSpellingGuardBlock = /(\bc?spell(?:-?checker)?::?)\s*disable(?!-line|-next)\b[\s\S]*?((?:\1\s*enable\b)|$)/gi;
|
|
122
|
+
exports.regExSpellingGuardNext = /\bc?spell(?:-?checker)?::?\s*disable-next\b.*\s\s?.*/gi;
|
|
123
|
+
exports.regExSpellingGuardLine = /^.*\bc?spell(?:-?checker)?::?\s*disable-line\b.*/gim;
|
|
124
|
+
const issueMessages = {
|
|
125
|
+
unknownDirective: 'Unknown CSpell directive',
|
|
126
|
+
};
|
|
127
|
+
function parseSettingMatchValidation(matchArray) {
|
|
128
|
+
const [fullMatch = ''] = matchArray;
|
|
129
|
+
const directiveMatch = fullMatch.match(regExCSpellDirectiveKey);
|
|
130
|
+
if (!directiveMatch)
|
|
131
|
+
return undefined;
|
|
132
|
+
const match = directiveMatch[1];
|
|
133
|
+
const possibleSetting = match.trim();
|
|
134
|
+
if (!possibleSetting)
|
|
135
|
+
return undefined;
|
|
136
|
+
const start = (matchArray.index || 0) + (directiveMatch.index || 0) + (match.length - match.trimStart().length);
|
|
137
|
+
const text = possibleSetting.replace(/^([-\w]+)?.*/, '$1');
|
|
138
|
+
const end = start + text.length;
|
|
139
|
+
if (!text)
|
|
140
|
+
return undefined;
|
|
141
|
+
const matchingParsers = settingParsers.filter(([regex]) => regex.test(possibleSetting));
|
|
142
|
+
if (matchingParsers.length > 0)
|
|
143
|
+
return undefined;
|
|
144
|
+
// No matches were found, let make some suggestions.
|
|
145
|
+
const dictSugs = dictInDocSettings
|
|
146
|
+
.suggest(text, { ignoreCase: false })
|
|
147
|
+
.map((sug) => sug.word)
|
|
148
|
+
.filter((a) => !noSuggestDirectives.has(a));
|
|
149
|
+
const sugs = new Set((0, cspell_pipe_1.pipeSync)(dictSugs, (0, cspell_pipe_1.opAppend)(allDirectives)));
|
|
150
|
+
const suggestions = [...sugs].slice(0, 8);
|
|
151
|
+
const issue = {
|
|
152
|
+
range: [start, end],
|
|
153
|
+
text,
|
|
154
|
+
message: issueMessages.unknownDirective,
|
|
155
|
+
suggestions,
|
|
156
|
+
};
|
|
157
|
+
return issue;
|
|
158
|
+
}
|
|
46
159
|
function parseSettingMatch(matchArray) {
|
|
47
160
|
const [, match = ''] = matchArray;
|
|
48
161
|
const possibleSetting = match.trim();
|
|
49
|
-
const settingParsers = [
|
|
50
|
-
[/^(?:enable|disable)(?:allow)?CompoundWords/i, parseCompoundWords],
|
|
51
|
-
[/^(?:enable|disable)CaseSensitive/i, parseCaseSensitive],
|
|
52
|
-
[/^words?\s/i, parseWords],
|
|
53
|
-
[/^ignore(?:words?)?\s/i, parseIgnoreWords],
|
|
54
|
-
[/^ignore_?Reg_?Exp\s+.+$/i, parseIgnoreRegExp],
|
|
55
|
-
[/^include_?Reg_?Exp\s+.+$/i, parseIncludeRegExp],
|
|
56
|
-
[/^locale?\s/i, parseLocale],
|
|
57
|
-
[/^language\s/i, parseLocale],
|
|
58
|
-
[/^dictionaries\s/i, parseDictionaries],
|
|
59
|
-
[/^LocalWords:/, (w) => parseWords(w.replace(/LocalWords:?/gi, ' '))],
|
|
60
|
-
];
|
|
61
162
|
return settingParsers
|
|
62
163
|
.filter(([regex]) => regex.test(possibleSetting))
|
|
63
164
|
.map(([, fn]) => fn)
|
|
@@ -72,7 +173,11 @@ function parseCaseSensitive(match) {
|
|
|
72
173
|
return { id: 'in-doc-caseSensitive', caseSensitive };
|
|
73
174
|
}
|
|
74
175
|
function parseWords(match) {
|
|
75
|
-
const words = match
|
|
176
|
+
const words = match
|
|
177
|
+
// .replace(/[@#$%^&={}/"]/g, ' ')
|
|
178
|
+
.split(/[,\s;]+/g)
|
|
179
|
+
.slice(1)
|
|
180
|
+
.filter((a) => !!a);
|
|
76
181
|
return { id: 'in-doc-words', words };
|
|
77
182
|
}
|
|
78
183
|
function parseLocale(match) {
|
|
@@ -84,6 +189,10 @@ function parseIgnoreWords(match) {
|
|
|
84
189
|
const wordsSetting = parseWords(match);
|
|
85
190
|
return (0, util_1.clean)({ id: 'in-doc-ignore', ignoreWords: wordsSetting.words });
|
|
86
191
|
}
|
|
192
|
+
function parseFlagWords(match) {
|
|
193
|
+
const wordsSetting = parseWords(match);
|
|
194
|
+
return (0, util_1.clean)({ id: 'in-doc-forbid', flagWords: wordsSetting.words });
|
|
195
|
+
}
|
|
87
196
|
function parseRegEx(match) {
|
|
88
197
|
const patterns = [match.replace(/^[^\s]+\s+/, '')].map((a) => {
|
|
89
198
|
const m = a.match(regExMatchRegEx);
|
|
@@ -113,6 +222,14 @@ function getWordsFromDocument(text) {
|
|
|
113
222
|
const { words = EmptyWords } = getInDocumentSettings(text);
|
|
114
223
|
return words;
|
|
115
224
|
}
|
|
225
|
+
function parseEnable(_match) {
|
|
226
|
+
// Do nothing. Enable / Disable is handled in a different way.
|
|
227
|
+
return {};
|
|
228
|
+
}
|
|
229
|
+
function parseDisable(_match) {
|
|
230
|
+
// Do nothing. Enable / Disable is handled in a different way.
|
|
231
|
+
return {};
|
|
232
|
+
}
|
|
116
233
|
function getIgnoreWordsFromDocument(text) {
|
|
117
234
|
const { ignoreWords = EmptyWords } = getInDocumentSettings(text);
|
|
118
235
|
return ignoreWords;
|
|
@@ -12,7 +12,7 @@ exports.regExCStyleHexValue = /\b0x[0-9a-f]+\b/gi;
|
|
|
12
12
|
exports.regExCSSHexValue = /#[0-9a-f]{3,8}\b/gi;
|
|
13
13
|
exports.regExUUID = /\b[0-9a-fx]{8}-[0-9a-fx]{4}-[0-9a-fx]{4}-[0-9a-fx]{4}-[0-9a-fx]{12}\b/gi; // x - represents placeholder values
|
|
14
14
|
exports.regExUnicodeRef = /\bU\+[0-9a-f]{4,5}(?:-[0-9a-f]{4,5})?/gi;
|
|
15
|
-
exports.regExSpellingGuardBlock = /(\bc?spell(?:-?checker)?::?)\s*disable(?!-line|-next)\b[\s\S]*?((?:\1\s*enable\b)|$)/gi;
|
|
15
|
+
exports.regExSpellingGuardBlock = /(\bc?spell(?:-?checker)?::?)\s*disable(?!-line|-next)\b(?!-)[\s\S]*?((?:\1\s*enable\b)|$)/gi;
|
|
16
16
|
exports.regExSpellingGuardNext = /\bc?spell(?:-?checker)?::?\s*disable-next\b.*\s\s?.*/gi;
|
|
17
17
|
exports.regExSpellingGuardLine = /^.*\bc?spell(?:-?checker)?::?\s*disable-line\b.*/gim;
|
|
18
18
|
exports.regExIgnoreSpellingDirectives = /\bc?spell(?:-?checker)?::?\s*ignoreRegExp.*/gim;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const configSettingsFileVersion0_1 = "0.1";
|
|
2
|
+
export declare const configSettingsFileVersion0_2 = "0.2";
|
|
3
|
+
export declare const currentSettingsFileVersion = "0.2";
|
|
4
|
+
export declare const ENV_CSPELL_GLOB_ROOT = "CSPELL_GLOB_ROOT";
|
|
5
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ENV_CSPELL_GLOB_ROOT = exports.currentSettingsFileVersion = exports.configSettingsFileVersion0_2 = exports.configSettingsFileVersion0_1 = void 0;
|
|
4
|
+
exports.configSettingsFileVersion0_1 = '0.1';
|
|
5
|
+
exports.configSettingsFileVersion0_2 = '0.2';
|
|
6
|
+
exports.currentSettingsFileVersion = exports.configSettingsFileVersion0_2;
|
|
7
|
+
exports.ENV_CSPELL_GLOB_ROOT = 'CSPELL_GLOB_ROOT';
|
|
8
|
+
//# sourceMappingURL=constants.js.map
|
package/dist/Settings/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { clearCachedSettingsFiles, defaultConfigFilenames, defaultFileName, extractImportErrors, getCachedFileSize, getGlobalSettings, loadConfig, loadPnP, loadPnPSync, readRawSettings, readSettings, readSettingsFiles, searchForConfig, sectionCSpell, } from './Controller/configLoader';
|
|
2
|
-
export { calcOverrideSettings, checkFilenameMatchesGlob,
|
|
2
|
+
export { calcOverrideSettings, checkFilenameMatchesGlob, extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, } from './CSpellSettingsServer';
|
|
3
|
+
export { currentSettingsFileVersion, ENV_CSPELL_GLOB_ROOT } from './constants';
|
|
3
4
|
export type { ConfigurationDependencies, ImportFileRefWithError } from './CSpellSettingsServer';
|
|
4
5
|
export { getDefaultSettings, getDefaultBundledSettings } from './DefaultSettings';
|
|
5
6
|
export { ImportError } from './Controller/ImportError';
|
package/dist/Settings/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ImportError = exports.getDefaultBundledSettings = exports.getDefaultSettings = exports.
|
|
3
|
+
exports.ImportError = exports.getDefaultBundledSettings = exports.getDefaultSettings = exports.ENV_CSPELL_GLOB_ROOT = exports.currentSettingsFileVersion = exports.mergeSettings = exports.mergeInDocSettings = exports.getSources = exports.finalizeSettings = exports.extractDependencies = exports.checkFilenameMatchesGlob = exports.calcOverrideSettings = exports.sectionCSpell = exports.searchForConfig = exports.readSettingsFiles = exports.readSettings = exports.readRawSettings = exports.loadPnPSync = exports.loadPnP = exports.loadConfig = exports.getGlobalSettings = exports.getCachedFileSize = exports.extractImportErrors = exports.defaultFileName = exports.defaultConfigFilenames = exports.clearCachedSettingsFiles = void 0;
|
|
4
4
|
var configLoader_1 = require("./Controller/configLoader");
|
|
5
5
|
Object.defineProperty(exports, "clearCachedSettingsFiles", { enumerable: true, get: function () { return configLoader_1.clearCachedSettingsFiles; } });
|
|
6
6
|
Object.defineProperty(exports, "defaultConfigFilenames", { enumerable: true, get: function () { return configLoader_1.defaultConfigFilenames; } });
|
|
@@ -19,13 +19,14 @@ Object.defineProperty(exports, "sectionCSpell", { enumerable: true, get: functio
|
|
|
19
19
|
var CSpellSettingsServer_1 = require("./CSpellSettingsServer");
|
|
20
20
|
Object.defineProperty(exports, "calcOverrideSettings", { enumerable: true, get: function () { return CSpellSettingsServer_1.calcOverrideSettings; } });
|
|
21
21
|
Object.defineProperty(exports, "checkFilenameMatchesGlob", { enumerable: true, get: function () { return CSpellSettingsServer_1.checkFilenameMatchesGlob; } });
|
|
22
|
-
Object.defineProperty(exports, "currentSettingsFileVersion", { enumerable: true, get: function () { return CSpellSettingsServer_1.currentSettingsFileVersion; } });
|
|
23
|
-
Object.defineProperty(exports, "ENV_CSPELL_GLOB_ROOT", { enumerable: true, get: function () { return CSpellSettingsServer_1.ENV_CSPELL_GLOB_ROOT; } });
|
|
24
22
|
Object.defineProperty(exports, "extractDependencies", { enumerable: true, get: function () { return CSpellSettingsServer_1.extractDependencies; } });
|
|
25
23
|
Object.defineProperty(exports, "finalizeSettings", { enumerable: true, get: function () { return CSpellSettingsServer_1.finalizeSettings; } });
|
|
26
24
|
Object.defineProperty(exports, "getSources", { enumerable: true, get: function () { return CSpellSettingsServer_1.getSources; } });
|
|
27
25
|
Object.defineProperty(exports, "mergeInDocSettings", { enumerable: true, get: function () { return CSpellSettingsServer_1.mergeInDocSettings; } });
|
|
28
26
|
Object.defineProperty(exports, "mergeSettings", { enumerable: true, get: function () { return CSpellSettingsServer_1.mergeSettings; } });
|
|
27
|
+
var constants_1 = require("./constants");
|
|
28
|
+
Object.defineProperty(exports, "currentSettingsFileVersion", { enumerable: true, get: function () { return constants_1.currentSettingsFileVersion; } });
|
|
29
|
+
Object.defineProperty(exports, "ENV_CSPELL_GLOB_ROOT", { enumerable: true, get: function () { return constants_1.ENV_CSPELL_GLOB_ROOT; } });
|
|
29
30
|
var DefaultSettings_1 = require("./DefaultSettings");
|
|
30
31
|
Object.defineProperty(exports, "getDefaultSettings", { enumerable: true, get: function () { return DefaultSettings_1.getDefaultSettings; } });
|
|
31
32
|
Object.defineProperty(exports, "getDefaultBundledSettings", { enumerable: true, get: function () { return DefaultSettings_1.getDefaultBundledSettings; } });
|
|
@@ -48,10 +48,23 @@ export declare type HasOptions = SearchOptions;
|
|
|
48
48
|
export interface SpellingDictionaryOptions {
|
|
49
49
|
repMap?: ReplaceMap;
|
|
50
50
|
useCompounds?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The dictionary is case aware.
|
|
53
|
+
*/
|
|
51
54
|
caseSensitive?: boolean;
|
|
52
55
|
noSuggest?: boolean;
|
|
53
56
|
weightMap?: WeightMap | undefined;
|
|
54
57
|
dictionaryInformation?: DictionaryInformation;
|
|
58
|
+
/**
|
|
59
|
+
* Strip Case and Accents to allow for case insensitive searches and
|
|
60
|
+
* words without accents.
|
|
61
|
+
*
|
|
62
|
+
* Note: this setting only applies to word lists. It has no-impact on trie
|
|
63
|
+
* dictionaries.
|
|
64
|
+
*
|
|
65
|
+
* @default true
|
|
66
|
+
*/
|
|
67
|
+
supportNonStrictSearches?: boolean;
|
|
55
68
|
}
|
|
56
69
|
export interface SpellingDictionary {
|
|
57
70
|
readonly name: string;
|
|
@@ -34,7 +34,8 @@ exports.createSpellingDictionary = createSpellingDictionary;
|
|
|
34
34
|
function _createSpellingDictionary(params) {
|
|
35
35
|
const [wordList, name, source, options] = params;
|
|
36
36
|
// console.log(`createSpellingDictionary ${name} ${source}`);
|
|
37
|
-
const
|
|
37
|
+
const parseOptions = { stripCaseAndAccents: options?.supportNonStrictSearches ?? true };
|
|
38
|
+
const words = (0, cspell_trie_lib_1.parseDictionaryLines)(wordList, parseOptions);
|
|
38
39
|
const trie = (0, cspell_trie_lib_1.buildTrieFast)(words);
|
|
39
40
|
const opts = { ...(options || defaultOptions) };
|
|
40
41
|
if (opts.weightMap === undefined && opts.dictionaryInformation) {
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type { CreateTextDocumentParams, TextDocument, TextDocumentLine } from '.
|
|
|
12
12
|
export * from './Settings';
|
|
13
13
|
export { defaultFileName as defaultSettingsFilename } from './Settings';
|
|
14
14
|
export { combineTextAndLanguageSettings, combineTextAndLanguageSettings as constructSettingsForText, } from './Settings/TextDocumentSettings';
|
|
15
|
-
export { determineFinalDocumentSettings, DetermineFinalDocumentSettingsResult, Document, fileToDocument, isBinaryFile, spellCheckDocument, spellCheckFile, SpellCheckFileOptions, SpellCheckFileResult, } from './spellCheckFile';
|
|
15
|
+
export { determineFinalDocumentSettings, DetermineFinalDocumentSettingsResult, Document, fileToDocument, fileToTextDocument, isBinaryFile, spellCheckDocument, spellCheckFile, SpellCheckFileOptions, SpellCheckFileResult, } from './spellCheckFile';
|
|
16
16
|
export { CompoundWordsMethod, createSpellingDictionary, isSpellingDictionaryLoadError, refreshDictionaryCache, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryLoadError, SuggestionCollector, SuggestionResult, SuggestOptions, } from './SpellingDictionary';
|
|
17
17
|
export { SuggestionError, suggestionsForWord, suggestionsForWords } from './suggestions';
|
|
18
18
|
export type { SuggestedWord, SuggestionOptions, SuggestionsForWordResult } from './suggestions';
|
|
@@ -21,7 +21,7 @@ export { traceWords, traceWordsAsync } from './trace';
|
|
|
21
21
|
export type { TraceOptions, TraceResult } from './trace';
|
|
22
22
|
export { getLogger, Logger, setLogger } from './util/logger';
|
|
23
23
|
export { resolveFile } from './util/resolveFile';
|
|
24
|
-
export { checkText, CheckTextInfo, IncludeExcludeFlag, IncludeExcludeOptions, TextInfoItem, validateText, ValidationIssue, } from './validator';
|
|
24
|
+
export { checkText, checkTextDocument, CheckTextInfo, IncludeExcludeFlag, IncludeExcludeOptions, TextInfoItem, validateText, ValidationIssue, } from './validator';
|
|
25
25
|
export { Text, Link };
|
|
26
26
|
export { ExclusionHelper };
|
|
27
27
|
export declare function clearCachedFiles(): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -26,7 +26,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
26
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getDictionary = exports.clearCachedFiles = exports.ExclusionHelper = exports.Link = exports.Text = exports.validateText = exports.IncludeExcludeFlag = exports.checkText = exports.resolveFile = exports.setLogger = exports.getLogger = exports.traceWordsAsync = exports.traceWords = exports.DocumentValidator = exports.suggestionsForWords = exports.suggestionsForWord = exports.SuggestionError = exports.SpellingDictionaryLoadError = exports.SpellingDictionaryCollection = exports.refreshDictionaryCache = exports.isSpellingDictionaryLoadError = exports.createSpellingDictionary = exports.CompoundWordsMethod = exports.spellCheckFile = exports.spellCheckDocument = exports.isBinaryFile = exports.fileToDocument = exports.determineFinalDocumentSettings = exports.constructSettingsForText = exports.combineTextAndLanguageSettings = exports.defaultSettingsFilename = exports.updateTextDocument = exports.createTextDocument = exports.getLanguagesForExt = exports.writeToFileIterableP = exports.writeToFileIterable = exports.writeToFile = exports.readFileSync = exports.readFile = exports.asyncIterableToArray = void 0;
|
|
29
|
+
exports.getDictionary = exports.clearCachedFiles = exports.ExclusionHelper = exports.Link = exports.Text = exports.validateText = exports.IncludeExcludeFlag = exports.checkTextDocument = exports.checkText = exports.resolveFile = exports.setLogger = exports.getLogger = exports.traceWordsAsync = exports.traceWords = exports.DocumentValidator = exports.suggestionsForWords = exports.suggestionsForWord = exports.SuggestionError = exports.SpellingDictionaryLoadError = exports.SpellingDictionaryCollection = exports.refreshDictionaryCache = exports.isSpellingDictionaryLoadError = exports.createSpellingDictionary = exports.CompoundWordsMethod = exports.spellCheckFile = exports.spellCheckDocument = exports.isBinaryFile = exports.fileToTextDocument = exports.fileToDocument = exports.determineFinalDocumentSettings = exports.constructSettingsForText = exports.combineTextAndLanguageSettings = exports.defaultSettingsFilename = exports.updateTextDocument = exports.createTextDocument = exports.getLanguagesForExt = exports.writeToFileIterableP = exports.writeToFileIterable = exports.writeToFile = exports.readFileSync = exports.readFile = exports.asyncIterableToArray = void 0;
|
|
30
30
|
const ExclusionHelper = __importStar(require("./exclusionHelper"));
|
|
31
31
|
exports.ExclusionHelper = ExclusionHelper;
|
|
32
32
|
const Settings_1 = require("./Settings");
|
|
@@ -58,6 +58,7 @@ Object.defineProperty(exports, "constructSettingsForText", { enumerable: true, g
|
|
|
58
58
|
var spellCheckFile_1 = require("./spellCheckFile");
|
|
59
59
|
Object.defineProperty(exports, "determineFinalDocumentSettings", { enumerable: true, get: function () { return spellCheckFile_1.determineFinalDocumentSettings; } });
|
|
60
60
|
Object.defineProperty(exports, "fileToDocument", { enumerable: true, get: function () { return spellCheckFile_1.fileToDocument; } });
|
|
61
|
+
Object.defineProperty(exports, "fileToTextDocument", { enumerable: true, get: function () { return spellCheckFile_1.fileToTextDocument; } });
|
|
61
62
|
Object.defineProperty(exports, "isBinaryFile", { enumerable: true, get: function () { return spellCheckFile_1.isBinaryFile; } });
|
|
62
63
|
Object.defineProperty(exports, "spellCheckDocument", { enumerable: true, get: function () { return spellCheckFile_1.spellCheckDocument; } });
|
|
63
64
|
Object.defineProperty(exports, "spellCheckFile", { enumerable: true, get: function () { return spellCheckFile_1.spellCheckFile; } });
|
|
@@ -84,6 +85,7 @@ var resolveFile_1 = require("./util/resolveFile");
|
|
|
84
85
|
Object.defineProperty(exports, "resolveFile", { enumerable: true, get: function () { return resolveFile_1.resolveFile; } });
|
|
85
86
|
var validator_1 = require("./validator");
|
|
86
87
|
Object.defineProperty(exports, "checkText", { enumerable: true, get: function () { return validator_1.checkText; } });
|
|
88
|
+
Object.defineProperty(exports, "checkTextDocument", { enumerable: true, get: function () { return validator_1.checkTextDocument; } });
|
|
87
89
|
Object.defineProperty(exports, "IncludeExcludeFlag", { enumerable: true, get: function () { return validator_1.IncludeExcludeFlag; } });
|
|
88
90
|
Object.defineProperty(exports, "validateText", { enumerable: true, get: function () { return validator_1.validateText; } });
|
|
89
91
|
async function clearCachedFiles() {
|
package/dist/spellCheckFile.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { CSpellSettingsWithSourceTrace, CSpellUserSettings } from '@cspell/cspell-types';
|
|
3
3
|
import { URI } from 'vscode-uri';
|
|
4
|
+
import { TextDocument } from './Models/TextDocument';
|
|
4
5
|
import { ValidateTextOptions, ValidationIssue } from './validator';
|
|
5
6
|
export interface SpellCheckFileOptions extends ValidateTextOptions {
|
|
6
7
|
/**
|
|
@@ -78,4 +79,6 @@ export declare function isBinaryFile(filenameUri: URI, languageId?: string | str
|
|
|
78
79
|
export declare function fileToDocument(file: string): Document;
|
|
79
80
|
export declare function fileToDocument(file: string, text: string, languageId?: string, locale?: string): DocumentWithText;
|
|
80
81
|
export declare function fileToDocument(file: string, text?: string, languageId?: string, locale?: string): Document | DocumentWithText;
|
|
82
|
+
export declare function fileToTextDocument(file: string): Promise<TextDocument>;
|
|
83
|
+
export declare function resolveDocumentToTextDocument(doc: Document): Promise<TextDocument>;
|
|
81
84
|
//# sourceMappingURL=spellCheckFile.d.ts.map
|
package/dist/spellCheckFile.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fileToDocument = exports.isBinaryFile = exports.isBinaryDoc = exports.determineFinalDocumentSettings = exports.spellCheckDocument = exports.spellCheckFile = void 0;
|
|
3
|
+
exports.resolveDocumentToTextDocument = exports.fileToTextDocument = exports.fileToDocument = exports.isBinaryFile = exports.isBinaryDoc = exports.determineFinalDocumentSettings = exports.spellCheckDocument = exports.spellCheckFile = void 0;
|
|
4
4
|
const fs_extra_1 = require("fs-extra");
|
|
5
5
|
const vscode_uri_1 = require("vscode-uri");
|
|
6
6
|
const LanguageIds_1 = require("./LanguageIds");
|
|
@@ -59,8 +59,7 @@ async function spellCheckDocument(document, options, settings) {
|
|
|
59
59
|
}
|
|
60
60
|
exports.spellCheckDocument = spellCheckDocument;
|
|
61
61
|
async function spellCheckFullDocument(document, options, settings) {
|
|
62
|
-
const
|
|
63
|
-
const doc = (0, TextDocument_1.createTextDocument)({ uri, content, languageId, locale });
|
|
62
|
+
const doc = documentToTextDocument(document);
|
|
64
63
|
const docValOptions = options;
|
|
65
64
|
const docValidator = new textValidation_1.DocumentValidator(doc, docValOptions, settings);
|
|
66
65
|
await docValidator.prepare();
|
|
@@ -159,4 +158,16 @@ function fileToDocument(file, text, languageId, locale) {
|
|
|
159
158
|
});
|
|
160
159
|
}
|
|
161
160
|
exports.fileToDocument = fileToDocument;
|
|
161
|
+
async function fileToTextDocument(file) {
|
|
162
|
+
return documentToTextDocument(await resolveDocument(fileToDocument(file)));
|
|
163
|
+
}
|
|
164
|
+
exports.fileToTextDocument = fileToTextDocument;
|
|
165
|
+
function documentToTextDocument(document) {
|
|
166
|
+
const { uri, text: content, languageId, locale } = document;
|
|
167
|
+
return (0, TextDocument_1.createTextDocument)({ uri, content, languageId, locale });
|
|
168
|
+
}
|
|
169
|
+
async function resolveDocumentToTextDocument(doc) {
|
|
170
|
+
return documentToTextDocument(await resolveDocument(doc));
|
|
171
|
+
}
|
|
172
|
+
exports.resolveDocumentToTextDocument = resolveDocumentToTextDocument;
|
|
162
173
|
//# sourceMappingURL=spellCheckFile.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MappedText, TextOffset as TextOffsetRW } from '@cspell/cspell-types';
|
|
1
|
+
import { MappedText, TextOffset as TextOffsetRW, Issue } from '@cspell/cspell-types';
|
|
2
2
|
export declare type TextOffsetRO = Readonly<TextOffsetRW>;
|
|
3
3
|
export interface ValidationOptions extends IncludeExcludeOptions {
|
|
4
4
|
maxNumberOfProblems?: number;
|
|
@@ -22,7 +22,7 @@ export interface WordRangeAcc {
|
|
|
22
22
|
isIncluded: boolean;
|
|
23
23
|
rangePos: number;
|
|
24
24
|
}
|
|
25
|
-
export interface ValidationResult extends TextOffsetRW {
|
|
25
|
+
export interface ValidationResult extends TextOffsetRW, Pick<Issue, 'message' | 'issueType'> {
|
|
26
26
|
line: TextOffsetRW;
|
|
27
27
|
isFlagged?: boolean | undefined;
|
|
28
28
|
isFound?: boolean | undefined;
|