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 OxideCore Scanner calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  c6b9ad01_bfbd_d4a3_0543_b60d5f83e5d7["get_candidates_with_positions()"]
  fac29078_c7d6_c129_1a2d_ea3b40373150["test_positions()"]
  fac29078_c7d6_c129_1a2d_ea3b40373150 -->|calls| c6b9ad01_bfbd_d4a3_0543_b60d5f83e5d7
  ad97b12c_67a2_add7_498d_ba391461a43e["read_changed_content()"]
  c6b9ad01_bfbd_d4a3_0543_b60d5f83e5d7 -->|calls| ad97b12c_67a2_add7_498d_ba391461a43e
  8b98e622_fb07_ab68_6ea9_cff96fc37db6["extract()"]
  c6b9ad01_bfbd_d4a3_0543_b60d5f83e5d7 -->|calls| 8b98e622_fb07_ab68_6ea9_cff96fc37db6
  style c6b9ad01_bfbd_d4a3_0543_b60d5f83e5d7 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.
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