Home / Function/ matched_ignore() — tailwindcss Function Reference

matched_ignore() — tailwindcss Function Reference

Architecture documentation for the matched_ignore() function in dir.rs from the tailwindcss codebase.

Function rust RustCore PreProcessors calls 4 called by 1

Entity Profile

Dependency Diagram

graph TD
  ac8fac4b_5baf_500a_e391_2a9d3774f354["matched_ignore()"]
  3d475977_d06e_4912_978d_07df5c71fed8["matched()"]
  3d475977_d06e_4912_978d_07df5c71fed8 -->|calls| ac8fac4b_5baf_500a_e391_2a9d3774f354
  7da428cb_cbf6_46bb_8faf_0fdbfebcd439["parents()"]
  ac8fac4b_5baf_500a_e391_2a9d3774f354 -->|calls| 7da428cb_cbf6_46bb_8faf_0fdbfebcd439
  23535d19_a8ff_f1b8_5e7a_39e4c1ab582f["absolute_base()"]
  ac8fac4b_5baf_500a_e391_2a9d3774f354 -->|calls| 23535d19_a8ff_f1b8_5e7a_39e4c1ab582f
  3d475977_d06e_4912_978d_07df5c71fed8["matched()"]
  ac8fac4b_5baf_500a_e391_2a9d3774f354 -->|calls| 3d475977_d06e_4912_978d_07df5c71fed8
  0a625c2b_b1dd_2da6_7dda_34ff725be14b["path()"]
  ac8fac4b_5baf_500a_e391_2a9d3774f354 -->|calls| 0a625c2b_b1dd_2da6_7dda_34ff725be14b
  style ac8fac4b_5baf_500a_e391_2a9d3774f354 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/ignore/src/dir.rs lines 408–533

    fn matched_ignore<'a>(&'a self, path: &Path, is_dir: bool) -> Match<IgnoreMatch<'a>> {
        let (mut m_custom_ignore, mut m_ignore, mut m_gi, mut m_gi_exclude, mut m_explicit) = (
            Match::None,
            Match::None,
            Match::None,
            Match::None,
            Match::None,
        );
        let any_git = !self.0.opts.require_git || self.parents().any(|ig| ig.0.has_git);
        let mut saw_git = false;
        for ig in self.parents().take_while(|ig| !ig.0.is_absolute_parent) {
            if m_custom_ignore.is_none() {
                m_custom_ignore =
                    ig.0.custom_ignore_matcher
                        .matched(path, is_dir)
                        .map(IgnoreMatch::gitignore);
            }
            if m_ignore.is_none() {
                m_ignore =
                    ig.0.ignore_matcher
                        .matched(path, is_dir)
                        .map(IgnoreMatch::gitignore);
            }
            if any_git && !saw_git && m_gi.is_none() {
                m_gi =
                    ig.0.git_ignore_matcher
                        .matched(path, is_dir)
                        .map(IgnoreMatch::gitignore);
            }
            if any_git && !saw_git && m_gi_exclude.is_none() {
                m_gi_exclude =
                    ig.0.git_exclude_matcher
                        .matched(path, is_dir)
                        .map(IgnoreMatch::gitignore);
            }
            saw_git = saw_git || ig.0.has_git;
        }
        if self.0.opts.parents {
            if let Some(_) = self.absolute_base() {
                // CHANGED: We removed a code path that rewrote the `path` to be relative to
                // `self.absolute_base()` because it assumed that the every path is inside the base
                // which is not the case for us as we use `WalkBuilder#add` to add roots outside of the
                // base.
                for ig in self.parents().skip_while(|ig| !ig.0.is_absolute_parent) {
                    if m_custom_ignore.is_none() {
                        m_custom_ignore =
                            ig.0.custom_ignore_matcher
                                .matched(&path, is_dir)
                                .map(IgnoreMatch::gitignore);
                    }
                    if m_ignore.is_none() {
                        m_ignore =
                            ig.0.ignore_matcher
                                .matched(&path, is_dir)
                                .map(IgnoreMatch::gitignore);
                    }
                    if any_git && !saw_git && m_gi.is_none() {
                        m_gi =
                            ig.0.git_ignore_matcher
                                .matched(&path, is_dir)
                                .map(IgnoreMatch::gitignore);
                    }
                    if any_git && !saw_git && m_gi_exclude.is_none() {
                        m_gi_exclude =
                            ig.0.git_exclude_matcher
                                .matched(&path, is_dir)
                                .map(IgnoreMatch::gitignore);
                    }
                    saw_git = saw_git || ig.0.has_git;
                }
            }
        }
        for gi in self.0.explicit_ignores.iter().rev() {
            // CHANGED: We need to make sure that the explicit gitignore rules apply to the path
            //
            //          path      = Is the current file/folder we are traversing
            //          gi.path() = Is the path of the custom gitignore file
            //
            //  E.g.: If we have a custom rule for `/src/utils` with `**/*`, and we are looking at
            //        just `/src`, then the `**/*` rules do not apply to this folder, so we can
            //        ignore the current custom gitignore file.
            //
            if !path.starts_with(gi.path()) {
                continue;
            }
            if !m_explicit.is_none() {
                break;
            }
            m_explicit = gi.matched(&path, is_dir).map(IgnoreMatch::gitignore);
        }
        let m_global = if any_git {
            self.0
                .git_global_matcher
                .matched(&path, is_dir)
                .map(IgnoreMatch::gitignore)
        } else {
            Match::None
        };

        // CHANGED: We added logic to configure an order in which the ignore files are respected and
        // allowed a whitelist in a later file to overrule a block on an earlier file.
        let order = [
            // Manually added ignores
            &m_explicit,
            // .custom-ignore
            &m_custom_ignore,
            // .ignore
            &m_ignore,
            // .gitignore
            &m_gi,
            // .git/info/exclude
            &m_gi_exclude,
            // Global gitignore
            &m_global,
        ];

        for check in order.into_iter() {
            if check.is_none() {
                continue;
            }

            return check.clone();
        }

        m_explicit
    }

Domain

Subdomains

Called By

Frequently Asked Questions

What does matched_ignore() do?
matched_ignore() is a function in the tailwindcss codebase.
What does matched_ignore() call?
matched_ignore() calls 4 function(s): absolute_base, matched, parents, path.
What calls matched_ignore()?
matched_ignore() is called by 1 function(s): matched.

Analyze Your Own Codebase

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

Try Supermodel Free