pub struct PreparedSource {
pub id: String,
pub format: String,
pub hashes: Vec<u64>,
pub spans: Vec<(Location, Location)>,
pub raw_hashes: Vec<u64>,
pub functions: Vec<FunctionSig>,
pub real_path: String,
pub embedded: bool,
}Expand description
A file ready for detection: pre-hashed, pre-filtered.
Produced either from SourceFile.tokens (backward compat) or directly from
tokenize_to_detection output (fast path used by orchestrate.rs).
Fields§
§id: String§format: String§hashes: Vec<u64>§spans: Vec<(Location, Location)>§raw_hashes: Vec<u64>Un-normalized token hashes, parallel to hashes. Empty unless a
normalization option rewrote at least one token of this source; then
it is used to classify clones as exact or renamed (issue #998).
functions: Vec<FunctionSig>Function signatures for similarity scoring (issue #999). Empty unless
--similarity is set and the format is JavaScript/TypeScript.
real_path: StringCanonical on-disk path of the file; empty when it equals id. The two
differ behind a symlink: id keeps the path the walker found the file
at, which is what reports, --ignore and the path filters use (issue
#1059). --skip-isolated falls back to this path so a group folder
that is itself a symlink still matches the files found through it.
embedded: boolTrue when this source is one language embedded in another — a fenced
block in markdown, a <script> in a single-file component. Its tokens
keep the host file’s line numbers, so a clone’s line span may run
across host text that belongs to no block (issue #1090); statistics
discount those lines.
Implementations§
Source§impl PreparedSource
impl PreparedSource
Sourcepub fn filter_path(&self) -> &str
pub fn filter_path(&self) -> &str
The canonical path when it differs from id, otherwise id itself.
Sourcepub fn from_detection_tokens(
id: String,
format: String,
tokens: &[DetectionToken],
) -> Self
pub fn from_detection_tokens( id: String, format: String, tokens: &[DetectionToken], ) -> Self
Build from a DetectionToken slice — the fast path.
Trait Implementations§
Source§impl Clone for PreparedSource
impl Clone for PreparedSource
Auto Trait Implementations§
impl Freeze for PreparedSource
impl RefUnwindSafe for PreparedSource
impl Send for PreparedSource
impl Sync for PreparedSource
impl Unpin for PreparedSource
impl UnsafeUnpin for PreparedSource
impl UnwindSafe for PreparedSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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