get_candidates_with_positions() — tailwindcss Function Reference
Architecture documentation for the get_candidates_with_positions() function in mod.rs from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 99d2dd55_e7d6_72e7_f911_7a13f8c522f7["get_candidates_with_positions()"] f2abcd97_28a1_dcf7_b230_da1e29c023b0["test_positions()"] f2abcd97_28a1_dcf7_b230_da1e29c023b0 -->|calls| 99d2dd55_e7d6_72e7_f911_7a13f8c522f7 c2328155_87f1_bade_2ea6_fa7f1910a5ef["read_changed_content()"] 99d2dd55_e7d6_72e7_f911_7a13f8c522f7 -->|calls| c2328155_87f1_bade_2ea6_fa7f1910a5ef e3c5d51c_7520_d380_3d8e_291bfd72cc41["extract()"] 99d2dd55_e7d6_72e7_f911_7a13f8c522f7 -->|calls| e3c5d51c_7520_d380_3d8e_291bfd72cc41 style 99d2dd55_e7d6_72e7_f911_7a13f8c522f7 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
Source
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