cspell-lib 8.13.0 → 8.13.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/{esm → lib}/Settings/Controller/configLoader/configLoader.js +1 -1
- package/dist/{esm → lib}/Settings/DefaultSettings.js +1 -1
- package/dist/{lib-cjs/pkg-info.d.cts → lib/pkg-info.d.mts} +1 -1
- package/dist/lib/pkg-info.mjs +15 -0
- package/dist/lib/textValidation/isWordValid.d.ts +11 -0
- package/dist/lib/textValidation/lineValidatorFactory.js +218 -0
- package/dist/{esm → lib}/util/TextRange.d.ts +3 -8
- package/dist/{esm → lib}/util/TextRange.js +43 -34
- package/dist/{esm → lib}/util/resolveFile.js +1 -1
- package/dist/{esm → lib}/util/text.d.ts +6 -1
- package/dist/{esm → lib}/util/text.js +19 -14
- package/dist/{esm → lib}/util/textRegex.d.ts +2 -0
- package/dist/{esm → lib}/util/textRegex.js +3 -1
- package/dist/{esm → lib}/util/url.js +1 -1
- package/dist/{esm → lib}/util/wordSplitter.d.ts +1 -1
- package/dist/{esm → lib}/util/wordSplitter.js +4 -4
- package/dist/lib/util/wordSplitter.perf.d.ts +2 -0
- package/dist/lib/util/wordSplitter.perf.js +125 -0
- package/package.json +25 -25
- package/dist/esm/textValidation/isWordValid.d.ts +0 -9
- package/dist/esm/textValidation/lineValidatorFactory.js +0 -128
- package/dist/lib-cjs/index.cjs +0 -10
- package/dist/lib-cjs/index.d.cts +0 -6
- package/dist/lib-cjs/pkg-info.cjs +0 -7
- /package/dist/{esm → lib}/Cache/cspell.cache.d.ts +0 -0
- /package/dist/{esm → lib}/Cache/cspell.cache.js +0 -0
- /package/dist/{esm → lib}/Cache/index.d.ts +0 -0
- /package/dist/{esm → lib}/Cache/index.js +0 -0
- /package/dist/{esm → lib}/Document/Document.d.ts +0 -0
- /package/dist/{esm → lib}/Document/Document.js +0 -0
- /package/dist/{esm → lib}/Document/index.d.ts +0 -0
- /package/dist/{esm → lib}/Document/index.js +0 -0
- /package/dist/{esm → lib}/Document/isBinaryDoc.d.ts +0 -0
- /package/dist/{esm → lib}/Document/isBinaryDoc.js +0 -0
- /package/dist/{esm → lib}/Document/normalizeLanguageIds.d.ts +0 -0
- /package/dist/{esm → lib}/Document/normalizeLanguageIds.js +0 -0
- /package/dist/{esm → lib}/Document/resolveDocument.d.ts +0 -0
- /package/dist/{esm → lib}/Document/resolveDocument.js +0 -0
- /package/dist/{esm → lib}/FeatureFlags/FeatureFlags.d.ts +0 -0
- /package/dist/{esm → lib}/FeatureFlags/FeatureFlags.js +0 -0
- /package/dist/{esm → lib}/FeatureFlags/index.d.ts +0 -0
- /package/dist/{esm → lib}/FeatureFlags/index.js +0 -0
- /package/dist/{esm → lib}/LanguageIds.d.ts +0 -0
- /package/dist/{esm → lib}/LanguageIds.js +0 -0
- /package/dist/{esm → lib}/Models/CSpellSettingsInternalDef.d.ts +0 -0
- /package/dist/{esm → lib}/Models/CSpellSettingsInternalDef.js +0 -0
- /package/dist/{esm → lib}/Models/PatternRegExp.d.ts +0 -0
- /package/dist/{esm → lib}/Models/PatternRegExp.js +0 -0
- /package/dist/{esm → lib}/Models/Suggestion.d.ts +0 -0
- /package/dist/{esm → lib}/Models/Suggestion.js +0 -0
- /package/dist/{esm → lib}/Models/TextDocument.d.ts +0 -0
- /package/dist/{esm → lib}/Models/TextDocument.js +0 -0
- /package/dist/{esm → lib}/Models/ValidationIssue.d.ts +0 -0
- /package/dist/{esm → lib}/Models/ValidationIssue.js +0 -0
- /package/dist/{esm → lib}/Models/ValidationResult.d.ts +0 -0
- /package/dist/{esm → lib}/Models/ValidationResult.js +0 -0
- /package/dist/{esm → lib}/Settings/CSpellSettingsServer.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/CSpellSettingsServer.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/ImportError.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/ImportError.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/PnPSettings.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/PnPSettings.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/configLoader.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/configLocations.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/configLocations.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/configSearch.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/configSearch.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/configToRawSettings.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/configToRawSettings.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/defaultConfigLoader.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/defaultConfigLoader.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/defaultSettings.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/defaultSettings.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/extractImportErrors.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/extractImportErrors.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/index.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/index.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/normalizeRawSettings.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/normalizeRawSettings.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/readSettings.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/readSettings.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/readSettingsFiles.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/readSettingsFiles.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/toGlobDef.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/toGlobDef.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/types.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/configLoader/types.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/index.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/index.js +0 -0
- /package/dist/{esm → lib}/Settings/Controller/pnpLoader.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/Controller/pnpLoader.js +0 -0
- /package/dist/{esm → lib}/Settings/DefaultSettings.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/DictionaryReferenceCollection.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/DictionaryReferenceCollection.js +0 -0
- /package/dist/{esm → lib}/Settings/DictionarySettings.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/DictionarySettings.js +0 -0
- /package/dist/{esm → lib}/Settings/GlobalSettings.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/GlobalSettings.js +0 -0
- /package/dist/{esm → lib}/Settings/InDocSettings.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/InDocSettings.js +0 -0
- /package/dist/{esm → lib}/Settings/LanguageSettings.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/LanguageSettings.js +0 -0
- /package/dist/{esm → lib}/Settings/RegExpPatterns.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/RegExpPatterns.js +0 -0
- /package/dist/{esm → lib}/Settings/TextDocumentSettings.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/TextDocumentSettings.js +0 -0
- /package/dist/{esm → lib}/Settings/calcOverrideSettings.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/calcOverrideSettings.js +0 -0
- /package/dist/{esm → lib}/Settings/cfgStore.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/cfgStore.js +0 -0
- /package/dist/{esm → lib}/Settings/checkFilenameMatchesGlob.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/checkFilenameMatchesGlob.js +0 -0
- /package/dist/{esm → lib}/Settings/constants.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/constants.js +0 -0
- /package/dist/{esm → lib}/Settings/index.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/index.js +0 -0
- /package/dist/{esm → lib}/Settings/index.link.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/index.link.js +0 -0
- /package/dist/{esm → lib}/Settings/link.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/link.js +0 -0
- /package/dist/{esm → lib}/Settings/mergeCache.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/mergeCache.js +0 -0
- /package/dist/{esm → lib}/Settings/mergeList.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/mergeList.js +0 -0
- /package/dist/{esm → lib}/Settings/patterns.d.ts +0 -0
- /package/dist/{esm → lib}/Settings/patterns.js +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/Dictionaries.d.ts +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/Dictionaries.js +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/DictionaryController/DictionaryLoader.d.ts +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/DictionaryController/DictionaryLoader.js +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/DictionaryController/index.d.ts +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/DictionaryController/index.js +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/DictionaryLoader.d.ts +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/DictionaryLoader.js +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/SpellingDictionary.d.ts +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/SpellingDictionary.js +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/SpellingDictionaryError.d.ts +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/SpellingDictionaryError.js +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/SuggestionCollector.d.ts +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/SuggestionCollector.js +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/entities.d.ts +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/entities.js +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/helpers.d.ts +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/helpers.js +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/suggest.d.ts +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/SuggestExperimental/suggest.js +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/index.d.ts +0 -0
- /package/dist/{esm → lib}/SpellingDictionary/index.js +0 -0
- /package/dist/{esm → lib}/clearCachedFiles.d.ts +0 -0
- /package/dist/{esm → lib}/clearCachedFiles.js +0 -0
- /package/dist/{esm → lib}/events/events.d.ts +0 -0
- /package/dist/{esm → lib}/events/events.js +0 -0
- /package/dist/{esm → lib}/events/index.d.ts +0 -0
- /package/dist/{esm → lib}/events/index.js +0 -0
- /package/dist/{esm → lib}/exclusionHelper.d.ts +0 -0
- /package/dist/{esm → lib}/exclusionHelper.js +0 -0
- /package/dist/{esm → lib}/fileSystem.d.ts +0 -0
- /package/dist/{esm → lib}/fileSystem.js +0 -0
- /package/dist/{esm → lib}/getDictionary.d.ts +0 -0
- /package/dist/{esm → lib}/getDictionary.js +0 -0
- /package/dist/{esm → lib}/globs/checkFilenameMatchesGlob.d.ts +0 -0
- /package/dist/{esm → lib}/globs/checkFilenameMatchesGlob.js +0 -0
- /package/dist/{esm → lib}/globs/getGlobMatcher.d.ts +0 -0
- /package/dist/{esm → lib}/globs/getGlobMatcher.js +0 -0
- /package/dist/{esm → lib}/index.d.ts +0 -0
- /package/dist/{esm → lib}/index.js +0 -0
- /package/dist/{esm → lib}/perf/index.d.ts +0 -0
- /package/dist/{esm → lib}/perf/index.js +0 -0
- /package/dist/{esm → lib}/perf/perf.d.ts +0 -0
- /package/dist/{esm → lib}/perf/perf.js +0 -0
- /package/dist/{esm → lib}/perf/timer.d.ts +0 -0
- /package/dist/{esm → lib}/perf/timer.js +0 -0
- /package/dist/{esm → lib}/spellCheckFile.d.ts +0 -0
- /package/dist/{esm → lib}/spellCheckFile.js +0 -0
- /package/dist/{esm → lib}/suggestions.d.ts +0 -0
- /package/dist/{esm → lib}/suggestions.js +0 -0
- /package/dist/{esm → lib}/textValidation/ValidateTextOptions.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/ValidateTextOptions.js +0 -0
- /package/dist/{esm → lib}/textValidation/ValidationTypes.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/ValidationTypes.js +0 -0
- /package/dist/{esm → lib}/textValidation/checkText.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/checkText.js +0 -0
- /package/dist/{esm → lib}/textValidation/defaultConstants.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/defaultConstants.js +0 -0
- /package/dist/{esm → lib}/textValidation/determineTextDocumentSettings.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/determineTextDocumentSettings.js +0 -0
- /package/dist/{esm → lib}/textValidation/docValidator.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/docValidator.js +0 -0
- /package/dist/{esm → lib}/textValidation/index.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/index.js +0 -0
- /package/dist/{esm → lib}/textValidation/isWordValid.js +0 -0
- /package/dist/{esm → lib}/textValidation/lineValidatorFactory.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/parsedText.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/parsedText.js +0 -0
- /package/dist/{esm → lib}/textValidation/settingsToValidateOptions.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/settingsToValidateOptions.js +0 -0
- /package/dist/{esm → lib}/textValidation/textValidator.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/textValidator.js +0 -0
- /package/dist/{esm → lib}/textValidation/traceWord.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/traceWord.js +0 -0
- /package/dist/{esm → lib}/textValidation/validator.d.ts +0 -0
- /package/dist/{esm → lib}/textValidation/validator.js +0 -0
- /package/dist/{esm → lib}/trace.d.ts +0 -0
- /package/dist/{esm → lib}/trace.js +0 -0
- /package/dist/{esm → lib}/util/AutoResolve.d.ts +0 -0
- /package/dist/{esm → lib}/util/AutoResolve.js +0 -0
- /package/dist/{esm → lib}/util/AutoResolveLRUCache.d.ts +0 -0
- /package/dist/{esm → lib}/util/AutoResolveLRUCache.js +0 -0
- /package/dist/{esm → lib}/util/Comparable.d.ts +0 -0
- /package/dist/{esm → lib}/util/Comparable.js +0 -0
- /package/dist/{esm → lib}/util/FreqCounter.d.ts +0 -0
- /package/dist/{esm → lib}/util/FreqCounter.js +0 -0
- /package/dist/{esm → lib}/util/IterableLike.d.ts +0 -0
- /package/dist/{esm → lib}/util/IterableLike.js +0 -0
- /package/dist/{esm → lib}/util/MinHeapQueue.d.ts +0 -0
- /package/dist/{esm → lib}/util/MinHeapQueue.js +0 -0
- /package/dist/{esm → lib}/util/PairingHeap.d.ts +0 -0
- /package/dist/{esm → lib}/util/PairingHeap.js +0 -0
- /package/dist/{esm → lib}/util/TextMap.d.ts +0 -0
- /package/dist/{esm → lib}/util/TextMap.js +0 -0
- /package/dist/{esm → lib}/util/Uri.d.ts +0 -0
- /package/dist/{esm → lib}/util/Uri.js +0 -0
- /package/dist/{esm → lib}/util/errors.d.ts +0 -0
- /package/dist/{esm → lib}/util/errors.js +0 -0
- /package/dist/{esm → lib}/util/fileReader.d.ts +0 -0
- /package/dist/{esm → lib}/util/fileReader.js +0 -0
- /package/dist/{esm → lib}/util/findUp.d.ts +0 -0
- /package/dist/{esm → lib}/util/findUp.js +0 -0
- /package/dist/{esm → lib}/util/findUpFromUrl.d.ts +0 -0
- /package/dist/{esm → lib}/util/findUpFromUrl.js +0 -0
- /package/dist/{esm → lib}/util/iterableIteratorLib.d.ts +0 -0
- /package/dist/{esm → lib}/util/iterableIteratorLib.js +0 -0
- /package/dist/{esm → lib}/util/logger.d.ts +0 -0
- /package/dist/{esm → lib}/util/logger.js +0 -0
- /package/dist/{esm → lib}/util/memorizeLastCall.d.ts +0 -0
- /package/dist/{esm → lib}/util/memorizeLastCall.js +0 -0
- /package/dist/{esm → lib}/util/memorizerWeak.d.ts +0 -0
- /package/dist/{esm → lib}/util/memorizerWeak.js +0 -0
- /package/dist/{esm → lib}/util/regexHelper.d.ts +0 -0
- /package/dist/{esm → lib}/util/regexHelper.js +0 -0
- /package/dist/{esm → lib}/util/repMap.d.ts +0 -0
- /package/dist/{esm → lib}/util/repMap.js +0 -0
- /package/dist/{esm → lib}/util/resolveFile.d.ts +0 -0
- /package/dist/{esm → lib}/util/search.d.ts +0 -0
- /package/dist/{esm → lib}/util/search.js +0 -0
- /package/dist/{esm → lib}/util/simpleCache.d.ts +0 -0
- /package/dist/{esm → lib}/util/simpleCache.js +0 -0
- /package/dist/{esm → lib}/util/templates.d.ts +0 -0
- /package/dist/{esm → lib}/util/templates.js +0 -0
- /package/dist/{esm → lib}/util/types.d.ts +0 -0
- /package/dist/{esm → lib}/util/types.js +0 -0
- /package/dist/{esm → lib}/util/url.d.ts +0 -0
- /package/dist/{esm → lib}/util/util.d.ts +0 -0
- /package/dist/{esm → lib}/util/util.js +0 -0
- /package/dist/{esm → lib}/validator.d.ts +0 -0
- /package/dist/{esm → lib}/validator.js +0 -0
- /package/dist/{esm → lib}/wordListHelper.d.ts +0 -0
- /package/dist/{esm → lib}/wordListHelper.js +0 -0
|
@@ -4,10 +4,10 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
|
4
4
|
import { createReaderWriter, CSpellConfigFileInMemory } from 'cspell-config-lib';
|
|
5
5
|
import { isUrlLike, toFileURL } from 'cspell-io';
|
|
6
6
|
import { URI, Utils as UriUtils } from 'vscode-uri';
|
|
7
|
-
import { srcDirectory } from '../../../../lib-cjs/index.cjs';
|
|
8
7
|
import { onClearCache } from '../../../events/index.js';
|
|
9
8
|
import { getVirtualFS } from '../../../fileSystem.js';
|
|
10
9
|
import { createCSpellSettingsInternal as csi } from '../../../Models/CSpellSettingsInternalDef.js';
|
|
10
|
+
import { srcDirectory } from '../../../pkg-info.mjs';
|
|
11
11
|
import { autoResolve, AutoResolveCache, autoResolveWeak } from '../../../util/AutoResolve.js';
|
|
12
12
|
import { logError, logWarning } from '../../../util/logger.js';
|
|
13
13
|
import { FileResolver } from '../../../util/resolveFile.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parsers } from 'cspell-grammar';
|
|
2
|
-
import { srcDirectory } from '../../lib-cjs/index.cjs';
|
|
3
2
|
import { createCSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef.js';
|
|
4
3
|
import { PatternRegExp } from '../Models/PatternRegExp.js';
|
|
4
|
+
import { srcDirectory } from '../pkg-info.mjs';
|
|
5
5
|
import { resolveFile } from '../util/resolveFile.js';
|
|
6
6
|
import { defaultConfigFileModuleRef } from './constants.js';
|
|
7
7
|
import { readSettings } from './Controller/configLoader/index.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const srcDirectory: string;
|
|
2
|
-
//# sourceMappingURL=pkg-info.d.
|
|
2
|
+
//# sourceMappingURL=pkg-info.d.mts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
/**
|
|
3
|
+
* This is the url of the current file, but it might be undefined if the environment does not support it.
|
|
4
|
+
*/
|
|
5
|
+
const url = import.meta.url;
|
|
6
|
+
function calcSrcDirectory() {
|
|
7
|
+
try {
|
|
8
|
+
return __dirname;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return url ? fileURLToPath(new URL('./', url)) : process.cwd();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export const srcDirectory = calcSrcDirectory();
|
|
15
|
+
//# sourceMappingURL=pkg-info.mjs.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TextOffsetRO } from './ValidationTypes.js';
|
|
2
|
+
interface Dict {
|
|
3
|
+
has(word: string): boolean;
|
|
4
|
+
}
|
|
5
|
+
declare function hasWordCheck(dict: Dict, word: string): boolean;
|
|
6
|
+
export declare function isWordValidWithEscapeRetry(dict: Dict, wo: TextOffsetRO, line: TextOffsetRO): boolean;
|
|
7
|
+
export declare const __testing__: {
|
|
8
|
+
hasWordCheck: typeof hasWordCheck;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=isWordValid.d.ts.map
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { opConcatMap, opFilter, pipe } from '@cspell/cspell-pipe/sync';
|
|
2
|
+
import { createCachingDictionary } from 'cspell-dictionary';
|
|
3
|
+
import * as RxPat from '../Settings/RegExpPatterns.js';
|
|
4
|
+
import { extractPossibleWordsFromTextOffset, extractText, extractWordsFromCodeTextOffset, extractWordsFromTextOffset, } from '../util/text.js';
|
|
5
|
+
import { split } from '../util/wordSplitter.js';
|
|
6
|
+
import { defaultMinWordLength } from './defaultConstants.js';
|
|
7
|
+
import { isWordValidWithEscapeRetry } from './isWordValid.js';
|
|
8
|
+
import { mapRangeBackToOriginalPos } from './parsedText.js';
|
|
9
|
+
export function lineValidatorFactory(sDict, options) {
|
|
10
|
+
const { minWordLength = defaultMinWordLength, flagWords = [], allowCompoundWords = false, ignoreCase = true, } = options;
|
|
11
|
+
const hasWordOptions = {
|
|
12
|
+
ignoreCase,
|
|
13
|
+
useCompounds: allowCompoundWords || undefined, // let the dictionaries decide on useCompounds if allow is false
|
|
14
|
+
};
|
|
15
|
+
const dictCol = createCachingDictionary(sDict, hasWordOptions);
|
|
16
|
+
const knownWords = new Map();
|
|
17
|
+
const setOfFlagWords = new Set(flagWords);
|
|
18
|
+
const setOfKnownIssues = new Map();
|
|
19
|
+
const setOfKnownSuccessfulWords = new Set();
|
|
20
|
+
const rememberFilter = (fn) => (v) => {
|
|
21
|
+
const keep = fn(v);
|
|
22
|
+
if (!keep) {
|
|
23
|
+
setOfKnownSuccessfulWords.add(v.text);
|
|
24
|
+
}
|
|
25
|
+
return keep;
|
|
26
|
+
};
|
|
27
|
+
const filterAlreadyChecked = (wo) => {
|
|
28
|
+
return !setOfKnownSuccessfulWords.has(wo.text);
|
|
29
|
+
};
|
|
30
|
+
const hasDict = {
|
|
31
|
+
has(word) {
|
|
32
|
+
const info = getWordInfo(word);
|
|
33
|
+
if (info.isFound !== undefined)
|
|
34
|
+
return info.isFound;
|
|
35
|
+
if (info.isFlagged)
|
|
36
|
+
return true;
|
|
37
|
+
if (info.isFlagged)
|
|
38
|
+
return false;
|
|
39
|
+
info.isFound = dictCol.has(word);
|
|
40
|
+
return info.isFound;
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
function calcIgnored(info) {
|
|
44
|
+
info.isIgnored ??= dictCol.isNoSuggestWord(info.word);
|
|
45
|
+
return info.isIgnored;
|
|
46
|
+
}
|
|
47
|
+
function calcFlagged(info) {
|
|
48
|
+
if (info.isFlagged !== undefined)
|
|
49
|
+
return info.isFlagged;
|
|
50
|
+
const word = info.word;
|
|
51
|
+
info.isFlagged =
|
|
52
|
+
(setOfFlagWords.has(word) || setOfFlagWords.has(word.toLowerCase()) || dictCol.isForbidden(word)) &&
|
|
53
|
+
!calcIgnored(info);
|
|
54
|
+
return info.isFlagged;
|
|
55
|
+
}
|
|
56
|
+
function isWordIgnored(word) {
|
|
57
|
+
return calcIgnored(getWordInfo(word));
|
|
58
|
+
}
|
|
59
|
+
function getSuggestions(word) {
|
|
60
|
+
return dictCol.getPreferredSuggestions(word);
|
|
61
|
+
}
|
|
62
|
+
function isWordFlagged(wo) {
|
|
63
|
+
return calcFlagged(getWordInfo(wo.text));
|
|
64
|
+
}
|
|
65
|
+
function annotateIsFlagged(word) {
|
|
66
|
+
word.isFlagged = isWordFlagged(word);
|
|
67
|
+
return word;
|
|
68
|
+
}
|
|
69
|
+
function annotateIssue(issue) {
|
|
70
|
+
const sugs = getSuggestions(issue.text);
|
|
71
|
+
if (sugs && sugs.length) {
|
|
72
|
+
issue.suggestionsEx = sugs;
|
|
73
|
+
}
|
|
74
|
+
return issue;
|
|
75
|
+
}
|
|
76
|
+
const isFlaggedOrMinLength = rememberFilter((wo) => wo.text.length >= minWordLength || !!wo.isFlagged);
|
|
77
|
+
const isFlaggedOrNotFound = rememberFilter((wo) => wo.isFlagged || !wo.isFound);
|
|
78
|
+
const isNotRepeatingChar = rememberFilter((wo) => !RxPat.regExRepeatedChar.test(wo.text));
|
|
79
|
+
function checkWord(issue) {
|
|
80
|
+
const info = getWordInfo(issue.text);
|
|
81
|
+
if (info.fin) {
|
|
82
|
+
const { isFlagged: isForbidden, isFound, isIgnored } = info;
|
|
83
|
+
const isFlagged = issue.isFlagged ?? (!isIgnored && isForbidden);
|
|
84
|
+
issue.isFlagged = isFlagged;
|
|
85
|
+
issue.isFound = isFlagged ? undefined : isFound;
|
|
86
|
+
return issue;
|
|
87
|
+
}
|
|
88
|
+
const isIgnored = calcIgnored(info);
|
|
89
|
+
const isFlagged = issue.isFlagged ?? calcFlagged(info);
|
|
90
|
+
info.isFound ??= isFlagged ? false : isIgnored || isWordValidWithEscapeRetry(hasDict, issue, issue.line);
|
|
91
|
+
info.isFlagged = !!isFlagged;
|
|
92
|
+
info.fin = true;
|
|
93
|
+
issue.isFlagged = isFlagged;
|
|
94
|
+
issue.isFound = isFlagged ? undefined : info.isFound;
|
|
95
|
+
return issue;
|
|
96
|
+
}
|
|
97
|
+
const fn = (lineSegment) => {
|
|
98
|
+
function splitterIsValid(word) {
|
|
99
|
+
return (setOfKnownSuccessfulWords.has(word.text) ||
|
|
100
|
+
(!isWordFlagged(word) && isWordValidWithEscapeRetry(hasDict, word, lineSegment.line)));
|
|
101
|
+
}
|
|
102
|
+
function checkFullWord(vr) {
|
|
103
|
+
if (vr.isFlagged) {
|
|
104
|
+
return [vr];
|
|
105
|
+
}
|
|
106
|
+
const codeWordResults = [];
|
|
107
|
+
for (const wo of extractWordsFromCodeTextOffset(vr)) {
|
|
108
|
+
if (setOfKnownSuccessfulWords.has(wo.text))
|
|
109
|
+
continue;
|
|
110
|
+
const issue = wo;
|
|
111
|
+
issue.line = vr.line;
|
|
112
|
+
issue.isFlagged = undefined;
|
|
113
|
+
issue.isFound = undefined;
|
|
114
|
+
annotateIsFlagged(issue);
|
|
115
|
+
if (!isFlaggedOrMinLength(issue))
|
|
116
|
+
continue;
|
|
117
|
+
checkWord(issue);
|
|
118
|
+
if (!isFlaggedOrNotFound(issue) || !isNotRepeatingChar(issue))
|
|
119
|
+
continue;
|
|
120
|
+
issue.text = extractText(lineSegment.segment, issue.offset, issue.offset + issue.text.length);
|
|
121
|
+
codeWordResults.push(issue);
|
|
122
|
+
}
|
|
123
|
+
if (!codeWordResults.length || isWordIgnored(vr.text) || checkWord(vr).isFound) {
|
|
124
|
+
rememberFilter((_) => false)(vr);
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
return codeWordResults;
|
|
128
|
+
}
|
|
129
|
+
const useKnownIssues = false;
|
|
130
|
+
function rebaseKnownIssues(possibleWord, known) {
|
|
131
|
+
const { issues } = known;
|
|
132
|
+
const adjOffset = possibleWord.offset - known.possibleWord.offset;
|
|
133
|
+
return issues.map((issue) => {
|
|
134
|
+
issue = { ...issue };
|
|
135
|
+
issue.offset += adjOffset;
|
|
136
|
+
issue.line = lineSegment.line;
|
|
137
|
+
return issue;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function checkPossibleWords(possibleWord) {
|
|
141
|
+
const known = setOfKnownIssues.get(possibleWord.text);
|
|
142
|
+
if (known && !known.issues.length)
|
|
143
|
+
return known.issues;
|
|
144
|
+
if (known && useKnownIssues) {
|
|
145
|
+
const adjusted = rebaseKnownIssues(possibleWord, known);
|
|
146
|
+
return adjusted;
|
|
147
|
+
}
|
|
148
|
+
const issues = _checkPossibleWords(possibleWord).map(annotateIssue);
|
|
149
|
+
setOfKnownIssues.set(possibleWord.text, { possibleWord, issues });
|
|
150
|
+
return issues;
|
|
151
|
+
}
|
|
152
|
+
function _checkPossibleWords(possibleWord) {
|
|
153
|
+
if (isWordFlagged(possibleWord)) {
|
|
154
|
+
const vr = {
|
|
155
|
+
...possibleWord,
|
|
156
|
+
line: lineSegment.line,
|
|
157
|
+
isFlagged: true,
|
|
158
|
+
};
|
|
159
|
+
return [vr];
|
|
160
|
+
}
|
|
161
|
+
const mismatches = [];
|
|
162
|
+
for (const wo of extractWordsFromTextOffset(possibleWord)) {
|
|
163
|
+
if (setOfKnownSuccessfulWords.has(wo.text))
|
|
164
|
+
continue;
|
|
165
|
+
const issue = wo;
|
|
166
|
+
issue.line = lineSegment.line;
|
|
167
|
+
annotateIsFlagged(issue);
|
|
168
|
+
if (!isFlaggedOrMinLength(issue))
|
|
169
|
+
continue;
|
|
170
|
+
for (const w of checkFullWord(issue)) {
|
|
171
|
+
mismatches.push(w);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (mismatches.length) {
|
|
175
|
+
// Try the more expensive word splitter
|
|
176
|
+
const splitResult = split(lineSegment.segment, possibleWord.offset, splitterIsValid);
|
|
177
|
+
const nonMatching = splitResult.words.filter((w) => !w.isFound);
|
|
178
|
+
if (nonMatching.length < mismatches.length) {
|
|
179
|
+
return nonMatching.map((w) => ({ ...w, line: lineSegment.line })).map(annotateIsFlagged);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return mismatches;
|
|
183
|
+
}
|
|
184
|
+
const checkedPossibleWords = pipe(extractPossibleWordsFromTextOffset(lineSegment.segment), opFilter(filterAlreadyChecked), opConcatMap(checkPossibleWords));
|
|
185
|
+
return checkedPossibleWords;
|
|
186
|
+
};
|
|
187
|
+
function getWordInfo(word) {
|
|
188
|
+
const info = knownWords.get(word);
|
|
189
|
+
if (info)
|
|
190
|
+
return info;
|
|
191
|
+
const result = { word, isFound: undefined, isFlagged: undefined, isIgnored: undefined, fin: false };
|
|
192
|
+
knownWords.set(word, result);
|
|
193
|
+
return result;
|
|
194
|
+
}
|
|
195
|
+
return { fn, dict: dictCol };
|
|
196
|
+
}
|
|
197
|
+
export function textValidatorFactory(dict, options) {
|
|
198
|
+
const lineValidator = lineValidatorFactory(dict, options);
|
|
199
|
+
const lineValidatorFn = lineValidator.fn;
|
|
200
|
+
function validate(pText) {
|
|
201
|
+
const { text, range: srcRange, map } = pText;
|
|
202
|
+
const srcOffset = srcRange[0];
|
|
203
|
+
const segment = { text, offset: 0 };
|
|
204
|
+
const lineSegment = { line: segment, segment };
|
|
205
|
+
function mapBackToOriginSimple(vr) {
|
|
206
|
+
const { text, offset, isFlagged, isFound, suggestionsEx } = vr;
|
|
207
|
+
const r = mapRangeBackToOriginalPos([offset, offset + text.length], map);
|
|
208
|
+
const range = [r[0] + srcOffset, r[1] + srcOffset];
|
|
209
|
+
return { text, range, isFlagged, isFound, suggestionsEx };
|
|
210
|
+
}
|
|
211
|
+
return [...lineValidatorFn(lineSegment)].map(mapBackToOriginSimple);
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
validate,
|
|
215
|
+
lineValidator,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=lineValidatorFactory.js.map
|
|
@@ -13,20 +13,15 @@ export interface MatchRangeOptionalText extends MatchRange {
|
|
|
13
13
|
text?: string;
|
|
14
14
|
}
|
|
15
15
|
export declare function findMatchingRanges(pattern: RegExp, text: string): MatchRangeOptionalText[];
|
|
16
|
-
export declare function unionRanges(ranges: MatchRange[]):
|
|
16
|
+
export declare function unionRanges(ranges: MatchRange[]): SortedMatchRangeArray;
|
|
17
17
|
export declare function findMatchingRangesForPatterns(patterns: RegExp[], text: string): MatchRange[];
|
|
18
18
|
/**
|
|
19
19
|
* Create a new set of positions that have the excluded position ranges removed.
|
|
20
20
|
*/
|
|
21
21
|
export declare function excludeRanges(includeRanges: MatchRange[], excludeRanges: MatchRange[]): MatchRange[];
|
|
22
22
|
export declare function extractRangeText(text: string, ranges: MatchRange[]): MatchRangeWithText[];
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
[SymSortedMatchRangeArray]: true;
|
|
23
|
+
interface SortedMatchRangeArray {
|
|
24
|
+
values: MatchRange[];
|
|
26
25
|
}
|
|
27
|
-
declare function makeSortedMatchRangeArray(sortedValues: MatchRange[]): SortedMatchRangeArray;
|
|
28
|
-
export declare const __testing__: {
|
|
29
|
-
makeSortedMatchRangeArray: typeof makeSortedMatchRangeArray;
|
|
30
|
-
};
|
|
31
26
|
export {};
|
|
32
27
|
//# sourceMappingURL=TextRange.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as GS from 'gensequence';
|
|
2
1
|
function toMatchRangeWithText(m) {
|
|
3
2
|
const index = m.index || 0;
|
|
4
3
|
const _text = m[0];
|
|
@@ -25,16 +24,17 @@ function compareRanges(a, b) {
|
|
|
25
24
|
return a.startPos - b.startPos || a.endPos - b.endPos;
|
|
26
25
|
}
|
|
27
26
|
export function unionRanges(ranges) {
|
|
28
|
-
return makeSortedMatchRangeArray([..._unionRanges(ranges)]);
|
|
29
|
-
}
|
|
30
|
-
function* _unionRanges(ranges) {
|
|
31
27
|
const sortedRanges = sortMatchRangeArray(ranges);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
ranges = sortedRanges.values;
|
|
29
|
+
if (!ranges.length)
|
|
30
|
+
return sortedRanges;
|
|
31
|
+
let i = 0;
|
|
32
|
+
let j = 0;
|
|
33
|
+
let { startPos, endPos } = ranges[i++];
|
|
34
|
+
for (; i < ranges.length; ++i) {
|
|
35
|
+
const r = ranges[i];
|
|
36
36
|
if (r.startPos > endPos) {
|
|
37
|
-
|
|
37
|
+
ranges[j++] = { startPos, endPos };
|
|
38
38
|
startPos = r.startPos;
|
|
39
39
|
endPos = r.endPos;
|
|
40
40
|
continue;
|
|
@@ -42,26 +42,32 @@ function* _unionRanges(ranges) {
|
|
|
42
42
|
endPos = Math.max(endPos, r.endPos);
|
|
43
43
|
}
|
|
44
44
|
if (startPos < endPos) {
|
|
45
|
-
|
|
45
|
+
ranges[j++] = { startPos, endPos };
|
|
46
46
|
}
|
|
47
|
+
ranges.length = j;
|
|
48
|
+
return sortedRanges;
|
|
47
49
|
}
|
|
48
50
|
export function findMatchingRangesForPatterns(patterns, text) {
|
|
49
|
-
const
|
|
50
|
-
return unionRanges(
|
|
51
|
+
const nested = patterns.map((pattern) => findMatchingRanges(pattern, text));
|
|
52
|
+
return unionRanges(flatten(nested)).values;
|
|
51
53
|
}
|
|
52
54
|
/**
|
|
53
55
|
* Create a new set of positions that have the excluded position ranges removed.
|
|
54
56
|
*/
|
|
55
57
|
export function excludeRanges(includeRanges, excludeRanges) {
|
|
56
|
-
return
|
|
58
|
+
return _excludeRanges(sortMatchRangeArray(includeRanges), sortMatchRangeArray(excludeRanges));
|
|
57
59
|
}
|
|
58
|
-
function
|
|
60
|
+
function _excludeRanges(sortedIncludeRanges, sortedExcludeRanges) {
|
|
61
|
+
const includeRanges = sortedIncludeRanges.values;
|
|
62
|
+
const excludeRanges = sortedExcludeRanges.values;
|
|
59
63
|
if (!includeRanges.length)
|
|
60
|
-
return;
|
|
64
|
+
return includeRanges;
|
|
61
65
|
if (!excludeRanges.length) {
|
|
62
|
-
|
|
63
|
-
return;
|
|
66
|
+
return includeRanges;
|
|
64
67
|
}
|
|
68
|
+
const ranges = [];
|
|
69
|
+
ranges.length = includeRanges.length + excludeRanges.length + 1;
|
|
70
|
+
let i = 0;
|
|
65
71
|
let exIndex = 0;
|
|
66
72
|
const limit = excludeRanges.length;
|
|
67
73
|
for (const incRange of includeRanges) {
|
|
@@ -74,16 +80,18 @@ function* _excludeRanges(includeRanges, excludeRanges) {
|
|
|
74
80
|
if (ex.endPos <= startPos)
|
|
75
81
|
continue;
|
|
76
82
|
if (ex.startPos > startPos) {
|
|
77
|
-
|
|
83
|
+
ranges[i++] = { startPos, endPos: ex.startPos };
|
|
78
84
|
}
|
|
79
85
|
startPos = ex.endPos;
|
|
80
86
|
if (startPos >= endPos)
|
|
81
87
|
break;
|
|
82
88
|
}
|
|
83
89
|
if (startPos < endPos) {
|
|
84
|
-
|
|
90
|
+
ranges[i++] = { startPos, endPos };
|
|
85
91
|
}
|
|
86
92
|
}
|
|
93
|
+
ranges.length = i;
|
|
94
|
+
return ranges;
|
|
87
95
|
}
|
|
88
96
|
export function extractRangeText(text, ranges) {
|
|
89
97
|
return ranges.map(({ startPos, endPos }) => ({
|
|
@@ -92,22 +100,23 @@ export function extractRangeText(text, ranges) {
|
|
|
92
100
|
text: text.slice(startPos, endPos),
|
|
93
101
|
}));
|
|
94
102
|
}
|
|
95
|
-
const SymSortedMatchRangeArray = Symbol('SortedMatchRangeArray');
|
|
96
103
|
function sortMatchRangeArray(values) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
return makeSortedMatchRangeArray(values.sort(compareRanges));
|
|
100
|
-
}
|
|
101
|
-
function isSortedMatchRangeArray(a) {
|
|
102
|
-
return a[SymSortedMatchRangeArray] === true;
|
|
104
|
+
values.sort(compareRanges);
|
|
105
|
+
return { values };
|
|
103
106
|
}
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
function flatten(data) {
|
|
108
|
+
let size = 0;
|
|
109
|
+
for (let i = data.length - 1; i >= 0; --i) {
|
|
110
|
+
size += data[i].length;
|
|
111
|
+
}
|
|
112
|
+
const result = new Array(size);
|
|
113
|
+
let k = 0;
|
|
114
|
+
for (let i = 0; i < data.length; ++i) {
|
|
115
|
+
const d = data[i];
|
|
116
|
+
for (let j = 0; j < d.length; ++j) {
|
|
117
|
+
result[k++] = d[j];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return result;
|
|
109
121
|
}
|
|
110
|
-
export const __testing__ = {
|
|
111
|
-
makeSortedMatchRangeArray,
|
|
112
|
-
};
|
|
113
122
|
//# sourceMappingURL=TextRange.js.map
|
|
@@ -6,8 +6,8 @@ import { fileURLToPath } from 'node:url';
|
|
|
6
6
|
import { resolveGlobal } from '@cspell/cspell-resolver';
|
|
7
7
|
import { importResolveModuleName } from '@cspell/dynamic-import';
|
|
8
8
|
import resolveFrom from 'resolve-from';
|
|
9
|
-
import { srcDirectory } from '../../lib-cjs/pkg-info.cjs';
|
|
10
9
|
import { getFileSystem } from '../fileSystem.js';
|
|
10
|
+
import { srcDirectory } from '../pkg-info.mjs';
|
|
11
11
|
import { envToTemplateVars, replaceTemplate } from './templates.js';
|
|
12
12
|
import { fileURLOrPathToPath, isDataURL, isFileURL, isURLLike, resolveFileWithURL, toFilePathOrHref, toFileUrl, toURL, } from './url.js';
|
|
13
13
|
const regExpStartsWidthNodeModules = /^node_modules[/\\]/;
|
|
@@ -11,7 +11,7 @@ export declare function splitCamelCaseWord(word: string): string[];
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function match(reg: RegExp, text: string): Iterable<RegExpExecArray>;
|
|
13
13
|
export declare function matchStringToTextOffset(reg: RegExp, text: string): Iterable<TextOffset>;
|
|
14
|
-
export declare function matchToTextOffset(reg: RegExp,
|
|
14
|
+
export declare function matchToTextOffset(reg: RegExp, t: TextOffset): Iterable<TextOffset>;
|
|
15
15
|
export declare function extractLinesOfText(text: string): Iterable<TextOffset>;
|
|
16
16
|
/**
|
|
17
17
|
* Extract out whole words from a string of text.
|
|
@@ -21,6 +21,11 @@ export declare function extractWordsFromText(text: string): Iterable<TextOffset>
|
|
|
21
21
|
* Extract out whole words from a string of text.
|
|
22
22
|
*/
|
|
23
23
|
export declare function extractWordsFromTextOffset(text: TextOffset): Iterable<TextOffset>;
|
|
24
|
+
/**
|
|
25
|
+
* Remove Hiragana, Han, Katakana, Hangul characters from the text.
|
|
26
|
+
* @param text
|
|
27
|
+
* @returns the text with the characters removed.
|
|
28
|
+
*/
|
|
24
29
|
export declare function cleanText(text: string): string;
|
|
25
30
|
export declare function cleanTextOffset(text: TextOffset): TextOffset;
|
|
26
31
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { opConcatMap, opMap, pipe } from '@cspell/cspell-pipe/sync';
|
|
2
2
|
import { binarySearch } from './search.js';
|
|
3
|
-
import { regExAccents, regExAllLower, regExAllUpper, regExFirstUpper, regExIgnoreCharacters,
|
|
3
|
+
import { regExAccents, regExAllLower, regExAllUpper, regExFirstUpper, regExIgnoreCharacters, regExpSplitWordBreaks, regExWords, regExWordsAndDigits, } from './textRegex.js';
|
|
4
4
|
import { toUri } from './Uri.js';
|
|
5
5
|
import { scanMap } from './util.js';
|
|
6
6
|
export { stringToRegExp } from './textRegex.js';
|
|
@@ -15,11 +15,7 @@ export function splitCamelCaseWordWithOffset(wo) {
|
|
|
15
15
|
* Split camelCase words into an array of strings.
|
|
16
16
|
*/
|
|
17
17
|
export function splitCamelCaseWord(word) {
|
|
18
|
-
|
|
19
|
-
const separator = '_<^*_*^>_';
|
|
20
|
-
const pass1 = wPrime.replace(regExSplitWords, '$1' + separator + '$2');
|
|
21
|
-
const pass2 = pass1.replace(regExSplitWords2, '$1' + separator + '$2');
|
|
22
|
-
return pass2.split(separator);
|
|
18
|
+
return word.split(regExpSplitWordBreaks);
|
|
23
19
|
}
|
|
24
20
|
/**
|
|
25
21
|
* This function lets you iterate over regular expression matches.
|
|
@@ -33,11 +29,11 @@ export function match(reg, text) {
|
|
|
33
29
|
export function matchStringToTextOffset(reg, text) {
|
|
34
30
|
return matchToTextOffset(reg, { text, offset: 0 });
|
|
35
31
|
}
|
|
36
|
-
export function matchToTextOffset(reg,
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
return pipe(match(reg,
|
|
32
|
+
export function matchToTextOffset(reg, t) {
|
|
33
|
+
const text = t.text;
|
|
34
|
+
const offset = t.offset;
|
|
35
|
+
// return opMap((m: RegExpExecArray) => ({ text: m[0], offset: offset + m.index }))(match(reg, text));
|
|
36
|
+
return pipe(match(reg, text), opMap((m) => ({ text: m[0], offset: offset + m.index })));
|
|
41
37
|
}
|
|
42
38
|
export function* extractLinesOfText(text) {
|
|
43
39
|
let i = 0;
|
|
@@ -61,11 +57,23 @@ export function extractWordsFromTextOffset(text) {
|
|
|
61
57
|
const reg = new RegExp(regExWords);
|
|
62
58
|
return matchToTextOffset(reg, cleanTextOffset(text));
|
|
63
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Remove Hiragana, Han, Katakana, Hangul characters from the text.
|
|
62
|
+
* @param text
|
|
63
|
+
* @returns the text with the characters removed.
|
|
64
|
+
*/
|
|
64
65
|
export function cleanText(text) {
|
|
66
|
+
regExIgnoreCharacters.lastIndex = 0;
|
|
67
|
+
if (!regExIgnoreCharacters.test(text))
|
|
68
|
+
return text;
|
|
65
69
|
text = text.replace(regExIgnoreCharacters, (match) => ' '.repeat(match.length));
|
|
66
70
|
return text;
|
|
67
71
|
}
|
|
68
72
|
export function cleanTextOffset(text) {
|
|
73
|
+
// Do not make a new object if the text is already clean.
|
|
74
|
+
regExIgnoreCharacters.lastIndex = 0;
|
|
75
|
+
if (!regExIgnoreCharacters.test(text.text))
|
|
76
|
+
return text;
|
|
69
77
|
return {
|
|
70
78
|
text: cleanText(text.text),
|
|
71
79
|
offset: text.offset,
|
|
@@ -135,9 +143,6 @@ export function extractText(textOffset, startPos, endPos) {
|
|
|
135
143
|
const b = Math.max(endPos - orig, 0);
|
|
136
144
|
return text.slice(a, b);
|
|
137
145
|
}
|
|
138
|
-
function offsetMap(offset) {
|
|
139
|
-
return (xo) => ({ ...xo, offset: xo.offset + offset });
|
|
140
|
-
}
|
|
141
146
|
export function calculateTextDocumentOffsets(uri, doc, wordOffsets) {
|
|
142
147
|
const lines = [
|
|
143
148
|
-1,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const regExUpperSOrIng: RegExp;
|
|
2
2
|
export declare const regExSplitWords: RegExp;
|
|
3
3
|
export declare const regExSplitWords2: RegExp;
|
|
4
|
+
export declare const regExpSplitWordBreaks: RegExp;
|
|
5
|
+
export declare const regExpAllPossibleWordBreaks: RegExp;
|
|
4
6
|
export declare const regExWords: RegExp;
|
|
5
7
|
export declare const regExWordsAndDigits: RegExp;
|
|
6
8
|
export declare const regExIgnoreCharacters: RegExp;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// cspell:ignore ings ning gimuy anrvtbf gimuxy
|
|
2
|
-
export const regExUpperSOrIng = /([\p{Lu}\p{M}]
|
|
2
|
+
export const regExUpperSOrIng = /([\p{Lu}\p{M}]+(?:\\?['’])?(?:s|ing|ies|es|ings|ed|ning))(?!\p{Ll})/gu;
|
|
3
3
|
export const regExSplitWords = /(\p{Ll}\p{M}?)(\p{Lu})/gu;
|
|
4
4
|
export const regExSplitWords2 = /(\p{Lu}\p{M}?)(\p{Lu}\p{M}?\p{Ll})/gu;
|
|
5
|
+
export const regExpSplitWordBreaks = /(?<=\p{Ll}\p{M}?)(?=\p{Lu})|(?<=\p{Lu}\p{M}?)(?=\p{Lu}\p{M}?\p{Ll})(?!\p{Lu}\p{M}?(?:s|ing|ies|es|ings|ed|ning)(?!\p{Ll}))/gu;
|
|
6
|
+
export const regExpAllPossibleWordBreaks = /(?<=\p{Ll}\p{M}?)(?=\p{Lu})|(?<=\p{Lu}\p{M}?)(?=\p{Lu}\p{M}?\p{Ll})|(?<=\p{Lu}\p{M}?\p{Lu}\p{M}?)(?=\p{Ll})|(?<=\p{L}\p{M}?)(?=\P{L})|(?<=\P{L})(?=\p{L})/gu;
|
|
5
7
|
export const regExWords = /\p{L}\p{M}?(?:(?:\\?['’])?\p{L}\p{M}?)*/gu;
|
|
6
8
|
// Words can be made of letters, numbers, period, underscore, dash, plus, and single quote
|
|
7
9
|
export const regExWordsAndDigits = /[\p{L}\w'’`.+-](?:(?:\\(?=[']))?[\p{L}\p{M}\w'’`.+-])*/gu;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { pathToFileURL } from 'node:url';
|
|
3
3
|
import { toFilePathOrHref, toFileURL } from '@cspell/url';
|
|
4
|
-
import { srcDirectory } from '
|
|
4
|
+
import { srcDirectory } from '../pkg-info.mjs';
|
|
5
5
|
export { addTrailingSlash, isDataURL, isFileURL, isUrlLike as isURLLike, toFileURL as resolveFileWithURL, toFileDirURL, toFilePathOrHref, toURL, } from '@cspell/url';
|
|
6
6
|
/**
|
|
7
7
|
* This is a URL that can be used for searching for modules.
|
|
@@ -24,7 +24,7 @@ export interface SplitOptions extends WordBreakOptions {
|
|
|
24
24
|
}
|
|
25
25
|
export declare function split(line: TextOffset, offset: number, isValidWord: IsValidWordFn, options?: SplitOptions): SplitResult;
|
|
26
26
|
declare function findNextWordText({ text, offset }: TextOffset): TextOffset;
|
|
27
|
-
type BreakPairs = readonly number
|
|
27
|
+
type BreakPairs = readonly [number, number];
|
|
28
28
|
interface PossibleWordBreak {
|
|
29
29
|
/** offset from the start of the string */
|
|
30
30
|
offset: number;
|
|
@@ -224,7 +224,7 @@ function splitIntoWords(lineSeg, breaks, has) {
|
|
|
224
224
|
}
|
|
225
225
|
return br.breaks.map(c);
|
|
226
226
|
}
|
|
227
|
-
function
|
|
227
|
+
function checkTextOffset(text, offset) {
|
|
228
228
|
const valid = has({ text, offset });
|
|
229
229
|
return {
|
|
230
230
|
text,
|
|
@@ -282,7 +282,7 @@ function splitIntoWords(lineSeg, breaks, has) {
|
|
|
282
282
|
// yes
|
|
283
283
|
const i = best.bp[0];
|
|
284
284
|
const j = best.bp[1];
|
|
285
|
-
const t = i > best.i ?
|
|
285
|
+
const t = i > best.i ? checkTextOffset(text.slice(best.i, i), best.i) : undefined;
|
|
286
286
|
const cost = !t || t.isFound ? 0 : t.text.length;
|
|
287
287
|
const mc = maxIndex - j;
|
|
288
288
|
best.c += cost;
|
|
@@ -304,12 +304,12 @@ function splitIntoWords(lineSeg, breaks, has) {
|
|
|
304
304
|
const c = makeCandidates(best.p, best.i, best.bi + 1, best.c);
|
|
305
305
|
candidates.append(c);
|
|
306
306
|
if (!c.length) {
|
|
307
|
-
const t = maxIndex > best.i ?
|
|
307
|
+
const t = maxIndex > best.i ? checkTextOffset(text.slice(best.i, maxIndex), best.i) : undefined;
|
|
308
308
|
const cost = !t || t.isFound ? 0 : t.text.length;
|
|
309
309
|
best.c += cost;
|
|
310
310
|
best.ec = best.c;
|
|
311
311
|
best.text = t;
|
|
312
|
-
const segText = t || best.p?.text ||
|
|
312
|
+
const segText = t || best.p?.text || checkTextOffset('', best.i);
|
|
313
313
|
const can = t ? { ...best, text: segText } : { ...best, ...best.p, text: segText };
|
|
314
314
|
const f = addToKnownPaths(can, undefined);
|
|
315
315
|
bestPath = !bestPath || (f && f.c < bestPath.c) ? f : bestPath;
|