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 Oxide Extractor 9 imports 7 functions

Entity Profile

Dependency Diagram

graph LR
  16b5fabd_92d2_8602_e43a_c1d04ce5e265["candidate_machine.rs"]
  13f7c7f6_6d92_75e0_f63a_8a67e8471166["super::CandidateMachine"]
  16b5fabd_92d2_8602_e43a_c1d04ce5e265 --> 13f7c7f6_6d92_75e0_f63a_8a67e8471166
  96a36755_a007_15e1_ec6c_526c02d24b9b["crate::cursor"]
  16b5fabd_92d2_8602_e43a_c1d04ce5e265 --> 96a36755_a007_15e1_ec6c_526c02d24b9b
  ca121d59_fbb0_c886_aae5_b1a2b149bb01["crate::extractor::boundary::"]
  16b5fabd_92d2_8602_e43a_c1d04ce5e265 --> ca121d59_fbb0_c886_aae5_b1a2b149bb01
  05907c18_a40e_a5a9_c7c3_5faba98e1e87["crate::extractor::machine::"]
  16b5fabd_92d2_8602_e43a_c1d04ce5e265 --> 05907c18_a40e_a5a9_c7c3_5faba98e1e87
  befe7555_81bf_06e4_5895_ae46d3bc2c3b["crate::extractor::utility_machine::UtilityMachine"]
  16b5fabd_92d2_8602_e43a_c1d04ce5e265 --> befe7555_81bf_06e4_5895_ae46d3bc2c3b
  087ad9fa_43e6_1338_b489_014631bd4014["crate::extractor::variant_machine::VariantMachine"]
  16b5fabd_92d2_8602_e43a_c1d04ce5e265 --> 087ad9fa_43e6_1338_b489_014631bd4014
  08d56117_492b_e9aa_d1a9_e91cd285e85b["crate::extractor::Span"]
  16b5fabd_92d2_8602_e43a_c1d04ce5e265 --> 08d56117_492b_e9aa_d1a9_e91cd285e85b
  4d153f79_f78b_b66c_1e8a_11a0eb99bd41["crate::extractor::machine::Machine"]
  16b5fabd_92d2_8602_e43a_c1d04ce5e265 --> 4d153f79_f78b_b66c_1e8a_11a0eb99bd41
  433675ca_8d0e_feff_42a5_b3f666878cca["pretty_assertions::assert_eq"]
  16b5fabd_92d2_8602_e43a_c1d04ce5e265 --> 433675ca_8d0e_feff_42a5_b3f666878cca
  style 16b5fabd_92d2_8602_e43a_c1d04ce5e265 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 Oxide 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: Oxide, 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