Skip to main content

TokenizeOptions

Struct TokenizeOptions 

Source
pub struct TokenizeOptions {
    pub mode: Mode,
    pub ignore_case: bool,
    pub ignore_ranges: Vec<[usize; 2]>,
    pub ignore_identifiers: bool,
    pub ignore_literals: bool,
    pub ignore_annotations: bool,
    pub code_ignore_regexes: Vec<Regex>,
    pub strip_types_formats: HashSet<String>,
}
Expand description

Options for the detection-path tokenizer.

Carries mode, case-folding flag, pre-parsed ignore-region byte ranges, and pre-compiled code-level regex patterns that skip matching tokens during detection.

Code-level ignore patterns (v4 ignorePattern) work by matching regex patterns against source text, collecting byte ranges of matches, and then filtering any token whose byte range overlaps a match — identical in effect to v4’s setupIgnorePatterns which injected Prism grammar tokens.

Fields§

§mode: Mode§ignore_case: bool

When true, token values are lowercased before hashing.

§ignore_ranges: Vec<[usize; 2]>

Ignored byte ranges from jscpd:ignore-start / jscpd:ignore-end and code-level regex matches from ignorePattern. Each entry is [start_byte, end_byte).

§ignore_identifiers: bool

Hash every identifier as $id so clones that differ only in variable, function or type names match (issue #998). Keywords are kept: the JavaScript tokenizer classifies them, other languages fall back to is_common_keyword.

§ignore_literals: bool

Hash string literals as $str and numeric literals as $num.

§ignore_annotations: bool

Drop @Name, @a.b.Name and @Name(...) annotation/decorator sequences before hashing, in formats listed by strips_annotations.

§code_ignore_regexes: Vec<Regex>

Pre-compiled code-level regex patterns inherited from v4 ignorePattern. Before tokenization, these are matched against the source text and overlapping byte ranges are added to ignore_ranges.

§strip_types_formats: HashSet<String>

Formats whose TypeScript-only syntax is stripped from the detection token stream (--cross-formats groups mixing TS with JS). Only typescript and tsx are meaningful here; empty by default so the standard detection path is untouched.

Implementations§

Source§

impl TokenizeOptions

Source

pub fn new(mode: Mode) -> Self

Trait Implementations§

Source§

impl Clone for TokenizeOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TokenizeOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<'a, T> FromIn<'a, T> for T

Source§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

Source§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.