Home / Function/ get_candidates_with_positions() — tailwindcss Function Reference

get_candidates_with_positions() — tailwindcss Function Reference

Architecture documentation for the get_candidates_with_positions() function in mod.rs from the tailwindcss codebase.

Function rust Oxide Scanner calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  5676281c_8167_04d8_78a5_361db3b21fc6["get_candidates_with_positions()"]
  b82a42d6_b7d3_c6d2_1e14_451f8382da81["mod.rs"]
  5676281c_8167_04d8_78a5_361db3b21fc6 -->|defined in| b82a42d6_b7d3_c6d2_1e14_451f8382da81
  8da9c2c7_d5cf_a790_341c_5565616a6dfc["test_positions()"]
  8da9c2c7_d5cf_a790_341c_5565616a6dfc -->|calls| 5676281c_8167_04d8_78a5_361db3b21fc6
  d7d2a290_6465_d83b_ad3d_f71ae61d67dc["read_changed_content()"]
  5676281c_8167_04d8_78a5_361db3b21fc6 -->|calls| d7d2a290_6465_d83b_ad3d_f71ae61d67dc
  e534aa81_6fd8_e24b_3a2a_5ca71f00058f["extract()"]
  5676281c_8167_04d8_78a5_361db3b21fc6 -->|calls| e534aa81_6fd8_e24b_3a2a_5ca71f00058f
  style 5676281c_8167_04d8_78a5_361db3b21fc6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/oxide/src/scanner/mod.rs lines 420–458

    pub fn get_candidates_with_positions(
        &mut self,
        changed_content: ChangedContent,
    ) -> Vec<(String, usize)> {
        let content = read_changed_content(changed_content).unwrap_or_default();
        let original_content = &content;

        // Workaround for legacy upgrades:
        //
        // `-[]` won't parse in the new parser (`[…]` must contain _something_), but we do need it
        // for people using `group-[]` (which we will later replace with `in-[.group]` instead).
        let content = content.replace("-[]", "XYZ");
        let offset = content.as_ptr() as usize;

        let mut extractor = Extractor::new(&content[..]);

        extractor
            .extract()
            .into_par_iter()
            .flat_map(|extracted| match extracted {
                Extracted::Candidate(s) => {
                    let i = s.as_ptr() as usize - offset;
                    let original = &original_content[i..i + s.len()];
                    if original.contains_str("-[]") {
                        return Some(unsafe {
                            (String::from_utf8_unchecked(original.to_vec()), i)
                        });
                    }

                    // SAFETY: When we parsed the candidates, we already guaranteed that the byte
                    // slices are valid, therefore we don't have to re-check here when we want to
                    // convert it back to a string.
                    Some(unsafe { (String::from_utf8_unchecked(s.to_vec()), i) })
                }

                _ => None,
            })
            .collect()
    }

Domain

Subdomains

Called By

Frequently Asked Questions

What does get_candidates_with_positions() do?
get_candidates_with_positions() is a function in the tailwindcss codebase, defined in crates/oxide/src/scanner/mod.rs.
Where is get_candidates_with_positions() defined?
get_candidates_with_positions() is defined in crates/oxide/src/scanner/mod.rs at line 420.
What does get_candidates_with_positions() call?
get_candidates_with_positions() calls 2 function(s): extract, read_changed_content.
What calls get_candidates_with_positions()?
get_candidates_with_positions() is called by 1 function(s): test_positions.

Analyze Your Own Codebase

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

Try Supermodel Free