Skip to content

Commit c5ecd71

Browse files
authoredJan 12, 2023
refactor: clean up any circular references (#4005)
* refactor: clean up trie-util * refactor: move walker files up a level * refactor: fix reference to separator * refactor: fix circular ref in config loader * refactor: Pull Document out into its own file * refactor: Move Document related functions into Document * Move constants into their own file. * Move ConfigLoader default settings into its own file. * Move constant into its own file.
1 parent 8e8242b commit c5ecd71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+348
-330
lines changed
 

‎packages/cspell-grammar/src/parsers/typescript/TypeScriptParser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { opFlatten, opMap, pipe } from '@cspell/cspell-pipe/sync';
22
import type { ParsedText, ParseResult, Scope, ScopeChain } from '@cspell/cspell-types/Parser';
33

4-
import { compileGrammar } from '../..';
54
import { grammar } from '../../grammars/typescript';
65
import { appendMappedText } from '../../mappers/appendMappedText';
76
import { mapRawString } from '../../mappers/typescript';
7+
import { compileGrammar } from '../../parser/grammar';
88
import { createParser } from '../../parser/parser';
99
import { ScopePool } from '../../parser/scope';
1010
import type { TokenizedLine } from '../../parser/types';

‎packages/cspell-lib/api/api.d.ts

+56-51
Original file line numberDiff line numberDiff line change
@@ -274,38 +274,18 @@ declare namespace text_d {
274274
};
275275
}
276276

277-
interface FeatureFlag {
278-
name: string;
279-
description: string;
280-
}
281-
type FlagTypes = string | boolean;
282-
/**
283-
* Feature Flags are used to turn on/off features.
284-
* These are primarily used before a feature has been fully released.
285-
*/
286-
declare class FeatureFlags {
287-
private flags;
288-
private flagValues;
289-
constructor(flags?: FeatureFlag[]);
290-
register(flag: FeatureFlag): this;
291-
register(name: string, description: string): this;
292-
getFlag(flag: string): FlagTypes | undefined;
293-
getFlagBool(flag: string): boolean | undefined;
294-
setFlag(flag: string, value?: FlagTypes): this;
295-
getFlagInfo(flag: string): FeatureFlag | undefined;
296-
getFlags(): FeatureFlag[];
297-
getFlagValues(): Map<string, FlagTypes>;
298-
reset(): this;
277+
interface Document {
278+
uri: UriString;
279+
text?: string;
280+
languageId?: string;
281+
locale?: string;
299282
}
300-
declare class UnknownFeatureFlagError extends Error {
301-
readonly flag: string;
302-
constructor(flag: string);
283+
type UriString = string;
284+
interface DocumentWithText extends Document {
285+
text: string;
303286
}
304-
declare function getSystemFeatureFlags(): FeatureFlags;
305287

306-
type LanguageId = string;
307-
declare function getLanguagesForExt(ext: string): string[];
308-
declare function getLanguagesForBasename(basename: string): string[];
288+
declare function isBinaryFile(filenameUri: URI, languageId?: string | string[]): boolean;
309289

310290
type DocumentUri = URI;
311291
interface Position {
@@ -369,13 +349,52 @@ interface TextDocumentContentChangeEvent {
369349
declare function createTextDocument({ uri, content, languageId, locale, version, }: CreateTextDocumentParams): TextDocument;
370350
declare function updateTextDocument(doc: TextDocument, edits: TextDocumentContentChangeEvent[], version?: number): TextDocument;
371351

352+
declare function fileToDocument(file: string): Document;
353+
declare function fileToDocument(file: string, text: string, languageId?: string, locale?: string): DocumentWithText;
354+
declare function fileToDocument(file: string, text?: string, languageId?: string, locale?: string): Document | DocumentWithText;
355+
declare function fileToTextDocument(file: string): Promise<TextDocument>;
356+
357+
interface FeatureFlag {
358+
name: string;
359+
description: string;
360+
}
361+
type FlagTypes = string | boolean;
362+
/**
363+
* Feature Flags are used to turn on/off features.
364+
* These are primarily used before a feature has been fully released.
365+
*/
366+
declare class FeatureFlags {
367+
private flags;
368+
private flagValues;
369+
constructor(flags?: FeatureFlag[]);
370+
register(flag: FeatureFlag): this;
371+
register(name: string, description: string): this;
372+
getFlag(flag: string): FlagTypes | undefined;
373+
getFlagBool(flag: string): boolean | undefined;
374+
setFlag(flag: string, value?: FlagTypes): this;
375+
getFlagInfo(flag: string): FeatureFlag | undefined;
376+
getFlags(): FeatureFlag[];
377+
getFlagValues(): Map<string, FlagTypes>;
378+
reset(): this;
379+
}
380+
declare class UnknownFeatureFlagError extends Error {
381+
readonly flag: string;
382+
constructor(flag: string);
383+
}
384+
declare function getSystemFeatureFlags(): FeatureFlags;
385+
386+
type LanguageId = string;
387+
declare function getLanguagesForExt(ext: string): string[];
388+
declare function getLanguagesForBasename(basename: string): string[];
389+
372390
declare const currentSettingsFileVersion = "0.2";
373391
declare const ENV_CSPELL_GLOB_ROOT = "CSPELL_GLOB_ROOT";
374392

375393
type LoaderResult = URI | undefined;
376394

377395
type CSpellSettingsWST$1 = CSpellSettingsWithSourceTrace;
378396
type CSpellSettingsI$1 = CSpellSettingsInternal;
397+
379398
type PnPSettings = OptionalOrUndefined<PnPSettings$1>;
380399
declare const sectionCSpell = "cSpell";
381400
declare const defaultFileName = "cspell.json";
@@ -391,13 +410,6 @@ declare function loadConfig(file: string, pnpSettings?: PnPSettings): Promise<CS
391410
declare function loadPnP(pnpSettings: PnPSettings, searchFrom: URI): Promise<LoaderResult>;
392411
declare function loadPnPSync(pnpSettings: PnPSettings, searchFrom: URI): LoaderResult;
393412
declare function readRawSettings(filename: string, relativeTo?: string): CSpellSettingsWST$1;
394-
/**
395-
*
396-
* @param filenames - settings files to read
397-
* @returns combined configuration
398-
* @deprecated true
399-
*/
400-
declare function readSettingsFiles(filenames: string[]): CSpellSettingsI$1;
401413
declare function getGlobalSettings(): CSpellSettingsI$1;
402414
declare function getCachedFileSize(): number;
403415
declare function clearCachedSettingsFiles(): void;
@@ -429,6 +441,14 @@ declare function readSettings(filename: string, defaultValues: CSpellSettingsWST
429441
declare function readSettings(filename: string, relativeTo: string): CSpellSettingsI$1;
430442
declare function readSettings(filename: string, relativeTo: string, defaultValues: CSpellSettingsWST$1): CSpellSettingsI$1;
431443

444+
/**
445+
*
446+
* @param filenames - settings files to read
447+
* @returns combined configuration
448+
* @deprecated true
449+
*/
450+
declare function readSettingsFiles(filenames: string[]): CSpellSettingsI$1;
451+
432452
declare class ImportError extends Error {
433453
readonly cause: Error | undefined;
434454
constructor(msg: string, cause?: Error | unknown);
@@ -713,16 +733,6 @@ interface SpellCheckFileResult {
713733
checked: boolean;
714734
errors: Error[] | undefined;
715735
}
716-
type UriString = string;
717-
interface DocumentWithText extends Document {
718-
text: string;
719-
}
720-
interface Document {
721-
uri: UriString;
722-
text?: string;
723-
languageId?: string;
724-
locale?: string;
725-
}
726736
/**
727737
* Spell Check a file
728738
* @param file - absolute path to file to read and check.
@@ -754,11 +764,6 @@ interface DetermineFinalDocumentSettingsResult {
754764
* @param settings - The near final settings. Should already be the combination of all configuration files.
755765
*/
756766
declare function determineFinalDocumentSettings(document: DocumentWithText, settings: CSpellUserSettings): DetermineFinalDocumentSettingsResult;
757-
declare function isBinaryFile(filenameUri: URI, languageId?: string | string[]): boolean;
758-
declare function fileToDocument(file: string): Document;
759-
declare function fileToDocument(file: string, text: string, languageId?: string, locale?: string): DocumentWithText;
760-
declare function fileToDocument(file: string, text?: string, languageId?: string, locale?: string): Document | DocumentWithText;
761-
declare function fileToTextDocument(file: string): Promise<TextDocument>;
762767

763768
interface SuggestedWordBase extends SuggestionResult {
764769
dictionaries: string[];

0 commit comments

Comments
 (0)
Please sign in to comment.