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

Entity Profile

Dependency Diagram

graph TD
  0f8d329e_0ee0_3682_91d0_989b1ec14827["get_candidates_with_positions()"]
  d865d4fd_bb15_6d9a_a900_10e82a6856fb["mod.rs"]
  0f8d329e_0ee0_3682_91d0_989b1ec14827 -->|defined in| d865d4fd_bb15_6d9a_a900_10e82a6856fb
  580d8793_ba3e_2444_5c7d_ac804fed1fd8["test_positions()"]
  580d8793_ba3e_2444_5c7d_ac804fed1fd8 -->|calls| 0f8d329e_0ee0_3682_91d0_989b1ec14827
  63be2454_f385_5711_9d49_84f7e913bd4b["read_changed_content()"]
  0f8d329e_0ee0_3682_91d0_989b1ec14827 -->|calls| 63be2454_f385_5711_9d49_84f7e913bd4b
  a07f5c0a_137c_8e35_bcb0_fe65e36c6864["extract()"]
  0f8d329e_0ee0_3682_91d0_989b1ec14827 -->|calls| a07f5c0a_137c_8e35_bcb0_fe65e36c6864
  style 0f8d329e_0ee0_3682_91d0_989b1ec14827 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