css_classes.ts

Collection management for extracted CSS classes.

Tracks classes per-file for efficient incremental updates during watch mode. Uses null instead of empty collections to avoid allocation overhead.

Declarations
#

view source

CssClasses
#

css_classes.ts view source

Collection of CSS classes extracted from source files. Tracks classes per-file for efficient incremental updates. Handles include/exclude filtering and explicit class tracking. Uses null instead of empty collections to avoid allocation overhead.

constructor

Creates a new CssClasses collection.

type new (additional_classes?: Set<string> | null, exclude_classes?: Set<string> | null): CssClasses

additional_classes

classes to always include (also treated as explicit for warnings)

type Set<string> | null
default null
exclude_classes

classes to exclude from output (also suppresses warnings)

type Set<string> | null
default null

add

Adds extraction results for a file. Replaces any previous classes and diagnostics for this file.

type (id: string, data: ExtractionData): void

id

file identifier

type string
data

extraction data fields to store for this file

returns void

delete

type (id: string): void

id
type string
returns void

get

Gets all unique class names as a Set (with exclude filter applied).

type (): Set<string>

returns Set<string>

get_with_locations

Gets all classes with their source locations (with exclude filter applied). Locations from additional_classes are null.

type (): Map<string, SourceLocation[] | null>

returns Map<string, SourceLocation[] | null>

get_all

Gets all classes and their locations in a single call. More efficient than calling get() and get_with_locations() separately when both are needed (avoids potential double recalculation).

Results have exclude filter applied and explicit_classes includes additional_classes.

type (): { all_classes: Set<string>; all_classes_with_locations: Map<string, SourceLocation[] | null>; explicit_classes: Set<string> | null; all_elements: Set<...>; explicit_elements: Set<...> | null; explicit_variables: Set<...> | null; }

returns { all_classes: Set<string>; all_classes_with_locations: Map<string, SourceLocation[] | null>; explicit_classes: Set<string> | null; all_elements: Set<...>; explicit_elements: Set<...> | null; explicit_variables: Set<...> | null; }

get_diagnostics

Gets all extraction diagnostics from all files.

type (): ExtractionDiagnostic[]

returns ExtractionDiagnostic[]

Imported by
#