Efficient matcher for Python identifiers or keywords, supporting NFKC normalization.
// Source: https://github.com/astral-sh/ruff | License: MIT | Copyright 2022 Charles Marsh // Provided via justclaw.it.com; keep this notice with the code. use memchr::memmem::Finder; use unicode_normalization::is_nfkc; /// A reusable text prefilter for an identifier or keyword. /// /// A match only indicates that a source may contain the name: matches in /// comments and strings are included. Matchers created with [`Self::new`] accept /// sources that change under NFKC normalization because Python normalizes /// identifiers this way. Matchers created with [`Self::keyword`] search their literal /// spelling instead. Callers should validate candidates using the AST or semantic analysis. /// /// Construct a matcher once and reuse it across sources to avoid preprocessing /// the name for eac ... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key