cspell-lib 6.6.1 → 6.8.1
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/Settings/CSpellSettingsServer.js +2 -2
- package/dist/Settings/Controller/ImportError.d.ts +11 -0
- package/dist/Settings/Controller/ImportError.js +24 -0
- package/dist/Settings/Controller/SettingsController.d.ts +9 -0
- package/dist/Settings/Controller/SettingsController.js +13 -0
- package/dist/Settings/{configLoader.d.ts → Controller/configLoader.d.ts} +2 -2
- package/dist/Settings/{configLoader.js → Controller/configLoader.js} +7 -7
- package/dist/Settings/Controller/index.d.ts +2 -0
- package/dist/Settings/Controller/index.js +6 -0
- package/dist/Settings/{pnpLoader.d.ts → Controller/pnpLoader.d.ts} +0 -6
- package/dist/Settings/{pnpLoader.js → Controller/pnpLoader.js} +11 -22
- package/dist/Settings/DefaultSettings.js +1 -1
- 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/index.d.ts +2 -2
- package/dist/Settings/index.js +2 -2
- package/dist/Settings/link.js +1 -1
- package/dist/SpellingDictionary/DictionaryController/DictionaryLoader.d.ts +30 -0
- package/dist/SpellingDictionary/DictionaryController/DictionaryLoader.js +273 -0
- package/dist/SpellingDictionary/DictionaryController/index.d.ts +2 -0
- package/dist/SpellingDictionary/DictionaryController/index.js +6 -0
- package/dist/SpellingDictionary/DictionaryLoader.d.ts +4 -46
- package/dist/SpellingDictionary/DictionaryLoader.js +14 -278
- 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/static.d.ts +3 -0
- package/dist/static.js +10 -0
- 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 +44 -2
- 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/util.d.ts +1 -1
- package/dist/validator.d.ts +1 -1
- package/dist/validator.js +2 -1
- package/package.json +17 -17
- package/dist/Settings/ImportError.d.ts +0 -5
- package/dist/Settings/ImportError.js +0 -12
|
@@ -269,9 +269,9 @@ function mergeSources(left, right) {
|
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
271
|
function max(a, b) {
|
|
272
|
-
if (a === undefined)
|
|
272
|
+
if (a === undefined || a === null)
|
|
273
273
|
return b;
|
|
274
|
-
if (b === undefined)
|
|
274
|
+
if (b === undefined || b === null)
|
|
275
275
|
return a;
|
|
276
276
|
return a > b ? a : b;
|
|
277
277
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class ImportError extends Error {
|
|
2
|
+
readonly cause: Error | undefined;
|
|
3
|
+
constructor(msg: string, cause?: Error | unknown);
|
|
4
|
+
}
|
|
5
|
+
export declare class UnsupportedSchema extends Error {
|
|
6
|
+
constructor(msg: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class UnsupportedPnpFile extends Error {
|
|
9
|
+
constructor(msg: string);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ImportError.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnsupportedPnpFile = exports.UnsupportedSchema = exports.ImportError = void 0;
|
|
4
|
+
const errors_1 = require("../../util/errors");
|
|
5
|
+
class ImportError extends Error {
|
|
6
|
+
constructor(msg, cause) {
|
|
7
|
+
super(msg);
|
|
8
|
+
this.cause = (0, errors_1.isError)(cause) ? cause : undefined;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.ImportError = ImportError;
|
|
12
|
+
class UnsupportedSchema extends Error {
|
|
13
|
+
constructor(msg) {
|
|
14
|
+
super(msg);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.UnsupportedSchema = UnsupportedSchema;
|
|
18
|
+
class UnsupportedPnpFile extends Error {
|
|
19
|
+
constructor(msg) {
|
|
20
|
+
super(msg);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.UnsupportedPnpFile = UnsupportedPnpFile;
|
|
24
|
+
//# sourceMappingURL=ImportError.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSpellIO } from 'cspell-io';
|
|
2
|
+
/**
|
|
3
|
+
* The settings controller manages requests to resolve configuration settings and files.
|
|
4
|
+
*/
|
|
5
|
+
export declare class SettingsController {
|
|
6
|
+
readonly cspellIO: CSpellIO;
|
|
7
|
+
constructor(cspellIO: CSpellIO);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=SettingsController.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SettingsController = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The settings controller manages requests to resolve configuration settings and files.
|
|
6
|
+
*/
|
|
7
|
+
class SettingsController {
|
|
8
|
+
constructor(cspellIO) {
|
|
9
|
+
this.cspellIO = cspellIO;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.SettingsController = SettingsController;
|
|
13
|
+
//# sourceMappingURL=SettingsController.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CSpellSettingsWithSourceTrace, CSpellUserSettings, ImportFileRef, PnPSettings as PnPSettingsStrict } from '@cspell/cspell-types';
|
|
2
2
|
import { URI } from 'vscode-uri';
|
|
3
|
-
import { CSpellSettingsInternal } from '
|
|
4
|
-
import { OptionalOrUndefined } from '
|
|
3
|
+
import { CSpellSettingsInternal } from '../../Models/CSpellSettingsInternalDef';
|
|
4
|
+
import { OptionalOrUndefined } from '../../util/types';
|
|
5
5
|
import { LoaderResult } from './pnpLoader';
|
|
6
6
|
declare type CSpellSettingsWST = CSpellSettingsWithSourceTrace;
|
|
7
7
|
declare type CSpellSettingsI = CSpellSettingsInternal;
|
|
@@ -28,13 +28,13 @@ const json = __importStar(require("comment-json"));
|
|
|
28
28
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
29
29
|
const path = __importStar(require("path"));
|
|
30
30
|
const vscode_uri_1 = require("vscode-uri");
|
|
31
|
-
const CSpellSettingsInternalDef_1 = require("
|
|
32
|
-
const logger_1 = require("
|
|
33
|
-
const resolveFile_1 = require("
|
|
34
|
-
const util = __importStar(require("
|
|
35
|
-
const CSpellSettingsServer_1 = require("
|
|
36
|
-
const DictionarySettings_1 = require("
|
|
37
|
-
const GlobalSettings_1 = require("
|
|
31
|
+
const CSpellSettingsInternalDef_1 = require("../../Models/CSpellSettingsInternalDef");
|
|
32
|
+
const logger_1 = require("../../util/logger");
|
|
33
|
+
const resolveFile_1 = require("../../util/resolveFile");
|
|
34
|
+
const util = __importStar(require("../../util/util"));
|
|
35
|
+
const CSpellSettingsServer_1 = require("../CSpellSettingsServer");
|
|
36
|
+
const DictionarySettings_1 = require("../DictionarySettings");
|
|
37
|
+
const GlobalSettings_1 = require("../GlobalSettings");
|
|
38
38
|
const ImportError_1 = require("./ImportError");
|
|
39
39
|
const pnpLoader_1 = require("./pnpLoader");
|
|
40
40
|
const supportedCSpellConfigVersions = [CSpellSettingsServer_1.configSettingsFileVersion0_2];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SettingsController = void 0;
|
|
4
|
+
var SettingsController_1 = require("./SettingsController");
|
|
5
|
+
Object.defineProperty(exports, "SettingsController", { enumerable: true, get: function () { return SettingsController_1.SettingsController; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -28,11 +28,5 @@ export declare class PnpLoader {
|
|
|
28
28
|
private calcKey;
|
|
29
29
|
}
|
|
30
30
|
export declare function pnpLoader(pnpFiles?: string[]): PnpLoader;
|
|
31
|
-
export declare class UnsupportedSchema extends Error {
|
|
32
|
-
constructor(msg: string);
|
|
33
|
-
}
|
|
34
|
-
export declare class UnsupportedPnpFile extends Error {
|
|
35
|
-
constructor(msg: string);
|
|
36
|
-
}
|
|
37
31
|
export declare function clearPnPGlobalCache(): Promise<undefined>;
|
|
38
32
|
//# sourceMappingURL=pnpLoader.d.ts.map
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.clearPnPGlobalCache = exports.
|
|
6
|
+
exports.clearPnPGlobalCache = exports.pnpLoader = exports.PnpLoader = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Handles loading of `.pnp.js` and `.pnp.js` files.
|
|
9
9
|
*/
|
|
@@ -11,6 +11,7 @@ const vscode_uri_1 = require("vscode-uri");
|
|
|
11
11
|
const import_fresh_1 = __importDefault(require("import-fresh"));
|
|
12
12
|
const find_up_1 = __importDefault(require("find-up"));
|
|
13
13
|
const clear_module_1 = __importDefault(require("clear-module"));
|
|
14
|
+
const ImportError_1 = require("./ImportError");
|
|
14
15
|
const defaultPnpFiles = ['.pnp.cjs', '.pnp.js'];
|
|
15
16
|
const supportedSchemas = new Set(['file']);
|
|
16
17
|
const cachedRequests = new Map();
|
|
@@ -28,6 +29,8 @@ class PnpLoader {
|
|
|
28
29
|
* @returns promise - rejects on error - success if loaded or not found.
|
|
29
30
|
*/
|
|
30
31
|
async load(uriDirectory) {
|
|
32
|
+
if (!supportedSchemas.has(uriDirectory.scheme))
|
|
33
|
+
return undefined;
|
|
31
34
|
await lock;
|
|
32
35
|
const cacheKey = this.calcKey(uriDirectory);
|
|
33
36
|
const cached = cachedRequests.get(cacheKey);
|
|
@@ -40,6 +43,8 @@ class PnpLoader {
|
|
|
40
43
|
return result;
|
|
41
44
|
}
|
|
42
45
|
async peek(uriDirectory) {
|
|
46
|
+
if (!supportedSchemas.has(uriDirectory.scheme))
|
|
47
|
+
return undefined;
|
|
43
48
|
await lock;
|
|
44
49
|
const cacheKey = this.calcKey(uriDirectory);
|
|
45
50
|
return cachedRequests.get(cacheKey) ?? Promise.resolve(undefined);
|
|
@@ -50,6 +55,8 @@ class PnpLoader {
|
|
|
50
55
|
* @returns promise - rejects on error - success if loaded or not found.
|
|
51
56
|
*/
|
|
52
57
|
loadSync(uriDirectory) {
|
|
58
|
+
if (!supportedSchemas.has(uriDirectory.scheme))
|
|
59
|
+
return undefined;
|
|
53
60
|
const cacheKey = this.calcKey(uriDirectory);
|
|
54
61
|
const cached = cachedRequestsSync.get(cacheKey);
|
|
55
62
|
if (cached)
|
|
@@ -60,6 +67,8 @@ class PnpLoader {
|
|
|
60
67
|
return r;
|
|
61
68
|
}
|
|
62
69
|
peekSync(uriDirectory) {
|
|
70
|
+
if (!supportedSchemas.has(uriDirectory.scheme))
|
|
71
|
+
return undefined;
|
|
63
72
|
const cacheKey = this.calcKey(uriDirectory);
|
|
64
73
|
return cachedRequestsSync.get(cacheKey);
|
|
65
74
|
}
|
|
@@ -78,23 +87,10 @@ function pnpLoader(pnpFiles) {
|
|
|
78
87
|
return new PnpLoader(pnpFiles);
|
|
79
88
|
}
|
|
80
89
|
exports.pnpLoader = pnpLoader;
|
|
81
|
-
class UnsupportedSchema extends Error {
|
|
82
|
-
constructor(msg) {
|
|
83
|
-
super(msg);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
exports.UnsupportedSchema = UnsupportedSchema;
|
|
87
|
-
class UnsupportedPnpFile extends Error {
|
|
88
|
-
constructor(msg) {
|
|
89
|
-
super(msg);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.UnsupportedPnpFile = UnsupportedPnpFile;
|
|
93
90
|
/**
|
|
94
91
|
* @param uriDirectory - directory to start at.
|
|
95
92
|
*/
|
|
96
93
|
async function findPnpAndLoad(uriDirectory, pnpFiles) {
|
|
97
|
-
validateSchema(uriDirectory);
|
|
98
94
|
const found = await (0, find_up_1.default)(pnpFiles, { cwd: uriDirectory.fsPath });
|
|
99
95
|
return loadPnpIfNeeded(found);
|
|
100
96
|
}
|
|
@@ -102,7 +98,6 @@ async function findPnpAndLoad(uriDirectory, pnpFiles) {
|
|
|
102
98
|
* @param uriDirectory - directory to start at.
|
|
103
99
|
*/
|
|
104
100
|
function findPnpAndLoadSync(uriDirectory, pnpFiles) {
|
|
105
|
-
validateSchema(uriDirectory);
|
|
106
101
|
const found = find_up_1.default.sync(pnpFiles, { cwd: uriDirectory.fsPath });
|
|
107
102
|
return loadPnpIfNeeded(found);
|
|
108
103
|
}
|
|
@@ -122,13 +117,7 @@ function loadPnp(pnpFile) {
|
|
|
122
117
|
pnp.setup();
|
|
123
118
|
return vscode_uri_1.URI.file(pnpFile);
|
|
124
119
|
}
|
|
125
|
-
throw new UnsupportedPnpFile(`Unsupported pnp file: "${pnpFile}"`);
|
|
126
|
-
}
|
|
127
|
-
function validateSchema(uri) {
|
|
128
|
-
if (!supportedSchemas.has(uri.scheme)) {
|
|
129
|
-
throw new UnsupportedSchema(`Unsupported schema for PNP: "${uri.scheme}"`);
|
|
130
|
-
}
|
|
131
|
-
return true;
|
|
120
|
+
throw new ImportError_1.UnsupportedPnpFile(`Unsupported pnp file: "${pnpFile}"`);
|
|
132
121
|
}
|
|
133
122
|
function clearPnPGlobalCache() {
|
|
134
123
|
if (lock)
|
|
@@ -28,7 +28,7 @@ const cspell_grammar_1 = require("cspell-grammar");
|
|
|
28
28
|
const CSpellSettingsInternalDef_1 = require("../Models/CSpellSettingsInternalDef");
|
|
29
29
|
const PatternRegExp_1 = require("../Models/PatternRegExp");
|
|
30
30
|
const resolveFile_1 = require("../util/resolveFile");
|
|
31
|
-
const configLoader_1 = require("./configLoader");
|
|
31
|
+
const configLoader_1 = require("./Controller/configLoader");
|
|
32
32
|
const index_1 = require("./index");
|
|
33
33
|
const LanguageSettings = __importStar(require("./LanguageSettings"));
|
|
34
34
|
const RegPat = __importStar(require("./RegExpPatterns"));
|
|
@@ -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/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;
|
package/dist/Settings/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { clearCachedSettingsFiles, defaultConfigFilenames, defaultFileName, extractImportErrors, getCachedFileSize, getGlobalSettings, loadConfig, loadPnP, loadPnPSync, readRawSettings, readSettings, readSettingsFiles, searchForConfig, sectionCSpell, } from './configLoader';
|
|
1
|
+
export { clearCachedSettingsFiles, defaultConfigFilenames, defaultFileName, extractImportErrors, getCachedFileSize, getGlobalSettings, loadConfig, loadPnP, loadPnPSync, readRawSettings, readSettings, readSettingsFiles, searchForConfig, sectionCSpell, } from './Controller/configLoader';
|
|
2
2
|
export { calcOverrideSettings, checkFilenameMatchesGlob, currentSettingsFileVersion, ENV_CSPELL_GLOB_ROOT, extractDependencies, finalizeSettings, getSources, mergeInDocSettings, mergeSettings, } from './CSpellSettingsServer';
|
|
3
3
|
export type { ConfigurationDependencies, ImportFileRefWithError } from './CSpellSettingsServer';
|
|
4
4
|
export { getDefaultSettings, getDefaultBundledSettings } from './DefaultSettings';
|
|
5
|
-
export { ImportError } from './ImportError';
|
|
5
|
+
export { ImportError } from './Controller/ImportError';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/Settings/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ImportError = exports.getDefaultBundledSettings = exports.getDefaultSettings = exports.mergeSettings = exports.mergeInDocSettings = exports.getSources = exports.finalizeSettings = exports.extractDependencies = exports.ENV_CSPELL_GLOB_ROOT = exports.currentSettingsFileVersion = 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
|
-
var configLoader_1 = require("./configLoader");
|
|
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; } });
|
|
7
7
|
Object.defineProperty(exports, "defaultFileName", { enumerable: true, get: function () { return configLoader_1.defaultFileName; } });
|
|
@@ -29,6 +29,6 @@ Object.defineProperty(exports, "mergeSettings", { enumerable: true, get: functio
|
|
|
29
29
|
var DefaultSettings_1 = require("./DefaultSettings");
|
|
30
30
|
Object.defineProperty(exports, "getDefaultSettings", { enumerable: true, get: function () { return DefaultSettings_1.getDefaultSettings; } });
|
|
31
31
|
Object.defineProperty(exports, "getDefaultBundledSettings", { enumerable: true, get: function () { return DefaultSettings_1.getDefaultBundledSettings; } });
|
|
32
|
-
var ImportError_1 = require("./ImportError");
|
|
32
|
+
var ImportError_1 = require("./Controller/ImportError");
|
|
33
33
|
Object.defineProperty(exports, "ImportError", { enumerable: true, get: function () { return ImportError_1.ImportError; } });
|
|
34
34
|
//# sourceMappingURL=index.js.map
|
package/dist/Settings/link.js
CHANGED
|
@@ -27,7 +27,7 @@ exports.__testing__ = exports.removePathsFromGlobalImports = exports.addPathsToG
|
|
|
27
27
|
const fs = __importStar(require("fs"));
|
|
28
28
|
const Path = __importStar(require("path"));
|
|
29
29
|
const util_1 = require("../util/util");
|
|
30
|
-
const configLoader_1 = require("./configLoader");
|
|
30
|
+
const configLoader_1 = require("./Controller/configLoader");
|
|
31
31
|
const GlobalSettings_1 = require("./GlobalSettings");
|
|
32
32
|
function listGlobalImports() {
|
|
33
33
|
const globalSettings = (0, GlobalSettings_1.getRawGlobalSettings)();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CSpellIO } from 'cspell-io';
|
|
2
|
+
import { DictionaryDefinitionInternal } from '../../Models/CSpellSettingsInternalDef';
|
|
3
|
+
import { SpellingDictionary } from '../SpellingDictionary';
|
|
4
|
+
export declare type LoadOptions = DictionaryDefinitionInternal;
|
|
5
|
+
export declare class DictionaryLoader {
|
|
6
|
+
private cspellIO;
|
|
7
|
+
private dictionaryCache;
|
|
8
|
+
private dictionaryCacheByDef;
|
|
9
|
+
private reader;
|
|
10
|
+
private readerSync;
|
|
11
|
+
constructor(cspellIO: CSpellIO);
|
|
12
|
+
loadDictionary(def: DictionaryDefinitionInternal): Promise<SpellingDictionary>;
|
|
13
|
+
loadDictionarySync(def: DictionaryDefinitionInternal): SpellingDictionary;
|
|
14
|
+
/**
|
|
15
|
+
* Check to see if any of the cached dictionaries have changed. If one has changed, reload it.
|
|
16
|
+
* @param maxAge - Only check the dictionary if it has been at least `maxAge` ms since the last check.
|
|
17
|
+
* @param now - optional timestamp representing now. (Mostly used in testing)
|
|
18
|
+
*/
|
|
19
|
+
refreshCacheEntries(maxAge?: number, now?: number): Promise<void>;
|
|
20
|
+
private getCacheEntry;
|
|
21
|
+
private setCacheEntry;
|
|
22
|
+
private refreshEntry;
|
|
23
|
+
private loadEntry;
|
|
24
|
+
private loadEntrySync;
|
|
25
|
+
private getStat;
|
|
26
|
+
private getStatSync;
|
|
27
|
+
private isEqual;
|
|
28
|
+
private normalizeOptions;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=DictionaryLoader.d.ts.map
|