Home / File/ candidate_machine.rs — tailwindcss Source File

candidate_machine.rs — tailwindcss Source File

Architecture documentation for candidate_machine.rs, a rust file in the tailwindcss codebase. 9 imports, 0 dependents.

File rust OxideEngine Extractor 9 imports 7 functions

Entity Profile

Dependency Diagram

graph LR
  add7fb68_668d_acbb_2d68_5b2963b9c0e4["candidate_machine.rs"]
  ade6872a_2bde_f750_5823_eb93d9cd78ba["super::CandidateMachine"]
  add7fb68_668d_acbb_2d68_5b2963b9c0e4 --> ade6872a_2bde_f750_5823_eb93d9cd78ba
  e4e20bdf_ad1e_e4a0_5cba_d0f5a5db787e["crate::cursor"]
  add7fb68_668d_acbb_2d68_5b2963b9c0e4 --> e4e20bdf_ad1e_e4a0_5cba_d0f5a5db787e
  fb1cff81_b9fd_f7c0_dd7f_b7712793214d["crate::extractor::boundary::"]
  add7fb68_668d_acbb_2d68_5b2963b9c0e4 --> fb1cff81_b9fd_f7c0_dd7f_b7712793214d
  cd83abb6_a664_e16d_ddc8_60a3f23ba86a["crate::extractor::machine::"]
  add7fb68_668d_acbb_2d68_5b2963b9c0e4 --> cd83abb6_a664_e16d_ddc8_60a3f23ba86a
  370a26dd_d0b6_503d_a6ce_7c631b4bb9c8["crate::extractor::utility_machine::UtilityMachine"]
  add7fb68_668d_acbb_2d68_5b2963b9c0e4 --> 370a26dd_d0b6_503d_a6ce_7c631b4bb9c8
  71141c85_3e46_c613_7ae6_deef432b10a2["crate::extractor::variant_machine::VariantMachine"]
  add7fb68_668d_acbb_2d68_5b2963b9c0e4 --> 71141c85_3e46_c613_7ae6_deef432b10a2
  b0be0e22_d5d3_57db_4ed0_a45699e2a447["crate::extractor::Span"]
  add7fb68_668d_acbb_2d68_5b2963b9c0e4 --> b0be0e22_d5d3_57db_4ed0_a45699e2a447
  9a9673b5_10d4_f716_360c_b2510082b102["crate::extractor::machine::Machine"]
  add7fb68_668d_acbb_2d68_5b2963b9c0e4 --> 9a9673b5_10d4_f716_360c_b2510082b102
  e4088d34_b5b4_ec51_b975_557a1536ec76["pretty_assertions::assert_eq"]
  add7fb68_668d_acbb_2d68_5b2963b9c0e4 --> e4088d34_b5b4_ec51_b975_557a1536ec76
  style add7fb68_668d_acbb_2d68_5b2963b9c0e4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

use crate::cursor;
use crate::extractor::boundary::{has_valid_boundaries, is_valid_before_boundary};
use crate::extractor::machine::{Machine, MachineState};
use crate::extractor::utility_machine::UtilityMachine;
use crate::extractor::variant_machine::VariantMachine;
use crate::extractor::Span;

/// Extract full candidates including variants and utilities.
#[derive(Debug, Default)]
pub struct CandidateMachine {
    /// Start position of the candidate
    start_pos: usize,

    /// End position of the last variant (if any)
    last_variant_end_pos: Option<usize>,

    utility_machine: UtilityMachine,
    variant_machine: VariantMachine,
}

impl Machine for CandidateMachine {
    #[inline(always)]
    fn reset(&mut self) {
        self.start_pos = 0;
        self.last_variant_end_pos = None;
    }

    #[inline]
    fn next(&mut self, cursor: &mut cursor::Cursor<'_>) -> MachineState {
        let len = cursor.input.len();

        while cursor.pos < len {
            // Skip ahead for known characters that will never be part of a candidate. No need to
            // run any sub-machines.
            if cursor.curr.is_ascii_whitespace() {
                self.reset();
                cursor.advance();
                continue;
            }

            // Candidates don't start with these characters, so we can skip ahead.
            if matches!(cursor.curr, b':' | b'"' | b'\'' | b'`') {
                self.reset();
                cursor.advance();
                continue;
            }

            // Jump ahead if the character is known to be an invalid boundary and we should start
            // at the next boundary even though "valid" candidates can exist.
            //
            // E.g.: `<div class="">`
            //         ^^^            Valid candidate
            //        ^               But this character makes it invalid
            //             ^          Therefore we jump here
            //
            // E.g.: `Some Class`
            //        ^    ^       Invalid, we can jump ahead to the next boundary
            //
            if matches!(cursor.curr, b'<' | b'A'..=b'Z') {
                if let Some(offset) = cursor.input[cursor.pos..]
// ... (302 more lines)

Domain

Subdomains

Dependencies

  • crate::cursor
  • crate::extractor::Span
  • crate::extractor::boundary::
  • crate::extractor::machine::
  • crate::extractor::machine::Machine
  • crate::extractor::utility_machine::UtilityMachine
  • crate::extractor::variant_machine::VariantMachine
  • pretty_assertions::assert_eq
  • super::CandidateMachine

Frequently Asked Questions

What does candidate_machine.rs do?
candidate_machine.rs is a source file in the tailwindcss codebase, written in rust. It belongs to the OxideEngine domain, Extractor subdomain.
What functions are defined in candidate_machine.rs?
candidate_machine.rs defines 7 function(s): do_not_consider_svg_path_commands, done_span, next, reset, test_candidate_extraction, test_candidate_machine_performance, test_js_interpolation.
What does candidate_machine.rs depend on?
candidate_machine.rs imports 9 module(s): crate::cursor, crate::extractor::Span, crate::extractor::boundary::, crate::extractor::machine::, crate::extractor::machine::Machine, crate::extractor::utility_machine::UtilityMachine, crate::extractor::variant_machine::VariantMachine, pretty_assertions::assert_eq, and 1 more.
Where is candidate_machine.rs in the architecture?
candidate_machine.rs is located at crates/oxide/src/extractor/candidate_machine.rs (domain: OxideEngine, subdomain: Extractor, directory: crates/oxide/src/extractor).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free